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
Checks that a cube is open, raising a NotAttached exception if one is not.
def check_attached check_connected raise NotAttached unless @app && @cube end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attached?\n interface.status == 'in-use'\n end", "def attached?\n\t\tCommon.device_status(@handle);\n end", "def attached?\n not self.info.nil?\n end", "def attached?\n not send(self.class.container_name).nil?\n end", "def check()\n # check if teh volume still exists\n begin\n volumes = $ec2.describe_volumes([self.id])\n rescue RightAws::AwsError\n if $!.errors[0][0] == \"InvalidVolume.NotFound\"\n puts \"WARN: Volume #{self.id} is not running\"\n delete()\n return\n else\n p $!.code\n end\n end\n\n # check that it is attached\n if volumes[0][:aws_attachment_status] == 'attached'\n if self.attached_instance != volumes[0][:aws_instance_id]\n self.attached_instance = volumes[0][:aws_instance_id]\n self.save()\n puts \"WARN: volume #{self.id} is now attached to #{self.attached_instance}\"\n end\n elsif self.attached_instance.nil?\n puts \"WARN: volume #{self.id} is no longer attached\"\n self.attached_instance = nil\n self.save()\n end\n end", "def sanity_check\n raise Net::SSH::Exception, \"session not open\" unless @open\n end", "def open?\n @connected\n end", "def ensure_photo\n unless self.photoConnect.attached?\n errors[:photo] << \"must be attached\"\n end\n end", "def connected?\n begin\n @client.cluster.health\n rescue => e\n raise Xi::ML::Error::CaughtException, \\\n \"ES client not connected: #{e.message}\"\n end\n true\n end", "def open?(direction)\r\n ! @exits[direction].nil?\r\n end", "def ensure_attachment_present\n if attachments.empty?\n false\n else\n errors.add(:base, 'Attachment needed')\n true\n end\n end", "def check_client\n unless client\n raise ClientNotSetup\n end\n unless client.connected?\n if raise_on_error\n raise ClientNotConnected\n else\n @logger.error 'Client not connected! Check internet connection'\n return false\n end\n end\n true\n end", "def attached?\n not identifier.blank?\n end", "def attached?\n self.attachments.map(&:state).any? { |state| state == \"attached\" || state == \"attaching\" }\n end", "def exists?\n assert_exists\n true\n rescue NoMatchingWindowFoundException\n false\n end", "def attached?\n instance_variable_defined?(\"@old\")\n end", "def open?\n @opened\n end", "def attached?\n attachment.present?\n end", "def check_state\n EM.stop if @setup.report_state.content =~ /operational|stranded/\n end", "def isAttached\n @attached\n end", "def exception?\n exception_state?(peek_current_state)\n end", "def open?\n !(closed?)\n end", "def check_face(face)\n raise StandardError, 'Wrong face choose between north, south, west, east' unless FACES.include?(face)\n end", "def attached?\n return true if (device_type.to_s != 'device')\n !!( device && File.exists?(device) )\n end", "def open?\n @state == :open\n end", "def opened?\n @opened\n end", "def alive?\n @ole_excel.Name\n true\n rescue\n # trace $!.message\n false\n end", "def check(message_parameters)\n raise ArgumentError, 'Message parameters must be durable.' if broker_channel.durable? && !message_parameters.durable?\n raise ArgumentError, 'Message parameters must not be durable.' if !broker_channel.durable? && message_parameters.durable?\n end", "def valid?\n acyclic? and connected?\n end", "def open?\n return @opened\n end", "def attached?\n !!@__parent_struct\n end", "def open?\n !closed?\n end", "def attached?\n @frame && @frame.mini_buffer == self\n end", "def opened?\n !closed?\n end", "def solvable?\n @cube_state.solvable?\n end", "def connected?\n @conn.connected? && @channel.open?\n end", "def open?\n @handshake&.finished? && !@closed\n end", "def open?\n state == :open\n end", "def cube\n @cube ||= \n begin\n cube_class = ActiveWarehouse::Cube.class_name(self.cube_name).constantize\n cube_class.new\n end\n end", "def open?\n event_status_id == 1\n end", "def open_scene?\n id = $game_temp.open_scene_event_id\n if id != nil\n interpreter = Game_Interpreter.new\n $game_temp.open_scene_event_id = nil\n event = $game_map.events[id]\n interpreter.setup(event.list, event.id)\n while interpreter.running?\n interpreter.update\n update_basic\n wait_for_message\n @message_window.update\n end\n end\n end", "def open?\n !closed?\n end", "def open?\n !closed?\n end", "def has_open_cases\n unless current_user.lawfirm.cases.where(open: true).exists?\n redirect_to new_case_path,\n :flash => {:danger => \"You must fill out or upload information of an open case to view.\"}\n end\n end", "def openable?\n true\n end", "def won?\n @grid.flatten.all? { |el| el.face_down == false }\n end", "def raise_if_dialog_displayed\n # Validate a dialog is not open\n if @dialog && @dialog.is_displayed\n begin\n fail 'Dialog is displayed on the screen when not expected' if @dialog.dialog_modal.displayed?\n rescue Selenium::WebDriver::Error::NoSuchElementError\n begin\n fail 'Parental Controls dialog is displayed on the screen when not expected' if @dialog.parental_dialog.displayed?\n rescue Selenium::WebDriver::Error::NoSuchElementError\n puts 'Dialog was not displayed - so continue'\n end\n end\n end\nend", "def won?\n grid.flatten.all?(&:face_up)\n end", "def open?(column, row)\n piece = self.pieces.find { |p| p.position.col == column && p.position.row == row }\n return true if piece.nil?\n return false\n end", "def attached?\n !!file\n end", "def open?(thing)\n false\n end", "def image_presence\n errors.add(:image, \"Image must be attached.\") unless image.attached?\n end", "def error?\n @level <= 3\n end", "def online?\n @presence && @presence.type == nil\n end", "def check_collection_loaded!\n raise \"Collection wasn't loaded?\" if @collection.is_a?(ActiveRecord::Relation) && !@collection.loaded?\n end", "def window_exists?\n @window.exists?\n end", "def assert_open\n raise ZookeeperException::SessionExpired if state == ZOO_EXPIRED_SESSION_STATE\n raise ZookeeperException::NotConnected unless connected?\n end", "def attachment?\n attachment.present? && attachment.readable?\n end", "def attached?\n @options[:attached]\n end", "def attached?\n attachments.any?\n end", "def open?\n state == \"open\"\n end", "def open?\n @open\n end", "def open?\n @open\n end", "def open?\n @open\n end", "def open?\n is_open\n end", "def open?\n fail NotImplementedError\n end", "def check_devices\n\traise \"No connected device was found.\" if no_device?\nend", "def opening?\n !(open? || closed?)\n end", "def alive?\n state == :open\n end", "def open?\n showback_pool.state == \"OPEN\"\n end", "def open?\n @open\n end", "def supports_group_cube?\n server_version >= 90500\n end", "def open?\n end", "def valid?\n return false if @_mc_connection.nil?\n return false unless @_mc_connection.active?\n return true\n end", "def connected?\n !closed?\n end", "def connected?\n !closed?\n end", "def established?\n @connected == true\n end", "def exist?\n !closed? && window.present?\n end", "def still_connected?\n true\n end", "def open?\n type == 'open'\n end", "def channel?\n self.channel_referent_id > 0\n end", "def valid_connection?\n @connection && @connection.valid?\n end", "def alive?\n @alive && @mailbox.alive?\n end", "def open?\n # typically, ruby devices are always open, subclasses might not be\n true\n end", "def validate_wdl_accessibility\n begin\n wdl = ApplicationController.firecloud_client.get_method(self.namespace, self.name, self.snapshot)\n if wdl.nil? || wdl['public'] == false\n errors.add(:base, \"#{self.identifier} is not viewable by Single Cell Portal. Please ensure that the analysis WDL is public.\")\n end\n rescue => e\n ErrorTracker.report_exception(e, self.user, self)\n errors.add(:base, \"#{self.identifier} is not viewable by Single Cell Portal. Please ensure that the analysis WDL is public.\")\n end\n end", "def connected?\n !@connected.nil? && @connected\n end", "def is_open?\n @open\n end", "def open?\n @session && @session.started?\n end", "def attached?\n xml || model \n end", "def open?\n @open || true\n end", "def connected?\n !@aborted\n end", "def raise_if_no_exists_in_one\n raise 'OpenNebula device does not exist at the moment' unless one?\n end", "def checkConnection\n unless connected?\n raise DictError.new(), \"Not connected.\"\n end\n end", "def checkConnection\n unless connected?\n raise DictError.new(), \"Not connected.\"\n end\n end", "def open_door\n if !self.open? && !self.locked?\n @opened = true\n elsif self.open?\n raise TypeError.new(\"This door is already opened. It cannot be opened again.\")\n elsif self.locked?\n raise TypeError.new(\"This door is locked. It cannot be opened.\")\n else\n return \"this door can't be opened and we don't know why!!!!!!!!!!!!\"\n end\n end", "def test_vertices\n\t\tassert_equal(Cube.vertices.size,8) #test that the cube has 8 vertices\n\t\tassert_equal(Cube.faces_indices.size,6) #test that is has 6 faces\n\t\tassert_equal(Cube.edge_indices.size,12) # test that the cube has 12 edges\n\t\tassert_equal(Cube.octahedron.size,6) # test that the cube's dual octahedron has 6 vertices\n\t\tassert_equal(Cube.faces.size, 6) #test that the cube has 6 faces\n\t\tassert_equal(Cube.faces[0].size, 4) # test that a face has 4 vertices\n\t\tassert_equal(Cube.edges.size, 12) # test for 12 edges\n\t\tassert_equal(Cube.edges[0].size,2) # test that an edge has 2 vertices\n\t\t# assert_equal(Vector.average(Cube.vertices),Vector[0,0,0]) # not working, args seeing array as a single param to the method, not several params\n\tend", "def openvas?\n\t\t\tif @ov\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\tprint_error(\"No OpenVAS connection available. Please use openvas_connect.\")\n\t\t\t\treturn false\n\t\t\tend\n\t\tend", "def opened?\n @session > -1 ? true : false\n end", "def open?\n @data_bytes[1] != 0\n end", "def detected?\n raise LicenseScout::Exceptions::Error.new(\"All DependencyManagers must have a `#detected?` method\")\n end" ]
[ "0.544216", "0.53384924", "0.53176224", "0.52649313", "0.5184758", "0.51149905", "0.50992036", "0.5036669", "0.501715", "0.49898186", "0.49860623", "0.49706852", "0.49439564", "0.49264377", "0.48942304", "0.48936844", "0.48797712", "0.48647383", "0.48555163", "0.4828772", "0.4823925", "0.4816112", "0.48141125", "0.481206", "0.48000288", "0.47939584", "0.47867692", "0.47575918", "0.47490507", "0.47371545", "0.4732686", "0.47294214", "0.47293422", "0.472839", "0.47142246", "0.47130603", "0.47126213", "0.4707178", "0.47054145", "0.46771577", "0.46756288", "0.4655242", "0.4655242", "0.4652935", "0.4650717", "0.46503493", "0.46498764", "0.46311912", "0.46201077", "0.46186966", "0.461402", "0.4611122", "0.46102047", "0.4608491", "0.46054253", "0.460506", "0.4593528", "0.45901644", "0.45890662", "0.45832518", "0.45769125", "0.45760795", "0.45704672", "0.45704672", "0.45617273", "0.4560344", "0.45602793", "0.45487362", "0.45292947", "0.45240286", "0.45225033", "0.45209157", "0.45114684", "0.4511392", "0.45080033", "0.45080033", "0.450256", "0.450232", "0.4494788", "0.4494489", "0.4490743", "0.4490475", "0.4489203", "0.4489048", "0.44874108", "0.44864956", "0.4486098", "0.4486025", "0.44832808", "0.4482602", "0.44798094", "0.4477541", "0.44759905", "0.44759905", "0.4472209", "0.44714934", "0.44702005", "0.44688398", "0.44485998", "0.44484654" ]
0.78451747
0
Sends the current request XML to the SmartView provider, and parses the response with hpricot. If an exception was returned, an SmartViewException is raised with the details of the error.
def invoke resp = nil ms = Benchmark.realtime do resp = @http.post @url, @req.to_s end @logger.info 'SmartView request %s completed in %.1fs' % [@req.method, ms] doc = Hpricot::XML(resp.body.content) if !doc.at("//res_#{@req.method}") @logger.error "Error invoking SmartView method #{@req.method}" @logger.debug "Request was:\n#{@req}" @logger.debug "Response was:\n#{resp.body.content}" if ex = doc.at('//exception') ex = SmartViewException.new(ex) @logger.error "An exception occurred in #{@req.method}" @logger.error ex raise ex else @logger.error "Unexpected response from SmartView provider:\n#{doc.to_plain_text}" raise RuntimeError, "Unexpected response from SmartView provider: #{doc.to_plain_text}" end end doc end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_xml(xml)\n connection.ProcessRequest(session, xml)\n rescue => e\n puts \"ERROR processing request:\\n#{xml}\"\n raise # Reraises the original error, only this way we got the xml output\n end", "def send_request( xml )\n write( xml )\n read\n end", "def send_raw(xml)\n open\n @soap_client.ProcessRequest(@ticket, xml)\n close \n end", "def op_send_request_xml(params)\n return '' unless valid?\n\n # update the ticket with the metadata sent at the first request for XML (i.e. if not blank)\n @ticket.update!(\n hpc_response: (@ticket.hpc_response || params[:hcpresponse]),\n company_file_name: (@ticket.company_file_name || params[:company]),\n country: (@ticket.country || params[:country]),\n qbxml_major_version: (@ticket.qbxml_major_version || params[:major_ver]),\n qbxml_minor_version: (@ticket.qbxml_minor_version || params[:minor_ver])\n )\n\n # only process when in the Authenticated or Processing states\n unless ['Authenticated', 'Processing'].include?(@ticket.state)\n @ticket.request_error!(@last_log_message)\n return ''\n end\n\n # either grab the current request or create a new one\n request = @ticket.qb_request\n unless request\n request = create_request\n @ticket.qb_request = request\n end\n\n # if we don't have a request, then we are done.\n unless request\n log \"There is no more work to be done. Marking ticket state as finished\"\n @ticket.update!(state: 'Finished')\n return ''\n end\n\n request.update!(qb_ticket: @ticket, request_sent_at: Time.zone.now)\n qb_xml = request.to_qb_xml\n request.update!(request_qbxml: qb_xml)\n\n # set the ticket into a Processing state\n @ticket.state = 'Processing'\n\n # save the changes.\n @ticket.save!\n\n log \"Sending request [#{request.state}] XML to QuickBooks\"\n\n qb_xml\n end", "def send_request(xml)\n send_frame(xml)\n response = get_frame\n end", "def send\n @system = \"\"\n yield @system\n\n result = 'qf=xml&xml=' + render_template( 'auth' )\n\n @url.post( @uri.path, result, @headers.merge('Content-length' => result.length.to_s) )\n end", "def send(xml)\n msg = <<EOL\n<?xml version=\"1.0\"?>\n<?qbxml version=\"#{QBXML_VERSION}\"?>\n<QBXML>\n <QBXMLMsgsRq onError=\"continueOnError\">\n #{xml}</QBXMLMsgsRq>\n</QBXML>\nEOL\n puts msg\n @soap_client.ProcessRequest(@ticket, xml)\n end", "def send_request(xml)\n send_frame(xml)\n get_frame\n end", "def call\n request = http_request_class.new(uri.request_uri, headers)\n request.body = body if body\n http = http_setup\n # http.set_debug_output($stdout)\n response = wait_for_completion(HttpResponse.new(http.request(request)))\n Nokogiri::XML response.body unless response.nil?\n end", "def call\n uri = URI(full_url)\n\n request = Net::HTTP::Post.new(uri)\n default_headers.each { |k, v| request[k] = v }\n request.body = to_xml\n\n https = Net::HTTP.new(uri.hostname, uri.port)\n https.use_ssl = true\n https.ssl_version = :TLSv1_2_client\n if Nuncium.configuration.cert_file\n https.verify_mode = OpenSSL::SSL::VERIFY_PEER\n https.cert = Nuncium.configuration.cert_file\n https.key = Nuncium.configuration.private_key\n https.verify_depth = 5\n request.basic_auth(Nuncium.configuration.data_box, '')\n else\n request.basic_auth(\n Nuncium.configuration.username,\n Nuncium.configuration.password\n )\n end\n response = https.request(request)\n call_reponse_wrapper(response)\n end", "def handle_xml_response(rawXML)\n facepricotXML = Facepricot.new(rawXML)\n\n # error checking \n if facepricotXML.at(\"error_response\")\n \n # get the error code\n errorCode = facepricotXML.at(\"error_code\").inner_html.to_i\n errorMessage = facepricotXML.at(\"error_msg\").inner_html\n log_debug \"** RFACEBOOK(GEM) - RFacebook::FacebookSession\\#remote_call - remote call failed (#{errorCode}: #{errorMessage})\"\n \n # TODO: remove these 2 lines\n @last_error_message = \"ERROR #{errorCode}: #{errorMessage}\" # DEPRECATED\n @last_error_code = errorCode # DEPRECATED\n \n # check to see if this error was an expired session error\n case errorCode\n\n # the remote method did not exist, convert that to a standard Ruby no-method error\n when 3\n raise NoMethodError, errorMessage unless quiet? == true\n \n # the parameters were wrong, or not enough parameters...convert that to a standard Ruby argument error\n when 100,606\n raise ArgumentError, errorMessage unless quiet? == true\n \n # when the session expires, we need to record that internally\n when 102\n @expired = true\n raise ExpiredSessionStandardError.new(errorMessage, errorCode) unless quiet? == true\n \n # otherwise, just raise a regular remote error with the error code\n else\n raise RemoteStandardError.new(errorMessage, errorCode) unless quiet? == true\n end\n \n # since the quiet flag may have been activated, we may not have thrown\n # an actual exception, so we still need to return nil here\n return nil\n end\n \n # everything was just fine, return the Facepricot XML response\n return facepricotXML\n end", "def request(xml)\n open_connection\n \n begin\n login\n @response = send_request(xml)\n ensure\n logout unless @old_server\n close_connection\n end\n \n return @response\n end", "def request( xml )\n # open_connection\n\n # @logged_in = true if login\n\n begin\n @response = send_request( xml )\n ensure\n if @logged_in && !old_server\n @logged_in = false if logout\n end\n end\n\n return @response\n end", "def response\n connection.send(request_method) do |req|\n req.url path\n req.headers['LicenseID'] = client.license_id\n req.headers['Host'] = client.host\n req.headers['Connection'] = 'Keep-Alive'\n req.headers['Expect'] = '100-continue'\n req.headers['Content-Type'] = 'text/xml'\n req.body = body\n end\n end", "def parse_to_xml\n raise_if_error\n response_xml\n end", "def request\n self.response = prepare_response(http_communication.content)\n end", "def dispatch(ews, soapmsg, opts)\n respmsg = post(soapmsg)\n @log.debug <<-EOF.gsub(/^ {6}/, '')\n Received SOAP Response:\n ----------------\n #{Nokogiri::XML(respmsg).to_xml}\n ----------------\n EOF\n opts[:raw_response] ? respmsg : ews.parse_soap_response(respmsg, opts)\n end", "def serveOAI\n content_type 'text/xml;charset=utf-8'\n provider = EscholProvider.new\n provider.process_request(params)\n end", "def process_request\n api_response = self.class.post(api_url, :body => build_xml)\n puts api_response if @debug == true\n response = parse_response(api_response)\n if success?(response)\n return response[:track_reply][:track_details]\n else\n puts api_response if @debug == true\n error_message = if response[:track_reply]\n [response[:track_reply][:notifications]].flatten.first[:message]\n else\n api_response[\"Fault\"][\"detail\"][\"fault\"][\"reason\"]\n end rescue $1\n raise TrackError, error_message\n end\n end", "def relay_response\n sim_response = AuthorizeNet::SIM::Response.new(params)\n if sim_response.success?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])\n render :text => sim_response.direct_post_reply(payments_receipt_url(:only_path => false), :include => true)\n else\n render\n end\n end", "def relay_response\n sim_response = AuthorizeNet::SIM::Response.new(params)\n if sim_response.success?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])\n render :text => sim_response.direct_post_reply(payments_receipt_url(:only_path => false), :include => true)\n else\n render\n end\n end", "def post\n response = HTTParty.post(servlet_url,\n :body => to_xml,\n :headers => { 'Content-Type' => 'application/xml' }\n ).response\n\n return Dhl::Shipment::Response.new(response.body)\n rescue Exception => e\n request_xml = if @to_xml.to_s.size>0\n @to_xml\n else\n '<not generated at time of error>'\n end\n\n response_body = if (response && response.body && response.body.to_s.size > 0)\n response.body\n else\n '<not received at time of error>'\n end\n\n log_level = if e.respond_to?(:log_level)\n e.log_level\n else\n :critical\n end\n\n log_request_and_response_xml(log_level, e, request_xml, response_body )\n raise e\n end", "def send\n http = Net::HTTP.new(@uri.host, @uri.port)\n http.read_timeout = @http_timeout\n\n # Output request XML if debug flag is set\n if debug == true\n logger.info \"Request URL: #{@uri.to_s}\"\n logger.info \"Request Timeout: #{@http_timeout}\"\n logger.info \"Request headers: #{headers}\"\n logger.info \"Request body: #{body}\"\n end\n\n if @uri.port == 443\n http.use_ssl = true\n http.ssl_timeout = @http_timeout\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n post = Net::HTTP::Post.new(@uri.path, headers)\n post.body = body\n post.content_type = 'text/xml'\n\n response = http.start { |http| http.request(post) }\n\n if debug == true\n logger.info \"Response: #{response}\"\n end\n\n if response.is_a? Net::HTTPInternalServerError\n logger.info \"#{response.class.to_s}: #{response.message}\"\n return Hashie::Mash.new({})\n end\n\n @response = Hashie::Mash.new(Response.new(self, response))\n end", "def send()\n uri = URI.parse(@service_end_point)\n signature = Amazon::FPS::SignatureUtils.sign_parameters({parameters: @params, \n aws_secret_key: @secret_key,\n host: uri.host,\n verb: @http_method,\n uri: uri.path })\n @params[Amazon::FPS::SignatureUtils::SIGNATURE_KEYNAME] = signature\n\n request = log_request(@params)\n response = self.class.get(@service_end_point, query: @params)\n response = strip_response(response)\n\n log_response(response, request)\n return response\n end", "def send_request\n @response = _send_request\n end", "def request(xml)\n open_connection\n\n @logged_in = true if login\n\n begin\n @response = send_request(xml)\n ensure\n @logged_in = false if @logged_in && logout\n\n close_connection\n end\n\n return @response\n end", "def service(request, response)\n if @valid_ip\n raise WEBrick::HTTPStatus::Forbidden unless @valid_ip.any? { |ip| request.peeraddr[3] =~ ip }\n end\n\n if request.request_method != \"POST\"\n raise WEBrick::HTTPStatus::MethodNotAllowed,\n \"unsupported method `#{request.request_method}'.\"\n end\n\n raise WEBrick::HTTPStatus::BadRequest if parse_content_type(request['Content-type']).first != \"text/xml\"\n\n length = (request['Content-length'] || 0).to_i\n\n raise WEBrick::HTTPStatus::LengthRequired unless length > 0\n\n data = request.body\n\n raise WEBrick::HTTPStatus::BadRequest if data.nil? or data.size != length\n\n resp = process(data, client_request(request))\n raise WEBrick::HTTPStatus::InternalServerError if resp.nil? or resp.size <= 0\n\n response.status = 200\n response['Content-Length'] = resp.size\n response['Content-Type'] = \"text/xml; charset=utf-8\"\n response.body = resp\n end", "def make_request\n if @test\n host = 'wwwcie.ups.com'\n else\n host = 'www.ups.com'\n end\n\n path = \"/ups.app/xml/Rate\"\n server = Net::HTTP.new(host, 443)\n data = @xml_pieces.collect{|p| p.to_s}.join(\"\\n\")\n if @debug\n File.open(@debug_request_path, 'w') do |file|\n file.puts data\n end\n end\n headers = { \"Content-Type\" => \"text/xml\"}\n server.use_ssl = true\n resp = server.post(path, data, headers)\n if @debug\n File.open(@debug_response_path, 'w') do |file|\n file.puts resp.body\n end\n end\n prices = parse_response(resp.body)\n end", "def xml_rpc\n begin\n @@xmlrpc_reader ||= XMLRPC::XMLParser::REXMLStreamParser.new\n method, args = @@xmlrpc_reader.parseMethodCall(request.content)\n if (args.length != 1) or\n !args[0].is_a?(Hash)\n raise \"Invalid request; expecting a single hash of named parameters.\"\n end\n args = args.first\n args[:method] = method\n args[:_safe] = false\n xact = Transaction.new(args)\n xact.validate_args\n api = xact.execute\n render_results(api)\n rescue => e\n api = API.new\n @errors = api.convert_error(e, 501, nil, true)\n render_results(api)\n end\n end", "def process_request\n @build_xml = build_xml\n pickup_serv_log('Final XML Request : ' + @build_xml.to_s)\n api_url_srv = api_url + \"/pickup\"\n pickup_serv_log('URL for API : ' + api_url_srv.to_s)\n api_response = self.class.post(api_url_srv, :body => build_xml)\n pickup_serv_log('API Response : ' + api_response.to_s)\n puts api_response if @debug\n response = parse_response(api_response)\n if success?(response)\n pickup_serv_log('Successfully Done : ' + response.to_s)\n success_response(api_response, response)\n else\n failure_response(api_response, response)\n end\n end", "def process_request\n api_response = self.class.post(api_url, :body => build_xml)\n puts api_response if @debug\n response = parse_response(api_response)\n if success?(response)\n success_response(api_response, response)\n else\n failure_response(api_response, response)\n end\n end", "def do_request(params)\n # Convert the uri to a URI if it's a string.\n if params[:uri].is_a?(String)\n params[:uri] = URI.parse(params[:uri])\n end\n host_url = \"#{params[:uri].scheme}://#{params[:uri].host}#{params[:uri].port ? \":#{params[:uri].port}\" : ''}\"\n\n # Hash connections on the host_url ... There's nothing to say we won't get URI's that go to\n # different hosts.\n @connections[host_url] ||= Fog::XML::Connection.new(host_url, @persistent, @connection_options)\n\n # Set headers to an empty hash if none are set.\n headers = params[:headers] || {}\n headers['Accept'] = 'application/*+xml;version=1.5' if version == '1.5'\n\n # Add our auth cookie to the headers\n if @cookie\n headers.merge!('Cookie' => @cookie)\n end\n\n # Make the request\n response = @connections[host_url].request({\n :body => params[:body] || '',\n :expects => params[:expects] || 200,\n :headers => headers,\n :method => params[:method] || 'GET',\n :path => params[:uri].path\n })\n\n # Parse the response body into a hash\n unless response.body.empty?\n if params[:parse]\n document = Fog::ToHashDocument.new\n parser = Nokogiri::XML::SAX::PushParser.new(document)\n parser << response.body\n parser.finish\n response.body = document.body\n end\n end\n\n response\n end", "def relay_response\n sim_response = AuthorizeNet::SIM::Response.new(params)\n if sim_response.success?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])\n render :text => sim_response.direct_post_reply(\n url_for(:controller => self.controller_name, :action => 'receipt', :only_path => false, \n :gateway => OPTIONS[:gateways][:authorize_net]), \n :include => true)\n else\n # return back to purchase page - will display error message there\n render :text => sim_response.direct_post_reply(\n url_for(:controller => self.controller_name, :action => 'purchase', :only_path => false, \n :order_id => params[:x_invoice_num], :failure => true), \n :include => true)\n end\n end", "def send_request; end", "def handle_xml( request )\n\t\tself.log.warn \"Unhandled XML message request (%p)\" % [ request.headers.pack ]\n\t\treturn nil\n\tend", "def send_xml_api_request(markup)\n result =\n if login_type == \"legacy\"\n send_request(markup, \"#{self.api_url}/XMLAPI#{@session_id}\", 'api')\n else\n send_oauth_request(markup, \"#{self.api_url}/XMLAPI\", 'api')\n end\n\n doc = Hash.from_xml(REXML::Document.new(result).to_s)\n\n return doc if silverpop_successful?(doc)\n\n raise_error(doc)\n end", "def send_request(method, options = {})\n http_method = :get\n endpoint = REST_API_ENDPOINT\n options.merge!(:api_key => @api_key, :method => method)\n sign_request(options)\n \n rsp = http_request(options, http_method, endpoint)\n \n rsp = '<rsp stat=\"ok\"></rsp>' if rsp == \"\"\n xm = XmlMagic.new(rsp)\n \n if xm[:stat] == 'ok'\n xm\n else\n raise Rocinante::Errors.error_for(xm.err[:code].to_i, xm.err[:msg])\n end\n end", "def render_evaluate_and_send(options)\n response = render_and_evaluate(options)\n Skates.router.connection.send_xml response \n end", "def request \n\t\t\tif self.valid?\n\t\t\t\tpath = \"/#{Base.config.api_path}/#{self.request_action}\"\n\t\t\t\tconnection.post(path, self.to_xml).tap do |response|\n\t\t\t\t\treturn handle_response(response)\n\t\t\t\tend\n\t\t\telse\n\t\t\t\treturn false\n\t\t\tend\n\t\tend", "def send_sms(params)\n self.current_params = params\n response = send_request(params)\n smart_response(response.parsed_response)\n end", "def check_for_xml \n return true unless is_xml_request? \n return(render(:text => '<Response>Error: bad xml</Response>')) unless @request.env['RAW_POST_DATA'] && !@request.env['RAW_POST_DATA'].strip.empty? \n\n # headers['Content-Type'], NOT headers['CONTENT_TYPE'] \n @response.headers['CONTENT_TYPE'] = 'text/xml; charset=utf-8' \n @response.headers['Content-Type'] = 'text/xml; charset=utf-8' \n\n xml = REXML::Document.new(request.env['RAW_POST_DATA']) \n login_user(xml) \n return(render(:text => '<Response>bad username or password</Response>') and false) unless current_user \n\n begin \n (delete_trust(xml) and return false) if is_delete_trust? \n (create_trust_xml(xml) and return false) if is_create_trust? \n (xml_profile_list(xml) and return false) if is_profile_list? \n (xml_query_profile(xml) and return false) if is_query_profile? \n\n params.merge!(get_params_from_xml(xml)) \n\n\t \t create_trust_if_necessary(xml) \n\t \trescue \n \t return(render(:text => '<Response>Error: bad xml format.</Response>')) \n end\n end", "def xml_http_request?; end", "def response_xml\r\n @sess.DoRequests(@request_set).ToXMLString\r\n end", "def run\n\n action Colors.grey(\"REQUEST \") + Colors.light_blue(\"#{options[:method].upcase} #{url}\")\n Console.instance.indent\n # run the request\n options[:ssl_verifypeer] = false\n options[:followlocation] = true\n\n Injector.decorate(options)\n\n # convert all headers keys to strings to avoid having symbols like :\"header\" when\n # declaring headers with colons instead of arrows\n if options.key?(:headers)\n new_opts = {}\n options[:headers].map do |k, v|\n new_opts[k.to_s] = v\n end\n options[:headers] = new_opts\n end\n\n if options.key?(:headers) and options[:headers].key?('Content-Type')\n ctype = options[:headers]['Content-Type']\n if ctype.include?('application/json')\n # automatically encode json content\n options[:body] = JSON.generate(options[:body], quirks_mode: true)\n end\n end\n\n\n\n self.response = Typhoeus::Request.new(url, options).run\n\n self.req_response = RequestResponse.new.tap { |r|\n r.raw_body = response.body\n r.headers = response.headers\n r.code = response.code\n r.total_time = response.total_time\n\n if !r.headers.nil? && r.headers.key?('Content-Type') && r.headers['Content-Type'].include?('application/json')\n r.body = JSON.parse(response.body)\n else\n r.body = response.body\n end\n }\n\n # reset assertion counter\n self.assert_no = 1\n\n # evaluate response against expectations\n begin\n instance_eval(&expectations)\n rescue AssertionException\n error error_msg + \" at #{expectations.source_location}\"\n raise RequestException\n rescue StandardError => e\n error 'Exception ' + e.message\n info e.backtrace.inspect\n _debug_info\n error error_msg\n raise RequestException\n ensure\n Console.instance.unindent\n end\n\n req_response\n\n end", "def process_request\n api_response = self.class.post(api_url, :body => build_xml)\n Rails.logger.info(build_xml)\n puts api_response if @debug == true\n response = parse_response(api_response)\n if success?(response)\n puts response.inspect if @debug == true\n return true\n else\n puts api_response if @debug == true\n error_message = if response[:shipment_reply]\n [response[:shipment_reply][:notifications]].flatten.first[:message]\n else\n api_response[\"Fault\"][\"detail\"][\"fault\"][\"reason\"]\n end rescue $1\n raise PickUpError, error_message\n end\n end", "def op_receive_response_xml(params)\n return -1 unless valid?\n\n # only process when in the 'Processing' state\n unless @ticket.state == 'Processing'\n log \"Ticket state #{@ticket.state} not valid for processing responses\"\n @ticket.request_error! @last_log_message\n return -1\n end\n\n responseXML = params[:response]\n log \"Received response XML from QuickBooks\"\n\n # handle a connection error\n unless params[:hresult].blank? and params[:message].blank?\n log \"Connection error with QuickBooks: #{params[:hresult]} : #{params[:message]}\"\n\n @ticket.request_error!(@last_log_message, connection_error_hresult: params[:hresult], connection_error_message: params[:message])\n\n # also update the request if it is able to be found\n request = find_outstanding_request(responseXML)\n request.update!(response_qbxml: responseXML, state: 'Error') if request\n\n return -1\n end\n\n # find the corresponding request\n request = find_outstanding_request(responseXML)\n\n unless request\n log \"Received response back from QuickBooks but it did not correspond to any outstanding ticket request\"\n @ticket.request_error! @last_log_message\n return -1\n end\n\n log \"Found corresponding request [#{request.state}]\"\n\n # safety check. we should always get a response back for the current request\n unless request == @ticket.qb_request\n log \"Received response from QuickBooks but it references a request other than the current request\"\n @ticket.request_error! @last_log_message\n return -1\n end\n\n # process the response XML now\n unless request.consume_response_xml(responseXML)\n # this request for some reason did not succeeed. Update the request and the ticket\n log \"Request [#{request.state}] could not process the QuickBooks response: #{request.error}\"\n request.update!(response_qbxml: responseXML, state: 'Error')\n @ticket.error! @last_log_message\n return -1\n end\n\n request.update!(response_qbxml: responseXML) # This was changed for effective_qb_sync\n\n # the request has processed the response XML. if it does not have any more work to do, then detach it\n\n if request.has_more_work?\n log \"Request [#{request.state}] has more work to do on the next request\"\n else\n # detach the current request\n @ticket.update!(qb_request: nil)\n log \"Request [#{request.state}] has completed its work\"\n end\n\n work_done = @ticket.qb_requests.size\n work_left = how_much_more_work\n work_left = work_left + 1 if @ticket.qb_request # if there is still a current request we need to add that to the work_left\n\n work_left == 0 ? 100 : (work_done * 100 / (work_done + work_left))\n end", "def process(xml)\n timeout(TIMEOUT) do\n url = URI.parse(webservices_url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n http.start {\n request = Net::HTTP::Post.new(url.to_s)\n request.body = xml\n response = http.request(request)\n response.body\n }\n end\n end", "def render_xml_response \n @trust.update_attributes(:expires_at => Time.now.utc) if @trust && @trust.xml_expire? \n response.headers['CONTENT_TYPE'] = 'text/xml; charset=utf-8' \n response.headers['Content-Type'] = 'text/xml; charset=utf-8' \n render :text => \"<Response>#{@resp.headers['location'].gsub(/&/,'&#38;')}</Response>\" \n end", "def exec\n # If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an\n # origin, we must make sure we send back HTTP/1.0 if this was\n # requested.\n # This is mainly because nginx doesn't support Chunked Transfer\n # Encoding, and this forces the webserver SabreDAV is running on,\n # to buffer entire responses to calculate Content-Length.\n @http_response.http_version = @http_request.http_version\n\n # Setting the base url\n @http_request.base_url = base_uri\n invoke_method(@http_request, @http_response)\n rescue ::Exception => e # use Exception (without ::) for easier debugging\n begin\n emit('exception', [e])\n rescue\n end\n\n dom = LibXML::XML::Document.new\n\n error = LibXML::XML::Node.new('d:error')\n LibXML::XML::Namespace.new(error, 'd', 'DAV:')\n LibXML::XML::Namespace.new(error, 's', NS_SABREDAV)\n dom.root = error\n\n h = lambda do |v|\n CGI.escapeHTML(v)\n end\n\n if self.class.expose_version\n error << LibXML::XML::Node.new('s:sabredav-version', h.call(Version::VERSION))\n end\n\n error << LibXML::XML::Node.new('s:exception', h.call(e.class.to_s))\n error << LibXML::XML::Node.new('s:message', h.call(e.message))\n\n if @debug_exceptions\n backtrace_node = LibXML::XML::Node.new('s:backtrace')\n e.backtrace.each do |entry|\n backtrace_node << LibXML::XML::Node.new('s:entry', entry)\n end\n error << backtrace_node\n end\n\n if e.is_a?(Exception)\n http_code = e.http_code\n e.serialize(self, error)\n headers = e.http_headers(self)\n else\n http_code = 500\n headers = {}\n end\n\n headers['Content-Type'] = 'application/xml; charset=utf-8'\n @http_response.status = http_code\n @http_response.update_headers(headers)\n @http_response.body = dom.to_s\n sapi.send_response(@http_response)\n end", "def disp_xml_rq\n body= File.open(\"public/OTA/OTA_HotelAvailRQ100.xml\").read\n render :xml => body\n end", "def execute\n options = {\n method: :post,\n timeout: 6000,\n open_timeout: 6000,\n accept: :schema\n }\n options.merge!(url: @url, payload: @html)\n begin\n res = RestClient::Request.execute(options).to_str\n @response = JSON.parse(res)\n rescue => e\n puts \"some problems with #{@url}\"\n puts e\n nil\n end\n end", "def do_request(command, params)\n url = request_url(command, params)\n @xml_getter.fetch url\n end", "def send_raw_request raw_params\n @request_id += 1\n begin\n raw_response = server.request(raw_post_request(raw_params))\n rescue NoMethodError, SocketError => e\n raise RequestError.new(\"Could not connect to Zabbix server at #{host_with_port}\")\n end\n raw_response\n end", "def request_message\n return if @parts.empty?\n\n @request_message = Part.new do\n content_type 'multipart/related; type=\"text/xml\"'\n end\n\n soap_body = self.to_xml\n soap_message = Part.new do\n content_type 'text/xml; charset=utf-8'\n add_content_transfer_encoding\n body soap_body\n end\n soap_message.add_content_id \"<savon_soap_xml_part>\"\n @request_message.add_part(soap_message)\n @parts.each do |part|\n @request_message.add_part(part)\n end\n #puts @request_message\n @request_message\n end", "def send_xml(out_xml)\n uri = URI.parse(@url)\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Post.new(uri.request_uri)\n\n @logger.error \"#$%$ #{@user}\"\n request.basic_auth @user, @password\n request.body = out_xml\n\n log(\"Sending request: #{request.inspect}\")\n response = http.request(request)\n\n log(\"Response: #{response}\")\n return response.body\n end", "def process_request\n client = Savon.client(wsdl: \"http://cit.seur.com/CIT-war/services/ImprimirECBWebService?wsdl\", \n namespaces: { \"xmlns:imp\" => \"http://localhost:7026/ImprimirECBWebService\" }, \n namespace_identifier: :imp, \n env_namespace: :soapenv, \n pretty_print_xml: true)\n \n # client.operations => [:impresion_integracion_pdf_con_ecbws, :impresion_integracion_con_ecbws]\n\n if credentials[:seur_printer].blank?\n operation = :impresion_integracion_pdf_con_ecbws\n message = build_messagePDF\n else\n operation = :impresion_integracion_con_ecbws\n message = build_messageECB\n end\n request = client.build_request(operation, message: Gyoku.xml(message))\n response = client.call(operation, message: Gyoku.xml(message))\n result = response, request\n rescue Savon::HTTPError => error\n Rails.logger.error error.http.code\n raise \n end", "def send_api_request(method, params={}, data=nil)\n url = get_url(method, params)\n\n @http_response = send_request(url, data)\n return { } if @http_response.body.empty?\n\n # 'Hashify' the XML\n @xml_response = @http_response.body\n hash = Hash.from_xml(@xml_response)\n\n # simple validation of the xml body\n unless hash.has_key?(:returncode)\n raise BigBlueButtonException.new(\"Invalid response body. Is the API URL correct? \\\"#{@url}\\\", version #{@version}\")\n end\n\n # default cleanup in the response\n hash = BigBlueButtonFormatter.new(hash).default_formatting\n\n # if the return code is an error generates an exception\n unless hash[:returncode]\n exception = BigBlueButtonException.new(hash[:message])\n exception.key = hash.has_key?(:messageKey) ? hash[:messageKey] : \"\"\n raise exception\n end\n\n hash\n end", "def parse(response)\n Hpricot.XML(response || '')\n end", "def send_request(method, options = {}, http_method = :get, endpoint = REST_ENDPOINT)\n options.merge!(:api_key => @api_key, :method => method)\n sign_request(options)\n \n rsp = request_over_http(options, http_method, endpoint)\n \n rsp = '<rsp stat=\"ok\"></rsp>' if rsp == \"\"\n xm = XmlMagic.new(rsp)\n \n if xm[:stat] == 'ok'\n xm\n else\n raise Flickr::Errors.error_for(xm.err[:code].to_i, xm.err[:msg])\n end\n end", "def send_action(service, action, param)\r\n param_str = \"\"\r\n param.each do |key, value|\r\n param_str << '<%{key}>%{value}</%{key}>'.%(key: key, value: value)\r\n end\r\n xmldata = ActionXML.%(type: service.type, action: action, arguments: param_str)\r\n req = Net::HTTP::Post.new(uri = URI(@igd_location + service.control_url))\r\n req.content_type = 'text/xml; charset=\"utf-8\"'\r\n req['SOAPAction'] = '\"%{type}#%{action}\"'.%(type: service.type, action: action)\r\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\r\n http.request(req, xmldata)\r\n end\r\n #res = Net::HTTP.request(req, xmldata)\r\n xml = REXML::Document.new(res.body).root\r\n if(res.is_a?(Net::HTTPSuccess))\r\n xml.each_element('s:Body/u:*') do |element|\r\n return {is_error: false, has_xml: true, xml: element}\r\n end\r\n else\r\n return {is_error: true, \r\n faultcode: xml.get_text('s:Body/s:Fault/faultcode').to_s,\r\n faultstring: xml.get_text('s:Body/s:Fault/faultstring').to_s,\r\n code: xml.get_text('s:Body/s:Fault/detail/UPnPError/errorCode').to_s.to_i,\r\n descr: xml.get_text('s:Body/s:Fault/detail/UPnPError/errorDescription').to_s\r\n }\r\n end\r\n return {is_error: false, has_xml: false}\r\n end", "def request\n http_segments = @segments.clone\n @params.each do |key,value|\n http_segments[key] = value\n end\n \n # avoid using URI.encode\n query = ''\n http_segments.each do |key, value|\n query += \"&#{key}=#{value}\"\n end\n query = query[1..-1]\n \n uri = URI::HTTP.build(\n :host => HOST,\n :path => @action_path,\n :query => query\n ).to_s\n result = JSON.parse(HTTParty.get(uri).parsed_response)\n Baidumap::Response.new(result,self)\n end", "def process_request(legacy_xml_or_hash)\n c.soap(:ProcessRequest, { \n :ProcessRequest => { \n :_attributes => { :xmlns => 'http://wildwestdomains.com/webservices/' },\n :sRequestXML => \n c.class.escape_html(\n \"<wapi clTRID='#{GoDaddyReseller::API.next_uid[0..50]}'\" + \n \" account='#{user_id}' pwd='#{password}'>\" +\n \"#{legacy_xml_or_hash.is_a?(Hash) ? c.class.xml_encode_hash(legacy_xml_or_hash) : legacy_xml_or_hash.to_s}\" +\n \"</wapi>\"\n )\n }\n }\n )\n end", "def process_request\n api_response = self.class.post(api_url, :body => build_xml)\n Rails.logger.info(build_xml)\n puts api_response if @debug == true\n response = parse_response(api_response)\n if success?(response)\n puts response.inspect if @debug == true\n return response[:pickup_availability_reply]\n else\n puts api_response if @debug == true\n error_message = if response[:pickup_availability_reply]\n [response[:pickup_availability_reply][:notifications]].flatten.first[:message]\n else\n api_response[\"Fault\"][\"detail\"][\"fault\"][\"reason\"]\n end rescue $1\n raise PickUpError, error_message\n end\n end", "def parse_response(xml)\n raise NotImplementedError\n end", "def ems\n GatewayMessage.store( params[:xml] )\n render :text => 'OK'\n end", "def render_xml\n content = Nokogiri::XML::Builder.new(:encoding => \"UTF-8\") do |xml|\n yield xml\n end.to_xml\n response.body = [content]\n response[\"Content-Type\"] = 'text/xml; charset=utf-8'\n response[\"Content-Length\"] = content.to_s.bytesize.to_s\n end", "def send\n post_params = {}\n self.parameters.each { |key, value|\n if value.is_a? Array\n i = 0\n value.each { |value_value|\n post_params[key.to_s + '[' + i.to_s + ']'] = value_value.to_s\n i += 1\n }\n elsif value.is_a? Hash\n value.each { |value_key, value_value|\n post_params[key.to_s + '[' + value_key.to_s + ']'] = value_value.to_s\n }\n else\n post_params[key.to_s] = value.to_s\n end\n }\n\n url = URI.parse(@@API_URL)\n http_request = Net::HTTP::Post.new(url.path)\n http_request.form_data = post_params\n http_request.basic_auth url.user, url.password if url.user\n\n response = Spree::PAYONE::Proxy::Response.new\n connection = Net::HTTP.new(url.host, url.port)\n load_ca_file connection\n connection.use_ssl = true\n connection.start { |http|\n http_response = http.request(http_request)\n response.response_body= http_response.body\n }\n\n response\n end", "def execute()\n # If we are using the simple review request configuration\n if @configurations['configuration_type'] == 'Simple'\n # Encode the csrv, this will ensure that any '#' characters in the\n # InstanceId are escaped.\n csrv = encode_url_parameter(@parameters['csrv'])\n # Concatenate the application path, review request Servlet path, and the\n # encoded InstanceId of the desired submission\n url = \"#{@configurations['application_path']}ReviewRequest?csrv=#{csrv}\"\n # If we are using the advanced review request configuration\n else\n # Build up the HTTP parameter name/value pair Strings\n parameter_strings = @parameters.collect {|name, value|\n # Each parameter pair String maps the parameter to the encoded parameter\n # value. It is important to encode the value so that special characters\n # (such as '#' or '&') don't modify the intended meaning of the URL.\n \"#{name}=#{encode_url_parameter(value)}\" unless value.nil?\n }.compact\n\n # Build up the URL\n url = \"#{@configurations['application_path']}ReviewRequest?#{parameter_strings.join('&')}\"\n end\n\n # Return the results String\n <<-RESULTS\n <results>\n <result name=\"URL\">#{escape(url)}</result>\n </results>\n RESULTS\n end", "def send_request(request)\n @@last_request = request.to_parms_string if @@debug\n unless (@@debug && @@next_response)\n res = @connection.post PayTrace.configuration.url, parmlist: request.to_parms_string\n raw_response = res.body\n else\n raw_response = @@next_response\n end\n \n @@last_response = raw_response\n response = PayTrace::API::Response.new(raw_response)\n @@last_response_object = response\n\n @@next_response = nil # just to be sure\n\n if @@raise_exceptions && response.has_errors?\n raise PayTrace::Exceptions::ErrorResponse.new(response)\n else\n response\n end\n end", "def execute!\n validate_request!\n\n build_response!\n end", "def send_post(data_xml,url)\r\n result = @client.post(self.target_uri(url), :body => data_xml , :head => {'Content-Type' => 'application/xml'} ) \r\n raise \"Invalid status #{result.http_status} from server #{@host}:#{@port}\" if(result.http_status != '200') \r\n #reply = Reply.from_xml(result.http_body)\r\n if block_given?\r\n yield(result.http_body)\r\n else\r\n result.http_body\r\n end\r\n end", "def execute()\n # Initialize a service instance, this represents the vSphere server we are\n # connecting too.\n service_instance = ServiceInstance.new(\n URL.new(\"#{@info_values['server_url']}\"),\n \"#{@info_values['username']}\",\n \"#{@info_values['password']}\",\n true\n )\n\n # Attempt to retrieve the virtual machine\n root_folder = service_instance.getRootFolder()\n inventory = InventoryNavigator.new(root_folder)\n vm = inventory.searchManagedEntity(\"VirtualMachine\", @parameters['vm_name'])\n\n # If we were unable to retrieve the virtual machine\n if vm.nil?\n # Raise an error that the VM with the supplied name can not be found\n raise(\"There was no virtual machine found with the name #{@parameters['vm_name']}\")\n end\n \n begin\n # Attempt to power off the virtual machine\n task = vm.powerOffVM_Task()\n # Wait to see if the task raises an exception\n task.waitForMe()\n rescue NativeException => exception\n # If there was an invalid power state exception\n if exception.cause.is_a? com.vmware.vim25.InvalidPowerState\n # Raise a more intelligent error message\n raise \"Unable to power off a Virtual Machine that is not powered on.\"\n else\n # Re-raise the original error\n raise\n end\n end\n \n # Build and return the results xml that will be returned by this handler.\n results = \"<results/>\"\n puts(\"Results: \\n#{results}\") if @debug_logging_enabled\n return results\n end", "def execute(request)\n savon_response = @client.call(request.type, :message => request.body)\n log_response(savon_response)\n request.response(savon_response)\n rescue Savon::SOAPFault => e\n raise SimpleShipping::RequestError.new(e)\n end", "def do_request(params)\n # Convert the uri to a URI if it's a string.\n if params[:uri].is_a?(String)\n params[:uri] = URI.parse(params[:uri])\n end\n host_url = \"#{params[:uri].scheme}://#{params[:uri].host}#{params[:uri].port ? \":#{params[:uri].port}\" : ''}\"\n\n # Hash connections on the host_url ... There's nothing to say we won't get URI's that go to\n # different hosts.\n @connections[host_url] ||= Fog::Connection.new(host_url, @persistent, @connection_options)\n\n # Set headers to an empty hash if none are set.\n headers = params[:headers] || {}\n\n # Add our auth cookie to the headers\n if @cookie\n headers.merge!('Cookie' => @cookie)\n end\n\n # Make the request\n response = @connections[host_url].request({\n :body => params[:body] || '',\n :expects => params[:expects] || 200,\n :headers => headers,\n :method => params[:method] || 'GET',\n :path => params[:uri].path\n })\n\n # Parse the response body into a hash\n #puts response.body\n unless response.body.empty?\n if params[:parse]\n document = Fog::ToHashDocument.new\n parser = Nokogiri::XML::SAX::PushParser.new(document)\n parser << response.body\n parser.finish\n\n response.body = document.body\n end\n end\n\n response\n end", "def send( xml )\n command = \"<unit x='#{x}' y='#{y}'>#{xml}</unit>\"\n response = @game.send command\n doc = Hpricot.XML( response )\n @finished = !! doc.at( 'finished' )\n if not @finished\n $stderr.puts \" #{self} NOT FINISHED:\\n\\t#{response}\"\n end\n if not doc.at( 'ok' )\n error = doc.at 'error'\n if error\n message = \"ERROR from server: #{error.inner_html}\"\n else\n message = \"RECEIVED:\\n#{response}\"\n end\n raise \"Failed to execute:\\n#{command}\\n#{message}\"\n end\n response\n end", "def request_for_twiml!(path, options = {})\n @current_path = normalize_redirect_path(path)\n\n # Post the query\n rack_test_session_wrapper = Capybara.current_session.driver\n @response = rack_test_session_wrapper.send(options[:method] || :post, @current_path,\n :format => :xml,\n :CallSid => @root_call.sid,\n :From => @root_call.from_number,\n :Digits => formatted_digits(options[:digits].to_s, :finish_on_key => options[:finish_on_key]),\n :To => @root_call.to_number,\n :AnsweredBy => (options[:is_machine] ? \"machine\" : \"human\"),\n :CallStatus => options.fetch(:call_status, \"in-progress\")\n )\n\n # All Twilio responses must be a success.\n raise \"Bad response: #{@response.status}\" unless @response.status == 200\n\n # Load the xml\n data = @response.body\n @response_xml = Nokogiri::XML.parse(data)\n set_xml(@response_xml.at_xpath(\"Response\"))\n end", "def send_request(request)\n\n factory_hash = request.to_hash\n @request.body = factory_hash.to_json\n\n # send request\n response = @http.request(@request)\n http_response = HttpResponse.new(response)\n\n parser = InjectionResponseParser.new\n parser.parse(http_response)\n\n end", "def sendToTrufina(xml)\n puts \"Sending XML to #{domain}#{endpoint}:\\n\\n#{xml}\\n\\n\" if Trufina::Config.debug?\n \n # Connection Info\n api = Net::HTTP.new( domain, 443 )\n api.use_ssl = true\n api.verify_mode = OpenSSL::SSL::VERIFY_NONE # Prevent annoying warnings\n \n # Request info\n method_call = Net::HTTP::Post.new( endpoint, {'Content-Type' => 'text/xml'} )\n method_call.body = xml\n\n if Config.staging?\n method_call.basic_auth(Config.staging_access[:username], Config.staging_access[:password])\n end\n \n # OK, execute the actual call\n response = api.request(method_call)\n raise Exceptions::NetworkError.new(response.msg) unless response.is_a?(Net::HTTPSuccess)\n parseFromTrufina(response.body)\n end", "def send_request\n setup_connection\n send_request_with_lazy_pirate unless error?\n end", "def result\n render_xml\n end", "def soap_call(name, method, params = {})\n begin\n result = @service.request(name) do |soap|\n # soap.action = \"KashFlow/#{method}\"\n\n params = params.pop if params.is_a?(Array)\n params_xml = Gyoku.xml(params, { key_converter: :camelcase }) if params.present?\n\n params_xml = params_xml.gsub(/Id>/,\"ID>\") if params_xml\n params_xml = params_xml.gsub(/Dbid>/,\"DBID>\") if params_xml\n params_xml = params_xml.gsub(/<InvoiceLine>/, \"<InvoiceLine xsi:type=\\\"InvoiceLine\\\">\") if params_xml\n pretext, posttext = object_wrapper(name, params_xml)\n\n soap.xml = %[<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soap:Body>\n <#{method} xmlns=\"KashFlow\">\n <UserName>#{@login}</UserName>\n <Password>#{@password}</Password>\n #{pretext}\n #{params_xml}\n #{posttext}\n </#{method}>\n </soap:Body>\n </soap:Envelope>]\n end.to_hash\n rescue Savon::SOAP::Fault => e\n puts \"soap fault:\" + e.inspect\n return false\n end\n end", "def execute(request)\n request.pretty_print\n element = @pt.extract(URI.parse(request.get_uri_path))\n if element.nil? then\n request.respond(CR[:not_found])\n else\n primary(request, element)\n end\n request.send_response\n ## XXX: do we need to be able to really handle\n ## this method in a custom fashion?\n end", "def execute\n res = Net::HTTP.start(@query.uri.hostname, @query.uri.port) do |http|\n req = Net::HTTP::Post.new(@query.uri)\n req['Cookie'] = @session_cookie_provider.current.value\n req['Content-Type'] = \"application/json; charset=utf-8\"\n req.body = build_body(@query.attributes)\n\n http.request(req)\n end\n # TODO: handle invalid responses\n @parser.parse(res.body)\n end", "def send_to_ocr\n run_callbacks :send_to_ocr do\n self.response = http.request(request)\n self.response_body = JSON.parse(response.body)\n end\n end", "def xml\n\t\theaders[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\t\trender :layout => false\n\tend", "def make_request action, params\r\n hash = to_wsdl(params)\r\n tries = 0\r\n\r\n begin\r\n tries += 1\r\n header = authentication_header unless action == 'AuthenticateUser'\r\n response = client.send(\"#{action}!\") do |soap|\r\n soap.namespace = LL_NAMESPACE + '/'\r\n soap.action = LL_NAMESPACE + '/' + action\r\n soap.input = action\r\n soap.header = header\r\n soap.body = hash\r\n end\r\n if response.http.code != '200'\r\n raise \"SYWR: SOAP #{action} failed\"\r\n else\r\n response\r\n end\r\n rescue => e\r\n if tries < 3\r\n reset_token if e == '(detail) Authenticated token has expired or is invalid'\r\n logger.debug \"SYWR: SOAP #{action} failed - #{e}\"\r\n retry\r\n else\r\n logger.warn \"SYWR: SOAP #{action} completely failed - #{e}\"\r\n @errors << 'failed'\r\n nil\r\n end\r\n end\r\n end", "def send_request(params, payload=nil, content_type=nil)\n req_params = setup_request(params, payload, content_type)\n\n handled_request(req_params) do\n request = RestClient::Request.new(req_params)\n\n response = request.execute\n if ![200, 201, 202, 204].include?(response.code)\n @logger.warn \"Warning: unattended code #{response.code}\"\n end\n\n parsed_response = Nokogiri::XML(response)\n @logger.debug \"Send request result: #{parsed_response}\"\n\n [parsed_response, response.headers]\n end\n end", "def http_report(request, _response)\n path = request.path\n\n root_element_name = Box.new('')\n result = @server.xml.parse(request.body, request.url, root_element_name)\n root_element_name = root_element_name.value\n\n if @server.emit('report', [root_element_name, result, path])\n # If emit returned true, it means the report was not supported\n fail Exception::ReportNotSupported\n end\n\n # Sending back false will interupt the event chain and tell the server\n # we've handled this method.\n false\n end", "def execute client, request_context\n #data = request_context[:data]\n #data = data.to_xml if data.respond_to?(:to_xml)\n url = [request_context[:path], request_context[:query]].join(\"?\")\n url = \"/\" + url unless url[0].chr == \"/\"\n begin\n body = direct.request(url, request_context[:data])\n rescue\n $!.extend RSolr::Error::SolrContext\n $!.request = request_context\n raise $!\n end\n {\n :status => 200,\n :body => body,\n :headers => {}\n }\n end", "def execute\n raise \"HTTP Method #{@http_method} is not implemented\" if params.nil?\n @response = execute_call\n @user_context.server_skew = @response.server_skew\n @response\n end", "def execute!\n validate_request!\n perform_request!\n\n build_response\n end", "def get_results\n begin\n results = Nokogiri::XML(open(URI.encode(@request.full)))\n rescue SystemCallError, EOFError\n retry\n end\n # puts results\n parse results, :query => @request.q\n end", "def call(requesth)\r\n # convert hash values to CGI request (NVP) format\r\n req_data= \"#{hash2cgiString(requesth)}&#{hash2cgiString(@@cre)}&#{hash2cgiString(@@ci)}\"\r\n\r\n if (@@pi[\"USE_PROXY\"])\r\n # if (@profile.m_use_proxy) # Using PayPalSDKProfiles::Profile\r\n if( @@pi[\"USER\"].nil? || @@pi[\"PASSWORD\"].nil? )\r\n http = Net::HTTP::Proxy(@@pi[\"ADDRESS\"],@@pi[\"PORT\"]).new(@@ep[\"SERVER\"], 443)\r\n else\r\n http = Net::HTTP::Proxy(@@pi[\"ADDRESS\"],@@pi[\"PORT\"],@@pi[\"USER\"], @@pi[\"PASSWORD\"]).new(@@ep[\"SERVER\"], 443)\r\n end\r\n else\r\n http = Net::HTTP.new(@@ep[\"SERVER\"], 443)\r\n end\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE #unless ssl_strict\r\n http.use_ssl = true\r\n\r\n maskedrequest = mask_data(req_data)\r\n# @@PayPalLog.info \"Sent: #{maskedrequest}\"\n @@PayPalLog.info \"Sent: #{CGI.unescape(maskedrequest)}\"\n# @@PayPalLog.info \"Sent: #{CGI.unescape(maskedrequest).gsub('&',';')}\"\r\n\n contents, unparseddata = http.post2(@@ep[\"SERVICE\"], req_data, @@headers)\r\n\n @@PayPalLog.info \"Received: #{CGI.unescape(unparseddata)}\"\n# @@PayPalLog.info \"Received: #{CGI.unescape(unparseddata).gsub('&',';')}\"\n# @@PayPalLog.info \"Received: #{CGI::parse(unparseddata).to_yaml}\"\r\n\n data =CGI::parse(unparseddata)\r\n transaction = Transaction.new(data)\r\n end", "def render_xml\n end", "def request\n result = {}\n req_xml.blank? ? xml = '' : xml = req_xml\n doc = Hpricot.XML(xml)\n (doc/:RequestAuth/:UserPass/:User).inner_html = 'XXXXXXXX'\n (doc/:RequestAuth/:UserPass/:Password).inner_html = 'XXXXXXXX'\n result[:xml] = ErpHelper.xml2html(doc.to_s)\n result[:street] = (doc/:BillTo/:Address/:Street).inner_text\n result[:city] = (doc/:BillTo/:Address/:City).inner_text\n result[:state] = (doc/:BillTo/:Address/:State).inner_text\n result[:zip] = (doc/:BillTo/:Address/:Zip).inner_text\n result[:country] = (doc/:BillTo/:Address/:Country).inner_text\n result[:amount] = (doc/:PayData/:Invoice/:TotalAmt).inner_text\n result[:safe_cc_number] = (doc/:Tender/:Card/:CardNum).inner_text\n result[:expiration_date] = (doc/:Tender/:Card/:ExpDate).inner_text\n result[:expiration_year] = result[:expiration_date][-4,2]\n result[:expiration_month] = result[:expiration_date][-2,2]\n return result\n end", "def execute\n begin\n # Build and send a SOAP request for the 'mc_issue_add' method (namespaced with\n # 'wsdl') of the configured soap endpoint by setting the 'input' body parameter.\n #\n # If there was a problem executing the SOAP request, a Savon::SOAP::Fault\n # (indicating a Web Service exception was raised) or a Savon::HTTP::Error\n # (indicating there was a problem communicating with the server) will be\n # raised.\n\t\t\n response = @client.request 'wsdl:mc_issue_set_tags' do |soap_message|\n # Set the enumeration parameter to the one selected during Task node\n # configuration. We need to prefix the parameter with a namespace since\n # it does not have a namespaced element to inherit from.\n soap_message.body = {\n\t\t\t'username' => @info_values['username'], 'password' => @info_values['password'], 'issue_id' => @parameters['issue_id'].to_i, 'tags' => \n\t\t\t{\n\t\t\t\t'item' => {\n\t\t\t\t\t'name' => @parameters['tag_name'],\n\t\t\t\t\t'id' => @parameters['tag_id']\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t}\n end\n # Rescue the error that is raised if we were unable to connect to the web\n # service server.\n rescue Errno::ECONNREFUSED\n # Re-raise a more intelligent error message (but maintain the original error backtrace).\n raise Errno::ECONNREFUSED, \"Unable to connect to the web service endpoint: #{@url}\", $!.backtrace\n # Rescue communication errors.\n rescue Savon::HTTP::Error\n # Re-raise a more intelligent error message (but maintain the original error type and backtrace).\n raise StandardError, \"There was a problem calling the web service: #{$!.to_s}\", $!.backtrace\n # Rescue exceptions raised by the web service\n rescue Savon::SOAP::Fault\n # Re-raise a more intelligent error message (but maintain the original error type and backtrace).\n raise StandardError, \"There was a problem executing the web method: #{$!.to_s}\", $!.backtrace\n end\n\n # In order to process the result, we will first convert the Savon::Response\n # object into a hash, then retrieve the desired value.\n res = response.to_hash[:mc_issue_set_tags_response][:return]\n\n # Build and return the results\n <<-RESULTS\n <results>\n <result name=\"Mantis_Issue_Tag_Added\">#{res}</result>\n </results>\n RESULTS\n end", "def run\n super\n\n # first, ensure we're fingerprinted\n require_enrichment\n\n uri = _get_entity_name\n\n headers = {}\n headers[\"Content-Type\"] = \"%{#context['com.opensymphony.xwork2.dispatcher.HttpServletResponse'].addHeader('X-Intrigue-Struts',888*888)}.multipart/form-data\"\n response = http_request(:get, uri, nil, headers) # no auth\n\n unless response\n _log_error \"No response received\"\n return\n end\n\n # show the response in the logs \n response.headers.each {|x| _log \"#{x}: #{response.headers[x]}\"}\n \n if response.headers['X-Intrigue-Struts'] =~ /788544/\n \n instance_details = { \n proof: \"#{response.headers['X-Intrigue-Struts']}\",\n }\n _create_linked_issue \"apache_struts_jakarta_parser\", instance_details\n end\n end", "def typhoeus_response\n @request.run\n end", "def send\n http = EM::HttpRequest.new(@uri).post(@request_options)\n\n http.callback do\n process(http.response)\n end\n\n http.errback do\n fail(http.error)\n end\n end", "def request\n @rpc.request\n end" ]
[ "0.6339378", "0.6231344", "0.61522204", "0.60964334", "0.600724", "0.597375", "0.58602387", "0.579789", "0.5697041", "0.5680977", "0.5674398", "0.5653115", "0.5624577", "0.55661297", "0.55544704", "0.5521125", "0.5497294", "0.5478834", "0.54606766", "0.54162884", "0.54162884", "0.5401033", "0.53885823", "0.53868407", "0.5385054", "0.53775924", "0.536927", "0.5361731", "0.5345863", "0.53393114", "0.53375846", "0.5335361", "0.5327876", "0.5323963", "0.528186", "0.5274291", "0.52423555", "0.5236464", "0.52279675", "0.52249795", "0.5219183", "0.52134955", "0.5211232", "0.5202795", "0.51976126", "0.51971346", "0.51903516", "0.5180416", "0.51747954", "0.5159645", "0.5158665", "0.5154112", "0.5152027", "0.5140938", "0.5135282", "0.5122802", "0.51079756", "0.50936997", "0.509193", "0.50841904", "0.5082151", "0.507153", "0.506683", "0.5066724", "0.5055672", "0.50462514", "0.5031521", "0.5027134", "0.5025182", "0.5023647", "0.50165147", "0.50119525", "0.4998671", "0.4996091", "0.49945855", "0.49297348", "0.4923586", "0.49232453", "0.49223354", "0.49127898", "0.49119857", "0.49115685", "0.4911049", "0.49076733", "0.4889074", "0.4887093", "0.48863605", "0.48756358", "0.48698553", "0.4867496", "0.4860688", "0.48517904", "0.48439634", "0.48435667", "0.48435166", "0.48346552", "0.48324943", "0.4828038", "0.48280105", "0.481722" ]
0.67916286
0
Insert filter arguments to a request
def insert_filter_args(xml, filter_args) if filter_args filter_args.each_with_index do |filter_arg, i| xml.arg({'id' => "#{i}"}, filter_arg) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_parameters=(_arg0); end", "def filter_parameters=(_arg0); end", "def add_filters(filters); end", "def filter_parameters; end", "def filter_parameters; end", "def Filter=(arg0)", "def filters=(_arg0); end", "def filters=(_arg0); end", "def query_parameters\n params = {}\n params['filter'] = @optional['filter'] if @optional['filter']\n params\n end", "def filter_args(filter)\n {\n list_position: filter.list_position.en.ordinate,\n real_size: filter.real_size.en.numwords,\n requested_size: filter.requested_size.en.numwords,\n filtered_size: filter.filtered_size.en.numwords,\n list_order: filter.list_order,\n filtered_position_offset: (filter.list_position + filter.filtered_size - 1).en.ordinate\n }\n end", "def add_filter\n @filter = true \n end", "def filter_argument; end", "def filter_params\n params.require(:filter).permit(:name, :description, :opt_in)\n end", "def add_filter(filter_argument = T.unsafe(nil), &filter_proc); end", "def set_arguments\n exclusion_list = %w[client_tag api request_name]\n all_parameters = request.request_parameters\n applicable_params = all_parameters.reject { |param_name, _value| exclusion_list.include?(param_name) }\n @arguments = {}\n applicable_params.each do |k, v|\n @arguments[k] = v.chomp\n end\n end", "def set_filter(opts)\n opts = check_params(opts,[:filters])\n super(opts)\n end", "def filter_params\n params.fetch(:filter, {}).permit(:text, :type)\n end", "def filter_method_params\n params.fetch(:filter_method, {})\n end", "def filter_params\n @_filter_params ||=\n case params[:filter]\n when Hash, ActionController::Parameters\n default_filters.each_with_object({}) do |field, hash|\n unformatted_field = @request.unformat_key(field)\n hash[unformatted_field] = params[:filter][field]\n end\n end\n end", "def anonymous_filter_params\n p = params.required('payload')\n # p.permit!('controls_params')\n # p.permit!('columns_params')\n # p.permit!('sorting')\n # p.permit!('global_config')\n p.permit(\n 'name',\n 'controls_list' => [],\n 'controls_hl_mode' => [],\n 'controls_params' => {},\n 'columns_list' => [],\n 'columns_params' => {},\n 'sorting' => {},\n 'global_config' => {}\n ).merge(permit_hashes(p, [\n 'controls_params',\n 'columns_params',\n 'sorting',\n 'global_config'\n ]))\n end", "def filtered_parameters; end", "def filter_params\n params.require(:filter).permit(:title, :department, :user, :commit)\n end", "def parameters_to_filter\n @parameters_to_filter ||= []\n end", "def filter_params\n params.require(:filter).permit(:template, :name, :code)\n end", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n end", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n end", "def filter_params\n params.require(:filter).permit(:name, :slug)\n end", "def filter_params\n params[:f] || {}\n end", "def filter_params\n params.require(:filter).permit(:name, :brand, :description, :notes)\n end", "def add_filters\n add_term_filters\n add_terms_filters\n add_range_filters\n end", "def filter_params\n params.require(:filter).permit(:name)\n end", "def filter\n @filter = params[:q]\n end", "def parse_filter_params(permitted:)\n # Symbolize the keys so the values can be used with keyword arguments in the filter scopes.\n filter_params = params[:filter].try(:permit, permitted).try(:to_h)\n end", "def to_param\n \"filter[#{name}]=#{value}\"\n end", "def filter_params\n @filter_params_cache ||= clean_hash(params[:filter]).with_indifferent_access\n end", "def add_filter(filter)\n @filters << filter\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def add_filter_param(param, value)\n @mg_params[filter_param_name.to_sym][param] = value unless @mg_params[filter_param_name.to_sym].key?(param)\n end", "def filtering_params\n params.slice(:country, :data_source, :vaccine,\n :date_updated_start_date, :date_updated_end_date,\n :first_vaccine_date_start, :first_vaccine_date_end)\n end", "def set_attributes(attrs)\n if attrs.has_key?(\"filters\")\n attrs = attrs.merge(attrs[\"filters\"])\n end\n super(attrs)\n end", "def parse_filters(params)\n if params['filters'].blank?\n Utilities::Geo::REGEXP_COORD.keys\n else\n params.permit(filters: [])[:filters].map(&:to_sym)\n end\n end", "def search_adding_filter(condition,value)\n conditions = params.dup[:conditions] || {}\n\n if PLURAL_FILTERS.include?(condition)\n conditions[condition] ||= []\n conditions[condition] << value\n else\n conditions[condition] = value\n end\n params.except(:quiet, :all, :facet).recursive_merge(:page => nil, :action => :show, :conditions => conditions)\n end", "def prepare_request_params(options)\n params = detect_request_input options.delete(:input)\n\n options.inject(params) do |params, kv|\n key, value = kv\n params.merge!(\"#{key.to_s.downcase.gsub(/_+/,'')}\" => value) \n end\n end", "def add_tag_filters\n return if options[:filter_ids].blank?\n options[:filter_ids].each do |filter_id|\n body.filter(:term, filter_ids: filter_id)\n end\n end", "def create_filter(**args)\n params = parameters(args) do\n required_params :name, :conditions, :type\n optional_params :name, :conditions, :type\n end\n request(:post, 'filters', params)\n end", "def filtering_params(params)\n\t\t params.slice(:name, :category_id, :trademark)\n\t\tend", "def filter\n params['filter_field'] || '*'\n end", "def filters=( args )\n @filters.clear\n add_filters(*args)\n end", "def controller_filter_params\n params.require(:controller_filter).permit(:http_method, :controller, :action_name)\n end", "def register_filter(mod); end", "def filtering_params\n params.slice( :title, :location )\n end", "def add_requirement( filter )\n\t\t\t@filterlist << filter\n\t\tend", "def strict_filters=(_arg0); end", "def filter_params\n\t\treturn params[:voter].permit(:name_for_filter, :election_id_for_filter)\n\tend", "def add_filter(filter_symbol)\n filters << filter_symbol\n end", "def apply_filter\n end", "def add_custom_search_filters(search); end", "def update!(**args)\n @communications_filter = args[:communications_filter] if args.key?(:communications_filter)\n @music_filter = args[:music_filter] if args.key?(:music_filter)\n @news_filter = args[:news_filter] if args.key?(:news_filter)\n @podcast_filter = args[:podcast_filter] if args.key?(:podcast_filter)\n @search_filter = args[:search_filter] if args.key?(:search_filter)\n @third_party_apps_filter = args[:third_party_apps_filter] if args.key?(:third_party_apps_filter)\n @video_filter = args[:video_filter] if args.key?(:video_filter)\n @webview_filter = args[:webview_filter] if args.key?(:webview_filter)\n end", "def parse_filter(filter_argument = T.unsafe(nil), &filter_proc); end", "def global_filter=(_arg0); end", "def filter_params\n params.require(:filter).permit(:source, :max_dist, :max_time)\n end", "def filter_parameters\n if @filter_parameters\n @filter_parameters || []\n else\n defined?(Rails) && Rails.application.config.filter_parameters\n end\n end", "def filter_params\n params.permit(*resource_filter_permitted_params)\n end", "def query_params=(_arg0); end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def filter(filter)\n @filters << CGI.escape(filter)\n self\n end", "def filter_params\n params.require(:filter).permit(family: [], number: [], sub_fam: [], sub_num: [], enhancement: [], enh_sub_fam: [], enh_sub_num: [])\n end", "def add_token_filter(filter, **options)\n add_into(@token_filters, filter, **options)\n nil\n end", "def filters\n end", "def also_use_rack_params_filters\n if cgi_data\n @params_filters ||= []\n @params_filters += cgi_data['action_dispatch.parameter_filter'] || []\n end\n end", "def filter *filters\n spawn :@filters, @filters + parse_filter_input(filters)\n end", "def add_filter(method_to_call, options = nil)\n if options == nil\n @filter_chain[method_to_call.to_sym] = true\n elsif options.has_key?(:only)\n @filter_chain[method_to_call.to_sym] = Hash.new\n @filter_chain[method_to_call.to_sym][:only] = options[:only]\n elsif options.has_key?(:except)\n @filter_chain[method_to_call.to_sym] = Hash.new\n @filter_chain[method_to_call.to_sym][:except] = options[:except]\n end\n end", "def filter_params\n params.permit(:zoom, :origin => [])\n end", "def build\n \"filter=#{filters.join(',')}\"\n end", "def filtering_params\n params.permit(:email)\n end", "def filters; end", "def filters; end", "def create_filter(options = {})\n context = options.delete(:context)\n context = [ context ] unless context.kind_of? Array\n options['context[]'] = context\n \n perform_request_with_object(:post, '/api/v1/filters',\n options, Mastodon::Filter)\n end", "def filtering_params(params)\n params.slice(:added_by, :after, :before)\n end", "def prepare_filters\n params = instance_values.symbolize_keys\n filters = clean_params(params)\n validate_filters(filters)\n end", "def add_filter(filter)\n @filters << filter\n self\n end", "def before_filter(filter_name, options)\n [options[:only]].flatten.each do |action|\n add_filter(filter_name, action)\n end\n end", "def advancedsearch\n params[:filter] = true;\n end", "def process_filters(search_opts = {})\n filter_str = ''\n if search_opts['filter']\n search_opts['filter'].each do |f|\n filter_str = \"#{filter_str} AND #{f}\"\n end\n search_opts.delete('filter')\n end\n filter_str\n end", "def update!(**args)\n @composite_filter = args[:composite_filter] if args.key?(:composite_filter)\n @value_filter = args[:value_filter] if args.key?(:value_filter)\n end", "def update!(**args)\n @composite_filter = args[:composite_filter] if args.key?(:composite_filter)\n @value_filter = args[:value_filter] if args.key?(:value_filter)\n end", "def register(params)\r\n @filter_field = params[\"filter\"]\r\n @return_field = params[\"return\"]\r\nend", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n @page_size = args[:page_size] if args.key?(:page_size)\n @page_token = args[:page_token] if args.key?(:page_token)\n end", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n @page_size = args[:page_size] if args.key?(:page_size)\n @page_token = args[:page_token] if args.key?(:page_token)\n end", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n @page_size = args[:page_size] if args.key?(:page_size)\n @page_token = args[:page_token] if args.key?(:page_token)\n end", "def add_facet_params(field, item)\n\t\tfilter(field).add(item).params\n\tend", "def filter_params\n params.permit(\n type: [],\n id: []\n ).to_h.symbolize_keys.merge!(project_id: sessions_current_project_id)\n end", "def entry_filter(args)\n if args.length == 1 && args.first.is_a?(String)\n { id: @api.normalize_id(args.first) }\n elsif args.length == 2\n { name: args.first, version: args.last }\n else\n raise ArgumentError\n end\n end", "def update!(**args)\n @filter_created = args[:filter_created] if args.key?(:filter_created)\n @filter_deleted = args[:filter_deleted] if args.key?(:filter_deleted)\n @filter_id = args[:filter_id] if args.key?(:filter_id)\n end", "def add_attribute filter, action\n @attributes[filter] << action\n end", "def build_args(args)\n args.each do |arg|\n arg.each do |key, value|\n case key.to_s\n when 'query_params'\n @query_params = value\n when 'request_headers'\n update_headers(value)\n when 'request_body'\n @request_body = value\n end\n end\n end\n end", "def named_filter; end", "def filter_redirect=(_arg0); end", "def filter_redirect=(_arg0); end", "def filter_params\n params.permit(\n :state,\n :start,\n :end,\n :course,\n :subject,\n :organizer_id,\n :teacher_email,\n :only_attended,\n :order_by\n )\n end" ]
[ "0.7019112", "0.7019112", "0.69137275", "0.6784069", "0.6784069", "0.6692211", "0.6600999", "0.6600999", "0.64978456", "0.6479139", "0.64715946", "0.6457765", "0.64549553", "0.6385913", "0.6374145", "0.6365863", "0.63474315", "0.6326313", "0.6320585", "0.62886226", "0.6262696", "0.6259233", "0.62443006", "0.6229767", "0.6198124", "0.6197459", "0.61642516", "0.6146469", "0.6129381", "0.6129123", "0.6123732", "0.6123722", "0.61054164", "0.6097109", "0.6088946", "0.60789716", "0.60637885", "0.6056592", "0.6055022", "0.6054281", "0.6048157", "0.6042143", "0.6014558", "0.6011073", "0.6001323", "0.6001057", "0.5997536", "0.5988514", "0.59872866", "0.59780055", "0.5977695", "0.596965", "0.5968235", "0.59637284", "0.59633046", "0.5954329", "0.5948394", "0.5947845", "0.5946675", "0.5935954", "0.59330237", "0.5905613", "0.5899663", "0.58959585", "0.5893211", "0.5887533", "0.58801407", "0.586278", "0.58580077", "0.5848205", "0.58127123", "0.58083826", "0.580382", "0.57936245", "0.57929546", "0.57929206", "0.57929206", "0.5776178", "0.577414", "0.5772693", "0.57680625", "0.576603", "0.57628614", "0.5761888", "0.5760846", "0.5760846", "0.5760263", "0.57586753", "0.57586753", "0.57586753", "0.5753869", "0.5747635", "0.57437295", "0.5742916", "0.5741185", "0.57322073", "0.57315075", "0.57312316", "0.57312316", "0.5729925" ]
0.7094534
0
Write a method that takes two arguments, a string and a positive integer, and prints the string as many times as the integer indicates. input: a string a positive integer output: at least one string
def repeat(string, integer) integer.times do puts string end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repeat(string, int)\n return 'invalid string argument' unless string.class == String\n return 'invalid integer argument' unless int.to_s.to_i == int\n int.times { |num| puts string }\nend", "def repeat(string, num)\n if num < 0\n puts 'The number is not a positive integer'\n else\n puts 'The number is a positive integer.'\n end\n num.times { puts string }\nend", "def repeat(string, i)\n if i == i.to_s.to_i # could make this it's own method like integer?()\n if i > 0\n i.times {puts string}\n else\n puts \"#{i} is not a positive integer.\"\n end\n else\n puts \"#{i} is not an integer.\"\n end\nend", "def repeat(str, nb_times)\r\n if nb_times < 0\r\n puts 'You must provide a positive number!'\r\n return\r\n end\r\n\r\n nb_times.times { puts str }\r\nend", "def repeat(string, num)\n string = string.to_s\n if num.to_i.positive?\n num\n else\n puts 'invalid input, integer must be positive'\n return\n end\n num.times { puts string }\nend", "def repeat(string, integer)\n unless integer.to_i > 0 || integer.is_a?(Integer)\n puts \"Incorrect input\"\n return\n end\n if string.empty?\n puts \"The string is empty\"\n return\n end\n integer.times { puts \"#{string}\"}\nend", "def repeat(string, integer)\n raise 'Integer must be positive' unless integer.positive?\n\n puts \"#{string}\\n\" * integer\nend", "def repeat(str, int)\n return puts \"Invalid parameters, please try again.\" if(int < 1 || str.empty?)\n \n int.times {puts str}\n \n # # other solution using loop\n # loop do \n # puts(str)\n # int -= 1\n # break if int == 0\n # end\nend", "def repeater(repetition = 1, string = \"No string was given :(\")\n repetition.times { p string }\nend", "def repeat(str, int)\n int.times { puts str }\nend", "def repeat(str, int)\n int.times { p str }\nend", "def repeat(string, int)\n int.times { puts string }\nend", "def repeat(str, num)\n if str.is_a?(String) == false || str.nil?\n puts \"Invalid input. Please enter a string.\"\n return\n end\n\n if num < 1 || num.nil?\n puts \"Invalid input. Please enter a number greater or equal to one.\"\n return\n elsif num.is_a?(Float)\n num = num.to_i\n end\n\n num.times { puts str }\nend", "def repeat(string, integer)\n integer.times { puts string }\nend", "def repeat_yourself(string,number)\n number.times { puts string }\nend", "def repeat(string, number)\n number.times{ puts string }\nend", "def repeat(str, num)\n num.times { puts str }\nend", "def repeat(str, num)\n num.times { puts str }\nend", "def repeat(str, num)\n num.times { puts str }\nend", "def repeat (string, integer)\n integer.times{puts string}\nend", "def repeat(string, number)\n number.times { puts string }\nend", "def repeat(string, number)\n number.times { puts string }\nend", "def repeat(string, int)\n int.times{puts string}\nend", "def repeat(string, num)\n num.times { puts string }\nend", "def repeat(string, num)\n num.times { puts string }\nend", "def repeat_yourself(str, int)\n count = 0\n loop do\n break if count == int \n\t puts str\n count +=1\n end\nend", "def repeat(string, int)\r\n int.times {puts string}\r\nend", "def repeat(input_str, number)\n number.times {puts input_str}\nend", "def repeat(str, num)\n puts num.times {puts str}\nend", "def repeat(str,int)\n while int.integer? && int > 0\n puts str\n int -= 1\n end\nend", "def repeat(string, int)\n int.times do\n p string\n end\nend", "def repeat(word, number)\n number.times { puts word}\nend", "def repeat(word, number)\n number.times { puts word }\nend", "def repeat(str, num)\n num.times do | i |\n puts str\n end\nend", "def repeat_it(string,n)\n string.is_a?(String) ? string*n : \"Not a string\"\nend", "def repeat(str, int)\n int.times do\n puts str\n end\nend", "def repeat(string, number)\n number.times {puts string}\nend", "def repeat(string, number)\n number.times {puts string}\nend", "def repeat_yourself(string, num) \n puts \"#{string}\\n\" * num\nend", "def repeat(string, num)\n num.times {puts string}\nend", "def repeat something, *rest\n if rest.length == 0\n return something + \" \" + something\n\n elsif not rest[0].to_i == 0\n number = rest[0].to_i\n repetitions = \"\"\n number.times do \n repetitions += something + \" \"\n end\n end\n repetitions.chop # remove last space \n # something + \" \" + something \nend", "def repeat(word, num)\n num.times { p word }\nend", "def q1_print_times(str, num)\n num.times {|num_here|\n p str\n }\nend", "def repeat(string, number)\n number.times do\n p string\n end\nend", "def times_string(str, num)\n p str * num\nend", "def stringy(int)\n (int/2).times { print 10 }\n 1 if int.odd?\nend", "def repeat(string, num)\n num.times do\n puts string\n end\nend", "def repeat(param_integer, param_string)\n param_integer.times do\n puts \"param_string\"\n end\nend", "def repeat_yourself(word, count)\n count.times {puts word}\n end", "def count_and_say(sequence)\n\treturn 0 if sequence == nil\n\tsequence = sequence.to_s\n\tn = sequence.to_s.size\n result = ''\n\ti = 1\n\trepeat = sequence[0]\n\ttimes = 1\n\twhile (i<=n) do\n\t\tif sequence[i] == repeat\n\t\t\ttimes += 1\n else\n \tresult += times.to_s + repeat.to_s\n \ttimes = 1\n repeat \t= sequence[i].to_i\n end\n i+=1\n end \n\treturn result \nend", "def plural_every(int, str)\r\n return \"#{int} #{str}s\" unless int == 1\r\n \"#{str}\"\r\n end", "def pluralizer string, n\n if n == 1 \n puts \"#{n} #{string}\"\n elsif n > 1 || n==0\n puts \"#{n} #{string}s\"\n end\nend", "def repeat(string, number)\n if !(string.instance_of?(String))\n raise \"first argument should be a String\"\n end\n if !(number.instance_of?(Integer))\n raise \"second argument should be a Integer\"\n end\n string*number\nend", "def repeat(string, number)\r\n number.times do\r\n puts string\r\n end\r\nend", "def num_repeats(string)\nend", "def stringy2(int, *zero)\n str = ''\n if zero == [0] then str += '0' else str += '1' end\n int.times do |n|\n if n > 0\n array = str.chars\n if array[n - 1] == '0' then str += '1' else str += '0' end\n end\n end\n p str\nend", "def print_line(str, num = 1)\n num.times { print str}\nend", "def repeat(input_str, pos_num)\n pos_num.times {puts input_str}\nend", "def repeat(str, n)\n\tn.times {|n| puts str}\nend", "def repeat(word, num)\n num.times { |_| puts word }\nend", "def repeater(n, str)\n i = 0\n while i < n\n puts str\n i += 1\n end\nend", "def repeating(str, num)\n x = 1\n while x <= num do \n puts str * x \n x += 1\n end\nend", "def repeat (say, how_many = 2)\n (\"#{say} \" * how_many).strip\n\nend", "def repeat_str (n, s)\r\n return s * n\r\nend", "def repeat(string, number_of_times)\n number_of_times.times do\n puts string\n end\nend", "def repeat_str(n, s)\n return s * n\nend", "def repeat(str, n)\n n.times do\n puts str\n end\nend", "def repeater(string, n)\n string * n\nend", "def repeat_str (n, s)\n s * n\nend", "def repeat_str (n, s)\n s * n\nend", "def repeat(string, times)\n times.times do\n print string\n end\nend", "def oneMore(number)\r\n symbol = number.to_s(2)\r\n kol = symbol.count(\"1\")\r\n puts(kol)\r\n #puts(12344.to_s(2))\r\n #puts (kol) #не_смог_через_return\r\nend", "def stringy(number, optional = 1)\n result = ''\n\n number.times do |num|\n if optional == 1\n result << ( numbers = num.even? ? '1' : '0' )\n else\n result << ( numbers = num.even? ? '0' : '1' )\n end\n end\n result\nend", "def stringy(integer, optional = 1)\n return_string = ''\n if optional == 1\n integer.times { |idx| idx.even? ? return_string << '1' : return_string << '0' }\n elsif optional == 0\n integer.times { |idx| idx.even? ? return_string << '0' : return_string << '1' }\n end\n return_string\nend", "def repeat_str n, s\n s * n\nend", "def output_spaces (intnumber, string=\"\")\n intnumber.times { print \" \" }\n puts string\nend", "def repeat(string, num = 2)\n\treturn ((string + \" \") * num).strip\nend", "def repeat_again(string, i)\n i.times {puts string}\nend", "def repeat_str (n, s)\n s*n\nend", "def repeat(str, num)\n counter = 0\n\n loop do\n break if counter == num\n\n puts str\n counter += 1\n end\nend", "def stringy(int)\n string = \"\"\n int.times do |x|\n x.even? ? string += \"1\" : string += \"0\"\n end\n string\nend", "def look_and_say(n)\n prev = \"1\"\n curr = \"\"\n\n while(n > 1)\n i = 0\n\n while(i < prev.length)\n\n char = prev[i]\n count = count_digits(i, prev)\n i += count\n\n curr << count.to_s << char\n end\n\n prev = curr.dup\n curr = \"\"\n n -= 1\n end\n\n prev\nend", "def loop_message_n_times(string, integer)\n counter = 0 \n while counter < integer do \n puts string \n counter += 1 \n end \nend", "def print_n_and_n_plus1(n)\n\tputs \"#{n} and #{n+1}\"\nend", "def stringy(int1, int2 = 1)\n numbers = []\n\n int1.times do |int| \n number = int.even? ? 0 : 1\n numbers << number\n end\n\n numbers.join\nend", "def stringy(int)\n new_string = \"\"\n (int / 2).times { new_string << \"10\" }\n new_string << \"1\" if int.odd? \n new_string\nend", "def pluralizer string, number\n if n == 1 \n puts \"#{number} #{string}\"\n elsif string == \"person\"\n puts \"#{number} people\"\n elsif string == \"child\"\n puts \"#{number} children\"\n elsif string == \"goose\"\n puts \"#{number} geese\"\n elsif n > 1 \n puts \"#{number} #{string}s\"\n end\nend", "def stringy(number, optional = 1)\n result = ''\n number.times do |num|\n if optional # dont need the == 1 here, just optional.\n num.even? ? result << '1' : result << '0'\n else num.odd? ? result << '1' : result << '0'\n end\n end\n result\nend", "def stringy(int)\n stringy = \"\"\n odd = false\n int.times do\n if odd == true\n stringy << \"0\"\n odd = false\n else \n stringy << \"1\"\n odd = true\n end\n end\n return stringy\nend", "def tame_it( number_of_shrews )\n puts \"Literally \" + number_of_shrews.to_s\nend", "def repeat(input, iterations = 0)\n if (iterations <= 2)\n \"#{input}\" + \" \" + \"#{input}\"\n else\n \"#{input} \" * (iterations - 1) + \"#{input}\"\n end\nend", "def printi(text, n = 1)\n print idt(n) + text\n end", "def stringy(integer)\n i = 1\n output = ''\n while i <= integer\n output += '1' if i.odd?\n output += '0' if i.even?\n i += 1\n end\n output\nend", "def stringy(int, int1 = 1)\n if int && int1 != 0\n Array.new(int) { |i| i.even? ? '1' : '0' }.join\n elsif int1 == 0\n Array.new(int) { |i| i.even? ? '0' : '1' }.join\n end\nend", "def stringy(num = 1)\n ones_zeros = []\n counter = 0\n \n loop do\n # break if num == 1\n if ones_zeros == []\n ones_zeros << 1\n end\n\n ones_zeros[counter] == 1 ? ones_zeros << 0 : ones_zeros << 1\n counter += 1\n break if counter == num -1\n end\n string_num = ones_zeros.join\nend", "def str_dup(n, str)\n n.times { print str, \" \"}\nend", "def stringy(number)\n string = \"\"\n number.times do |n|\n n.even? ? string << \"1\" : string << \"0\"\n end\n string\nend", "def string_length(num)\n if num == 0\n puts \"You have to give me something to work with, here.\"\n elsif num <= 10\n puts \"You're not much with words, are you?\"\n elsif num <= 20\n puts \"You've got a lot to say.\"\n else\n puts \"Sounds like you had quite a day!\"\n end\n end", "def stringy(number, optional = 1)\n result = ''\n 1.upto(number) do |num|\n if optional == 1\n answer = num.odd? ? '1' : '0'\n result << answer\n else\n answer = num.even? ? '1' : '0'\n result << answer\n end\n end\n\n result\nend", "def say_baa number_of_baas\n puts 'baaaaaaa...'*number_of_baas\n 'yellow submarine'\nend" ]
[ "0.77459663", "0.76784885", "0.76408774", "0.7569376", "0.7561316", "0.75529027", "0.72775435", "0.71979725", "0.7147224", "0.7125909", "0.70867366", "0.7080978", "0.70470273", "0.70152044", "0.7014705", "0.70093966", "0.6961474", "0.6961474", "0.6961474", "0.6957185", "0.6955336", "0.6955336", "0.69480747", "0.69445163", "0.69445163", "0.69304097", "0.69099236", "0.6905832", "0.68735534", "0.6869606", "0.68625826", "0.6841275", "0.6840694", "0.68292904", "0.68288904", "0.68288505", "0.68116003", "0.68116003", "0.6806802", "0.6795152", "0.6794431", "0.6786879", "0.67592907", "0.67093724", "0.6708075", "0.6707254", "0.6699891", "0.6693192", "0.66891724", "0.6681753", "0.66732574", "0.6595137", "0.6586575", "0.6573172", "0.65672946", "0.65401554", "0.65166485", "0.65146816", "0.65053815", "0.647386", "0.64699847", "0.64421785", "0.6417014", "0.63472813", "0.6342886", "0.63332784", "0.6328374", "0.6309729", "0.6309666", "0.6309666", "0.62905735", "0.6286157", "0.62778145", "0.62733436", "0.62703496", "0.6258477", "0.6253191", "0.6246831", "0.6240308", "0.62393564", "0.6229513", "0.6226962", "0.62255013", "0.62196", "0.6201703", "0.61989886", "0.6181145", "0.61810464", "0.61759293", "0.6174811", "0.6160624", "0.61586416", "0.6152502", "0.61403114", "0.6133218", "0.61231965", "0.61199707", "0.61108494", "0.6105751", "0.61041737" ]
0.67674845
42
store the countries information and create region list
def store_countries Countries::Data.get_data @regions = Countries::Country.create_region_list end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def countries_list\n [\n ['Afghanistan', 'Afghanistan'],\n ['Albania', 'Albania'],\n ['Algeria', 'Algeria'],\n ['American Samoa', 'American Samoa'],\n ['Andorra', 'Andorra'],\n ['Angola', 'Angola'],\n ['Antigua and Barbuda', 'Antigua and Barbuda'],\n ['Argentina', 'Argentina'],\n ['Armenia', 'Armenia'],\n ['Australia', 'Australia'],\n ['Austria', 'Austria'],\n ['Azerbaijan', 'Azerbaijan'],\n ['Bahamas', 'Bahamas'],\n ['Bahrain', 'Bahrain'],\n ['Bangladesh', 'Bangladesh'],\n ['Barbados', 'Barbados'],\n ['Belarus', 'Belarus'],\n ['Belgium', 'Belgium'],\n ['Belize', 'Belize'],\n ['Benin', 'Benin'],\n ['Bermuda', 'Bermuda'],\n ['Bhutan', 'Bhutan'],\n ['Bolivia', 'Bolivia'],\n ['Bosnia and Herzegovina', 'Bosnia and Herzegovina'],\n ['Botswana', 'Botswana'],\n ['Brazil', 'Brazil'],\n ['Brunei', 'Brunei'],\n ['Bulgaria', 'Bulgaria'],\n ['Burkina Faso', 'Burkina Faso'],\n ['Burundi', 'Burundi'],\n ['Cambodia', 'Cambodia'],\n ['Cameroon', 'Cameroon'],\n ['Canada', 'Canada'],\n ['Cape Verde', 'Cape Verde'],\n ['Cayman Islands', 'Cayman Islands'],\n ['Central African Republic', 'Central African Republic'],\n ['Chad', 'Chad'],\n ['Chile', 'Chile'],\n ['China', 'China'],\n ['Colombia', 'Colombia'],\n ['Comoros', 'Comoros'],\n ['Congo, Democratic Republic of the', 'Congo, Democratic Republic of the'],\n ['Congo, Republic of the', 'Congo, Republic of the'],\n ['Costa Rica', 'Costa Rica'],\n [\"Côte d'Ivoire\", \"Côte d'Ivoire\"],\n ['Croatia', 'Croatia'],\n ['Cuba', 'Cuba'],\n ['Cyprus', 'Cyprus'],\n ['Czech Republic', 'Czech Republic'],\n ['Denmark', 'Denmark'],\n ['Djibouti', 'Djibouti'],\n ['Dominica', 'Dominica'],\n ['Dominican Republic', 'Dominican Republic'],\n ['East Timor', 'East Timor'],\n ['Ecuador', 'Ecuador'],\n ['Egypt', 'Egypt'],\n ['El Salvador', 'El Salvador'],\n ['Equatorial Guinea', 'Equatorial Guinea'],\n ['Eritrea', 'Eritrea'],\n ['Estonia', 'Estonia'],\n ['Ethiopia', 'Ethiopia'],\n ['Fiji', 'Fiji'],\n ['Finland', 'Finland'],\n ['France', 'France'],\n ['French Polynesia', 'French Polynesia'],\n ['Gabon', 'Gabon'],\n ['Gambia', 'Gambia'],\n ['Georgia', 'Georgia'],\n ['Germany', 'Germany'],\n ['Ghana', 'Ghana'],\n ['Greece', 'Greece'],\n ['Greenland', 'Greenland'],\n ['Grenada', 'Grenada'],\n ['Guam', 'Guam'],\n ['Guatemala', 'Guatemala'],\n ['Guinea', 'Guinea'],\n ['Guinea-Bissau', 'Guinea-Bissau'],\n ['Guyana', 'Guyana'],\n ['Haiti', 'Haiti'],\n ['Honduras', 'Honduras'],\n ['Hong Kong', 'Hong Kong'],\n ['Hungary', 'Hungary'],\n ['Iceland', 'Iceland'],\n ['India', 'India'],\n ['Indonesia', 'Indonesia'],\n ['Iran', 'Iran'],\n ['Iraq', 'Iraq'],\n ['Ireland', 'Ireland'],\n ['Israel', 'Israel'],\n ['Italy', 'Italy'],\n ['Jamaica', 'Jamaica'],\n ['Japan', 'Japan'],\n ['Jordan', 'Jordan'],\n ['Kazakhstan', 'Kazakhstan'],\n ['Kenya', 'Kenya'],\n ['Kiribati', 'Kiribati'],\n ['North Korea', 'North Korea'],\n ['South Korea', 'South Korea'],\n ['Kosovo', 'Kosovo'],\n ['Kuwait', 'Kuwait'],\n ['Kyrgyzstan', 'Kyrgyzstan'],\n ['Laos', 'Laos'],\n ['Latvia', 'Latvia'],\n ['Lebanon', 'Lebanon'],\n ['Lesotho', 'Lesotho'],\n ['Liberia', 'Liberia'],\n ['Libya', 'Libya'],\n ['Liechtenstein', 'Liechtenstein'],\n ['Lithuania', 'Lithuania'],\n ['Luxembourg', 'Luxembourg'],\n ['Macedonia', 'Macedonia'],\n ['Madagascar', 'Madagascar'],\n ['Malawi', 'Malawi'],\n ['Malaysia', 'Malaysia'],\n ['Maldives', 'Maldives'],\n ['Mali', 'Mali'],\n ['Malta', 'Malta'],\n ['Marshall Islands', 'Marshall Islands'],\n ['Mauritania', 'Mauritania'],\n ['Mauritius', 'Mauritius'],\n ['Mexico', 'Mexico'],\n ['Micronesia', 'Micronesia'],\n ['Moldova', 'Moldova'],\n ['Monaco', 'Monaco'],\n ['Mongolia', 'Mongolia'],\n ['Montenegro', 'Montenegro'],\n ['Morocco', 'Morocco'],\n ['Mozambique', 'Mozambique'],\n ['Myanmar', 'Myanmar'],\n ['Namibia', 'Namibia'],\n ['Nauru', 'Nauru'],\n ['Nepal', 'Nepal'],\n ['Netherlands', 'Netherlands'],\n ['New Zealand', 'New Zealand'],\n ['Nicaragua', 'Nicaragua'],\n ['Niger', 'Niger'],\n ['Nigeria', 'Nigeria'],\n ['Norway', 'Norway'],\n ['Northern Mariana Islands', 'Northern Mariana Islands'],\n ['Oman', 'Oman'],\n ['Pakistan', 'Pakistan'],\n ['Palau', 'Palau'],\n ['Palestine', 'Palestine'],\n ['Panama', 'Panama'],\n ['Papua New Guinea', 'Papua New Guinea'],\n ['Paraguay', 'Paraguay'],\n ['Peru', 'Peru'],\n ['Philippines', 'Philippines'],\n ['Poland', 'Poland'],\n ['Portugal', 'Portugal'],\n ['Puerto Rico', 'Puerto Rico'],\n ['Qatar', 'Qatar'],\n ['Romania', 'Romania'],\n ['Russia', 'Russia'],\n ['Rwanda', 'Rwanda'],\n ['Saint Kitts and Nevis', 'Saint Kitts and Nevis'],\n ['Saint Lucia', 'Saint Lucia'],\n ['Saint Vincent and the Grenadines', 'Saint Vincent and the Grenadines'],\n ['Samoa', 'Samoa'],\n ['San Marino', 'San Marino'],\n ['Sao Tome and Principe', 'Sao Tome and Principe'],\n ['Saudi Arabia', 'Saudi Arabia'],\n ['Senegal', 'Senegal'],\n ['Serbia and Montenegro', 'Serbia and Montenegro'],\n ['Seychelles', 'Seychelles'],\n ['Sierra Leone', 'Sierra Leone'],\n ['Singapore', 'Singapore'],\n ['Slovakia', 'Slovakia'],\n ['Slovenia', 'Slovenia'],\n ['Solomon Islands', 'Solomon Islands'],\n ['Somalia', 'Somalia'],\n ['South Africa', 'South Africa'],\n ['Spain', 'Spain'],\n ['Sri Lanka', 'Sri Lanka'],\n ['Sudan', 'Sudan'],\n ['Sudan, South', 'Sudan, South'],\n ['Suriname', 'Suriname'],\n ['Swaziland', 'Swaziland'],\n ['Sweden', 'Sweden'],\n ['Switzerland', 'Switzerland'],\n ['Syria', 'Syria'],\n ['Taiwan', 'Taiwan'],\n ['Tajikistan', 'Tajikistan'],\n ['Tanzania', 'Tanzania'],\n ['Thailand', 'Thailand'],\n ['Togo', 'Togo'],\n ['Tonga', 'Tonga'],\n ['Trinidad and Tobago', 'Trinidad and Tobago'],\n ['Tunisia', 'Tunisia'],\n ['Turkey', 'Turkey'],\n ['Turkmenistan', 'Turkmenistan'],\n ['Tuvalu', 'Tuvalu'],\n ['Uganda', 'Uganda'],\n ['Ukraine', 'Ukraine'],\n ['United Arab Emirates', 'United Arab Emirates'],\n ['United Kingdom', 'United Kingdom'],\n ['United States', 'United States'],\n ['Uruguay', 'Uruguay'],\n ['Uzbekistan', 'Uzbekistan'],\n ['Vanuatu', 'Vanuatu'],\n ['Vatican City', 'Vatican City'],\n ['Venezuela', 'Venezuela'],\n ['Vietnam', 'Vietnam'],\n ['Virgin Islands, British', 'Virgin Islands, British'],\n ['Virgin Islands, U.S.', 'Virgin Islands, U.S.'],\n ['Yemen', 'Yemen'],\n ['Zambia', 'Zambia'],\n ['Zimbabwe', 'Zimbabwe']\n ]\n end", "def build_areas_from_country_codes\n CSV.read(\"#{@args[:data_directory]}data/external/country_names_and_code_elements.txt\", options = {headers: true, col_sep: ';'}).each do |r|\n @data_index.add_item(\n name: uncapitalize(r['Country Name']),\n parent_names: [@earth.name],\n lvl0: uncapitalize(r['Country Name']),\n source_table: 'country_names_and_code_elements',\n geographic_area_type_name: 'Country',\n is_internal_node: true,\n iso_3166_a2: r['ISO 3166-1-alpha-2 code']\n )\n end\n end", "def add_to_region\r\n western_states = [\"Arizona\", \"Colorado\", \"Idaho\", \"Montana\", \"Nevada\", \"New Mexico\", \"Utah\", \"Wyoming\", \"Alaska\", \"California\", \"Hawaii\", \"Oregon\", \"Washington\"]\r\n southern_states = [\"Alabama\", \"Arkansas\", \"Delaware\", \"Florida\", \"Georgia\", \"Kentucky\", \"Louisiana\", \"Maryland\", \"Mississippi\", \"North Carolina\", \"Oklahoma\", \"South Carolina\", \"Tennessee\", \"Texas\", \"Virgina\", \"West Virginia\"]\r\n eastern_states = [\"Maine\", \"New Hampshire\", \"Vermont\", \"Massachusetts\", \"Rhode Island\", \"Connecticut\", \"New York\", \"Pennsylvania\", \"New Jersey\"]\r\n midwest_states = [\"Wisconsin\", \"Michigan\", \"Illinois\", \"Indiana\", \"Ohio\", \"North Dakota\", \"South Dakota\", \"Nebraska\", \"Kansas\", \"Minnesota\", \"Iowa\", \"Missouri\"]\r\n\r\n if western_states.include?(name)\r\n @@wregion[:confirmed_cases] += self.confirmed_cases\r\n @@wregion[:overall_deaths] += self.overall_deaths\r\n elsif southern_states.include?(name)\r\n @@sregion[:confirmed_cases] += self.confirmed_cases\r\n @@sregion[:overall_deaths] += self.overall_deaths\r\n elsif eastern_states.include?(name)\r\n @@eregion[:confirmed_cases] += self.confirmed_cases\r\n @@eregion[:overall_deaths] += self.overall_deaths\r\n elsif midwest_states.include?(name)\r\n @@mregion[:confirmed_cases] += self.confirmed_cases\r\n @@mregion[:overall_deaths] += self.overall_deaths\r\n end\r\n\r\n end", "def set_countries\n writer_arr = Writer.select(\"country_id\").distinct.map{|c| c.country_id}\n outlet_arr = Outlet.select(\"country_id\").distinct.map{|c| c.country_id}\n @current_countries = (outlet_arr + writer_arr).sort.uniq\n end", "def countries\n countries = YAML.load_file(Rails.root.join('data', 'locale_countries.yml'))\n countries.select! { |_, flag| File.exist? Rails.root.join('app', 'assets', 'images', 'country-flags', \"#{flag.downcase}.png\") }\n # apply potential region values too\n Dir.glob(Rails.root.join('app', 'assets', 'images', 'country-flags', '*.png')).each do |file|\n base = File.basename(file, '.png')\n next if base.starts_with?('_')\n countries[base.upcase] = base\n end\n\n countries.each { |key, flag| countries[key] = view_context.image_path(\"country-flags/#{flag.downcase}.png\") }\n\n render json: countries.to_json\n end", "def countries\n @countries = Spree::Country.where(name: Spree::Config[:default_address_country])\n zone = Spree::Zone.find_by(name: Spree::Config[:address_zone_name]) if Spree::Config[:address_zone_name]\n @countries = zone.countries.order(:name) if zone.present?\n end", "def country_list_by_region(region)\n # select list of countries based on the region\n @countries = Countries::Country.find_by_region(region)\n \n # print the list of countries as table format\n Table.display_as_table(@countries)\n end", "def location\n # Retrieve info for dropdown\n @nationwide = Location.get_nationwide\n #@provinces = Location.provinces.where('id != ?', @nationwide.id).order('denorm_sort').collect {|p| [p.name.capitalize, p.id]}.insert(0, [@nationwide.name.capitalize, @nationwide.id])\n @provinces = Location.provinces.where('id != ?', @nationwide.id).order('denorm_sort')\n\n # Retrieve previously selected locations\n @curr_locations = current_user.present? ? current_user.locations.pluck(:id) : []\n\n # Get all regions for the map display \n @regions = Region.order('region_iso').all\n end", "def index\n @region_countries = RegionCountry.all\n \n\n end", "def identify_countries\n names = YAML.load_file( File.dirname(File.expand_path(__FILE__)) + '/lang/' + @lang + '/countries.yml' )\n names.each do |code,name|\n @svg.gsub!(\"class=\\\"land #{code}\\\"\", \"class=\\\"land #{code}\\\" country-name=\\\"#{name}\\\" country-value=\\\"#{@data[code]}\\\" onmouseover=\\\"worldMapOver(this)\\\" onmouseout=\\\"worldMapOut(this)\\\" onclick=\\\"worldMapClick(this)\\\" ondblclick=\\\"worldMapDblClick(this)\\\"\")\n end\n end", "def add_countries\n projects = Project.find_public(:all, :conditions => [\"continent_id=?\", params[:continent_id].to_i])\n @countries = [[ 'All ...', '']]\n projects.each do |project|\n sum = 0\n projects.each do |pj|\n sum += 1 if project.country_id==pj.country_id\n end\n name = \"#{!project.country_id.nil? ? project.nation.name : project.place.country.name} (#{sum})\"\n @countries << [name, project.country_id]\n end\n @countries.uniq!\n respond_to do |format|\n format.js {\n render :update do |page|\n page.replace_html \"country_id_container\", :partial => \"select_countries\"\n end\n }\n end\n end", "def load_countries_and_zones\n \n IO.foreach(@input_dir + File::SEPARATOR + 'iso3166.tab') {|line| \n if line =~ /^([A-Z]{2})\\t(.*)$/\n code = $1\n name = $2\n @countries[code] = TZDataCountry.new(code, name)\n end\n }\n\n\n IO.foreach(@input_dir + File::SEPARATOR + 'zone.tab') {|line| \n line.chomp! \n\n if line =~ /^([A-Z]{2})\\t([^\\t]+)\\t([^\\t]+)(\\t(.*))?$/\n code = $1\n location_str = $2\n zone_name = $3\n description = $5\n\n country = @countries[code]\n raise \"Country not found: #{code}\" if country.nil?\n \n location = TZDataLocation.new(location_str)\n \n zone = @zones[zone_name] \n raise \"Zone not found: #{zone_name}\" if zone.nil? \n\n description = nil if description == ''\n \n country.add_zone(TZDataCountryTimezone.new(zone, description, location))\n\n lo_n = location.longitude.to_s.gsub(/\\/[0-9]*/, '')\n lo_d = location.longitude.to_s.gsub(/[0-9]*\\//, '')\n la_n = location.latitude.to_s.gsub(/\\/[0-9]*/, '')\n la_d = location.latitude.to_s.gsub(/[0-9]*\\//, '')\n\n @timezones << [code, zone_name, lo_n, lo_d, la_n, la_d, description]\n end\n }\n\n # Creates CountryInfo for each country with all the associated timezones\n @countries.each do |code,country|\n # Creates CountryInfo for each country\n info = CountryInfo.new(code, country.name)\n\n # Adds timezones to CountryInfo for each country\n @timezones.each do |t|\n if code == t[0]\n info.timezone t[1], t[2], t[3], t[4], t[5], t[6]\n end\n end\n\n Country.add(code,Country.new(info))\n end\n\n end", "def countries\r\n\t\t\tCOUNTRIES\r\n\t\tend", "def create_countries(country_table)\n country_table.each do |country|\n abbreviation = country[0]\n name = country[1]\n info_link = country[2]\n name = Country.new(name, abbreviation, info_link)\n end\nend", "def registered_country; end", "def calendar_regions\n @regions ||= parse_countries(load_page(@cal_url))\n end", "def load_countries(iso3166_tab_path, zone_tab_path); end", "def set_country\n self.country = self.region.country if self.region && self.region.country\n end", "def country_values\n %w(\n Austria\n Belgium\n Denmark\n Finland\n France\n Germany\n Greece\n Iceland\n Ireland\n Italy\n Netherlands\n Norway\n Portugal\n Spain\n Sweden\n Switzerland\n United Kingdom\n USA\n )\n end", "def countries\n @data.map { |iso2, data| iso2 }\n end", "def get_all_countries\n puts \"collecting countries infomation..\"\n f1 = open(@CIA_URL)\n doc = Nokogiri::HTML(f1)\n open('countries.txt', 'wb') do |file|\n file << open(@CIA_URL)\n end\n doc.css(\"ul#GetAppendix_TextVersion li a\").each do |item|\n country_name = item.text\n next if country_name == \"World\" or country_name == \"European Union\" or country_name == \"Antarctica\"\n country_url = @CIA_URL\n new_url = (country_url.split('/')[0..-2]).join('/')\n country_url = new_url << '/' << item['href']\n puts \"#{country_name}\"\n f = open(country_url)\n doc = f.read()\n f.close()\n country = CountryInfo.new(country_name, country_url, doc)\n continent = get_continent(doc)\n if continent != nil\n continent.downcase!\n @country_lists[continent] += [country]\n end\n \n end\n # helper_save\n puts \"========================================================================\"\n puts \"========================================================================\"\n puts \"==============================start parsing=============================\"\n puts \"========================================================================\"\n puts \"========================================================================\"\n end", "def init_states\n russia_states = Country.find_by_iso(\"RU\").states\n ukraine_states = Country.find_by_iso(\"UA\").states\n @states = russia_states + ukraine_states\n end", "def country_list\n @countries ||= case kind\n when 'country' then\n zoneables\n when 'state' then\n zoneables.collect(&:country)\n when 'county'\n zone_member.zoneable.country_list\n else\n []\n end.flatten.compact.uniq\n end", "def country_map\n @country_map ||= load_countries\n end", "def set_region_country\n @region_country = RegionCountry.find(params[:id])\n end", "def load_data\n @regions = Region.find(:all, :order => \"name\")\n end", "def set_country_region\n @country_region = CountryRegion.find(params[:id])\n end", "def set_states_cities data\n states_hash = Hash.new { |h,k| h[k] = [] }\n cities_hash = Hash.new { |h,k| h[k] = [] }\n data.each do |row|\n if !states_hash[row[\"country_name\"]].include?(row[\"province_name\"])\n states_hash[row[\"country_name\"]] << row[\"province_name\"]\n end\n if !cities_hash[row[\"province_name\"]].include?(row[\"city_name\"])\n cities_hash[row[\"province_name\"]] << row[\"city_name\"]\n end\n end\n @@all_cities = cities_hash\n @@all_states = states_hash\n build_result(@distributor_name, @include_regions, @exclude_regions)\n end", "def get_countries\n countries=[]\n @locations.each do |loc|\n countries << loc.country.capitalize if loc.country\n end\n countries.uniq\n end", "def country_list\n get_request( \"/api/v2_1/api/countries\")\n end", "def select_region\n\n origin_labs = Strain.find_by_sql(\"select origin_lab from strains group by origin_lab\")\n @lab_menu = []\n origin_labs.each do |lab|\n @lab_menu << lab.origin_lab if (lab.origin_lab != nil && lab.origin_lab != '')\n end\n\n origin_country = Strain.find_by_sql(\"select origin from strains group by origin\")\n @country_menu = []\n origin_country.each do |country|\n @country_menu << country.origin if (country.origin != nil && country.origin != '')\n end\n\n chromosomes = MapPosition.find_by_sql(\"select chromosome_label from map_positions where map_id = 1 group by chromosome_label order by chromosome_number asc\")\n @chromosome_menu = []\n chromosomes.each do |chr|\n @chromosome_menu << chr.chromosome_label\n end\n\n @strains = Strain.find(:all, :conditions => ['taxon_id = ?',10116], :order => \"symbol ASC\")\n\n end", "def index\n @regionais = Regional.all\n end", "def region_opts\n res = $store.select(RegionTable, \n \"reg_affiliate=? order by reg_name\",\n @data_object.aff_id)\n\n regions = { Affiliate::NONE => \"unassigned\" } \n\n res.each {|r| regions[r.reg_id] = r.reg_name}\n \n regions\n end", "def countries_or_regions_of_origin=(value)\n @countries_or_regions_of_origin = value\n end", "def country_list\n @countries = Country.find(:all, :order => \"name\" )\n return @countries\n end", "def index\n # Rails.cache.delete('region_list')\n @regions = Rails.cache.fetch(\"region_list\", :expires_in => 1.week) do\n global = Region.find_by_name(\"Global\")\n united_states = Region.find_by_name(\"United States\")\n other_regions = Region.where(\"name != ? AND name != ?\", \"United States\", \"Global\").order(:name)\n \n regions_array = []\n regions_array << global << united_states\n other_regions.each do |region|\n regions_array << region\n end\n regions_array\n end\n\n \n end", "def countries\n @countries ||= Fotolia::Countries.new(self)\n end", "def regions(for_select = true)\n fetch_array_for $regions, for_select\n end", "def set_request\n @countries = ISO3166::Country.all.map { |c| [c.name, c.alpha3] }.sort\n\n if @countries && params[:id]\n @country = @country.find(params[:id])\n end\n end", "def db_countries\r\n\t\tLocation.find :all, :order=>\"country ASC\", :select => \"DISTINCT country\"\r\n\tend", "def show\n @countries = [[\"OC Oceania\",\"oc\"],[\"AD Andorra\", \"ad\"],[\"AE United Arab Emirates\", \"ae\"],[\"AF Afghanistan\", \"af\"],[\"AG Antigua and Barbuda\", \"ag\"],[\"AI Anguilla\", \"ai\"],[\"AL Albania\", \"al\"],[\"AM Armenia\", \"am\"],[\"AO Angola\", \"ao\"],[\"AQ Antarctica\", \"aq\"],[\"AR Argentina\", \"ar\"],[\"AS American Samoa\", \"as\"],[\"AT Austria\", \"at\"],[\"AU Australia\", \"au\"],[\"AW Aruba\", \"aw\"],[\"AX Åland Islands\", \"ax\"],[\"AZ Azerbaijan\", \"az\"],[\"BA Bosnia and Herzegovina\", \"ba\"],[\"BB Barbados\", \"bb\"],[\"BD Bangladesh\", \"bd\"],[\"BE Belgium\", \"be\"],[\"BF Burkina Faso\", \"bf\"],[\"BG Bulgaria\", \"bg\"],[\"BH Bahrain\", \"bh\"],[\"BI Burundi\", \"bi\"],[\"BJ Benin\", \"bj\"],[\"BL Saint Barthélemy\", \"bl\"],[\"BM Bermuda\", \"bm\"],[\"BN Brunei Darussalam\", \"bn\"],[\"BO Bolivia, Plurinational State of\", \"bo\"],[\"BQ Bonaire, Sint Eustatius and Saba\", \"bq\"],[\"BR Brazil\", \"br\"],[\"BS Bahamas\", \"bs\"],[\"BT Bhutan\", \"bt\"],[\"BV Bouvet Island\", \"bv\"],[\"BW Botswana\", \"bw\"],[\"BY Belarus\", \"by\"],[\"BZ Belize\", \"bz\"],[\"CA Canada\", \"ca\"],[\"CC Cocos (Keeling) Islands\", \"cc\"],[\"CD Congo, the Democratic Republic of the\", \"cd\"],[\"CF Central African Republic\", \"cf\"],[\"CG Congo\", \"cg\"],[\"CH Switzerland\", \"ch\"],[\"CI Côte d'Ivoire\", \"ci\"],[\"CK Cook Islands\", \"ck\"],[\"CL Chile\", \"cl\"],[\"CM Cameroon\", \"cm\"],[\"CN China\", \"cn\"],[\"CO Colombia\", \"co\"],[\"CR Costa Rica\", \"cr\"],[\"CU Cuba\", \"cu\"],[\"CV Cape Verde\", \"cv\"],[\"CW Curaçao\", \"cw\"],[\"CX Christmas Island\", \"cx\"],[\"CY Cyprus\", \"cy\"],[\"CZ Czech Republic\", \"cz\"],[\"DE Germany\", \"de\"],[\"DJ Djibouti\", \"dj\"],[\"DK Denmark\", \"dk\"],[\"DM Dominica\", \"dm\"],[\"DO Dominican Republic\", \"do\"],[\"DZ Algeria\", \"dz\"],[\"EC Ecuador\", \"ec\"],[\"EE Estonia\", \"ee\"],[\"EG Egypt\", \"eg\"],[\"EH Western Sahara\", \"eh\"],[\"ER Eritrea\", \"er\"],[\"ES Spain\", \"es\"],[\"ET Ethiopia\", \"et\"],[\"FI Finland\", \"fi\"],[\"FJ Fiji\", \"fj\"],[\"FK Falkland Islands (Malvinas)\", \"fk\"],[\"FM Micronesia, Federated States of\", \"fm\"],[\"FO Faroe Islands\", \"fo\"],[\"FR France\", \"fr\"],[\"GA Gabon\", \"ga\"],[\"GB United Kingdom\", \"gb\"],[\"GD Grenada\", \"gd\"],[\"GE Georgia\", \"ge\"],[\"GF French Guiana\", \"gf\"],[\"GG Guernsey\", \"gg\"],[\"GH Ghana\", \"gh\"],[\"GI Gibraltar\", \"gi\"],[\"GL Greenland\", \"gl\"],[\"GM Gambia\", \"gm\"],[\"GN Guinea\", \"gn\"],[\"GP Guadeloupe\", \"gp\"],[\"GQ Equatorial Guinea\", \"gq\"],[\"GR Greece\", \"gr\"],[\"GS South Georgia and the South Sandwich Islands\", \"gs\"],[\"GT Guatemala\", \"gt\"],[\"GU Guam\", \"gu\"],[\"GW Guinea-Bissau\", \"gw\"],[\"GY Guyana\", \"gy\"],[\"HK Hong Kong\", \"hk\"],[\"HM Heard Island and McDonald Islands\", \"hm\"],[\"HN Honduras\", \"hn\"],[\"HR Croatia\", \"hr\"],[\"HT Haiti\", \"ht\"],[\"HU Hungary\", \"hu\"],[\"ID Indonesia\", \"id\"],[\"IE Ireland\", \"ie\"],[\"IL Israel\", \"il\"],[\"IM Isle of Man\", \"im\"],[\"IN India\", \"in\"],[\"IO British Indian Ocean Territory\", \"io\"],[\"IQ Iraq\", \"iq\"],[\"IR Iran, Islamic Republic of\", \"ir\"],[\"IS Iceland\", \"is\"],[\"IT Italy\", \"it\"],[\"JE Jersey\", \"je\"],[\"JM Jamaica\", \"jm\"],[\"JO Jordan\", \"jo\"],[\"JP Japan\", \"jp\"],[\"KE Kenya\", \"ke\"],[\"KG Kyrgyzstan\", \"kg\"],[\"KH Cambodia\", \"kh\"],[\"KI Kiribati\", \"ki\"],[\"KM Comoros\", \"km\"],[\"KN Saint Kitts and Nevis\", \"kn\"],[\"KP Korea, Democratic People's Republic of\", \"kp\"],[\"KR Korea, Republic of\", \"kr\"],[\"KW Kuwait\", \"kw\"],[\"KY Cayman Islands\", \"ky\"],[\"KZ Kazakhstan\", \"kz\"],[\"LA Lao People's Democratic Republic\", \"la\"],[\"LB Lebanon\", \"lb\"],[\"LC Saint Lucia\", \"lc\"],[\"LI Liechtenstein\", \"li\"],[\"LK Sri Lanka\", \"lk\"],[\"LR Liberia\", \"lr\"],[\"LS Lesotho\", \"ls\"],[\"LT Lithuania\", \"lt\"],[\"LU Luxembourg\", \"lu\"],[\"LV Latvia\", \"lv\"],[\"LY Libya\", \"ly\"],[\"MA Morocco\", \"ma\"],[\"MC Monaco\", \"mc\"],[\"MD Moldova, Republic of\", \"md\"],[\"ME Montenegro\", \"me\"],[\"MF Saint Martin (French part)\", \"mf\"],[\"MG Madagascar\", \"mg\"],[\"MH Marshall Islands\", \"mh\"],[\"MK Macedonia, the former Yugoslav Republic of\", \"mk\"],[\"ML Mali\", \"ml\"],[\"MM Myanmar\", \"mm\"],[\"MN Mongolia\", \"mn\"],[\"MO Macao\", \"mo\"],[\"MP Northern Mariana Islands\", \"mp\"],[\"MQ Martinique\", \"mq\"],[\"MR Mauritania\", \"mr\"],[\"MS Montserrat\", \"ms\"],[\"MT Malta\", \"mt\"],[\"MU Mauritius\", \"mu\"],[\"MV Maldives\", \"mv\"],[\"MW Malawi\", \"mw\"],[\"MX Mexico\", \"mx\"],[\"MY Malaysia\", \"my\"],[\"MZ Mozambique\", \"mz\"],[\"NA Namibia\", \"na\"],[\"NC New Caledonia\", \"nc\"],[\"NE Niger\", \"ne\"],[\"NF Norfolk Island\", \"nf\"],[\"NG Nigeria\", \"ng\"],[\"NI Nicaragua\", \"ni\"],[\"NL Netherlands\", \"nl\"],[\"NO Norway\", \"no\"],[\"NP Nepal\", \"np\"],[\"NR Nauru\", \"nr\"],[\"NU Niue\", \"nu\"],[\"NZ New Zealand\", \"nz\"],[\"OM Oman\", \"om\"],[\"PA Panama\", \"pa\"],[\"PE Peru\", \"pe\"],[\"PF French Polynesia\", \"pf\"],[\"PG Papua New Guinea\", \"pg\"],[\"PH Philippines\", \"ph\"],[\"PK Pakistan\", \"pk\"],[\"PL Poland\", \"pl\"],[\"PM Saint Pierre and Miquelon\", \"pm\"],[\"PN Pitcairn\", \"pn\"],[\"PR Puerto Rico\", \"pr\"],[\"PS Palestine, State of\", \"ps\"],[\"PT Portugal\", \"pt\"],[\"PW Palau\", \"pw\"],[\"PY Paraguay\", \"py\"],[\"QA Qatar\", \"qa\"],[\"RE Réunion\", \"re\"],[\"RO Romania\", \"ro\"],[\"RS Serbia\", \"rs\"],[\"RU Russian Federation\", \"ru\"],[\"RW Rwanda\", \"rw\"],[\"SA Saudi Arabia\", \"sa\"],[\"SB Solomon Islands\", \"sb\"],[\"SC Seychelles\", \"sc\"],[\"SD Sudan\", \"sd\"],[\"SE Sweden\", \"se\"],[\"SG Singapore\", \"sg\"],[\"SH Saint Helena, Ascension and Tristan da Cunha\", \"sh\"],[\"SI Slovenia\", \"si\"],[\"SJ Svalbard and Jan Mayen\", \"sj\"],[\"SK Slovakia\", \"sk\"],[\"SL Sierra Leone\", \"sl\"],[\"SM San Marino\", \"sm\"],[\"SN Senegal\", \"sn\"],[\"SO Somalia\", \"so\"],[\"SR Suriname\", \"sr\"],[\"SS South Sudan\", \"ss\"],[\"ST Sao Tome and Principe\", \"st\"],[\"SV El Salvador\", \"sv\"],[\"SX Sint Maarten (Dutch part)\", \"sx\"],[\"SY Syrian Arab Republic\", \"sy\"],[\"SZ Swaziland\", \"sz\"],[\"TC Turks and Caicos Islands\", \"tc\"],[\"TD Chad\", \"td\"],[\"TF French Southern Territories\", \"tf\"],[\"TG Togo\", \"tg\"],[\"TH Thailand\", \"th\"],[\"TJ Tajikistan\", \"tj\"],[\"TK Tokelau\", \"tk\"],[\"TL Timor-Leste\", \"tl\"],[\"TM Turkmenistan\", \"tm\"],[\"TN Tunisia\", \"tn\"],[\"TO Tonga\", \"to\"],[\"TR Turkey\", \"tr\"],[\"TT Trinidad and Tobago\", \"tt\"],[\"TV Tuvalu\", \"tv\"],[\"TW Taiwan, Province of China\", \"tw\"],[\"TZ Tanzania, United Republic of\", \"tz\"],[\"UA Ukraine\", \"ua\"],[\"UG Uganda\", \"ug\"],[\"UM United States Minor Outlying Islands\", \"um\"],[\"US United States\", \"us\"],[\"UY Uruguay\", \"uy\"],[\"UZ Uzbekistan\", \"uz\"],[\"VA Holy See (Vatican City State)\", \"va\"],[\"VC Saint Vincent and the Grenadines\", \"vc\"],[\"VE Venezuela, Bolivarian Republic of\", \"ve\"],[\"VG Virgin Islands, British\", \"vg\"],[\"VI Virgin Islands, U.S.\", \"vi\"],[\"VN Viet Nam\", \"vn\"],[\"VU Vanuatu\", \"vu\"],[\"WF Wallis and Futuna\", \"wf\"],[\"WS Samoa\", \"ws\"],[\"YE Yemen\", \"ye\"],[\"YT Mayotte\", \"yt\"],[\"ZA South Africa\", \"za\"],[\"ZM Zambia\", \"zm\"],[\"ZW Zimbabwe\", \"zw\"]]\n @fullscreen = true\n @match = nil\n # current match\n if @table.matches.where(is_running: true).size > 0\n @match = @table.matches.where(is_running: true).first\n end\n # previous match\n if @table.matches.where(is_running: true).size == 0 && @table.matches.where(is_over: true).size > 0\n @match = @table.matches.where(is_over: true).reorder(\"matches.finished_at DESC\").first\n end\n if @table.banner.blank?\n @banner = false\n else\n @banner = true\n end\n end", "def country_list\n return [] if type == \"state\"\n return countries if type == \"country\"\n members.collect { |zone| zone.country_list }.flatten\n end", "def import_countries(file)\n Country.transaction do\n while (line = file.gets)\n next if line.match(/^#/)\n line = line.split(/\\t/)\n \n c = Country.create(\n :iso2 => line[0], :iso3 => line[1], :ison => line[2],\n :name => line[4], :capital => line[5], :area => line[6],\n :continent => line[8], :currency_code => line[10], :currency_name => line[11],\n :phone => line[12], :geoname_id => line[16]\n )\n @@countries[line[0]] = c.id\n end\n end\n end", "def load_locations\n add_location('Bangalore', 'Belgaum', 24)\n add_location('Bangalore', 'Mysore', 71)\n add_location('Belgam', 'Tumkur', 59)\n add_location('Mandya', 'Mangalore', 141)\n add_location('Tumkur', 'Mandya', 65.5)\n add_location('Mandya', 'Mysore', 101)\n add_location('Belgaum', 'Chickmangalur', 103)\n add_location('Mandya', 'Tumkur', 65)\n add_location('Mangalore', 'Mysore', 169)\n add_location('Mysore', 'Tumkur', 134)\n end", "def country_chosen\n if !params[:id].blank?\n @country = Country.find(params[:id])\n @regions = Region.find(:all, :conditions => ['country_id =?', @country.country_id], :order => 'region_order')\n else\n @country = @regions = nil\n end\n render :layout => false\n end", "def get_regions()\n\t\t{\"include_regions\"=>@include_regions,\"exclude_regions\"=>@exclude_regions}\n\tend", "def add_region(db, state,country)\n\tdb.execute(\"INSERT INTO region (state, country) VALUES(?,?)\", [state,country])\nend", "def countries\n collection(\"countries\")\n end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def index\n @regions = Region.all\n end", "def load_regions\n\t\t\tregions = Locations::Regions.const_get(ENV['CURRENT_CITY'])\n\t\tend", "def load_regions\n YAML.load_file(\"#{root_path}/config/countries.yml\")\n end", "def country(code, name); end", "def create_regions bracket_json\n region_array = bracket_json[\"game_and_pick_list\"][\"regions\"]\n region_array.each do |region|\n Region.create({name: region['name']})\n end\n end", "def location_countries\r\n\t\treturn LocationCountry.find :all, :order=>\"sort_order, name ASC\"\r\n\tend", "def create\n @region_country = RegionCountry.new(region_country_params)\n\n respond_to do |format|\n if @region_country.save\n format.html { redirect_to @region_country, notice: 'Region country was successfully created.' }\n format.json { render :show, status: :created, location: @region_country }\n else\n format.html { render :new }\n format.json { render json: @region_country.errors, status: :unprocessable_entity }\n end\n end\n end", "def country_zones(country_code)\n code = country_code.to_s.upcase\n @country_zones[code] ||= load_country_zones(code)\n end", "def spot_countries\n now = DateTime.now\n hash_groups = countries(from: now - 24.hours, to: now, tick: \"15 minutes\")\n .select_append { avg(:local_ppi).over(partition: :country, order: Sequel.desc(:tick), frame: :all).as(:avg_24h_local_ppi) }\n .to_hash_groups(:country)\n hash_groups.each { |country, data| hash_groups[country] = data.first }\n hash_groups\n end", "def whitelisted_filters_for_countries\n country_slugs = @params[:countries] || []\n @regions.each do |region|\n country_slugs = country_slugs.concat(region[:countries])\n end\n if country_slugs.empty?\n []\n else\n Country.where(slug: country_slugs)\n end\n end", "def country_or_region=(value)\n @country_or_region = value\n end", "def address_regions(address)\n return [] unless address\n \n if address.new_record? && address.country_id\n Region.find_all_by_country_id(address.country_id)\n elsif address.region\n address.regions\n else\n []\n end\n end", "def country_details(region, input)\n country = @countries[input - 1]\n\n Table.display_as_summary(country)\n browse_online(country)\n end", "def countries_or_regions_of_origin\n return @countries_or_regions_of_origin\n end", "def set_current_address_states\n @current_address_states = CmtGeo.states_for_country(params[:current_address_country]) || []\n end", "def countries\n countries_ids = self.answers.where(answer_type: 'geo_countries').first.try(:text_value).split(',')\n Country.where(:id => countries_ids)\n end", "def country_options\n Country.all.map{|country| [country.title, country.id]}\n end", "def load_geo_data\n countries_hash = JSON.parse(File.read(Rails.root.join('lib/countries_data/countries.json')))\n cities_hash = JSON.parse(File.read(Rails.root.join('lib/countries_data/cities.json')))\n countries_hash.each do |country_hash|\n cities_arr = cities_hash[country_hash['name']]\n\n next if cities_arr.nil?\n\n country_model = create_country country_hash\n create_cities(country_model, cities_arr)\n end\nend", "def index\n @regions = Region.all\n end", "def index\n @regions = Region.all\n end", "def us_zones\n country_zones(:us)\n end", "def index\n @world_regions = WorldRegion.all\n end", "def import\n\n output = ''\n\n country_src = 'tmp/Countries.txt'\n \n rs = File.open(country_src)\n rs.gets # <-- remove first line (columns header) \"CountryID:Title\"\n countries = {}\n City.delete_all\n Region.delete_all\n Country.delete_all\n\n while (row = rs.gets) \n row = row.split(':')\n row[0].gsub!(/\\n/, '')\n row[1].gsub!(/\\n/, '')\n countries[row[0]] = {:name => row[1], :regions => {}, :model => nil}\n c = Country.new\n c.iso = row[0]\n c.name = row[1]\n c.save\n countries[row[0]][:model] = c\n end\n\n regions_src = 'tmp/Regions.txt'\n \n rs = File.open(regions_src)\n rs.gets # <-- remove the 1st line (header row) #CountryID:RegionID:Title\n while (row = rs.gets) \n row = row.split(':')\n row[0].gsub!(/\\n/, '')\n row[1].gsub!(/\\n/, '')\n row[2].gsub!(/\\n/, '')\n c = countries[row[0]][:model]\n r = Region.new\n r.iso = row[1]\n r.country_id = c.id\n\n # magic trick to ignore UTF-8 chars for now.\n ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')\n r.name = ic.iconv(row[2] + ' ')[0..-2]\n r.save\n countries[row[0]][:regions][row[1]] = r\n\n end\n\n cities_src = 'tmp/Cities.txt'\n \n rs = File.open(cities_src)\n rs.gets # <-- remove 1st row (header) #CountryID:RegionID:Title:Latitude:Longitude\n while(row = rs.gets)\n row = row.split(':')\n row[1].gsub!(/\\n/, '')\n row[2].gsub!(/\\n/, '')\n row[3].gsub!(/\\n/, '')\n row[4].gsub!(/\\n/, '')\n \n r = countries[row[0]][:regions][row[1]]\n if (!r.nil?) \n c = City.new\n ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')\n c.name = ic.iconv(row[2] + ' ')[0..-2] \n c.region_id = r.id\n c.lat = row[3]\n c.lng = row[4]\n c.save\n end\n end\n\n output += '<h1>Import complete</h1>'\n render(:text => output, :layout => false)\n end", "def load_country_index(iso3166_tab_path, zone_tab_path)\n \n # Handle standard 3 to 4 column zone.tab files as well as the 4 to 5 \n # column format used by Solaris.\n #\n # On Solaris, an extra column before the comment gives an optional \n # linked/alternate timezone identifier (or '-' if not set).\n #\n # Additionally, there is a section at the end of the file for timezones\n # covering regions. These are given lower-case \"country\" codes. The timezone\n # identifier column refers to a continent instead of an identifier. These\n # lines will be ignored by TZInfo.\n #\n # Since the last column is optional in both formats, testing for the \n # Solaris format is done in two passes. The first pass identifies if there\n # are any lines using 5 columns.\n\n\n # The first column is allowed to be a comma separated list of country\n # codes, as used in zone1970.tab (introduced in tzdata 2014f).\n #\n # The first country code in the comma-separated list is the country that\n # contains the city the zone identifer is based on. The first country\n # code on each line is considered to be primary with the others\n # secondary.\n #\n # The zones for each country are ordered primary first, then secondary.\n # Within the primary and secondary groups, the zones are ordered by their\n # order in the file.\n \n file_is_5_column = false\n zone_tab = []\n \n RubyCoreSupport.open_file(zone_tab_path, 'r', :external_encoding => 'UTF-8', :internal_encoding => 'UTF-8') do |file|\n file.each_line do |line|\n line.chomp!\n \n if line =~ /\\A([A-Z]{2}(?:,[A-Z]{2})*)\\t(?:([+\\-])(\\d{2})(\\d{2})([+\\-])(\\d{3})(\\d{2})|([+\\-])(\\d{2})(\\d{2})(\\d{2})([+\\-])(\\d{3})(\\d{2})(\\d{2}))\\t([^\\t]+)(?:\\t([^\\t]+))?(?:\\t([^\\t]+))?\\z/\n codes = $1\n \n if $2\n latitude = dms_to_rational($2, $3, $4)\n longitude = dms_to_rational($5, $6, $7)\n else\n latitude = dms_to_rational($8, $9, $10, $11)\n longitude = dms_to_rational($12, $13, $14, $15)\n end\n \n zone_identifier = $16\n column4 = $17\n column5 = $18\n \n file_is_5_column = true if column5\n \n zone_tab << [codes.split(','.freeze), zone_identifier, latitude, longitude, column4, column5]\n end\n end\n end\n \n primary_zones = {}\n secondary_zones = {}\n \n zone_tab.each do |codes, zone_identifier, latitude, longitude, column4, column5|\n description = file_is_5_column ? column5 : column4\n country_timezone = CountryTimezone.new(zone_identifier, latitude, longitude, description)\n\n # codes will always have at least one element\n\n (primary_zones[codes.first] ||= []) << country_timezone\n\n codes[1..-1].each do |code|\n (secondary_zones[code] ||= []) << country_timezone\n end\n end\n \n countries = {}\n \n RubyCoreSupport.open_file(iso3166_tab_path, 'r', :external_encoding => 'UTF-8', :internal_encoding => 'UTF-8') do |file|\n file.each_line do |line|\n line.chomp!\n \n # Handle both the two column alpha-2 and name format used in the tz \n # database as well as the 4 column alpha-2, alpha-3, numeric-3 and \n # name format used by FreeBSD and OpenBSD.\n \n if line =~ /\\A([A-Z]{2})(?:\\t[A-Z]{3}\\t[0-9]{3})?\\t(.+)\\z/\n code = $1\n name = $2\n zones = (primary_zones[code] || []) + (secondary_zones[code] || [])\n\n countries[code] = ZoneinfoCountryInfo.new(code, name, zones)\n end\n end\n end\n \n countries\n end", "def set_country\n id = params[:id]\n @country = Countries.list[id.to_i - 1]\n end", "def index\n @user_regions = UserRegion.all\n end", "def show\n @country = Carmen::Country.coded(@profile.country_code)\n @subregions = @country.subregions\n @state = @subregions.coded(@profile.state_code)\n end", "def to_jaxb_json_hash\n _h = super\n if !list.nil?\n _ha = Array.new\n list.each { | _item | _ha.push _item.to_jaxb_json_hash }\n _h['country'] = _ha\n end\n return _h\n end", "def country; end", "def country; end", "def country; end", "def country_fr()\n @request_data = {\n\t\t\t\"type\"\t\t=> \"home\",\n \"ip\" => \"178.251.201.141\",\n \"session\" => \"new\",\n \"cuid\" => \"new\",\n \"lang\" => \"en\",\n \"site\" => \"ctshirts\",\n \"currentURI\" => \"http://www.ctshirts.co.uk\",\n \"previousURI\" => \"http://www.ctshirts.co.uk\",\n \"clientToken\" => \"677ab692r2t3u4t\", \n \"recContent\" => \"refCodeOnly\",\n }\n @json_request = \"\"\n @response_times = []\n\t\tend", "def set_vars_for_form region\n @volunteers = Volunteer.all_for_region(region.id).collect{ |v| [v.name,v.id] }\n @donors = Location.donors.where(:region_id=>region.id).collect{ |d| [d.name,d.id] }\n @recipients = Location.recipients.where(:region_id=>region.id).collect{ |r| [r.name,r.id] }\n @food_types = FoodType.regional(region.id).collect{ |ft| [ft.name,ft.id] }\n @transport_types = TransportType.all.collect{ |tt| [tt.name,tt.id] }\n @scale_types = ScaleType.regional(region.id).collect{ |st| [\"#{st.name} (#{st.weight_unit})\",st.id] }\n @regions = Region.all\n end", "def visit_country\n self.user_countries.create!(user_id: self.visitor_id)\n end", "def index\n Country.retrieveCountries\n @countries = Country.all\n\n\n end", "def generateRegionData()\n firstDayOfFinYear = first_day_of_financial_year(DateTime.now)\n lastDayOfFinYear = last_day_of_financial_year(DateTime.now)\n sectorBudgets = Oj.load(RestClient.get api_simple_log(settings.oipa_api_url + \"budgets/aggregations/?format=json&reporting_organisation_identifier=#{settings.goverment_department_ids}&budget_period_start=#{firstDayOfFinYear}&budget_period_end=#{lastDayOfFinYear}&group_by=recipient_region,sector&aggregations=count,value&recipient_region=298,798,89,589,389,189,679,289,380,998&activity_status=2\"))\n sectorHierarchies = Oj.load(File.read('data/sectorHierarchies.json'))\n sectorBudgets = sectorBudgets[\"results\"]\n sectorBudgets = sectorBudgets.group_by{|key| key[\"recipient_region\"][\"code\"]}\n sectorBudgets.each do |regionData|\n sectorBudgets[regionData[0]].each do |regionLevelSectorData|\n tempDAC5Code = regionLevelSectorData['sector']['code']\n pullHighLevelSectorData = sectorHierarchies.select{|key| key[\"Code (L3)\"] == tempDAC5Code.to_i}.first\n regionLevelSectorData['sector']['code'] = pullHighLevelSectorData[\"High Level Code (L1)\"]\n regionLevelSectorData['sector']['name'] = pullHighLevelSectorData[\"High Level Sector Description\"]\n end\n end\n regionHash = {}\n sectorBudgets.each do |regionData|\n regionHash[regionData[0]] = {}\n sectorBudgets[regionData[0]].each do |countryLevelSectorData|\n if !regionHash[regionData[0]].key?(countryLevelSectorData['sector']['name'])\n regionHash[regionData[0]][countryLevelSectorData['sector']['name']] = {}\n regionHash[regionData[0]][countryLevelSectorData['sector']['name']]['code'] = countryLevelSectorData['sector']['code']\n regionHash[regionData[0]][countryLevelSectorData['sector']['name']]['name'] = countryLevelSectorData['sector']['name']\n regionHash[regionData[0]][countryLevelSectorData['sector']['name']]['budget'] = countryLevelSectorData['value'].to_i\n else\n regionHash[regionData[0]][countryLevelSectorData['sector']['name']]['budget'] = regionHash[regionData[0]][countryLevelSectorData['sector']['name']]['budget'].to_i + countryLevelSectorData['value'].to_i\n end\n end\n end\n regionHash.each do |key|\n regionHash[key[0]] = key[1].sort_by{ |x, y| -y[\"budget\"] }\n end\n regionHash\n end", "def countries\n xml.css('country').map{|c| Allorails::Country.new(c)}\n end", "def index\n @ag_countries = Ag::Country.all\n end", "def regions\n client.get_stats('/stats/regions')\n end", "def country\n query = create_query(\n :Location, :regexp_search, regexp: \"#{params[:country]}$\"\n )\n show_selected_locations(query, link_all_sorts: true)\n end", "def index\n # TODO Need to sort on the Rails side so we can sort in the\n # proper order for the translated country name. In fact, if we're\n # already doing that, then the following line is unnecessary.\n options = {:order => 'country, state, city, name'}\n\n # TODO tease apart all this logic and move it under sensibly named\n # methods.\n if params[:country]\n country_name = seo_decode(params[:country])\n @country = I18n.t(country_name, :scope => :reverse_countries, :locale => host_locale) || country_name\n\n redirect_country = seo_encode better_translation(country_name, @country, :countries)\n\n if params[:state]\n state_name = seo_decode(params[:state])\n state = t(state_name, :scope => [:reverse_provinces, @country], :locale => host_locale) || state_name\n\n redirect_state = seo_encode better_translation(state_name, state, [:provinces, @country])\n\n redirect_to(:country => (redirect_country||params[:country]), :state => (redirect_state||params[:state]), :status => :moved_permanently) && return if redirect_country || redirect_state\n\n options[:conditions] = ['country = ? AND state = ?', @country, state]\n @heading = t 'clubs_in_location', :location => t(state, :scope => [:provinces, @country], :default => state_name)\n\n @title = t 'clubs_in_state_and_country', :state => state_name, :country => country_name\n else\n redirect_to(:country => redirect_country, :status => :moved_permanently) && return if redirect_country\n\n options[:conditions] = ['country = ?', @country]\n @heading = @title = t('clubs_in_location', :location => t(@country, :scope => :countries, :default => country_name))\n end\n end\n\n @locations = Location.visible.find(:all, options)\n\n @map = create_map(@locations, 1) unless @locations.blank?\n\n @locations.each do |location|\n pushpin_for_club(location, :link_club => true) if location.lat && location.lng\n end if @map\n\n respond_to do |format|\n format.html # index.html.haml\n format.xml { render :xml => @locations }\n end\n end", "def countries\n puts \"Which country would you like to explore?\"\n puts <<-DOC\n 1. Scotland\n 2. Ireland\n 3. United States of America\n 4. Japan\n 5. Canada\n 6. Other countries\n DOC\n country_list\n end", "def set_region_name\n @region_name = RegionName.includes( :country_name ).find( params[ :id ])\n end", "def countries\n array = []\n details.css(\"div.txt-block a[href^='/country/']\").each do |node|\n array << {:code => node['href'].clean_href, :name => node.text.strip}\n end\n\n array\n end", "def listRegions\n\t\t\treturn MU::Config.listRegions\n\t\tend", "def countries\n document[\"nationality\"].collect {|nation| nation[\"$\"]} rescue nil\n end" ]
[ "0.6857831", "0.68053675", "0.6796844", "0.6672254", "0.65704274", "0.6566891", "0.6477582", "0.6476874", "0.64247", "0.6422858", "0.6376245", "0.633171", "0.62361586", "0.62327844", "0.6219856", "0.6216796", "0.62142414", "0.6202572", "0.6197147", "0.6186581", "0.61776906", "0.6176314", "0.6163461", "0.61578804", "0.6146852", "0.61448175", "0.6111861", "0.61022055", "0.6101623", "0.60911417", "0.6078475", "0.607307", "0.6064242", "0.6053893", "0.60462433", "0.6036447", "0.6033851", "0.6012516", "0.6004922", "0.6002819", "0.5988488", "0.59880143", "0.59722257", "0.5950772", "0.5927383", "0.5922901", "0.591802", "0.58950055", "0.5876315", "0.5876315", "0.5876315", "0.5876315", "0.5876315", "0.5876315", "0.5863712", "0.58604896", "0.5843753", "0.5841448", "0.5840982", "0.5816873", "0.5805076", "0.58047146", "0.5801964", "0.5797206", "0.57944465", "0.5772769", "0.5769089", "0.57659036", "0.5764243", "0.57517725", "0.57468516", "0.5743385", "0.5726297", "0.5726297", "0.57185066", "0.5681065", "0.5669841", "0.56625116", "0.56546044", "0.56497324", "0.5630871", "0.5620368", "0.56197834", "0.56197834", "0.56197834", "0.56145465", "0.5613412", "0.56115973", "0.560993", "0.5607245", "0.56012636", "0.5600042", "0.55894434", "0.5588097", "0.5586876", "0.5584041", "0.5578686", "0.55754954", "0.5572378", "0.55693316" ]
0.8644318
0
get the selected country information from the list of countries
def selected_country(input_region) new_input = nil while new_input != "exit" puts "\nEnter the country number (1-#{@countries.size}) to get more information or type 'return' to go the previous menu or".bold.cyan puts "\ntype 'list' to see the list of countries again or 'exit':".bold.cyan new_input = digit_or_word case new_input when (1..@countries.size) country_details(input_region, new_input.to_i) when "list" country_list_by_region(input_region) when "return" menu new_input = "exit" when "exit" break else puts "\nPlease enter a valid input, (1-#{@countries.size}) or type 'list' to see the list of countries again or 'exit':".bold.red end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def country\n client.places.get_countries.select{|hash| hash[\"cid\"] == @params[:country].to_i}.first[:title]\n end", "def country_select(country)\n select(country, :from => countryname[:id])\n end", "def get_selected_country\n countries = @chrome_driver.find_element(:id, COUNTRY_DROP_DOWN_LIST)\n countries.find_element(:tag_name, 'option').text\n end", "def country_list\n get_request( \"/api/v2_1/api/countries\")\n end", "def country\n data['country']\n end", "def country\n query = create_query(\n :Location, :regexp_search, regexp: \"#{params[:country]}$\"\n )\n show_selected_locations(query, link_all_sorts: true)\n end", "def get_selected_country\n @chrome_driver.find_element(:id, COUNTRY_DROP_DOWN_LIST)[\"value\"]\n end", "def country\n params['country']\n end", "def get_country\n @single_city_data[\"sys\"][\"country\"]\n end", "def countries(input)\n get_single_method(:countries, input)\n end", "def country_options\n Country.all.map{|country| [country.title, country.id]}\n end", "def countries\n countries_ids = self.answers.where(answer_type: 'geo_countries').first.try(:text_value).split(',')\n Country.where(:id => countries_ids)\n end", "def countries(input)\n get_single_method('countries', input)\n end", "def country_list\n @countries = Country.find(:all, :order => \"name\" )\n return @countries\n end", "def country\n self[:C]\n end", "def country\n @country\n end", "def countries\r\n\t\t\tCOUNTRIES\r\n\t\tend", "def get_selected_country\n country_list = @chrome_driver.find_element(:id, COUNTRY_DROP_DOWN_LIST)\n options = country_list.find_elements(:tag_name => 'option')\n options.each do |option|\n if option.text == \"Brazil\"\n option.click\n end\n end\n\n end", "def get_countries\n \tresponse = invoke(\"web:GetCountries\", :soap_action => :none)\n\n \tnode = response.document.xpath('//ns:GetCountriesResult', ns)[0]\n \tparse_country_description(node)\n end", "def countries\n collection(\"countries\")\n end", "def country()\n country = Country.find_by_id(@country_id)\n return country\n end", "def countries\n doc.search(\"table.info a[href*='/m_act%5Bcountry%5D/']\").map(&:text)\n end", "def get_countries\n perform(:get, 'enum/countries', nil, nonauth_headers).body\n end", "def select_country(user_country)\n countires = @browser.find_elements(:xpath, COUNTRIES)\n countires.each.find do |country|\n country.text == user_country\n end.click\n end", "def country\n @country ||= IsoCountryCodes.find(alpha2)\n end", "def country_select(method, options = {}, html_options = {}, additional_country = nil)\n @countries ||= (additional_country ? [additional_country] : []) + Country.find(:all, :order => 'sort, name asc')\n self.menu_select(method, I18n.t('muck.engine.choose_country'), @countries, options.merge(:prompt => I18n.t('muck.engine.select_country_prompt'), :wrapper_id => 'countries-container'), html_options.merge(:id => 'countries'))\n end", "def country(code, name); end", "def get_movie_country( the_country_num )\n @countryInfos = CountryInfo.all\n @countryInfos.each{ |country_info|\n if country_info.country_id === the_country_num\n country_info.country_name\n end\n }\n end", "def countries_list\n [\n ['Afghanistan', 'Afghanistan'],\n ['Albania', 'Albania'],\n ['Algeria', 'Algeria'],\n ['American Samoa', 'American Samoa'],\n ['Andorra', 'Andorra'],\n ['Angola', 'Angola'],\n ['Antigua and Barbuda', 'Antigua and Barbuda'],\n ['Argentina', 'Argentina'],\n ['Armenia', 'Armenia'],\n ['Australia', 'Australia'],\n ['Austria', 'Austria'],\n ['Azerbaijan', 'Azerbaijan'],\n ['Bahamas', 'Bahamas'],\n ['Bahrain', 'Bahrain'],\n ['Bangladesh', 'Bangladesh'],\n ['Barbados', 'Barbados'],\n ['Belarus', 'Belarus'],\n ['Belgium', 'Belgium'],\n ['Belize', 'Belize'],\n ['Benin', 'Benin'],\n ['Bermuda', 'Bermuda'],\n ['Bhutan', 'Bhutan'],\n ['Bolivia', 'Bolivia'],\n ['Bosnia and Herzegovina', 'Bosnia and Herzegovina'],\n ['Botswana', 'Botswana'],\n ['Brazil', 'Brazil'],\n ['Brunei', 'Brunei'],\n ['Bulgaria', 'Bulgaria'],\n ['Burkina Faso', 'Burkina Faso'],\n ['Burundi', 'Burundi'],\n ['Cambodia', 'Cambodia'],\n ['Cameroon', 'Cameroon'],\n ['Canada', 'Canada'],\n ['Cape Verde', 'Cape Verde'],\n ['Cayman Islands', 'Cayman Islands'],\n ['Central African Republic', 'Central African Republic'],\n ['Chad', 'Chad'],\n ['Chile', 'Chile'],\n ['China', 'China'],\n ['Colombia', 'Colombia'],\n ['Comoros', 'Comoros'],\n ['Congo, Democratic Republic of the', 'Congo, Democratic Republic of the'],\n ['Congo, Republic of the', 'Congo, Republic of the'],\n ['Costa Rica', 'Costa Rica'],\n [\"Côte d'Ivoire\", \"Côte d'Ivoire\"],\n ['Croatia', 'Croatia'],\n ['Cuba', 'Cuba'],\n ['Cyprus', 'Cyprus'],\n ['Czech Republic', 'Czech Republic'],\n ['Denmark', 'Denmark'],\n ['Djibouti', 'Djibouti'],\n ['Dominica', 'Dominica'],\n ['Dominican Republic', 'Dominican Republic'],\n ['East Timor', 'East Timor'],\n ['Ecuador', 'Ecuador'],\n ['Egypt', 'Egypt'],\n ['El Salvador', 'El Salvador'],\n ['Equatorial Guinea', 'Equatorial Guinea'],\n ['Eritrea', 'Eritrea'],\n ['Estonia', 'Estonia'],\n ['Ethiopia', 'Ethiopia'],\n ['Fiji', 'Fiji'],\n ['Finland', 'Finland'],\n ['France', 'France'],\n ['French Polynesia', 'French Polynesia'],\n ['Gabon', 'Gabon'],\n ['Gambia', 'Gambia'],\n ['Georgia', 'Georgia'],\n ['Germany', 'Germany'],\n ['Ghana', 'Ghana'],\n ['Greece', 'Greece'],\n ['Greenland', 'Greenland'],\n ['Grenada', 'Grenada'],\n ['Guam', 'Guam'],\n ['Guatemala', 'Guatemala'],\n ['Guinea', 'Guinea'],\n ['Guinea-Bissau', 'Guinea-Bissau'],\n ['Guyana', 'Guyana'],\n ['Haiti', 'Haiti'],\n ['Honduras', 'Honduras'],\n ['Hong Kong', 'Hong Kong'],\n ['Hungary', 'Hungary'],\n ['Iceland', 'Iceland'],\n ['India', 'India'],\n ['Indonesia', 'Indonesia'],\n ['Iran', 'Iran'],\n ['Iraq', 'Iraq'],\n ['Ireland', 'Ireland'],\n ['Israel', 'Israel'],\n ['Italy', 'Italy'],\n ['Jamaica', 'Jamaica'],\n ['Japan', 'Japan'],\n ['Jordan', 'Jordan'],\n ['Kazakhstan', 'Kazakhstan'],\n ['Kenya', 'Kenya'],\n ['Kiribati', 'Kiribati'],\n ['North Korea', 'North Korea'],\n ['South Korea', 'South Korea'],\n ['Kosovo', 'Kosovo'],\n ['Kuwait', 'Kuwait'],\n ['Kyrgyzstan', 'Kyrgyzstan'],\n ['Laos', 'Laos'],\n ['Latvia', 'Latvia'],\n ['Lebanon', 'Lebanon'],\n ['Lesotho', 'Lesotho'],\n ['Liberia', 'Liberia'],\n ['Libya', 'Libya'],\n ['Liechtenstein', 'Liechtenstein'],\n ['Lithuania', 'Lithuania'],\n ['Luxembourg', 'Luxembourg'],\n ['Macedonia', 'Macedonia'],\n ['Madagascar', 'Madagascar'],\n ['Malawi', 'Malawi'],\n ['Malaysia', 'Malaysia'],\n ['Maldives', 'Maldives'],\n ['Mali', 'Mali'],\n ['Malta', 'Malta'],\n ['Marshall Islands', 'Marshall Islands'],\n ['Mauritania', 'Mauritania'],\n ['Mauritius', 'Mauritius'],\n ['Mexico', 'Mexico'],\n ['Micronesia', 'Micronesia'],\n ['Moldova', 'Moldova'],\n ['Monaco', 'Monaco'],\n ['Mongolia', 'Mongolia'],\n ['Montenegro', 'Montenegro'],\n ['Morocco', 'Morocco'],\n ['Mozambique', 'Mozambique'],\n ['Myanmar', 'Myanmar'],\n ['Namibia', 'Namibia'],\n ['Nauru', 'Nauru'],\n ['Nepal', 'Nepal'],\n ['Netherlands', 'Netherlands'],\n ['New Zealand', 'New Zealand'],\n ['Nicaragua', 'Nicaragua'],\n ['Niger', 'Niger'],\n ['Nigeria', 'Nigeria'],\n ['Norway', 'Norway'],\n ['Northern Mariana Islands', 'Northern Mariana Islands'],\n ['Oman', 'Oman'],\n ['Pakistan', 'Pakistan'],\n ['Palau', 'Palau'],\n ['Palestine', 'Palestine'],\n ['Panama', 'Panama'],\n ['Papua New Guinea', 'Papua New Guinea'],\n ['Paraguay', 'Paraguay'],\n ['Peru', 'Peru'],\n ['Philippines', 'Philippines'],\n ['Poland', 'Poland'],\n ['Portugal', 'Portugal'],\n ['Puerto Rico', 'Puerto Rico'],\n ['Qatar', 'Qatar'],\n ['Romania', 'Romania'],\n ['Russia', 'Russia'],\n ['Rwanda', 'Rwanda'],\n ['Saint Kitts and Nevis', 'Saint Kitts and Nevis'],\n ['Saint Lucia', 'Saint Lucia'],\n ['Saint Vincent and the Grenadines', 'Saint Vincent and the Grenadines'],\n ['Samoa', 'Samoa'],\n ['San Marino', 'San Marino'],\n ['Sao Tome and Principe', 'Sao Tome and Principe'],\n ['Saudi Arabia', 'Saudi Arabia'],\n ['Senegal', 'Senegal'],\n ['Serbia and Montenegro', 'Serbia and Montenegro'],\n ['Seychelles', 'Seychelles'],\n ['Sierra Leone', 'Sierra Leone'],\n ['Singapore', 'Singapore'],\n ['Slovakia', 'Slovakia'],\n ['Slovenia', 'Slovenia'],\n ['Solomon Islands', 'Solomon Islands'],\n ['Somalia', 'Somalia'],\n ['South Africa', 'South Africa'],\n ['Spain', 'Spain'],\n ['Sri Lanka', 'Sri Lanka'],\n ['Sudan', 'Sudan'],\n ['Sudan, South', 'Sudan, South'],\n ['Suriname', 'Suriname'],\n ['Swaziland', 'Swaziland'],\n ['Sweden', 'Sweden'],\n ['Switzerland', 'Switzerland'],\n ['Syria', 'Syria'],\n ['Taiwan', 'Taiwan'],\n ['Tajikistan', 'Tajikistan'],\n ['Tanzania', 'Tanzania'],\n ['Thailand', 'Thailand'],\n ['Togo', 'Togo'],\n ['Tonga', 'Tonga'],\n ['Trinidad and Tobago', 'Trinidad and Tobago'],\n ['Tunisia', 'Tunisia'],\n ['Turkey', 'Turkey'],\n ['Turkmenistan', 'Turkmenistan'],\n ['Tuvalu', 'Tuvalu'],\n ['Uganda', 'Uganda'],\n ['Ukraine', 'Ukraine'],\n ['United Arab Emirates', 'United Arab Emirates'],\n ['United Kingdom', 'United Kingdom'],\n ['United States', 'United States'],\n ['Uruguay', 'Uruguay'],\n ['Uzbekistan', 'Uzbekistan'],\n ['Vanuatu', 'Vanuatu'],\n ['Vatican City', 'Vatican City'],\n ['Venezuela', 'Venezuela'],\n ['Vietnam', 'Vietnam'],\n ['Virgin Islands, British', 'Virgin Islands, British'],\n ['Virgin Islands, U.S.', 'Virgin Islands, U.S.'],\n ['Yemen', 'Yemen'],\n ['Zambia', 'Zambia'],\n ['Zimbabwe', 'Zimbabwe']\n ]\n end", "def country\n ISO3166::Country[@country_code]\n end", "def user_country\n USER_COUNTRY[country]\n end", "def country_list\n return [] if type == \"state\"\n return countries if type == \"country\"\n members.collect { |zone| zone.country_list }.flatten\n end", "def show_countries(countries)\n for country in countries\n puts country[:name]\n end\nend", "def pick_whiskies\n countries\n end", "def country; end", "def country; end", "def country; end", "def country_values\n %w(\n Austria\n Belgium\n Denmark\n Finland\n France\n Germany\n Greece\n Iceland\n Ireland\n Italy\n Netherlands\n Norway\n Portugal\n Spain\n Sweden\n Switzerland\n United Kingdom\n USA\n )\n end", "def get_countries\n countries=[]\n @locations.each do |loc|\n countries << loc.country.capitalize if loc.country\n end\n countries.uniq\n end", "def set_country\n id = params[:id]\n @country = Countries.list[id.to_i - 1]\n end", "def countries\n document[\"nationality\"].collect {|nation| nation[\"$\"]} rescue nil\n end", "def get_country_name\n subdivision = Geonames::WebService.country_subdivision @latitude, @longitude\n subdivision.country_name\n end", "def country\n if(@country_code.to_i == 280)\n IsoCountryCodes.find(276) #since 1990 we use 176 for whole germany, 280 was for \"west germany\" WTF\n else\n IsoCountryCodes.find(@country_code)\n end\n end", "def get_countries\n doc = Nokogiri::HTML(open('https://www.britannica.com/topic/list-of-countries-1993160'))\n countries_extracted = doc.css(\"li a\").text.split('Britannica')[1].split(' geography')[0].rstrip\n @processed_countries = countries_extracted.split(/(?<!\\s)(?=[A-Z])/)\n end", "def countries\n puts \"Which country would you like to explore?\"\n puts <<-DOC\n 1. Scotland\n 2. Ireland\n 3. United States of America\n 4. Japan\n 5. Canada\n 6. Other countries\n DOC\n country_list\n end", "def registered_country; end", "def countries\n @data.map { |iso2, data| iso2 }\n end", "def country_details(region, input)\n country = @countries[input - 1]\n\n Table.display_as_summary(country)\n browse_online(country)\n end", "def user_country_options(new_country)\n puts \"You picked #{new_country.name}. WHat would you like to know about it?\\n\n 1. Capital City\\n\n 2. Region of the World\\n\n 3. Population in #{new_country.name}\\n\n 4. Timezones\\n\n PLEASE SELECT A NUMBER FROM ABOVE\\n\".green\n self.second_level_choice(new_country)\n end", "def country\n \tself.contry\n end", "def all\n countries\n end", "def country_shortcuts\n COUNTRIES\n end", "def represented_country; end", "def country_name\n ISO3166::Country[country_code].name if country_code.present?\n end", "def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end", "def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end", "def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end", "def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end", "def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end", "def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end", "def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end", "def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end", "def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end", "def country\n 'United Kingdom'\n end", "def country_options_for_select(selected = nil, options = nil)\n options ||= {}\n\n selected = if selected.present?\n selected\n elsif options[:placeholder]\n :placeholder\n elsif options[:priority_countries]\n :first_country\n else nil end\n\n [ optional_placeholder(options, selected),\n optional_priority_countries_list(options, selected),\n full_countries_list(options, selected)\n ].join.html_safe\n end", "def country\n 'Australia'\n end", "def country\n @country ||= begin\n valid_countries.find do |iso2|\n @data[iso2][Core::MAIN_COUNTRY_FOR_CODE] == 'true'\n end || valid_countries.first || countries.first\n end\n end", "def country_name\n country = ISO3166::Country[country_code]\n # country.translations[I18n.locale.to_s] || country.name\n # country.name\n end", "def find_country\n\t @country = Country.get(params[:country_id])\n\tend", "def find_country\n\t @country = Country.get(params[:country_id])\n\tend", "def set_request\n @countries = ISO3166::Country.all.map { |c| [c.name, c.alpha3] }.sort\n\n if @countries && params[:id]\n @country = @country.find(params[:id])\n end\n end", "def find_country\n\t\t\t@country = Category.find_by_parent_uuid_and_url_part(Category.find(:first, :conditions => [\"parent_uuid IS NULL AND url_part = ?\", \"places\"]).uuid, params[:country_id].downcase) if params[:country_id]\n\t\tend", "def find_country\n\t\t\t@country = Category.find_by_parent_uuid_and_url_part(Category.find(:first, :conditions => [\"parent_uuid IS NULL AND url_part = ?\", \"places\"]).uuid, params[:country_id].downcase) if params[:country_id]\n\t\tend", "def country_list\n @countries ||= case kind\n when 'country' then\n zoneables\n when 'state' then\n zoneables.collect(&:country)\n when 'county'\n zone_member.zoneable.country_list\n else\n []\n end.flatten.compact.uniq\n end", "def countries\n @countries = Spree::Country.where(name: Spree::Config[:default_address_country])\n zone = Spree::Zone.find_by(name: Spree::Config[:address_zone_name]) if Spree::Config[:address_zone_name]\n @countries = zone.countries.order(:name) if zone.present?\n end", "def country\n if !block_given?\n return @j_del.java_method(:country, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling country()\"\n end", "def get_country(str)\n data = check_local_db(str)\n\n if data.nil? \n data = Geocoder.search(str)\n\n #has to parse through geocode data to find correct result\n data.first.address_components.each do |obj|\n data = obj[\"short_name\"] if obj[\"types\"][0] == \"country\"\n end\n\n save_to_db(str, data)\n end\n\n return data\n end", "def country\n location[2] || location[1]\n end", "def get_country(code, options = {})\n root = get_root\n object_from_response(GogoKit::Country,\n GogoKit::CountryRepresenter,\n :get,\n \"#{root.links['self'].href}/countries/#{code}\",\n options)\n end", "def all_countries \n\t\tself.class.get('/all')\n\tend", "def country\n @country || @default_country || 'GB'\n end", "def countries\n array = []\n details.css(\"div.txt-block a[href^='/country/']\").each do |node|\n array << {:code => node['href'].clean_href, :name => node.text.strip}\n end\n\n array\n end", "def countryChosen\n \n show_params(params)\n logger.debug \"Params id is #{params[:id]}\"\n \n if params[:id] != \"\"\n @country = Country.find(params[:id])\n @regions = @country.regions\n else\n @country = nil\n end\n render :layout => false\n end", "def print_all_countries\n @country_lists.each do |country|\n puts puts \"#{country.country_name}\\t#{}\"\n end\n end", "def db_countries\r\n\t\tLocation.find :all, :order=>\"country ASC\", :select => \"DISTINCT country\"\r\n\tend", "def country\n self.well_info.country\n end", "def country_code\n end", "def country_code\n end", "def filter_countries\n SUPER_COUNTRIES\n end", "def show\n json_response(@country)\n end", "def get_country_code\n Geonames::WebService.country_code @latitude, @longitude\n end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def countries\n document.search(\"h5[text()='Country:'] ~ a[@href*=/country/']\").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []\n end", "def getCountries(url)\n page = Nokogiri::HTML(RestClient.get(url))\n rawLinks = page.css(\"li a\")\n selection = []\n for link in rawLinks\n if link[\"href\"].include? \"country\"\n selection.push [link.text.strip, \"#{url}#{link[\"href\"]}\"]\n end\n end\n return selection\nend", "def countries\n xml.css('country').map{|c| Allorails::Country.new(c)}\n end", "def get_country(device_access_id)\n DeviceAccess.find(device_access_id).access_country\n end" ]
[ "0.7727084", "0.7558824", "0.7439343", "0.74220604", "0.7421992", "0.7320288", "0.72973764", "0.7171137", "0.7160514", "0.71356726", "0.71346307", "0.71215004", "0.7118109", "0.7029274", "0.69996035", "0.6995505", "0.69755256", "0.69649816", "0.69537985", "0.6927001", "0.68991214", "0.6884529", "0.6865179", "0.6863909", "0.68575615", "0.68462145", "0.6834976", "0.6818438", "0.67876524", "0.67853785", "0.67724836", "0.67619425", "0.67404455", "0.6736576", "0.6727044", "0.6727044", "0.6727044", "0.6726023", "0.6684748", "0.66831106", "0.6682923", "0.66800267", "0.6666043", "0.6664543", "0.66593456", "0.66577786", "0.66566014", "0.66475874", "0.66273475", "0.66228515", "0.66201067", "0.66036314", "0.65929556", "0.6589212", "0.65805614", "0.65805614", "0.65805614", "0.65805614", "0.65805614", "0.65805614", "0.65805614", "0.65805614", "0.6579405", "0.6567898", "0.6555605", "0.6549146", "0.6545784", "0.6532843", "0.6532192", "0.6532192", "0.65253687", "0.65239567", "0.65239567", "0.65229964", "0.65157104", "0.6510072", "0.64870304", "0.6482542", "0.6473632", "0.64672655", "0.64671934", "0.6461927", "0.64464253", "0.64418465", "0.6424945", "0.6421392", "0.6414662", "0.64093375", "0.64073527", "0.6402976", "0.638676", "0.6375288", "0.6375288", "0.6375288", "0.6375288", "0.6375288", "0.6375288", "0.6368626", "0.6345168", "0.6332601", "0.633192" ]
0.0
-1
get the country list of given region
def country_list_by_region(region) # select list of countries based on the region @countries = Countries::Country.find_by_region(region) # print the list of countries as table format Table.display_as_table(@countries) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def country_list\n return [] if type == \"state\"\n return countries if type == \"country\"\n members.collect { |zone| zone.country_list }.flatten\n end", "def get_countries\n countries=[]\n @locations.each do |loc|\n countries << loc.country.capitalize if loc.country\n end\n countries.uniq\n end", "def country_list\n get_request( \"/api/v2_1/api/countries\")\n end", "def country_list\n @countries ||= case kind\n when 'country' then\n zoneables\n when 'state' then\n zoneables.collect(&:country)\n when 'county'\n zone_member.zoneable.country_list\n else\n []\n end.flatten.compact.uniq\n end", "def country_list\n @countries = Country.find(:all, :order => \"name\" )\n return @countries\n end", "def countries_or_regions_of_origin\n return @countries_or_regions_of_origin\n end", "def country_values\n %w(\n Austria\n Belgium\n Denmark\n Finland\n France\n Germany\n Greece\n Iceland\n Ireland\n Italy\n Netherlands\n Norway\n Portugal\n Spain\n Sweden\n Switzerland\n United Kingdom\n USA\n )\n end", "def countries\n @data.map { |iso2, data| iso2 }\n end", "def countries\r\n\t\t\tCOUNTRIES\r\n\t\tend", "def countries_list\n [\n ['Afghanistan', 'Afghanistan'],\n ['Albania', 'Albania'],\n ['Algeria', 'Algeria'],\n ['American Samoa', 'American Samoa'],\n ['Andorra', 'Andorra'],\n ['Angola', 'Angola'],\n ['Antigua and Barbuda', 'Antigua and Barbuda'],\n ['Argentina', 'Argentina'],\n ['Armenia', 'Armenia'],\n ['Australia', 'Australia'],\n ['Austria', 'Austria'],\n ['Azerbaijan', 'Azerbaijan'],\n ['Bahamas', 'Bahamas'],\n ['Bahrain', 'Bahrain'],\n ['Bangladesh', 'Bangladesh'],\n ['Barbados', 'Barbados'],\n ['Belarus', 'Belarus'],\n ['Belgium', 'Belgium'],\n ['Belize', 'Belize'],\n ['Benin', 'Benin'],\n ['Bermuda', 'Bermuda'],\n ['Bhutan', 'Bhutan'],\n ['Bolivia', 'Bolivia'],\n ['Bosnia and Herzegovina', 'Bosnia and Herzegovina'],\n ['Botswana', 'Botswana'],\n ['Brazil', 'Brazil'],\n ['Brunei', 'Brunei'],\n ['Bulgaria', 'Bulgaria'],\n ['Burkina Faso', 'Burkina Faso'],\n ['Burundi', 'Burundi'],\n ['Cambodia', 'Cambodia'],\n ['Cameroon', 'Cameroon'],\n ['Canada', 'Canada'],\n ['Cape Verde', 'Cape Verde'],\n ['Cayman Islands', 'Cayman Islands'],\n ['Central African Republic', 'Central African Republic'],\n ['Chad', 'Chad'],\n ['Chile', 'Chile'],\n ['China', 'China'],\n ['Colombia', 'Colombia'],\n ['Comoros', 'Comoros'],\n ['Congo, Democratic Republic of the', 'Congo, Democratic Republic of the'],\n ['Congo, Republic of the', 'Congo, Republic of the'],\n ['Costa Rica', 'Costa Rica'],\n [\"Côte d'Ivoire\", \"Côte d'Ivoire\"],\n ['Croatia', 'Croatia'],\n ['Cuba', 'Cuba'],\n ['Cyprus', 'Cyprus'],\n ['Czech Republic', 'Czech Republic'],\n ['Denmark', 'Denmark'],\n ['Djibouti', 'Djibouti'],\n ['Dominica', 'Dominica'],\n ['Dominican Republic', 'Dominican Republic'],\n ['East Timor', 'East Timor'],\n ['Ecuador', 'Ecuador'],\n ['Egypt', 'Egypt'],\n ['El Salvador', 'El Salvador'],\n ['Equatorial Guinea', 'Equatorial Guinea'],\n ['Eritrea', 'Eritrea'],\n ['Estonia', 'Estonia'],\n ['Ethiopia', 'Ethiopia'],\n ['Fiji', 'Fiji'],\n ['Finland', 'Finland'],\n ['France', 'France'],\n ['French Polynesia', 'French Polynesia'],\n ['Gabon', 'Gabon'],\n ['Gambia', 'Gambia'],\n ['Georgia', 'Georgia'],\n ['Germany', 'Germany'],\n ['Ghana', 'Ghana'],\n ['Greece', 'Greece'],\n ['Greenland', 'Greenland'],\n ['Grenada', 'Grenada'],\n ['Guam', 'Guam'],\n ['Guatemala', 'Guatemala'],\n ['Guinea', 'Guinea'],\n ['Guinea-Bissau', 'Guinea-Bissau'],\n ['Guyana', 'Guyana'],\n ['Haiti', 'Haiti'],\n ['Honduras', 'Honduras'],\n ['Hong Kong', 'Hong Kong'],\n ['Hungary', 'Hungary'],\n ['Iceland', 'Iceland'],\n ['India', 'India'],\n ['Indonesia', 'Indonesia'],\n ['Iran', 'Iran'],\n ['Iraq', 'Iraq'],\n ['Ireland', 'Ireland'],\n ['Israel', 'Israel'],\n ['Italy', 'Italy'],\n ['Jamaica', 'Jamaica'],\n ['Japan', 'Japan'],\n ['Jordan', 'Jordan'],\n ['Kazakhstan', 'Kazakhstan'],\n ['Kenya', 'Kenya'],\n ['Kiribati', 'Kiribati'],\n ['North Korea', 'North Korea'],\n ['South Korea', 'South Korea'],\n ['Kosovo', 'Kosovo'],\n ['Kuwait', 'Kuwait'],\n ['Kyrgyzstan', 'Kyrgyzstan'],\n ['Laos', 'Laos'],\n ['Latvia', 'Latvia'],\n ['Lebanon', 'Lebanon'],\n ['Lesotho', 'Lesotho'],\n ['Liberia', 'Liberia'],\n ['Libya', 'Libya'],\n ['Liechtenstein', 'Liechtenstein'],\n ['Lithuania', 'Lithuania'],\n ['Luxembourg', 'Luxembourg'],\n ['Macedonia', 'Macedonia'],\n ['Madagascar', 'Madagascar'],\n ['Malawi', 'Malawi'],\n ['Malaysia', 'Malaysia'],\n ['Maldives', 'Maldives'],\n ['Mali', 'Mali'],\n ['Malta', 'Malta'],\n ['Marshall Islands', 'Marshall Islands'],\n ['Mauritania', 'Mauritania'],\n ['Mauritius', 'Mauritius'],\n ['Mexico', 'Mexico'],\n ['Micronesia', 'Micronesia'],\n ['Moldova', 'Moldova'],\n ['Monaco', 'Monaco'],\n ['Mongolia', 'Mongolia'],\n ['Montenegro', 'Montenegro'],\n ['Morocco', 'Morocco'],\n ['Mozambique', 'Mozambique'],\n ['Myanmar', 'Myanmar'],\n ['Namibia', 'Namibia'],\n ['Nauru', 'Nauru'],\n ['Nepal', 'Nepal'],\n ['Netherlands', 'Netherlands'],\n ['New Zealand', 'New Zealand'],\n ['Nicaragua', 'Nicaragua'],\n ['Niger', 'Niger'],\n ['Nigeria', 'Nigeria'],\n ['Norway', 'Norway'],\n ['Northern Mariana Islands', 'Northern Mariana Islands'],\n ['Oman', 'Oman'],\n ['Pakistan', 'Pakistan'],\n ['Palau', 'Palau'],\n ['Palestine', 'Palestine'],\n ['Panama', 'Panama'],\n ['Papua New Guinea', 'Papua New Guinea'],\n ['Paraguay', 'Paraguay'],\n ['Peru', 'Peru'],\n ['Philippines', 'Philippines'],\n ['Poland', 'Poland'],\n ['Portugal', 'Portugal'],\n ['Puerto Rico', 'Puerto Rico'],\n ['Qatar', 'Qatar'],\n ['Romania', 'Romania'],\n ['Russia', 'Russia'],\n ['Rwanda', 'Rwanda'],\n ['Saint Kitts and Nevis', 'Saint Kitts and Nevis'],\n ['Saint Lucia', 'Saint Lucia'],\n ['Saint Vincent and the Grenadines', 'Saint Vincent and the Grenadines'],\n ['Samoa', 'Samoa'],\n ['San Marino', 'San Marino'],\n ['Sao Tome and Principe', 'Sao Tome and Principe'],\n ['Saudi Arabia', 'Saudi Arabia'],\n ['Senegal', 'Senegal'],\n ['Serbia and Montenegro', 'Serbia and Montenegro'],\n ['Seychelles', 'Seychelles'],\n ['Sierra Leone', 'Sierra Leone'],\n ['Singapore', 'Singapore'],\n ['Slovakia', 'Slovakia'],\n ['Slovenia', 'Slovenia'],\n ['Solomon Islands', 'Solomon Islands'],\n ['Somalia', 'Somalia'],\n ['South Africa', 'South Africa'],\n ['Spain', 'Spain'],\n ['Sri Lanka', 'Sri Lanka'],\n ['Sudan', 'Sudan'],\n ['Sudan, South', 'Sudan, South'],\n ['Suriname', 'Suriname'],\n ['Swaziland', 'Swaziland'],\n ['Sweden', 'Sweden'],\n ['Switzerland', 'Switzerland'],\n ['Syria', 'Syria'],\n ['Taiwan', 'Taiwan'],\n ['Tajikistan', 'Tajikistan'],\n ['Tanzania', 'Tanzania'],\n ['Thailand', 'Thailand'],\n ['Togo', 'Togo'],\n ['Tonga', 'Tonga'],\n ['Trinidad and Tobago', 'Trinidad and Tobago'],\n ['Tunisia', 'Tunisia'],\n ['Turkey', 'Turkey'],\n ['Turkmenistan', 'Turkmenistan'],\n ['Tuvalu', 'Tuvalu'],\n ['Uganda', 'Uganda'],\n ['Ukraine', 'Ukraine'],\n ['United Arab Emirates', 'United Arab Emirates'],\n ['United Kingdom', 'United Kingdom'],\n ['United States', 'United States'],\n ['Uruguay', 'Uruguay'],\n ['Uzbekistan', 'Uzbekistan'],\n ['Vanuatu', 'Vanuatu'],\n ['Vatican City', 'Vatican City'],\n ['Venezuela', 'Venezuela'],\n ['Vietnam', 'Vietnam'],\n ['Virgin Islands, British', 'Virgin Islands, British'],\n ['Virgin Islands, U.S.', 'Virgin Islands, U.S.'],\n ['Yemen', 'Yemen'],\n ['Zambia', 'Zambia'],\n ['Zimbabwe', 'Zimbabwe']\n ]\n end", "def region_names(language=nil)\n language ? @region_names.select { |name| name.language == language } : @region_names\n end", "def countries\n document[\"nationality\"].collect {|nation| nation[\"$\"]} rescue nil\n end", "def listRegions\n\t\t\treturn MU::Config.listRegions\n\t\tend", "def all\n countries\n end", "def countries\n @countries = Spree::Country.where(name: Spree::Config[:default_address_country])\n zone = Spree::Zone.find_by(name: Spree::Config[:address_zone_name]) if Spree::Config[:address_zone_name]\n @countries = zone.countries.order(:name) if zone.present?\n end", "def get_countries\n doc = Nokogiri::HTML(open('https://www.britannica.com/topic/list-of-countries-1993160'))\n countries_extracted = doc.css(\"li a\").text.split('Britannica')[1].split(' geography')[0].rstrip\n @processed_countries = countries_extracted.split(/(?<!\\s)(?=[A-Z])/)\n end", "def address_regions(address)\n return [] unless address\n \n if address.new_record? && address.country_id\n Region.find_all_by_country_id(address.country_id)\n elsif address.region\n address.regions\n else\n []\n end\n end", "def whitelisted_filters_for_countries\n country_slugs = @params[:countries] || []\n @regions.each do |region|\n country_slugs = country_slugs.concat(region[:countries])\n end\n if country_slugs.empty?\n []\n else\n Country.where(slug: country_slugs)\n end\n end", "def get_countries\n \tresponse = invoke(\"web:GetCountries\", :soap_action => :none)\n\n \tnode = response.document.xpath('//ns:GetCountriesResult', ns)[0]\n \tparse_country_description(node)\n end", "def filter_countries\n SUPER_COUNTRIES\n end", "def all\n # return an array of all the regions\n return NAMES\n end", "def countries_not_in_selected_regions\n country_list = []\n @countries.each do |country|\n not_in_region = true\n @regions.each do |region|\n if region[:countries].include? country[:slug]\n not_in_region = false\n break\n end\n end\n country_list.push(country) if not_in_region\n end\n country_list\n end", "def countries(input)\n get_single_method(:countries, input)\n end", "def countries\n array = []\n details.css(\"div.txt-block a[href^='/country/']\").each do |node|\n array << {:code => node['href'].clean_href, :name => node.text.strip}\n end\n\n array\n end", "def countries\n countries_ids = self.answers.where(answer_type: 'geo_countries').first.try(:text_value).split(',')\n Country.where(:id => countries_ids)\n end", "def location_countries\r\n\t\treturn LocationCountry.find :all, :order=>\"sort_order, name ASC\"\r\n\tend", "def calendar_regions\n @regions ||= parse_countries(load_page(@cal_url))\n end", "def get_countries\n perform(:get, 'enum/countries', nil, nonauth_headers).body\n end", "def region_of_country(country_code = 'JP')\n result = @regions['asia'].to_s\n @regions.each do |region, countries|\n countries.each do |country|\n return result = region.to_s unless country[country_code].nil?\n end\n end\n rescue NoMethodError\n return 'asia'\n end", "def regions(for_select = true)\n fetch_array_for $regions, for_select\n end", "def countries(input)\n get_single_method('countries', input)\n end", "def countries\n collection(\"countries\")\n end", "def us_zones\n country_zones(:us)\n end", "def getCountries(url)\n page = Nokogiri::HTML(RestClient.get(url))\n rawLinks = page.css(\"li a\")\n selection = []\n for link in rawLinks\n if link[\"href\"].include? \"country\"\n selection.push [link.text.strip, \"#{url}#{link[\"href\"]}\"]\n end\n end\n return selection\nend", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def regions\n client.get_stats('/stats/regions')\n end", "def country\n query = create_query(\n :Location, :regexp_search, regexp: \"#{params[:country]}$\"\n )\n show_selected_locations(query, link_all_sorts: true)\n end", "def get_cis\n @cis['countries'].map{ |c| find_by_code(c) }\n end", "def getCountryBoundsForRegions(targetRegionData)\n countryMappedFile = JSON.parse(File.read('data/country_ISO3166_mapping.json'))\n country3DigitCodeList = Array.new\n targetRegionData.each do |key,val|\n if countryMappedFile.has_key?(key.to_s)\n country3DigitCodeList.push(countryMappedFile[key])\n end\n end\n geoLocationData = ''\n geoJsonData = Array.new\n if country3DigitCodeList != ''\n geoLocationData = JSON.parse(File.read('data/world.json'))\n country3DigitCodeList.each do |countryCode|\n geoLocationData['features'].each do |loc|\n if loc['properties']['ISO_A3'].to_s == countryCode.to_s\n geoJsonData.push(loc['geometry'])\n break\n end\n end\n end\n end\n geoJsonData\n end", "def get_country_name\n subdivision = Geonames::WebService.country_subdivision @latitude, @longitude\n subdivision.country_name\n end", "def regions\n AWS.regions.map(&:name)\n end", "def index\n @region_countries = RegionCountry.all\n \n\n end", "def list(filter)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'filter', filter)\n\t\t\tclient.queue_service_action_call('region', 'list', 'KalturaRegionListResponse', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend", "def countries\n xml.css('country').map{|c| Allorails::Country.new(c)}\n end", "def list(filter)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'filter', filter)\n\t\t\tclient.queue_service_action_call('country', 'list', 'KalturaCountryListResponse', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend", "def db_countries\r\n\t\tLocation.find :all, :order=>\"country ASC\", :select => \"DISTINCT country\"\r\n\tend", "def current_region(default: [])\n return default unless params[:region]\n icao_starts = params[:region].split(/[\\-,]/)\n icao_starts.compact!\n icao_starts.uniq!\n icao_starts.map!{|s| s.upcase.tr(\"^A-Z\",\"\")}\n return icao_starts\n end", "def countries\n doc.search(\"table.info a[href*='/m_act%5Bcountry%5D/']\").map(&:text)\n end", "def all_countries \n\t\tself.class.get('/all')\n\tend", "def regional_sitelist\n query('txt/wxfcs/regionalforecast/json/sitelist')\n end", "def store_countries\n Countries::Data.get_data\n @regions = Countries::Country.create_region_list\n end", "def get_regions()\n\t\t{\"include_regions\"=>@include_regions,\"exclude_regions\"=>@exclude_regions}\n\tend", "def region_opts\n res = $store.select(RegionTable, \n \"reg_affiliate=? order by reg_name\",\n @data_object.aff_id)\n\n regions = { Affiliate::NONE => \"unassigned\" } \n\n res.each {|r| regions[r.reg_id] = r.reg_name}\n \n regions\n end", "def getRegions(config, servername)\n connection = HConnectionManager::getConnection(config);\n return ProtobufUtil::getOnlineRegions(connection.getAdmin(ServerName.valueOf(servername)));\nend", "def countries\n all_structures.reduce(Set.new) { |a, s| a.add(s[:country]) }.to_a.sort\n end", "def country_details(region, input)\n country = @countries[input - 1]\n\n Table.display_as_summary(country)\n browse_online(country)\n end", "def country\n if !block_given?\n return @j_del.java_method(:country, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling country()\"\n end", "def regions\n Vultr::Resource::Region.new(@faraday)\n end", "def country\n client.places.get_countries.select{|hash| hash[\"cid\"] == @params[:country].to_i}.first[:title]\n end", "def countries\n puts \"Which country would you like to explore?\"\n puts <<-DOC\n 1. Scotland\n 2. Ireland\n 3. United States of America\n 4. Japan\n 5. Canada\n 6. Other countries\n DOC\n country_list\n end", "def pbAllRegionalSpecies(region)\n ret=[0]\n pbRgssOpen(\"Data/regionals.dat\",\"rb\"){|f|\n numRegions=f.fgetw\n numDexDatas=f.fgetw\n if region>=0 && region<numRegions\n f.pos=4+region*numDexDatas*2\n # \"i\" specifies the national species\n for i in 0...numDexDatas\n regionalNum=f.fgetw\n ret[regionalNum]=i if regionalNum!=0\n end\n # Replace unspecified regional\n # numbers with zeros\n for i in 0...ret.length\n ret[i]=0 if !ret[i]\n end\n end\n }\n return ret\nend", "def shipping_countries\n ShippingMethod.all.collect { |method| method.zone.country_list }.flatten.uniq.sort_by {|item| item.send 'name'}\n end", "def localized_countries_array(options={})\n exclude = Array(options[:exclude]).map {|code| code.to_s.upcase }\n if(options[:description]==:abbreviated)\n if Rails.env!='staging'\n I18n.translate(:countries).map { |key, value| [key.to_s.upcase] if !exclude.include?(key.to_s.upcase) }\n else\n COUNTRIES_FALLBACK[I18n.locale].map { |key, value| [key.to_s.upcase] if !exclude.include?(key.to_s.upcase) }\n end\n else\n if Rails.env!='staging'\n I18n.translate(:countries).map { |key, value| [value, key.to_s.upcase] if !exclude.include?(key.to_s.upcase) }\n else\n COUNTRIES_FALLBACK[I18n.locale].map { |key, value| [value, key.to_s.upcase] if !exclude.include?(key.to_s.upcase) }\n end\n end.compact.sort_by { |country| country.first.parameterize }\n end", "def regions\n @attributes[:regions]\n end", "def by_country(country='all')\n\n result = [ ['Country', 'Amount'] ]\n country = (country == 'all') ? \"[Nationalities].children\" : \"[Nationalities].[#{country}]\"\n\n r = @connection.from('Gears').\n columns('[Measures].[Players]').\n rows(country).\n nonempty().execute\n\n r.axis_full_names[1].each_with_index {|country, index|\n\n c = TZInfo::Country.get(country.split('.')[1].gsub('[','').gsub(']','')).name\n v = r.values[index][0]\n result << [ c , v ]\n }\n result\n end", "def load_regions\n\t\t\tregions = Locations::Regions.const_get(ENV['CURRENT_CITY'])\n\t\tend", "def get_continent(country_doc)\n my_html = Nokogiri::HTML(country_doc)\n doc = my_html.at(\"table tr td div.region1 a\")\n region = nil\n if doc != nil then\n region = doc.text.to_s\n if str_include?(region, 'Asia')\n region = 'Asia'\n elsif str_include?(region, 'middle east')\n region = 'Asia'\n end\n end\n return region\n end", "def visited_countries\n countries = Country.list\n visited_codes = pins.map(&:country_code).uniq\n countries.select! { |c| visited_codes.include? c[\"countryCode\"] }\n countries.sort! { |a,b| a[\"name\"].downcase <=> b[\"name\"].downcase }\n end", "def all_organisations_in_country(country)\n sparql = \"\n SELECT DISTINCT ?uri ?label\n WHERE \n {\n VALUES ?country { \\\"#{country}\\\" }\n GRAPH <http://data.artsapi.com/graph/organisations> {\n ?uri <http://data.artsapi.com/def/arts/locationCountry> ?country .\n ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?label .\n }\n }\n \"\n\n results = User.current_user.within { Tripod::SparqlClient::Query.select(sparql) }\n\n results.map { |r| [r[\"uri\"][\"value\"], r[\"label\"][\"value\"]] }\n end", "def available_services_regions\n unless @regions\n @regions = []\n service_catalog.each do |service|\n next if service[\"type\"]==\"identity\"\n (service[\"endpoints\"] || []).each do |endpint|\n @regions << endpint['region']\n end\n end\n @regions.uniq!\n end\n @regions\n end", "def registered_country; end", "def countries\n countries = YAML.load_file(Rails.root.join('data', 'locale_countries.yml'))\n countries.select! { |_, flag| File.exist? Rails.root.join('app', 'assets', 'images', 'country-flags', \"#{flag.downcase}.png\") }\n # apply potential region values too\n Dir.glob(Rails.root.join('app', 'assets', 'images', 'country-flags', '*.png')).each do |file|\n base = File.basename(file, '.png')\n next if base.starts_with?('_')\n countries[base.upcase] = base\n end\n\n countries.each { |key, flag| countries[key] = view_context.image_path(\"country-flags/#{flag.downcase}.png\") }\n\n render json: countries.to_json\n end", "def countries\n @countries ||= Fotolia::Countries.new(self)\n end", "def country; end", "def country; end", "def country; end", "def countries_rights\n countries=[]\n if @publishing_detail\n countries+=@publishing_detail.sales_rights.map{|sr| sr.territory.countries}.flatten.uniq\n end\n\n if @product_supplies\n countries+=@product_supplies.map{|ps| ps.markets.map{|m| m.territory.countries}.flatten}.flatten.uniq\n end\n\n countries.uniq\n end", "def getVendorsAndRegions\n fetch(@config[:finance_path], 'Finance.getVendorsAndRegions')\n end", "def country_options\n Country.all.map{|country| [country.title, country.id]}\n end", "def country(code, name); end", "def index\n # Rails.cache.delete('region_list')\n @regions = Rails.cache.fetch(\"region_list\", :expires_in => 1.week) do\n global = Region.find_by_name(\"Global\")\n united_states = Region.find_by_name(\"United States\")\n other_regions = Region.where(\"name != ? AND name != ?\", \"United States\", \"Global\").order(:name)\n \n regions_array = []\n regions_array << global << united_states\n other_regions.each do |region|\n regions_array << region\n end\n regions_array\n end\n\n \n end", "def regional_office\n []\n end", "def regional_office\n []\n end", "def regional_office\n []\n end", "def countries_or_regions_of_origin=(value)\n @countries_or_regions_of_origin = value\n end", "def country_or_region\n return @country_or_region\n end", "def pbAllRegionalSpecies(region_dex)\n return nil if region_dex < 0\n dex_list = pbLoadRegionalDexes[region_dex]\n return nil if !dex_list || dex_list.length == 0\n return dex_list.clone\nend", "def get_country_code\n Geonames::WebService.country_code @latitude, @longitude\n end", "def to_s\n '#<Twilio.Voice.V1.CountryList>'\n end", "def index\n @user_regions = UserRegion.all\n end", "def selected_filter_option_names(filter)\n region_names = filter.regions(:name).sort\n country_names = filter.reduced_countries(:name).sort\n region_names.concat(country_names)\n end", "def get_country\n @single_city_data[\"sys\"][\"country\"]\n end", "def region_names_short(language=nil)\n language ? @region_names_short.select { |name| name.language == language } : @region_names_short\n end", "def region() ; info[:region] ; end", "def region() ; info[:region] ; end" ]
[ "0.7619613", "0.7324609", "0.72546595", "0.7250403", "0.7059625", "0.7008309", "0.6882325", "0.687028", "0.6860345", "0.6838286", "0.6737262", "0.6724257", "0.66977495", "0.66964805", "0.66939497", "0.6610382", "0.6607012", "0.65989596", "0.6598801", "0.65600556", "0.6545739", "0.65381837", "0.64875036", "0.6479075", "0.6475687", "0.6460666", "0.64576817", "0.64438796", "0.6441967", "0.64417225", "0.6429059", "0.64263", "0.642507", "0.6397958", "0.6385759", "0.6385759", "0.6385759", "0.6385759", "0.6385759", "0.6385759", "0.6367096", "0.63609797", "0.63556194", "0.6268232", "0.62561995", "0.62519455", "0.6239576", "0.6219581", "0.62117463", "0.62115335", "0.6198755", "0.6172137", "0.61681885", "0.6152842", "0.6136215", "0.6087688", "0.6079885", "0.60344905", "0.6030769", "0.6020321", "0.6017767", "0.60141015", "0.6000918", "0.5996158", "0.5993204", "0.5990026", "0.5984642", "0.5968259", "0.596685", "0.5927909", "0.5922094", "0.59176475", "0.59160316", "0.59107155", "0.59101224", "0.59060806", "0.5890003", "0.5874199", "0.5869601", "0.5869601", "0.5869601", "0.58686364", "0.58681446", "0.5864394", "0.58642167", "0.5851404", "0.5850548", "0.5850548", "0.5850548", "0.58468246", "0.58267975", "0.58239025", "0.582214", "0.5819912", "0.58194137", "0.5814508", "0.58127594", "0.58104277", "0.58067554", "0.58067554" ]
0.78170156
0
country details based on region and country
def country_details(region, input) country = @countries[input - 1] Table.display_as_summary(country) browse_online(country) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_country\n @single_city_data[\"sys\"][\"country\"]\n end", "def country\n data['country']\n end", "def represented_country; end", "def registered_country; end", "def country; end", "def country; end", "def country; end", "def region_of_country(country_code = 'JP')\n result = @regions['asia'].to_s\n @regions.each do |region, countries|\n countries.each do |country|\n return result = region.to_s unless country[country_code].nil?\n end\n end\n rescue NoMethodError\n return 'asia'\n end", "def country_or_region\n return @country_or_region\n end", "def country\n ISO3166::Country[@country_code]\n end", "def country\n 'United Kingdom'\n end", "def set_country\n self.country = self.region.country if self.region && self.region.country\n end", "def country\n 'Australia'\n end", "def country_name\n ISO3166::Country[country_code].name if country_code.present?\n end", "def get_country_name\n subdivision = Geonames::WebService.country_subdivision @latitude, @longitude\n subdivision.country_name\n end", "def country\n self[:C]\n end", "def get_continent(country_doc)\n my_html = Nokogiri::HTML(country_doc)\n doc = my_html.at(\"table tr td div.region1 a\")\n region = nil\n if doc != nil then\n region = doc.text.to_s\n if str_include?(region, 'Asia')\n region = 'Asia'\n elsif str_include?(region, 'middle east')\n region = 'Asia'\n end\n end\n return region\n end", "def country\n self.well_info.country\n end", "def country\n client.places.get_countries.select{|hash| hash[\"cid\"] == @params[:country].to_i}.first[:title]\n end", "def country\n location[2] || location[1]\n end", "def country(code, name); end", "def country\n @country\n end", "def country_or_region=(value)\n @country_or_region = value\n end", "def region\n @control_data['region'] | 'National'\n end", "def region() ; info[:region] ; end", "def region() ; info[:region] ; end", "def user_country\n USER_COUNTRY[country]\n end", "def country_code; end", "def country_code; end", "def country_code\n end", "def country_code\n end", "def country\n @country || @default_country || 'GB'\n end", "def country\n params['country']\n end", "def country\n \tself.contry\n end", "def countries_or_regions_of_origin\n return @countries_or_regions_of_origin\n end", "def country\n if(@country_code.to_i == 280)\n IsoCountryCodes.find(276) #since 1990 we use 176 for whole germany, 280 was for \"west germany\" WTF\n else\n IsoCountryCodes.find(@country_code)\n end\n end", "def country\n query = create_query(\n :Location, :regexp_search, regexp: \"#{params[:country]}$\"\n )\n show_selected_locations(query, link_all_sorts: true)\n end", "def country_name\n country = ISO3166::Country[country_code]\n # country.translations[I18n.locale.to_s] || country.name\n # country.name\n end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def country_codes; end", "def country\n RAILS_DEFAULT_LOGGER.debug(\"profile.country -- returning #{setting(:company_country)}\")\n \n setting(:company_country).to_s\n end", "def country_values\n %w(\n Austria\n Belgium\n Denmark\n Finland\n France\n Germany\n Greece\n Iceland\n Ireland\n Italy\n Netherlands\n Norway\n Portugal\n Spain\n Sweden\n Switzerland\n United Kingdom\n USA\n )\n end", "def show\n @country = Carmen::Country.coded(@profile.country_code)\n @subregions = @country.subregions\n @state = @subregions.coded(@profile.state_code)\n end", "def title_with_country\n # Remove special country values (e.g. 'DIT HQ')\n countries = opportunity.countries.where.not(id: [198, 199, 142, 200])\n if source('post') && !countries.empty? && countries.map(&:region_id).include?(18)\n opportunity.title\n else\n country = if countries.size > 1\n 'Multi Country'\n else\n countries.map(&:name).join\n end\n\n if country.present?\n \"#{country} - #{opportunity.title}\"\n else\n opportunity.title\n end\n end\n end", "def country\n @country ||= IsoCountryCodes.find(alpha2)\n end", "def country\n city.country\n end", "def location\n c = Country.find_country_by_alpha2(country)\n country_name = !c.nil? ? c.name : nil\n if (postcode and country)\n return postcode + \", \" + (country_name or country)\n else\n return (postcode or country_name or country)\n end\n end", "def country_code\n decode hash[\"CountryCode\"]\n end", "def get_country_code\n Geonames::WebService.country_code @latitude, @longitude\n end", "def country_name\n cc = carmen_country\n\n cc ? \"#{cc.name}\" : ''\n end", "def country_name\n countryfull = ISO3166::Country[country]\n countryfull.translations[I18n.locale.to_s] || countryfull.name\n end", "def state\n country = ISO3166::Country[country_residence]\n if country.try(:subdivisions?)\n country.subdivisions[state_code].try(:[], \"name\")\n else\n state_code\n end\n end", "def country_code\n if self.uk?\n UK_COUNTRY_CODE\n else\n IE_COUNTRY_CODE\n end\n end", "def countries\n document[\"nationality\"].collect {|nation| nation[\"$\"]} rescue nil\n end", "def country_name\n country = ISO3166::Country[country_code]\n country.translations[I18n.locale.to_s] || country.name\n end", "def country_name\n country = ISO3166::Country[country_code]\n country.translations[I18n.locale.to_s] || country.name\n end", "def country_name\n country = ISO3166::Country[country_code]\n country.translations[I18n.locale.to_s] || country.name\n end", "def region_opts\n res = $store.select(RegionTable, \n \"reg_affiliate=? order by reg_name\",\n @data_object.aff_id)\n\n regions = { Affiliate::NONE => \"unassigned\" } \n\n res.each {|r| regions[r.reg_id] = r.reg_name}\n \n regions\n end", "def country_code\n Geocoder.search(hotel.city).first.country_code\n rescue Exception\n 'CZ'\n end", "def country\n @country ||= begin\n valid_countries.find do |iso2|\n @data[iso2][Core::MAIN_COUNTRY_FOR_CODE] == 'true'\n end || valid_countries.first || countries.first\n end\n end", "def location\n country = Carmen::Country.coded(self.country)\n if country.present? && self.state.present?\n location = country.subregions? ? country.subregions.coded(self.state).name : self.state\n location += \", \"\n else\n location = ''\n end\n country.present? ? location + country.name : nil\n end", "def city_and_country\n \"#{self.location.city} - #{self.location.country}\"\n end", "def country(hostname)\n case @database_type\n when Edition::CITY_REV0, Edition::CITY_REV1, Edition::CITY_REV1_V6\n city(hostname)\n\n when Edition::REGION_REV0, Edition::REGION_REV1\n region(hostname)\n\n when Edition::NETSPEED, Edition::NETSPEED_REV1\n netspeed(hostname)\n\n when Edition::COUNTRY, Edition::PROXY, Edition::COUNTRY_V6\n ip = lookup_ip(hostname)\n if @ip_bits > 32\n\tipaddr = IPAddr.new ip\n\tcode = (seek_record(ipaddr.to_i) - COUNTRY_BEGIN)\n else\n\t# Convert numeric IP address to an integer\n\tipnum = iptonum(ip)\n\tcode = (seek_record(ipnum) - @database_segments[0])\n end\n read_country(code, hostname, ip)\n else\n throw \"Invalid GeoIP database type #{@database_type}, can't look up Country by IP\"\n end\n end", "def country_code\n return @country_code\n end", "def country(code)\n\t\tcase code\n\t\t\twhen \"AD\"\tthen \"Andorra\"\n\t\t\twhen \"AE\"\tthen \"United Arab Emirates\"\n\t\t\twhen \"AF\"\tthen \"Afghanistan\"\n\t\t\twhen \"AG\"\tthen \"Antigua and Barbuda\"\n\t\t\twhen \"AI\"\tthen \"Anguilla\"\n\t\t\twhen \"AL\"\tthen \"Albania\"\n\t\t\twhen \"AM\"\tthen \"Armenia\"\n\t\t\twhen \"AO\"\tthen \"Angola\"\n\t\t\twhen \"AR\"\tthen \"Argentina\"\n\t\t\twhen \"AS\"\tthen \"American Samoa\"\n\t\t\twhen \"AT\"\tthen \"Austria\"\n\t\t\twhen \"AU\"\tthen \"Australia\"\n\t\t\twhen \"AW\"\tthen \"Aruba\"\n\t\t\twhen \"AX\"\tthen \"Aland Islands\"\n\t\t\twhen \"AZ\"\tthen \"Azerbaijan\"\n\t\t\twhen \"BA\"\tthen \"Bosnia and Herzegovina\"\n\t\t\twhen \"BB\"\tthen \"Barbados\"\n\t\t\twhen \"BD\"\tthen \"Bangladesh\"\n\t\t\twhen \"BE\"\tthen \"Belgium\"\n\t\t\twhen \"BF\"\tthen \"Burkina Faso\"\n\t\t\twhen \"BG\"\tthen \"Bulgaria\"\n\t\t\twhen \"BH\"\tthen \"Bahrain\"\n\t\t\twhen \"BI\"\tthen \"Burundi\"\n\t\t\twhen \"BJ\"\tthen \"Benin\"\n\t\t\twhen \"BL\"\tthen \"Saint Barthelemy\"\n\t\t\twhen \"BN\"\tthen \"Brunei Darussalam\"\n\t\t\twhen \"BO\"\tthen \"Bolivia\"\n\t\t\twhen \"BM\"\tthen \"Bermuda\"\n\t\t\twhen \"BQ\"\tthen \"Bonaire Saint Eustachius and Saba\"\n\t\t\twhen \"BR\"\tthen \"Brazil\"\n\t\t\twhen \"BS\"\tthen \"Bahamas\"\n\t\t\twhen \"BT\"\tthen \"Bhutan\"\n\t\t\twhen \"BV\"\tthen \"Bouvet Island\"\n\t\t\twhen \"BW\"\tthen \"Botswana\"\n\t\t\twhen \"BY\"\tthen \"Belarus\"\n\t\t\twhen \"BZ\"\tthen \"Belize\"\n\t\t\twhen \"CA\"\tthen \"Canada\"\n\t\t\twhen \"CC\"\tthen \"Cocos (Keeling) Islands\"\n\t\t\twhen \"CD\"\tthen \"Democratic Republic of Congo\"\n\t\t\twhen \"CF\"\tthen \"Central African Republic\"\n\t\t\twhen \"CG\"\tthen \"Republic of Congo\"\n\t\t\twhen \"CH\"\tthen \"Switzerland\"\n\t\t\twhen \"CI\"\tthen \"Côte d'Ivoire\"\n\t\t\twhen \"CK\"\tthen \"Cook Islands\"\n\t\t\twhen \"CL\"\tthen \"Chile\"\n\t\t\twhen \"CM\"\tthen \"Cameroon\"\n\t\t\twhen \"CN\"\tthen \"China\"\n\t\t\twhen \"CO\"\tthen \"Colombia\"\n\t\t\twhen \"CR\"\tthen \"Costa Rica\"\n\t\t\twhen \"CU\"\tthen \"Cuba\"\n\t\t\twhen \"CV\"\tthen \"Cape Verde\"\n\t\t\twhen \"CW\"\tthen \"Curaçao\"\n\t\t\twhen \"CX\"\tthen \"Christmas Island\"\n\t\t\twhen \"CY\"\tthen \"Cyprus\"\n\t\t\twhen \"CZ\"\tthen \"Czech Republic\"\n\t\t\twhen \"DE\"\tthen \"Germany\"\n\t\t\twhen \"DJ\"\tthen \"Djibouti\"\n\t\t\twhen \"DK\"\tthen \"Denmark\"\n\t\t\twhen \"DM\"\tthen \"Dominica\"\n\t\t\twhen \"DO\"\tthen \"Dominican Republic\"\n\t\t\twhen \"DZ\"\tthen \"Algeria\"\n\t\t\twhen \"EC\"\tthen \"Ecuador\"\n\t\t\twhen \"EG\"\tthen \"Egypt\"\n\t\t\twhen \"EE\"\tthen \"Estonia\"\n\t\t\twhen \"EH\"\tthen \"Western Sahara\"\n\t\t\twhen \"ER\"\tthen \"Eritrea\"\n\t\t\twhen \"ES\"\tthen \"Spain\"\n\t\t\twhen \"ET\"\tthen \"Ethiopia\"\n\t\t\twhen \"FI\"\tthen \"Finland\"\n\t\t\twhen \"FJ\"\tthen \"Fiji\"\n\t\t\twhen \"FK\"\tthen \"Falkland Islands\"\n\t\t\twhen \"FM\"\tthen \"Federated States of Micronesia\"\n\t\t\twhen \"FO\"\tthen \"Faroe Islands\"\n\t\t\twhen \"FR\"\tthen \"France\"\n\t\t\twhen \"GA\"\tthen \"Gabon\"\n\t\t\twhen \"GB\"\tthen \"United Kingdom\"\n\t\t\twhen \"GE\"\tthen \"Georgia\"\n\t\t\twhen \"GD\"\tthen \"Grenada\"\n\t\t\twhen \"GF\"\tthen \"French Guiana\"\n\t\t\twhen \"GG\"\tthen \"Guernsey\"\n\t\t\twhen \"GH\"\tthen \"Ghana\"\n\t\t\twhen \"GI\"\tthen \"Gibraltar\"\n\t\t\twhen \"GL\"\tthen \"Greenland\"\n\t\t\twhen \"GM\"\tthen \"Gambia\"\n\t\t\twhen \"GN\"\tthen \"Guinea\"\n\t\t\twhen \"GO\"\tthen \"Glorioso Islands\"\n\t\t\twhen \"GP\"\tthen \"Guadeloupe\"\n\t\t\twhen \"GQ\"\tthen \"Equatorial Guinea\"\n\t\t\twhen \"GR\"\tthen \"Greece\"\n\t\t\twhen \"GS\"\tthen \"South Georgia and South Sandwich Islands\"\n\t\t\twhen \"GT\"\tthen \"Guatemala\"\n\t\t\twhen \"GU\"\tthen \"Guam\"\n\t\t\twhen \"GW\"\tthen \"Guinea-Bissau\"\n\t\t\twhen \"GY\"\tthen \"Guyana\"\n\t\t\twhen \"HK\"\tthen \"Hong Kong\"\n\t\t\twhen \"HM\"\tthen \"Heard Island and McDonald Islands\"\n\t\t\twhen \"HN\"\tthen \"Honduras\"\n\t\t\twhen \"HR\"\tthen \"Croatia\"\n\t\t\twhen \"HT\"\tthen \"Haiti\"\n\t\t\twhen \"HU\"\tthen \"Hungary\"\n\t\t\twhen \"ID\"\tthen \"Indonesia\"\n\t\t\twhen \"IE\"\tthen \"Ireland\"\n\t\t\twhen \"IL\"\tthen \"Israel\"\n\t\t\twhen \"IM\"\tthen \"Isle of Man\"\n\t\t\twhen \"IN\"\tthen \"India\"\n\t\t\twhen \"IO\"\tthen \"British Indian Ocean Territory\"\n\t\t\twhen \"IQ\"\tthen \"Iraq\"\n\t\t\twhen \"IR\"\tthen \"Iran\"\n\t\t\twhen \"IS\"\tthen \"Iceland\"\n\t\t\twhen \"IT\"\tthen \"Italy\"\n\t\t\twhen \"JE\"\tthen \"Jersey\"\n\t\t\twhen \"JM\"\tthen \"Jamaica\"\n\t\t\twhen \"JO\"\tthen \"Jordan\"\n\t\t\twhen \"JP\"\tthen \"Japan\"\n\t\t\twhen \"JU\"\tthen \"Juan De Nova Island\"\n\t\t\twhen \"KE\"\tthen \"Kenya\"\n\t\t\twhen \"KG\"\tthen \"Kyrgyzstan\"\n\t\t\twhen \"KH\"\tthen \"Cambodia\"\n\t\t\twhen \"KI\"\tthen \"Kiribati\"\n\t\t\twhen \"KM\"\tthen \"Comoros\"\n\t\t\twhen \"KN\"\tthen \"Saint Kitts and Nevis\"\n\t\t\twhen \"KP\"\tthen \"North Korea\"\n\t\t\twhen \"KR\"\tthen \"South Korea\"\n\t\t\twhen \"XK\"\tthen \"Kosovo\"\n\t\t\twhen \"KW\"\tthen \"Kuwait\"\n\t\t\twhen \"KY\"\tthen \"Cayman Islands\"\n\t\t\twhen \"KZ\"\tthen \"Kazakhstan\"\n\t\t\twhen \"LA\"\tthen \"Lao People's Democratic Republic\"\n\t\t\twhen \"LB\"\tthen \"Lebanon\"\n\t\t\twhen \"LC\"\tthen \"Saint Lucia\"\n\t\t\twhen \"LI\"\tthen \"Liechtenstein\"\n\t\t\twhen \"LK\"\tthen \"Sri Lanka\"\n\t\t\twhen \"LR\"\tthen \"Liberia\"\n\t\t\twhen \"LS\"\tthen \"Lesotho\"\n\t\t\twhen \"LT\"\tthen \"Lithuania\"\n\t\t\twhen \"LU\"\tthen \"Luxembourg\"\n\t\t\twhen \"LV\"\tthen \"Latvia\"\n\t\t\twhen \"LY\"\tthen \"Libya\"\n\t\t\twhen \"MA\"\tthen \"Morocco\"\n\t\t\twhen \"MC\"\tthen \"Monaco\"\n\t\t\twhen \"MD\"\tthen \"Moldova\"\n\t\t\twhen \"MG\"\tthen \"Madagascar\"\n\t\t\twhen \"ME\"\tthen \"Montenegro\"\n\t\t\twhen \"MF\"\tthen \"Saint Martin\"\n\t\t\twhen \"MH\"\tthen \"Marshall Islands\"\n\t\t\twhen \"MK\"\tthen \"Macedonia\"\n\t\t\twhen \"ML\"\tthen \"Mali\"\n\t\t\twhen \"MO\"\tthen \"Macau\"\n\t\t\twhen \"MM\"\tthen \"Myanmar\"\n\t\t\twhen \"MN\"\tthen \"Mongolia\"\n\t\t\twhen \"MP\"\tthen \"Northern Mariana Islands\"\n\t\t\twhen \"MQ\"\tthen \"Martinique\"\n\t\t\twhen \"MR\"\tthen \"Mauritania\"\n\t\t\twhen \"MS\"\tthen \"Montserrat\"\n\t\t\twhen \"MT\"\tthen \"Malta\"\n\t\t\twhen \"MU\"\tthen \"Mauritius\"\n\t\t\twhen \"MV\"\tthen \"Maldives\"\n\t\t\twhen \"MW\"\tthen \"Malawi\"\n\t\t\twhen \"MX\"\tthen \"Mexico\"\n\t\t\twhen \"MY\"\tthen \"Malaysia\"\n\t\t\twhen \"MZ\"\tthen \"Mozambique\"\n\t\t\twhen \"NA\"\tthen \"Namibia\"\n\t\t\twhen \"NC\"\tthen \"New Caledonia\"\n\t\t\twhen \"NE\"\tthen \"Niger\"\n\t\t\twhen \"NF\"\tthen \"Norfolk Island\"\n\t\t\twhen \"NG\"\tthen \"Nigeria\"\n\t\t\twhen \"NI\"\tthen \"Nicaragua\"\n\t\t\twhen \"NL\"\tthen \"Netherlands\"\n\t\t\twhen \"NO\"\tthen \"Norway\"\n\t\t\twhen \"NP\"\tthen \"Nepal\"\n\t\t\twhen \"NR\"\tthen \"Nauru\"\n\t\t\twhen \"NU\"\tthen \"Niue\"\n\t\t\twhen \"NZ\"\tthen \"New Zealand\"\n\t\t\twhen \"OM\"\tthen \"Oman\"\n\t\t\twhen \"PA\"\tthen \"Panama\"\n\t\t\twhen \"PE\"\tthen \"Peru\"\n\t\t\twhen \"PF\"\tthen \"French Polynesia\"\n\t\t\twhen \"PG\"\tthen \"Papua New Guinea\"\n\t\t\twhen \"PH\"\tthen \"Philippines\"\n\t\t\twhen \"PK\"\tthen \"Pakistan\"\n\t\t\twhen \"PL\"\tthen \"Poland\"\n\t\t\twhen \"PM\"\tthen \"Saint Pierre and Miquelon\"\n\t\t\twhen \"PN\"\tthen \"Pitcairn Islands\"\n\t\t\twhen \"PR\"\tthen \"Puerto Rico\"\n\t\t\twhen \"PS\"\tthen \"Palestinian Territories\"\n\t\t\twhen \"PT\"\tthen \"Portugal\"\n\t\t\twhen \"PW\"\tthen \"Palau\"\n\t\t\twhen \"PY\"\tthen \"Paraguay\"\n\t\t\twhen \"QA\"\tthen \"Qatar\"\n\t\t\twhen \"RE\"\tthen \"Reunion\"\n\t\t\twhen \"RO\"\tthen \"Romania\"\n\t\t\twhen \"RS\"\tthen \"Serbia\"\n\t\t\twhen \"RU\"\tthen \"Russia\"\n\t\t\twhen \"RW\"\tthen \"Rwanda\"\n\t\t\twhen \"SA\"\tthen \"Saudi Arabia\"\n\t\t\twhen \"SB\"\tthen \"Solomon Islands\"\n\t\t\twhen \"SC\"\tthen \"Seychelles\"\n\t\t\twhen \"SD\"\tthen \"Sudan\"\n\t\t\twhen \"SE\"\tthen \"Sweden\"\n\t\t\twhen \"SG\"\tthen \"Singapore\"\n\t\t\twhen \"SH\"\tthen \"Saint Helena\"\n\t\t\twhen \"SI\"\tthen \"Slovenia\"\n\t\t\twhen \"SJ\"\tthen \"Svalbard and Jan Mayen\"\n\t\t\twhen \"SK\"\tthen \"Slovakia\"\n\t\t\twhen \"SL\"\tthen \"Sierra Leone\"\n\t\t\twhen \"SM\"\tthen \"San Marino\"\n\t\t\twhen \"SN\"\tthen \"Senegal\"\n\t\t\twhen \"SO\"\tthen \"Somalia\"\n\t\t\twhen \"SR\"\tthen \"Suriname\"\n\t\t\twhen \"SS\"\tthen \"South Sudan\"\n\t\t\twhen \"ST\"\tthen \"Sao Tome and Principe\"\n\t\t\twhen \"SV\"\tthen \"El Salvador\"\n\t\t\twhen \"SX\"\tthen \"Saint Martin\"\n\t\t\twhen \"SY\"\tthen \"Syria\"\n\t\t\twhen \"SZ\"\tthen \"Swaziland\"\n\t\t\twhen \"TC\"\tthen \"Turks and Caicos Islands\"\n\t\t\twhen \"TD\"\tthen \"Chad\"\n\t\t\twhen \"TF\"\tthen \"French Southern and Antarctic Lands\"\n\t\t\twhen \"TG\"\tthen \"Togo\"\n\t\t\twhen \"TH\"\tthen \"Thailand\"\n\t\t\twhen \"TJ\"\tthen \"Tajikistan\"\n\t\t\twhen \"TK\"\tthen \"Tokelau\"\n\t\t\twhen \"TL\"\tthen \"Timor-Leste\"\n\t\t\twhen \"TM\"\tthen \"Turkmenistan\"\n\t\t\twhen \"TN\"\tthen \"Tunisia\"\n\t\t\twhen \"TO\"\tthen \"Tonga\"\n\t\t\twhen \"TR\"\tthen \"Turkey\"\n\t\t\twhen \"TT\"\tthen \"Trinidad and Tobago\"\n\t\t\twhen \"TV\"\tthen \"Tuvalu\"\n\t\t\twhen \"TW\"\tthen \"Taiwan\"\n\t\t\twhen \"TZ\"\tthen \"Tanzania\"\n\t\t\twhen \"UA\"\tthen \"Ukraine\"\n\t\t\twhen \"UG\"\tthen \"Uganda\"\n\t\t\twhen \"UM_DQ\"\tthen \"Jarvis Island\"\n\t\t\twhen \"UM_FQ\"\tthen \"Baker Island\"\n\t\t\twhen \"UM_HQ\"\tthen \"Howland Island\"\n\t\t\twhen \"UM_JQ\"\tthen \"Johnston Atoll\"\n\t\t\twhen \"UM_MQ\"\tthen \"Midway Islands\"\n\t\t\twhen \"UM_WQ\"\tthen \"Wake Island\"\n\t\t\twhen \"US\"\tthen \"United States\"\n\t\t\twhen \"UY\"\tthen \"Uruguay\"\n\t\t\twhen \"UZ\"\tthen \"Uzbekistan\"\n\t\t\twhen \"VA\"\tthen \"Vatican City\"\n\t\t\twhen \"VC\"\tthen \"Saint Vincent and the Grenadines\"\n\t\t\twhen \"VE\"\tthen \"Venezuela\"\n\t\t\twhen \"VG\"\tthen \"British Virgin Islands\"\n\t\t\twhen \"VI\"\tthen \"US Virgin Islands\"\n\t\t\twhen \"VN\"\tthen \"Vietnam\"\n\t\t\twhen \"VU\"\tthen \"Vanuatu\"\n\t\t\twhen \"WF\"\tthen \"Wallis and Futuna\"\n\t\t\twhen \"WS\"\tthen \"Samoa\"\n\t\t\twhen \"YE\"\tthen \"Yemen\"\n\t\t\twhen \"YT\"\tthen \"Mayotte\"\n\t\t\twhen \"ZA\"\tthen \"South Africa\"\n\t\t\twhen \"ZM\"\tthen \"Zambia\"\n\t\t\twhen \"ZW\"\tthen \"Zimbabwe\"\n\t\t\telse\n\t\t\t\t\"ERROR\"\n\t\tend\n\tend", "def us_zones\n country_zones(:us)\n end", "def office_country\n self.dig_for_string(\"agentSummary\", \"office\", \"officeAddress\", \"country\")\n end", "def set_region_country\n @region_country = RegionCountry.find(params[:id])\n end", "def get_countries\n countries=[]\n @locations.each do |loc|\n countries << loc.country.capitalize if loc.country\n end\n countries.uniq\n end", "def country_name(multilingual = false)\n if self.country\n country_data = ISO3166::Country[self.country]\n\t\t\tif country_data and multilingual\n\t\t\t country_data.translations[I18n.locale.to_s] || country_data.name\n\t\t\telsif country_data\n\t\t\t country_data.name\n\t\t\telse\n\t\t\t self.country\n\t\t\tend\n else\n \"\"\n end\n end", "def find_country\n\t\t\t@country = Category.find_by_parent_uuid_and_url_part(Category.find(:first, :conditions => [\"parent_uuid IS NULL AND url_part = ?\", \"places\"]).uuid, params[:country_id].downcase) if params[:country_id]\n\t\tend", "def find_country\n\t\t\t@country = Category.find_by_parent_uuid_and_url_part(Category.find(:first, :conditions => [\"parent_uuid IS NULL AND url_part = ?\", \"places\"]).uuid, params[:country_id].downcase) if params[:country_id]\n\t\tend", "def country_fr()\n @request_data = {\n\t\t\t\"type\"\t\t=> \"home\",\n \"ip\" => \"178.251.201.141\",\n \"session\" => \"new\",\n \"cuid\" => \"new\",\n \"lang\" => \"en\",\n \"site\" => \"ctshirts\",\n \"currentURI\" => \"http://www.ctshirts.co.uk\",\n \"previousURI\" => \"http://www.ctshirts.co.uk\",\n \"clientToken\" => \"677ab692r2t3u4t\", \n \"recContent\" => \"refCodeOnly\",\n }\n @json_request = \"\"\n @response_times = []\n\t\tend", "def country_name\n iso_country = ISO3166::Country[country] # `country` should be code like 'AU'\n iso_country.translations[I18n.locale.to_s] || iso_country.name\n end", "def state_or_province\n end", "def country_list_by_region(region)\n # select list of countries based on the region\n @countries = Countries::Country.find_by_region(region)\n \n # print the list of countries as table format\n Table.display_as_table(@countries)\n end", "def country\n Faker::Address.country\n end", "def country\n Faker::Address.country\n end", "def get_country_name_lib country_code\n country = Carmen::Country.coded(country_code)\n if country\n country.name\n else\n \"N/A\"\n end\n end", "def get_country(str)\n data = check_local_db(str)\n\n if data.nil? \n data = Geocoder.search(str)\n\n #has to parse through geocode data to find correct result\n data.first.address_components.each do |obj|\n data = obj[\"short_name\"] if obj[\"types\"][0] == \"country\"\n end\n\n save_to_db(str, data)\n end\n\n return data\n end", "def country_name(country_code)\n country = ISO3166::Country[country_code]\n country.name\n end", "def country_code\n \"+#{fetch('country_code')}\"\n end", "def country\n if !block_given?\n return @j_del.java_method(:country, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling country()\"\n end", "def country_us()\n @request_data = {\n\t\t\t\"type\"\t\t=> \"home\",\n \"ip\" => \"12.25.205.51\",\n \"session\" => \"new\",\n \"cuid\" => \"new\",\n \"lang\" => \"en\",\n \"site\" => \"ctshirts\",\n \"currentURI\" => \"http://www.ctshirts.co.uk\",\n \"previousURI\" => \"http://www.ctshirts.co.uk\",\n \"clientToken\" => \"677ab692r2t3u4t\", \n \"recContent\" => \"refCodeOnly\",\n }\n @json_request = \"\"\n @response_times = []\n end", "def get country_code, city, region=\"\", latitude=nil, longitude=nil\n begin\n m = self.new country_code, city, region, latitude, longitude\n m.timezone\n rescue Exception \n nil\n end\n end", "def full_descriptor\n city_country_tz = \"<img src='/images/flags/#{self.country.country_code.downcase}.png' /> #{self.utf8_name}\" # we will search on the ascii name but display the UTF8 one\n \n # if city has a region mapped in the db, print it out\n city_country_tz += \", #{self.region.name}\" if (self.region)\n \n # If the city has a country mapped in the db, print it out\n city_country_tz += \", #{self.country.name}\" if (self.country)\n \n # If the city has a time zone mapped in the db, print it out\n city_country_tz += \" (#{self.time_zone.name})\" if (self.time_zone) \n \n # this is a bad hack to make sure the seperator value is include\n # need to figure out how auto-complete can append this once a selection is selected\n #city_country_tz += \"; \"\n \n # Return the array\n city_country_tz\n end", "def get_iso_country(country)\n #Kinda redundant but downcasing first makes the hardcoding a bit more obvious\n country = country.downcase\n\n if country == \"bosnia-herzogovnia\"\n country = \"bosnia and herzogovnia\"\n elsif country == \"russia\"\n country = \"russian federation\"\n elsif country == \"laos\"\n country = \"lao peoples democratic republic\"\n elsif country == \"iran\"\n country = \"islamic republic of iran\"\n elsif country == \"taiwan\"\n country = \"province of china taiwan\"\n elsif country == \"north korea\"\n country = \"democratic people's republic of korea\"\n elsif country == \"south korea\"\n country = \"republic of korea\"\n elsif country == \"basque spain\"\n country = \"spain\"\n elsif country == \"macedonia\"\n country = \"the former yugoslav republic of macedonia\"\n elsif country == \"tanzania\"\n country = \"united republic of tanzania\"\n elsif country == \"vietnam\"\n country = \"viet nam\"\n elsif country == \"venezuela\"\n country = \"bolivarian republic of venezuela\"\n elsif country == \"syria\"\n country = \"syrian arab republic\"\n elsif country == \"rep.dem.congo\"\n country = \"congo\"\n elsif country == \"dagestan\"\n country = \"russian federation\"\n elsif country == \"adygea\"\n country = \"russian federation\"\n elsif country == \"karachaevo circassia\"\n country = \"russian federation\"\n elsif country == \"tartarstan\"\n country = \"russian federation\"\n #elsif country == \"ivory coast\"\n # This seems like the wrong way of doing this but not sure how else to guarentee the match\n #country = \"CÔTE D'IVOIRE\".downcase\n end\n\n country = normalize(country)\n \n @@iso_country_codes.xpath(\"//ISO_3166-1_Entry\").each do |code|\n n_country = normalize(code.xpath(\"ISO_3166-1_Country_name\")[0].content)\n\n if (country.upcase == n_country.upcase)\n return code.xpath(\"ISO_3166-1_Alpha-2_Code_element\")[0].content\n end\n end\n return \"ZZ\"\n end", "def countries\n @countries = Spree::Country.where(name: Spree::Config[:default_address_country])\n zone = Spree::Zone.find_by(name: Spree::Config[:address_zone_name]) if Spree::Config[:address_zone_name]\n @countries = zone.countries.order(:name) if zone.present?\n end", "def set_country_region\n @country_region = CountryRegion.find(params[:id])\n end", "def load_country_info(code)\n info = @country_index[code]\n raise InvalidCountryCode, 'Invalid country code' unless info\n info\n end", "def country_str(specimens)\r\n v = {} \r\n v[\"country not specified\"] = []\r\n specimens.each do |s|\r\n if !s.ce.blank? && !s.ce.geog.blank? && !s.ce.geog.country.blank? && !s.ce.geog.country.name.blank?\r\n if v[s.ce.geog.country.name].nil?\r\n v[s.ce.geog.country.name] = [s]\r\n else\r\n v[s.ce.geog.country.name] << s\r\n end\r\n else\r\n v[\"country not specified\"] << s\r\n end\r\n end\r\n v.delete(\"country not specified\") if v[\"country not specified\"].size == 0 \r\n is = []\r\n v.keys.sort.each do |c|\r\n txt = \"#{c.upcase}: \"\r\n txt << sex_str(v[c])\r\n txt += \". \"\r\n txt += inst_str(v[c]) + \".\"\r\n is << txt\r\n end\r\n is.join(\" \") \r\n end", "def require_country?\n true\n end", "def show\r\n\t\trender_result(\r\n\t\t\tdata: @addr_country,\r\n\t\t\tmeta: {}\r\n\t\t)\r\n\tend", "def state_or_province\n end", "def get_verbose_name\n country_desc = (self.country_code.nil? || (self.country_code == \"I\")) ? \"\" :\n \" #{self.country} (#{self.country_code})\"\n get_full_name + country_desc\n end", "def country_of_payment\n case payment_method.downcase\n when 'paypal'\n notify_data&.params ? notify_data.params['residence_country'] : ''\n when 'sofort'\n notify_data&.params ? notify_data.params['sender_country_id'] : ''\n when 'cash'\n ''\n when 'wire transfer'\n ''\n else\n ''\n end\n end" ]
[ "0.76016486", "0.7420104", "0.7379968", "0.7351726", "0.72804105", "0.72804105", "0.72804105", "0.72547114", "0.7232474", "0.71334577", "0.7127241", "0.71272", "0.7089775", "0.708491", "0.70717144", "0.70615244", "0.7058763", "0.7039556", "0.70295686", "0.70279956", "0.702027", "0.701949", "0.7009509", "0.6988906", "0.69873977", "0.69873977", "0.6987229", "0.69567513", "0.69567513", "0.6925844", "0.6904243", "0.6882379", "0.6877762", "0.687728", "0.6871735", "0.6855745", "0.683942", "0.6833591", "0.68262804", "0.68262804", "0.68262804", "0.68262804", "0.68262804", "0.68262804", "0.681399", "0.67898554", "0.6785561", "0.6780506", "0.67668384", "0.6744786", "0.66946673", "0.6693215", "0.66874206", "0.66672564", "0.6651006", "0.6650976", "0.6628928", "0.65716004", "0.65683717", "0.65683717", "0.65683717", "0.6560003", "0.65573114", "0.6553772", "0.65464604", "0.6541679", "0.65270466", "0.650984", "0.64914715", "0.6489935", "0.6488882", "0.6479921", "0.64663976", "0.644361", "0.64399046", "0.64399046", "0.64337283", "0.6428427", "0.6424858", "0.6421525", "0.64170456", "0.64170456", "0.6408329", "0.6400926", "0.63947886", "0.639389", "0.6391804", "0.6390903", "0.6370421", "0.6368553", "0.6365387", "0.63549554", "0.63234466", "0.63203675", "0.63131565", "0.63010186", "0.62965244", "0.62855905", "0.6284844", "0.6277069" ]
0.78632003
0
check the input is a string or fixnum
def digit_or_word input = gets.strip.downcase input.match(/\d+/).to_s.to_i == 0 ? input : input.to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number?(str)\n !!Integer(str)\nrescue ArgumentError, TypeError\n false\nend", "def valid_number?(num)\n\n integer?(num) || float?(num)\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend", "def valid_number?(num)\n\n integer?(num) || float?(num)\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend", "def is_numeric(s)\n begin\n Integer(s)\n rescue\n puts \"please enter a number\" \n end\nend", "def can_be_number(string)\n forced_as_f = string.to_f # force string to be a float\n forced_as_i = string.to_i # force string to be an integer\n return string == forced_as_f.to_s || string == forced_as_i.to_s # see if either of the forced strings equal the original\nend", "def is_int? str\n Integer(str) rescue return false\n return true\nend", "def is_digit?(input)\n !!Float(input) rescue false\nend", "def is_number? string\n true if Float(string) rescue false\nend", "def float?(num)\n num.to_f.to_s == num # converts num to interger and back to string and then compares this with num.\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend", "def float?(num)\n num.to_f.to_s == num # converts num to interger and back to string and then compares this with num.\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend", "def is_number(str)\n true if Float(str)\nrescue StandardError\n false\nend", "def is_number(input)\n input.to_s == input.to_i.to_s\nend", "def is_a_number?(word)\n Integer(word) rescue false\nend", "def is_number?(string)\n # catch and return false if it isn't an integer\n true if Float(string) rescue false \nend", "def is_number? string\n \t\ttrue if Float(string) rescue false\n\tend", "def valid_input(num)\n if num.to_i().to_s() == num\n return true\n elsif num.to_f().to_s() == num\n return true\n else\n return false\n end\nend", "def is_number?(str)\n return str == str.to_f.to_s || str == str.to_i.to_s\nend", "def valid_num?(input)\n integer?(input) || float?(input)\nend", "def float_valid?(input)\n temp = input.to_s\n true_num = true\n #invalid input if there are more than one \".\"\n #and start with \".\"\n dot_num = temp.count(\".\") \n if dot_num != 0\n if dot_num > 1\n true_num = false\n end\n if temp.index(\".\") == 0\n true_num = false\n end\n end\n #invalid input if there are more than one \"-\"\n #and not start with \"-\"\n minus_num = temp.count(\"-\")\n if minus_num != 0\n if minus_num > 1\n true_num = false\n end\n if temp.index(\"-\") != 0\n true_num = false\n end\n end\n \n #invalid input if there are other symbols\n temp.each_char do |r|\n flag = (45..57).cover?(r.ord) && r.ord != 47\n if !flag\n true_num = false\n end\n end\n return true_num\n end", "def numeric?(str)\n !str.to_s.match(/^-?[\\d.]+$/).nil?\n # str.to_i.to_s == str\nend", "def integer?(input)\n # could also do input.to_i.to_s == input but something with a\n # leading 0 (\"00\", \"01\", etc) will return false\n Integer(input)\nrescue ArgumentError\n false\nend", "def type_of_input(x)\n\n # Remember that the .class method tells you the type of a variable.\n if (x.class == Fixnum) then\n return \"number\"\n # elsif (x.class == ** fill in something here **) then\n # To make this work, you have to figure out what Ruby type is a string, just as it calls numbers Fixnum\n # return \"string\"\n end\nend", "def is_number(input)\n \t\tinput.to_f == input\n\tend", "def number2?(input)\n /\\p{N}/.match(input) || /\\p{Nd}/.match(input)\nend", "def isIntegerString?(string)\n Integer(string)\n return true\nrescue ArgumentError\n return false\nend", "def valid_looking_string?(str)\n str =~ /\\d/\n end", "def integer?(num)\n num.to_i.to_s == num # converts num to interger and back to string and then compares this with num.\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend", "def integer?(num)\n num.to_i.to_s == num # converts num to interger and back to string and then compares this with num.\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend", "def is_number(string)\r\n\ttrue if Float(string) rescue false\r\nend", "def is_number?(str)\n true if Float(str) rescue false\n end", "def _is_numeric?(str)\n Float(str) != nil rescue false\n end", "def is_number? string\n true if Float(string) rescue false\n end", "def is_number? string\n true if Float(string) rescue false\n end", "def is_number? (num)\n \tnum.to_f.to_s == num.to_s || num.to_i.to_s == num.to_s\nend", "def valid_number?(input)\n input.to_i.to_s == input\nend", "def value_is_integer?(string)\n return string.strip.numeric?\n end", "def is_number?(input)\n true if Float(input) rescue false\n end", "def is_numeric?\n self.match(/^[0-9]+$/)\n end", "def integer?(input)\n Integer(input) rescue false\nend", "def is_number?(string)\n true if Float(string) rescue false #need to understand this\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\n end", "def is_numeric(str)\n true if Integer(str) rescue false\nend", "def is_num(str)\n\treturn true if str =~ /^\\d+$/\n true if Int(str) rescue false\nend", "def is_numeric?(s)\n begin\n Float(s)\n rescue\n false # not numeric\n else\n true # numeric\n end\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def is_number? string\n true if Float(string) rescue false\n end", "def number?\n\t\ttrue if Float(string) rescue false\n\tend", "def valid_number?(num)\n num.to_s unless num.is_a? String\n /\\A[+-]?\\d+(\\.[\\d]+)?\\z/.match num\nend", "def isNum?(num)\n /[0-9]/.match(num.to_s) != nil\nend", "def valid_number?(num)\n num.to_i() != 0 || num == '0' # this also includes the option for receiving 0 as input\nend", "def valid_integer?(string)\r\n string.to_i.to_s == string\r\nend", "def validnum?(num)\n num == num.to_i.to_s\nend", "def is_num(num)\n #First convert num to float or integer . If it is not a number, result will be 0.0. Convert that back in to string to confirm that it matches\n num.to_f.to_s == num || num.to_i.to_s == num\nend", "def test_is_nummeric\n assert(StringChecker.is_numeric?(\"+20\"))\n assert(StringChecker.is_numeric?(\"-020\"))\n assert(StringChecker.is_numeric?(\"123\"))\n assert(StringChecker.is_numeric?(\"0123\"))\n assert(!StringChecker.is_numeric?(\"1.2\"))\n assert(!StringChecker.is_numeric?(\"asdf\"))\n assert(!StringChecker.is_numeric?(\" \"))\n end", "def is_a_number?(str)\n str.match(/\\d/)\nend", "def is_num?(input_value)\n (input_value =~ /^-?[0-9]+$/) == 0 ? true : false\nend", "def isNum(c)\r\n\tInteger(c) rescue return false\r\n\treturn true\r\nend", "def is_integer?(input)\n input.to_i.to_s == input\nend", "def is_number?(string)\n true if Float(string) rescue false\n end", "def check_input(input)\n if /\\D/.match(input)\n false\n else\n true \n end\nend", "def integer?(string)\n b = Integer(string)\n return b\nrescue ArgumentError\n return false\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(number_string)\n number_string.to_i.to_s == number_string\nend", "def valid_number?(num)\n if num.to_i.to_s == num\n num.to_i\n elsif num.to_f.to_s == num\n num.to_f\n else\n false\n end\nend", "def is_number(str)\n str.to_f.to_s == str.to_s || str.to_i.to_s == str.to_s\n end", "def is_numeric?(num)\n num == num.to_i.to_s || num == num.to_f.to_s\nend", "def valid_num?(number)\n number == number.to_i.to_s\nend", "def is_integer?(input)\n return input.to_s.ord >= 48 and input.to_s.ord <= 57\nend", "def valid_integer?(string)\n string.to_i.to_s == string\nend", "def valid_integer?(string)\n string.to_i.to_s == string\nend", "def is_number? string\n true if Float(string) rescue false\n end", "def is_integer? string\n true if Integer(string) rescue false\n end", "def validate_str_is_integer(value)\n !!(value =~ /\\A[-+]?[0-9]+\\z/)\n end", "def string_is_integer?(n)\n n == n.to_i.to_s\nend", "def valid_int_str?(str)\n str =~ /^[+\\-]?[\\d]*$/ # optional sign, then only digits\n end", "def valid_number?(num)\n num.to_i.to_s == num\nend", "def check_number(input)\n\t\tif input.is_a?(Float) or input =~ /[\\d\\.]+/\n\t\t\treturn input.to_f\n\t\telse\n\t\t\tputs \"You must enter a number. Please try again..\"\n\t\t\tinput = $stdin.gets.chomp\n\t\t\tcheck_number(input)\n\t\tend\n\t\treturn input\n\tend", "def valid_number?(n_s)\n n_s.to_i.to_s == n_s && n_s.to_i != 0\nend", "def is_numeric(str)\n Float(str) != nil rescue false\n end", "def is_number?(string)\n true if Integer(string) && Integer(string) >= 0 rescue false\n end", "def number?(input)\n #edge case, doesn't deal with 1. or 1.30 it either adds a zero or takes one off\n input.to_i.to_s == input || input.to_f.to_s == input\nend", "def valid_number?(num)\n integer?(num) || float?(num)\nend", "def is_a_number?(s)\n \ts.to_s.match(/\\A[+-]?\\d+?(\\.\\d+)?\\Z/) == nil ? false : true\n\tend" ]
[ "0.7460665", "0.73973626", "0.73973626", "0.7263427", "0.7236833", "0.71894115", "0.71755767", "0.71707666", "0.716606", "0.716606", "0.71638185", "0.7161648", "0.7151615", "0.71485186", "0.7132887", "0.70909905", "0.7090485", "0.708787", "0.70739913", "0.7070891", "0.70562184", "0.70553154", "0.70426846", "0.70311415", "0.703086", "0.7029305", "0.7026979", "0.7026979", "0.7001789", "0.69970477", "0.69854814", "0.6969369", "0.6969369", "0.6966326", "0.69557905", "0.6951474", "0.6940107", "0.6934967", "0.69340986", "0.6933236", "0.69266564", "0.69097984", "0.69072074", "0.69021267", "0.6900312", "0.6898338", "0.6889774", "0.6889755", "0.6877326", "0.6870722", "0.6870022", "0.686522", "0.68491924", "0.6846334", "0.6842019", "0.68395406", "0.6833333", "0.6833205", "0.6826517", "0.6825561", "0.68242246", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6820235", "0.6808266", "0.680666", "0.67987186", "0.6793408", "0.6791859", "0.67856026", "0.67856026", "0.6777352", "0.6774106", "0.67726064", "0.675028", "0.67475134", "0.67425454", "0.67382663", "0.6737495", "0.67373204", "0.6735954", "0.67332566", "0.6726032", "0.6724873" ]
0.0
-1
Run `rspec /spec/username_spec.rb` to get started.
def format_name(first, last) (First[0]+last).downcase end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_check_user_name\n user = User.named(\"HansliCaramell\")\n\n assert(!user.name.nil? ,\"No User Name\")\n assert_equal(\"HansliCaramell\", user.name, \"Wrong User name\")\n end", "def test_is_username\n assert(StringChecker.is_valid_username?(\"ese\"))\n assert(!StringChecker.is_valid_username?(\"e se\"))\n assert(!StringChecker.is_valid_username?(\"<script>alert()</script>\"))\n assert(!StringChecker.is_valid_username?(\"happy-emu\"))\n assert(StringChecker.is_valid_username?(\"happy_emu\"))\n assert(!StringChecker.is_valid_username?(\"happy-\"))\n end", "def test_username_with_invalid_examples\n person = @valid_person\n invalid_usernames = %w{rails/rocks web2.0 javscript:something ME}\n invalid_usernames.each do |username|\n person.username = username\n assert !person.valid?, \"#{username} shouldn't pass validation, but does\"\n end\n end", "def test_ID_25837_edit_profile_name\n login_as_user1\n go_to_edit_profile_page\n verify_user_name_populated \"Jame Smith\"\n end", "def test_ID_25837_edit_profile_name\n login_as_user1\n go_to_edit_profile_page\n verify_user_name_populated_on_name_textfield \"test_ID_25837_edit_profile_name\", \"Jamie Smith\"\n end", "def test_input_username_retrieves_info_from_github\n skip\n # get \"/\"\n # post \"/profile\"\n assert_equal \"https://api.github.com/users/stevefake/repos\", \"\"\n end", "def test_name_present\n user_name_output = @user.name\n assert_equal(NAME, user_name_output)\n end", "def test_username_with_valid_examples\n person = @valid_person\n valid_usernames = %w{juho kusti juho_kusti enu}\n valid_usernames.each do |username|\n person.username = username\n assert person.valid?, \"#{username} should pass validation, but doesn't\"\n end\n end", "def test_ID_25847_edit_profile_name_limit\n login_as_user1\n go_to_edit_profile_page\n verify_user_names_are_not_required_to_be_unique \"Jame Smith\"\n end", "def test_ID_25847_edit_profile_name_limit\n login_as_user1\n go_to_edit_profile_page\n verify_user_names_are_not_required_to_be_unique \"Jame Smith\"\n end", "def test_assert_that_5_character_username_is_invalid\n\t\tusername = 12345\n\t\tassert_equal(\"invalid\", set_up_username(username))\n\tend", "def test_full_name\n\t\tassert_equal \"David Rosillo\", @user.full_name\n\tend", "def name\n # If you activate lib/String.rb enable the next line\n # spec.full_name.or_else(login_name)\n spec.full_name\n end", "def test_ID_25846_edit_profile_name_validation\n login_as_user1\n go_to_edit_profile_page\n verify_name_change_is_saved \"test_ID_25835_edit_profile_desc\", \"Jame Smith\", \"Temp name\"\n verify_name_validation \"test_ID_25835_edit_profile_desc\", \"Jame Smith\", \"%$#%<html>\"\n end", "def test_read_user_name\n get '/v1/read_all?data=eyJOYW1lIjogIkVkdWFyZG8iLCAiQ291bnRyeSI6ICJCcmF6aWwiIH0%3D'\n assert last_response.ok?\n assert last_response.body.include?('Eduardo')\n end", "def input_valid_username\n fill_in(USERNAME_INPUT_ID, :with => 'Believe')\n end", "def test_ID_25846_edit_profile_name_validation\n login_as_user1\n go_to_edit_profile_page\n verify_name_change_is_saved \"test_ID_25835_edit_profile_desc\", \"Jamie Smith\", \"Temp name\"\n verify_name_validation \"test_ID_25835_edit_profile_desc\", \"Jamie Smith\", \"%$#%<html>\"\n end", "def test_12_accepts_doesnt_include_password\n result = not_including_username?(\"HatBox1992!\", \"gdavida\")\n assert(result, \"HatBox1992! does not include your username, should be valid\")\n end", "def username\n params[:username].downcase\n end", "def get_username_and_test_validity(company)\n prompt = TTY::Prompt.new\n username = prompt.ask(\"Please enter your username:\")\n company.username == username\n end", "def test_authenticate\n assert_equal users(:jordan), User.authenticate('jordan@test.com', 'test')\n end", "def test_login_username_password\n user = create(:user)\n\n try_password_login user.display_name, \"test\"\n\n assert_template \"changeset/history\"\n assert_select \"span.username\", user.display_name\n end", "def test_it_can_be_named_somethig_else\n\t\tunicorn = Unicorn.new(\"Joseph\")\n\t\tassert_equal \"Joseph\", unicorn.name\n\tend", "def username\n \"rocky\"\n end", "def username\n end", "def username; end", "def username; end", "def username; end", "def username; end", "def edit_username(username)\n wait_until{ change_username_link.visible? }\n change_username_link.click\n username_tb.type_text username\n submit_edit_username_btn.click\n verify_password(QA_ENV['bus_password'])\n alert_accept\n wait_until{ !submit_edit_username_btn.visible? }\n end", "def find_username\n @username || $config.fetch(:username) || prompt_username\n end", "def prompt_username\n TTY::Prompt.new.ask(\"Redacted username?\", required: true, modify: :strip)\n end", "def test_admin_can_show_user\n # first log in\n get '/login' # need to do this to set up the form container.\n post '/login', { :username => GOOD_USERNAME, :password => GOOD_PASSWORD }\n\n user_id = User.find_by_username(NOBODY_USERNAME).id\n\n get \"/user/#{user_id}\"\n assert last_response.ok?\n assert last_response.body.include?(NOBODY_USERNAME)\n\n # ensure a request for unknown ID is bounced.\n get \"/user/153\"\n assert last_response.ok?\n assert last_response.body.include?(\"The user id supplied was not recognised\")\n\n end", "def test_logged_in_user_access_to_userland_approved\n # first log in\n post '/login', { :username => GOOD_USERNAME, :password => GOOD_PASSWORD }\n\n # then specifically request the index page in userland\n get '/in/index'\n assert last_response.ok?\n assert last_response.body.include?('You are logged in as') \n assert last_response.body.include?(GOOD_USERNAME) \n end", "def username\n name\n end", "def verify_username(*options)\n request('/verifyUsername', {body: {\n session_key: options[0],\n session_secret: options[1],\n username: options[2],\n display_name: options[3]\n }})\n end", "def ensure_username\n if self.username != \"\"\n self.username \n else\n self.username = \"user#{((self.email).hash).to_s[0,6]}\"\n end\n end", "def test_031\n test_000\n login(\"root\",\"root\")\n ## create new user\n create_user\n wait_for_text_present(\"#{_(\"User\")} #{USER_LAST_NAME} #{_(\"was registered\")}\")\n total_user=get_xpath_count($xpath[\"user\"][\"user_list_row\"])\n assert_equal USER_LAST_NAME + \" \"+ USER_FIRST_NAME, @selenium.get_text($xpath[\"user\"][\"user_list_row\"]+\"[#{total_user}]/td[4]\")\n assert_equal USER_EMAIL, @selenium.get_text($xpath[\"user\"][\"user_list_row\"]+\"[#{total_user}]/td[6]\")\n logout\n end", "def test_uniqueness_of_username\n person_repeat = Person.new(:username => @valid_person.username.upcase)\n assert !person_repeat.valid?\n assert_equal @error_messages[:taken], person_repeat.errors[:username][0], \"Test must be case sensitive.\"\n end", "def test_function_check_username_and_password_existed\n username = \"ladywind\"\n password = \"1234567890\"\n actual = V1::User.check_username_and_password_existed(username,password)\n expected = true\n puts this_method_name + \" - \" +assert_equal(expected, actual).to_s\n end", "def testNoAction\n executeTest('DummyUser', {})\n end", "def determine_username\n\tputs \"What is your name?\"\n\tusername = gets.strip.to_s\nend", "def test_user_features\n \n # create new user\n post '/user', \"{ \\\"First Name\\\": \\\"Tom\\\", \\\"Last Name\\\": \\\"#{$user_name}\\\", \\\"User Login\\\": \\\"#{$user_name}\\\", \\\"act_key\\\": 1, \\\"Role\\\": \\\"Full-Time\\\" }\"\n assert (last_response.status == 200), \"Create user: response is not 200\"\n \n # get user with Last Name \"$user_guid\"\n get \"/user?Last%20Name=#{$user_name}\"\n $user_guid = JSON::parse(last_response.body)[0]['usr_key']\n assert (last_response.body.size > 50), \"Get user by name: response too small for valid data\"\n\n # modify user with guid defined in @guid variable\n put \"/user/#{$user_guid}\", '{\"Fax\": \"12345\", \"Description\": \"User Description\"}'\n assert (last_response.status == 200), \"Put user (modify): response is not 200\"\n \n # get user with uid defined in $user_guid variable\n get \"/user/#{$user_guid}\"\n assert (last_response.body.size > 50), \"Get user by id: response too small for valid data\"\n\n # change password for user with guid defined in $user_guid variable\n put \"/user/#{$user_guid}/password\", '{\"password\": \"Montag14\", \"notify_racf\": \"false\"}'\n assert (last_response.status == 200), \"Response is not 200\"\n \n # get user with uid defined in $user_name variable\n get \"/#{$user_name}\"\n assert (last_response.body.size > 50), \"Get user by username: response too small for valid data\"\n\n ## change password for user with user login defined in $user_name variable\n put \"/#{$user_name}/password\", '{\"password\": \"Montag15\", \"notify_racf\": false}'\n assert (last_response.status == 200), \"Response is not 200\"\n \n # get all users\n get '/user'\n assert (last_response.body.size > 50), \"Get all users: Response too small for valid data\"\n\n # get available user attributes\n get '/user/attributes'\n assert (last_response.body.size > 50), \"Get user attributes: Response too small for valid data\"\n \n # delete user with uid defined in @guid variable\n delete \"/user/#{$user_guid}\"\n assert (last_response.status == 204), \"Response is not 204\"\n end", "def initialize(username, name)\n @username = username\n @name = name\n end", "def test_LogIn_usernameblank\n\n loginpage = Hudl_Login_Page.new @@driver\n\n loginpage.LogIn(\"\", @@longpassword)\n\n loginpage.VerifyUnrecognisedEmailPasswordErrorMessage()\n\n end", "def test_13_rejects_doesnt_include_password\n result = not_including_username?(\"iloveGdavida\", \"gdavida\")\n refute(result, \"iloveGdavida includes your username, should be valid\")\n end", "def initialize(username)\n @username = username\n end", "def initialize(username)\n @username = username\n end", "def initialize(username)\n @username = username\n end", "def initialize(username)\n @username = username\n end", "def test_login_username_password_duplicate\n # Attempt to log in as one user, it should work\n user = create(:user)\n _uppercase_user = build(:user, :display_name => user.display_name.upcase).tap { |u| u.save(:validate => false) }\n\n try_password_login user.display_name, \"test\"\n\n assert_template \"changeset/history\"\n assert_select \"span.username\", user.display_name\n end", "def user(username, realname, invisible = true)\n raw \"USER #{username} #{invisible ? 8 : 0} * :#{realname}\\r\\n\"\n end", "def test02_member_search_logged_in_TC_24435\n\t\tloginGroup \n\t\t$browser.cookies.clear\n\t\t$browser.goto($patch)\n\t\tsleep 4\n\t\t$search_text_field.set(\"User 70\")\n\t\t$search_button.click\n\t\tsleep 4\n\t\t$user_70.click\n\t\tsleep 2\n\t\t\n\t\tbegin\n\t\tassert $browser.text.include? \"User 70\"\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"GS3_T2: FAILED! Logged out user unable to find user.\"\n\t\tend\n\tend", "def username\n ENV['USER']\n end", "def username=(_arg0); end", "def username=(_arg0); end", "def username=(_arg0); end", "def test_users_searches\n do_users_all\n do_simple_query\n do_tag_query\n do_profile_query\n end", "def check_username username\n\t\t\traise 'Username must be a String' unless username.is_a?(String)\n\t\t\traise 'Username must be >= 10 characters.' unless username.to_s.length >= 10\n\t\t\traise 'Spaces are not permitted in usernames.' if username =~ /[[:space:]]/\n\t\tend", "def test_good_login\r\n\t\tpost :home, :login => 'login', :email => 'god@example.com', :password => 'betterthanyou'\r\n\t\tassert_response :success\r\n\r\n\t\t# make sure the user_id is stored in the session\r\n\t\tassert_not_nil(session[:user_id])\r\n\t\tuser = User.find(session[:user_id])\r\n\t\tassert_equal 'deity.family', user.last_name\r\n\tend", "def username\n ENV.fetch(\"USERNAME\")\nend", "def username\n ENV.fetch(\"USERNAME\")\nend", "def valid_username?(name)\n\t\t$users_and_passwords.each do |element|\n\t\t\tif element[USERNAME] == name\n\t\t\t\t@username=name\n\t\t\t\treturn true\n\t\t\tend\n\t\tend\t\t\t\n\t\treturn false\n\tend", "def username=(new_username)\n @username = new_username\n end", "def setup\n \n @user = users(:david)\n \n end", "def username\n params[:username].downcase\n end", "def test_getting_name\n result = get_name(@person5)\n assert_equal(\"Daphne\", result)\n end", "def test_basic_auth_with_password\n assert_warning :type => :controller,\n :warning_type => \"Basic Auth\",\n :line => 4,\n :message => /^Basic authentication password stored in source code/,\n :confidence => 0,\n :file => /users_controller\\.rb/\n end", "def initialize(username)\n @username = username\n end", "def user_name\n \"someone\"\n end", "def setup\n @user = users(:michael)\n end", "def test_login_email_password\n user = create(:user)\n\n try_password_login user.email, \"test\"\n\n assert_template \"changeset/history\"\n assert_select \"span.username\", user.display_name\n end", "def random_username( givenname_full, surname )\n name_part_separator =\n UsernamePartSeparators[rand(UsernamePartSeparators.length)]\n givenname = givenname_full.split(/\\s/).join(name_part_separator)\n erb_template = ERB.new( UsernameTemplates[rand(UsernameTemplates.length)] )\n erb_template.result( binding )\n end", "def username\n username = user.username\n end", "def username(name = nil)\n if !name then @username\n else @username = name\n end\n end", "def generate_username\n\t\tself.username = \"guest_#{Time.now.to_i}#{rand(100)}\" if username.blank?\n\tend", "def setup\n @user = users(:tommy)\n end", "def add_user_name(username)\n\t\tuser_name_input.set(username)\n\tend", "def username\n puts 'Please enter your full name and press ENTER:'\n gets.chomp\nend", "def set_username\n self.username = \"#{self.email.split('@').first}#{Faker::Number.number(3)}\"\n end", "def test_003\n test_000\n login(\"root\",\"root\")\n ## create new user\n create_user\n total_user=get_xpath_count($xpath[\"user\"][\"user_list_row\"])\n assert_equal USER_LAST_NAME + \" \"+ USER_FIRST_NAME, @selenium.get_text($xpath[\"user\"][\"user_list_row\"]+\"[#{total_user}]/td[4]\")\n assert_equal USER_EMAIL, @selenium.get_text($xpath[\"user\"][\"user_list_row\"]+\"[#{total_user}]/td[6]\")\n logout\n end", "def test_auth_use_available\n user = User.authenticate('MyString');\n if(user)\n assert true\n else\n assert false, 'find user false'\n end\n end", "def update_username(username)\n @username = username\n end", "def set_username\n return if username?\n return unless email?\n\n base = email.partition('@').first.tr('.', '_')\n\n self.username = generate_username(base)\n end", "def setup\n @user = users(:tom)\n end", "def test_user_input_driver_print_valid\n\n end", "def setup\n @user = users :michael\n end", "def username=(value)\n\t write_attribute(:username, value.downcase)\n\tend", "def setup\n @user = users(:brock)\n end", "def find_user_byname(username)\n @user = User.where(username: username)\n end", "def check_username\n if /[a-zA-Z0-9_-]/.match(params[:username])\n user = User.username(params[:username])\n if user.blank?\n render :json => [\"free\", \":)\"]\n else\n render :json => [\"taken\", \"Sorry, username exists!\"]\n end\n else\n render :json => [\"Letters, numbers, dashes and underscores only please :)\"]\n end\n end", "def test_search_user_successful\n keyword = \"anh\"\n expected = 200\n response = Net::HTTP.get(URI.parse('http://localhost:3000/v1/users/search/'+keyword))\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end", "def test_comment_full_name\n 't1_cce66qf'\nend", "def username\n @username ||= match[3]\n end", "def start\n puts \"Welcome to the Todo-Listz!\"\n puts \"Please login with your username:\"\n user_name = gets.chomp.downcase\n end", "def test02_member_search_logged_in_TC_24435\n\t\tlogin $user_1_email, $master_password \n#\t\t$browser.cookies.clear\n\t\t$browser.goto($patch)\n\t\tsleep 4\n\t\t$search_text_field.set(\"Keelawn\")\n\t\t$search_button.click\n\t\t$search_result_keelawn.when_present.click\n\t\tsleep 2\n\t\t\n\t\tassert $browser.text.include? \"eelawn\"\n\tend", "def spec(argv=ARGV)\n # disable autorun in case the user left it in spec_helper.rb\n RSpec::Core::Runner.disable_autorun!\n exit RSpec::Core::Runner.run(argv)\n end", "def username= username\n\t\t\tcheck_username username\n\t\t\t@username = username\n\t\tend", "def test_accessors\n assert_kind_of User, @user\n assert_equal \"ga\", @user.username\n assert_equal \"********\", @user.password\n end", "def username=(username)\n validate_options(username: username)\n @username = username\n end", "def test_no_alice\n skip\n names = [\"chuck\", \"charlene\", \"cory\", \"chris\", \"carl\"]\n # write code here\n refute has_alice\n end" ]
[ "0.61162275", "0.6105939", "0.6105773", "0.60648304", "0.60635483", "0.605991", "0.59905696", "0.5952525", "0.59419495", "0.59419495", "0.5938926", "0.589761", "0.57347393", "0.5695146", "0.5690247", "0.56885564", "0.56859624", "0.56583273", "0.55981666", "0.5597601", "0.55844027", "0.5574678", "0.5569652", "0.5559249", "0.55416113", "0.5532545", "0.5532545", "0.5532545", "0.5532545", "0.54924434", "0.5481845", "0.54791355", "0.54579365", "0.5440615", "0.54320824", "0.5410864", "0.5405798", "0.5371818", "0.53714794", "0.5365977", "0.5361552", "0.53584796", "0.5342109", "0.53254944", "0.531799", "0.5316793", "0.5312432", "0.5312432", "0.5312432", "0.5312432", "0.53050333", "0.53036684", "0.52953464", "0.52935106", "0.5282754", "0.5282754", "0.5282754", "0.527815", "0.5264176", "0.52532303", "0.524741", "0.524741", "0.52465874", "0.5244444", "0.52247155", "0.52241325", "0.521443", "0.52108926", "0.5208965", "0.5207442", "0.5207377", "0.51870626", "0.5184421", "0.5173095", "0.5172952", "0.51704156", "0.5170289", "0.5169881", "0.5155766", "0.5152951", "0.515042", "0.514396", "0.51402694", "0.51373583", "0.5133793", "0.51314485", "0.51307684", "0.51290286", "0.5126626", "0.5123593", "0.5122568", "0.5111545", "0.5110072", "0.51065934", "0.51035684", "0.510129", "0.5100151", "0.5096419", "0.5096054", "0.50950974", "0.5085158" ]
0.0
-1
RedCounter::TestCase.create_fixtures(Redmine::Plugin.find(:red_counter).directory + '/tests/fixtures/', [:rc_types])
def setup TestUtils.set_workday_default TestUtils.enable_module_on_project 1 @request.session[:user_id] = 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_default_fixtures(files = ['sample_actors' , 'users', 'wiki_entries'])\n Fixtures.reset_cache\n files.each do |f|\n Fixtures.create_fixtures( File.dirname(__FILE__) + '/../fixtures' , File.basename( f , '.*'))\n end\nend", "def load_all_fixtures\n \n end", "def load_fixtures\n # fixtures = ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(File.dirname(__FILE__), 'test', 'fixtures', '*.{yml,csv}')) \n fixtures = [ 'active_sources', 'semantic_relations', 'semantic_properties' 'data_records']\n fixtures.reverse.each { |f| ActiveRecord::Base.connection.execute \"DELETE FROM #{f}\" }\n fixtures.each do |fixture_file|\n Fixtures.create_fixtures(File.join('test', 'fixtures'), File.basename(fixture_file, '.*')) \n end \n end", "def fixture_path\n File.expand_path('../fixtures', __FILE__)\nend", "def build_test_fixtures \n \n return if skip_method(__method__)\n \n puts \"build Rails fixture for #{model_name} in test/fixtures\"\n \n filename = \"#{plural_table_name}.yml\"\n template = File.read(template(\"rails/test/fixtures.yml\"))\n # #text = ERB.new(template, nil, '-').result(binding)\n text = Erubis::Eruby.new(template).evaluate( self )\n\n path = File.join(\"test\",\"fixtures\",filename)\n write_artifact(path,text) \n end", "def fixture_dir\n File.join File.dirname(__FILE__), 'fixture'\nend", "def before_load(test_files); end", "def setup\n # Retrieve fixtures via their name\n # @first = gizmo_types(:first)\n end", "def fixture(name)\n File.open(File.expand_path(File.dirname(__FILE__) + \"/fixtures/#{name}\"))\nend", "def fixtures_path\n root_path.join('spec', 'fixtures')\nend", "def setup\n # Retrieve fixtures via their name\n # @first = vr_cc_solicituds(:first)\n end", "def setup\n # Retrieve fixtures via their name\n # @first = accounts(:first)\n end", "def sphinx_fixture(name, type = :request)\n File.open(File.join(File.dirname(__FILE__), 'fixtures', \"#{type}s\", \"#{name}.dat\"), 'rb') do |f|\n f.read\n end\nend", "def fixture(path)\n File.join(FIXTURES_ROOT, path)\nend", "def fixture(name)\r\n File.read \"test/fixtures/#{name}\"\r\n end", "def fixtures(name)\n entry = YAML::load_file(File.dirname(__FILE__) + \"/spec/fixtures/#{name}.yaml\")\n klass = begin\n Kernel::const_get(Inflector.classify(Inflector.singularize(name)))\n rescue\n nil\n end\n\n unless klass.nil?\n database.logger.debug { \"AUTOMIGRATE: #{klass}\" }\n klass.auto_migrate!\n\n (entry.kind_of?(Array) ? entry : [entry]).each do |hash|\n if hash['type']\n Object::const_get(hash['type'])::create(hash)\n else\n klass::create(hash)\n end\n end\n else\n table = database.table(name.to_s)\n table.create! true\n table.activate_associations!\n\n #pp database.schema\n\n (entry.kind_of?(Array) ? entry : [entry]).each do |hash|\n table.insert(hash)\n end\n end\nend", "def fixtures\n @fixtures ||= Dir[Rails.root.join(\"spec\", \"fixtures\", \"*/*\")]\n end", "def fixture_module(name)\n File.join(fixture_dir, name)\nend", "def fixture_filename(filename)\n File.expand_path(File.join(\"fixtures\", filename), File.dirname(__FILE__))\nend", "def fixture_path(filename)\n File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)\nend", "def install_fixtures\n fixtures = String.new\n if @config[@origin].has_key?('fixtures')\n fixtures = @config[@origin]['fixtures'].to_yaml.chop.gsub(\"---\\n\", '').gsub(\"\\n\", \"\\n \")\n end\n\n subs = {\n '##FIXTURES##' => fixtures,\n '##SHORT_NAME##' => @short_name,\n }\n\n install_template(\n [\"#{@templates}/.fixtures.yml\"], '.fixtures.yml', subs)\n end", "def entities_fixture_dir\n File.join(fixture_path, 'entities')\nend", "def setup\n # Retrieve fixtures via their name\n # @first = contacts(:first)\n end", "def setup\r\n # Retrieve fixtures via their name\r\n # @first = categories(:first)\r\n end", "def setup\n # Retrieve fixtures via their name\n # @first = vr_cc_solicitudes(:first)\n end", "def intents_fixture_dir\n File.join(fixture_path, 'intents')\nend", "def setup\r\n # Retrieve fixtures via their name\r\n # @first = category(:first)\r\n end", "def fixture(name, extension=\"json\")\n File.read(Rails.root.join(\"test\", \"fixtures\", \"#{name}.#{extension}\"))\nend", "def fixture_path\n File.expand_path('fixtures', 'spec')\n end", "def fixture(name)\n File.read(fixture_location(name))\nend", "def read_fixture( path )\n File.read(\"#{ fixtures_folder }/#{ path }\")\nend", "def testFixtureSetup()\n @windows = []\n # setup your objects for the tests (if needed)\n end", "def testFixtureSetup()\n @windows = []\n # setup your objects for the tests (if needed)\n end", "def file_fixture(filename)\n filename = File.join(File.dirname(__FILE__), 'fixtures', filename.to_s)\n File.open(filename).read\nend", "def runFixtureAndTests(testDirPath, collectionName, fixtureFileName)\n setFixture(collectionName,fixtureFileName) {runTests(testDirPath)}\nend", "def fixture(name)\n File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', name))\n end", "def fixture(name)\n File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', name))\n end", "def uses_fixture(fixture_name)\n require File.join(File.dirname(__FILE__), 'fixtures', fixture_name.to_s)\nend", "def setup\n # Retrieve fixtures via their name\n # @first = <%= plural_name %>(:first)\n end", "def source_paths\n fixtures_directory = Pathname.new(__dir__).join('..', 'spec', 'fixtures')\n [__dir__, fixtures_directory] + Array(super)\nend", "def load_fixtures\n Firefly::Url.destroy\n urls = YAML::load(File.open('spec/fixtures/urls.yml'))\n urls.each { |key, url| Firefly::Url.create(url) }\n end", "def setup\n # Retrieve fixtures via their name\n # @first = volunteer_tasks(:first)\n end", "def before_setup\n Account.connection.drop_table :accounts, if_exists: true\n Account.connection.exec_query(\"CREATE SEQUENCE accounts_id_seq\")\n Account.connection.exec_query(\"\n CREATE TABLE accounts (\n id BIGINT PRIMARY KEY DEFAULT nextval('accounts_id_seq'),\n firm_id bigint,\n firm_name character varying,\n credit_limit integer\n )\n \")\n\n Company.connection.drop_table :companies, if_exists: true\n Company.connection.exec_query(\"CREATE SEQUENCE companies_nonstd_seq\")\n Company.connection.exec_query(\"\n CREATE TABLE companies (\n id BIGINT PRIMARY KEY DEFAULT nextval('companies_nonstd_seq'),\n type character varying,\n firm_id bigint,\n firm_name character varying,\n name character varying,\n client_of bigint,\n rating bigint,\n account_id integer,\n description character varying\n )\n \")\n\n Course.connection.drop_table :courses, if_exists: true\n Course.connection.exec_query(\"CREATE SEQUENCE courses_id_seq\")\n Course.connection.exec_query(\"\n CREATE TABLE courses (\n id INT PRIMARY KEY DEFAULT nextval('courses_id_seq'),\n name character varying,\n college_id integer\n )\n \")\n\n self.class.fixtures :accounts\n self.class.fixtures :companies\n self.class.fixtures :courses\n end", "def test_can_add_paths_to_library_path\n Crd::Spec.new 'Testing' do |s|\n s.library_path << 'test/fixtures'\n assert_equal( [ 'test/fixtures' ], s.library_path )\n end\n end", "def read_fixture(name)\n IO.read(File.dirname(__FILE__) + \"/fixtures/#{name}.json\")\nend", "def read_fixture(file)\n File.read(File.join(File.dirname(__FILE__), \"fixtures\", file))\nend", "def read_fixture(file)\n File.read(File.join(File.dirname(__FILE__), \"fixtures\", file))\nend", "def create_ruby_test_files\n create_directories\n template \"poro.erb\", ruby_template\n template \"poro_test.erb\", test_template\n end", "def json_fixture(path)\n File.read(Rails.root.join(*%W[spec fixtures #{path}.json]))\nend", "def generate_resource_tests(pwd, data) end", "def load_fixtures\n load(*fixture_table_names)\n end", "def test_add_dir()\n dirpath = \"#{ENV['TCGA_CLINICAL_TEST_DATA']}/Biotab/\"\n rs = ClinicalTCGA::RetrieveSamples.new([\"TCGA-A6-2671\"], [\"death_days_to\"], false)\n rs.add_all_sources(dirpath, false) # suppress progress bar for unit test\n\n assert_equal(rs.h.keys.size, 18)\n assert(rs.h.has_key?(\"biospecimen_sample\"))\n end", "def setup\n FileUtils.mkdir_p(data_path)\n end", "def setup\n FileUtils.mkdir_p(data_path)\n end", "def setup\r\n puts 'starting a new test: ' + self.name\r\n cfT1 = CustomField.new(\"testField\", \"kuku\")\r\n cfT2 = CustomField.new(\"tester\", \"new_tester\")\r\n @reportiumClient.testStart(self.name, TestContext.new(TestContext::TestContextBuilder\r\n\t .withCustomFields(cfT1, cfT2)\r\n .withTestExecutionTags('TagYW1', 'TagYW2', 'unittest')\r\n .build()))\r\n end", "def generate_fixtures_data\n # Determine if there are symlinks, either for the default modulename, or for anything in the modulepath\n symlinks = []\n modulepath = ''\n if (File.exists?('environment.conf') and environment_conf = File.read('environment.conf'))\n puts \"\\nGenerating .fixtures.yml for a controlrepo.\" unless @options[:silent]\n\n environment_conf.split(\"\\n\").each do |line|\n modulepath = (line.split('='))[1].gsub(/\\s+/,'') if line =~ /^modulepath/\n end\n\n paths = modulepath.split(':').delete_if { |path| path =~ /^\\$/ }\n paths.each do |path|\n Dir[\"#{path}/*\"].each do |module_location|\n next unless File.directory?(module_location)\n module_name = File.basename(module_location)\n module_path = module_location\n symlinks << {\n :name => module_name,\n :path => '\"#{source_dir}/' + module_path + '\"',\n }\n end\n end\n else\n puts \"\\nGenerating .fixtures.yml using module name #{@options[:modulename]}.\" unless @options[:silent]\n\n symlinks << { \n :name => @options[:modulename],\n :path => '\"#{source_dir}\"',\n }\n end\n\n # Header for fixtures file creates symlinks for the controlrepo's modulepath, or for the current module\"\n fixtures_data = \"fixtures:\\n\"\n if symlinks\n fixtures_data += \" symlinks:\\n\"\n symlinks.sort_by!{|symlink| symlink[:name]}.each do |symlink|\n fixtures_data += \" #{symlink[:name]}: #{symlink[:path]}\\n\"\n end\n end\n\n unless @repository_data.empty?\n fixtures_data += \" repositories:\\n\"\n @repository_data.sort_by!{|repo| repo[:name]}.each do |repodata|\n # Each repository has two or pieces of data\n # Mandatory: the module name, the URI/location\n # Optional: the type (ref, branch, commit, etc.) and ID (tag, branch name, commit hash, etc.)\n name = repodata[:name]\n location = repodata[:location]\n type = repodata[:type]\n id = repodata[:id]\n\n data = <<-EOF\n #{name}:\n repo: \"#{location}\"\n EOF\n data += \" #{type}: \\\"#{id}\\\"\\n\" unless @options[:latest_versions] || !type || !id\n\n fixtures_data += data\n end\n end\n\n\n unless @module_data.empty?\n fixtures_data += \" forge_modules:\\n\"\n @module_data.keys.sort_by!{|mod| mod.split(/[\\/-]/)[1]}.each do |modulename|\n shortname = modulename.split(/[\\/-]/)[1]\n version = @module_data[modulename] \n data = <<-EOF\n #{shortname}:\n repo: \"#{modulename}\"\n EOF\n data += \" ref: \\\"#{version}\\\"\\n\" unless @options[:latest_versions] || version.nil?\n\n fixtures_data += data\n end\n end\n\n fixtures_data\n end", "def path_for(config); File.expand_path(File.join('../fixtures', config), __FILE__) ;end", "def setup\n FileUtils.mkdir TEMP_SITE_PATH\n FileUtils.cp_r File.join(TEST_SITE_PATH, '.'), TEMP_SITE_PATH\n # FIXME: I don't like this; change it when we can handle multiple ruhohs\n Ruhoh::Utils.stub(:parse_yaml_file).and_return('theme' => 'twitter')\n Ruhoh::Paths.stub(:theme_is_valid?).and_return(true)\n Ruhoh::Manager.setup :source => TEMP_SITE_PATH\nend", "def setup_test(operations, ot_type_name)\n operations.make\n operations.each do |op|\n output_collection = op.output('PCR Plate').collection\n rows = output_collection.dimensions[0]\n sample_names = ['RP', '2019-nCoVPC_N1', '2019-nCoVPC_N2']\n (rows/(sample_names.length)).times do\n sample_names.each do |name|\n collection = Collection.new_collection(ot_type_name)\n samples = Array.new(collection.dimensions[0], Sample.find_by_name(name))\n collection.add_samples(samples)\n end\n end\n end\n end", "def test_can_add_paths_to_source_path\n Crd::Spec.new 'Testing' do |s|\n s.source_path << 'test/fixtures'\n assert_equal( [ 'test/fixtures' ], s.source_path )\n end\n end", "def json_fixture(name)\n YAML.load(fixture(name))\nend", "def fixture(file)\n File.new(fixture_path + '/' + file)\nend", "def test_add_resource_cathedral\n @d.current_location = \"Cathedral\"\n assert_equal @d.resources[\"classes\"], 2\n end", "def test_file1\n File.new(\"#{TEST_DIR}/fixtures/uploads/test_file1.txt\")\n end", "def pre_testdata\n RVTEST_DATA_BEGIN()\n TEST_DATA()\n RVTEST_DATA_END()\n end", "def setup\n # reload the fixtures since each test is NOT wrapped in a transaction\n self.class.fixtures :all\n self.class.open_browser(@@testing_browser)\n end", "def app_template_fixture(name)\n File.expand_path(\"fixtures/#{name}\",File.dirname(__FILE__))\n end", "def fixtures(number_of_directories = 1)\n current_pwd = Dir.pwd\n paths = 1.upto(number_of_directories).map { mk_fixture_tmp_dir }\n\n FileUtils.cd(paths.first) if number_of_directories == 1\n\n yield(*paths)\nensure\n FileUtils.cd current_pwd\n paths.map { |p| FileUtils.rm_rf(p) if File.exist?(p) }\nend", "def file_fixture(path)\n return File.expand_path(File.join(File.dirname(__dir__), \"test\", \"fixtures\", \"files\", path))\nend", "def file_fixture(path)\n return File.expand_path(File.join(File.dirname(__dir__), \"test\", \"fixtures\", \"files\", path))\nend", "def file_fixture(path)\n return File.expand_path(File.join(File.dirname(__dir__), \"test\", \"fixtures\", \"files\", path))\nend", "def datadir\n \"#{Rails.root}/test/data\"\n end", "def test_create_object_by_type\r\n\t VCR.use_cassette('create_object') do\r\n\t\t cred=JSON.parse(YAML::load_file('test/fixtures/credential.yml').to_json)\r\n\t json = JSON.parse(File.read(\"test/fixtures/new_specimen.json\"))\r\n\t\t result=CordraRestClient::DigitalObject.create(API_URL, json[\"identifier\"],\"DigitalSpecimen\",json, cred[\"uc_1\"])\r\n\r\n\t\t #check that the result is saved\r\n\t\t assert_equal 200, result[:code]\r\n\t\t assert_equal \"OK\", result[\"message\"]\r\n\t\tend\r\n\t end", "def fixture_path\n @fixture_path ||=\n File.expand_path(File.join(__dir__, '..', '..', 'fixtures', 'files'))\nend", "def fixture_path(path)\n return File.join(File.expand_path('../../fixtures', __FILE__), path)\nend", "def fixture_io(name)\r\n File.open File.join(File.dirname(__FILE__), 'fixtures', name)\r\n end", "def load_fixture(name)\n path = File.join('spec', 'fixtures', \"#{name}.json\")\n open(path).readlines.join(\"\\n\")\nend", "def tests; end", "def tests; end", "def file_fixture_path(filename)\n File.expand_path(File.dirname(__FILE__) + \"/../fixtures/Upload/#{ filename }\")\nend", "def fixture_content(filename)\n path = File.expand_path(\"../fixtures/#{filename}\", __FILE__)\n File.read(path)\nend", "def file_fixture(name)\n File.read(File.join(File.dirname(__FILE__), \"file_fixtures\", name))\n end", "def testdata\n prefix/\"test\"\n end", "def setup\n @testnum += 1\n @tempdirname = \".ocratest-#{$$}-#{@testnum}\"\n Dir.mkdir @tempdirname\n Dir.chdir @tempdirname\n end", "def test_find_tests_for_template\n create_template(\"Test Template\")\n template_id = find_last_template_id\n create_test(template_id)\n tests = @db.find_tests_for_template(template_id)\n\n assert_instance_of(Array, tests)\n\n delete_template(template_id)\n end", "def fixture(name)\r\n fixture_io(name).read\r\n end", "def fixture_file(filename)\n File.join fixtures_dir, \"#{filename}.yml\"\n end", "def load_default_test_data_to_db_before_suite\n community1 = FactoryGirl.create(:community, :ident => \"test\", :consent => \"test_consent0.1\", :settings => {\"locales\" => [\"en\", \"fi\"]}, :real_name_required => true)\n community1.community_customizations.create(name: \"Yelo\", locale: \"fi\")\n community2 = FactoryGirl.create(:community, :ident => \"test2\", :consent => \"KASSI_FI1.0\", :settings => {\"locales\" => [\"en\"]}, :real_name_required => true, :allowed_emails => \"@example.com\")\n community3 = FactoryGirl.create(:community, :ident => \"test3\", :consent => \"KASSI_FI1.0\", :settings => {\"locales\" => [\"en\"]}, :real_name_required => true)\n\n [community1, community2, community3].each { |c| TestHelpers::CategoriesHelper.load_test_categories_and_listing_shapes_to_db(c) }\n end", "def fixture\n pwd = FileUtils.pwd\n path = File.expand_path(File.join(pwd, \"spec/.fixtures/#{rand(99999)}\"))\n\n FileUtils.mkdir_p(path)\n FileUtils.cd(path)\n\n yield(path)\n\n ensure\n FileUtils.cd pwd\n FileUtils.rm_rf(path) if File.exists?(path)\n end", "def xml_fixture(name)\n File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml', \"#{name}.xml\"))\nend", "def fixture_path\n File.join(__dir__, '../chef/fixtures')\n end", "def initialize_test_layout\n self.model_tests_dir = \"test/unit\"\n self.controller_tests_dir = \"test/functional\"\n self.view_tests_dir = \"test/views\"\n self.fixtures_dir = \"test/fixtures\"\n end", "def get_fixture(name)\n #JSON.parse(File.read(File.expand_path(\"../fixtures/#{name}\", __FILE__)))\n File.read(File.expand_path(\"../fixtures/#{name}\", __FILE__))\nend", "def generate_alltest\n\n end", "def run_test\n # Add your code here...\n end", "def run_test\n # Add your code here...\n end", "def assert_generated_fixtures_for(name)\n assert_generated_yaml \"test/fixtures/#{name.to_s.underscore}\" do |yaml|\n yield yaml if block_given?\n end\n end", "def nagios_fixture(name)\n fixtures_dir = File.join(File.dirname(__FILE__), 'fixtures')\n File.read(File.join(fixtures_dir, name)).encode('ASCII-8BIT')\nend", "def load_users_fixture\n self.class.load_users_fixture\n end", "def tests_generated(directory)\n puts green(\"Test reports saved to: #{directory}\")\n end", "def seed_refund_types\n\tdata = ActiveSupport::JSON.decode(File.read('db/seeds/refund_types.json'))\n\tdata.each do |d|\n\t\tRefundType.create!(d)\n\tend\nend" ]
[ "0.6776879", "0.65703833", "0.65081245", "0.6399609", "0.63323057", "0.6288054", "0.6127184", "0.612064", "0.6112131", "0.6098784", "0.60510594", "0.604035", "0.6039325", "0.60387486", "0.5976574", "0.5955166", "0.5927808", "0.59264755", "0.5844803", "0.58405685", "0.5833745", "0.5811543", "0.5808802", "0.57949054", "0.57763135", "0.5773621", "0.5770089", "0.57634073", "0.5760638", "0.5760009", "0.57451576", "0.5724988", "0.5724988", "0.57232344", "0.5709408", "0.5704463", "0.5704463", "0.56985533", "0.56574297", "0.5641048", "0.56190246", "0.5602391", "0.56010604", "0.5597792", "0.55915636", "0.5516144", "0.5516144", "0.55122834", "0.54972965", "0.5496856", "0.5495932", "0.5480515", "0.54804564", "0.54804564", "0.54783374", "0.54706097", "0.5448996", "0.5448785", "0.54463935", "0.5441411", "0.54273945", "0.5426331", "0.54115224", "0.5408951", "0.54080963", "0.5403471", "0.5397859", "0.5397623", "0.5392472", "0.5392472", "0.5392472", "0.53908247", "0.5385604", "0.5383382", "0.53759307", "0.5366139", "0.5350739", "0.53494257", "0.53494257", "0.53438836", "0.53309506", "0.53228635", "0.5313658", "0.5313274", "0.5312993", "0.53120893", "0.5311596", "0.53071916", "0.5303742", "0.5296706", "0.5295539", "0.5290708", "0.5287864", "0.52853894", "0.5282919", "0.5282919", "0.5277898", "0.5276873", "0.5275865", "0.52685463", "0.5268011" ]
0.0
-1
GET /results GET /results.json
def index @results = Result.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def results(path, params = {}, opts = {})\n get(path, params, opts)['results']\n end", "def results\n with_monitoring do\n response = perform(:get, results_url, query_params)\n Search::ResultsResponse.from(response)\n end\n rescue => e\n handle_error(e)\n end", "def index\n get_results\n end", "def get_results\n\t\trace_id = params[:id]\n\t\t\n\t\trace = Race.find_by_id(race_id)\n\t\tresults = Result.get_race_results(race_id)\n\t\t\n\t\trender :json=>{:results=>results}\n\tend", "def index\n @results = Result.all\n @results = Result.paginate(:per_page => 15, :page => params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @results }\n end\n end", "def results\n raw_input = params[:search].to_s\n formatted_input = raw_input.gsub(\" \", \"+\")\n\n @client = HTTParty.get(\"http://api.shopstyle.com/api/v2/products?pid=uid5001-30368749-95&fts='#{formatted_input}'&offset=0&limit=20\")\n\n render json: @client\n end", "def index\n @results = Result.all\n end", "def index\n @results = Result.all\n end", "def results\n response['data']\n end", "def results\n begin\n self.to_json[\"SearchResponse\"][\"Web\"][\"Results\"].map do |result_hash|\n LiveAPI::Search::Result.new(result_hash)\n end\n rescue\n self.to_json[\"SearchResponse\"]\n end\n end", "def index\n @am_results = AmResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @am_results }\n end\n end", "def search\n @q = params[:q]\n @results = Series.external_search(@q)\n\n respond_to do |format|\n format.html # search.html.haml\n format.json { render json: @results.to_json }\n end\n end", "def results\n respond_to do |format|\n format.html do\n content = get_content('opportunities/results.yml')\n results = Search.new(params, limit: 500).run\n @subscription = SubscriptionForm.new(results).data\n @page = PagePresenter.new(content)\n @results = OpportunitySearchResultsPresenter.new(content, results)\n render layout: 'results'\n end\n format.any(:atom, :xml) do\n results = Search.new(params, limit: 500,\n results_only: true,\n sort: 'updated_at').run\n @query = AtomOpportunityQueryDecorator.new(results, view_context)\n render :index, formats: :atom\n end\n end\n end", "def index\n @results = Result.all\n end", "def index\n @results = Result.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @results }\n end\n end", "def results\n index.results\n end", "def\tsearch\n\t\tresult = query_google_places\n\t\trender :json => result\n\tend", "def index\n @searches = Search.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @searches }\n end\n end", "def index\n @results = Result.where(:student_id => @student.id)\n .order('result_date desc')\n .paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @results }\n end\n end", "def results\n # lat, lng, and term from user.js AJAX get request\n p params\n @lat = params[:lat]\n @long = params[:lng]\n term = params[:term]\n yelp_params = { term: term, limit: 5, sort: 1}\n coordinates = { latitude: @lat, longitude: @long }\n new_search = Yelp.client.search_by_coordinates(coordinates, yelp_params)\n # TODO - refactor into a separate function\n p new_search\n new_search.businesses.each do |business|\n \t result_name = business.name\n result_distance = business.distance\n \t result_address = business.location.address\n \t result_lat = business.location.coordinate.latitude\n \t result_long = business.location.coordinate.longitude\n \t # result_review = business.review_count\n \t # result_rating = business.rating\n end \n render json: new_search\n end", "def search\n terms = @authority.search(url_search)\n render json: terms\n end", "def index\n @response = search_service.search_results\n\n respond_to do |format|\n format.html { store_preferred_view }\n format.rss { render layout: false }\n format.atom { render layout: false }\n format.json do\n @presenter = Blacklight::JsonPresenter.new(@response,\n blacklight_config)\n end\n additional_response_formats(format)\n document_export_formats(format)\n end\n end", "def filtered_results\n results = PropertyResults.paginated_results(params[:facets], params[:page], params[:per_page], params[:offset], params[:query])\n respond_to do |format|\n format.json { render json: results.to_json }\n end\n end", "def search\n results = @test.search(test_params)\n return render json: {results: results, total: results.total_entries}\n end", "def index\n @evaluation_results = EvaluationResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluation_results }\n end\n end", "def index\n @contacts = Contact.all\n @calltypes = CallType.all\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @results }\n end\n end", "def search_result\n @search = params[:search]\n query = params[:search] #Query variable is the string a user enters in the search bar.\n url = Addressable::URI.parse('https://api.themoviedb.org/3/search/tv?api_key=fb6a1d3f38c3d97f67df6d141f936f29&language=en-US')\n url.query_values = url.query_values.merge(query: query)\n response = HTTParty.get(url)\n @results = JSON.parse(response.body, symbolize_names: true) \n end", "def index\n @searches = @website.searches.all\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @searches }\n end\n end", "def search(query, results = nil)\n params = { :query => query }\n params[:results] = results unless results.nil?\n get :webSearch, params\n end", "def index\n @results = FourSquare.new(foursquare_params).search\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end", "def index\n @q = params[:q]\n @q ||= \"\"\n @shops = Shop.search(@q).records\n\n\n respond_to do |format|\n format.html { render action: 'index' }\n format.json { render json: @shops, each_serializer: ShopListSerializer }\n end\n end", "def all\n response = RestClient.get(@all_url, params)\n parsed = JSON.parse(response)\n \n parsed['results']['result']\n end", "def index\n @search = Problem.search(params[:q])\n @problems = @search.result.paginate(:page => params[:page], :per_page => 10).order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @problems }\n end\n end", "def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end", "def print_results(response)\n puts response.to_json\nend", "def index\n @user = current_user\n @search = @user.loops.search(params[:q]) \n @loops = @search.result \n \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @loops }\n end\n end", "def results\n get_results(true)\n render :partial => (params[:result_partial] || 'results')\n end", "def index\n query = params[:q]\n @courses = query ? Course.search(query) : Course.all.order(:id)\n\n render json: @courses\n end", "def search\n @tweets = TwitterClient.search(params[:query], result_type: 'recent').take(20)\n render json: @tweets\n end", "def index\n @searches = @user.searches\n respond_to do |format|\n format.html { }\n format.json { @presenter = json_presenter(@searches) }\n end\n end", "def index\n @campaign_results = CampaignResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @campaign_results }\n end\n end", "def search_result\n query = search_params.presence && search_params\n results = query.present? ? helpers.search_query(query) :helpers.create_query(current_user)\n render json: {:data => results, :total => results.results.total}\n end", "def results\n @results\n end", "def show\n @result = Result.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @result }\n end\n end", "def show\n @result = Result.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @result }\n end\n end", "def show\n @result = Result.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @result }\n end\n end", "def show\n @result = Result.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @result }\n end\n end", "def results_info\n render json: {results: @experiment.results, error_reason: @experiment.error_reason}\n end", "def index\n @hits = Hit.order(\"created_at DESC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hits }\n end\n end", "def index\n @players = Player.search(params[:team_id], params[:player_forename], params[:player_surename])\n\n respond_to do |format|\n format.html # index.html.erb\n hash = {:players => @players}\n format.json { render :json => hash }\n end\n end", "def result_params\n params[:results]\n end", "def index\n @survey = Survey.find(params[:survey_id])\n @results = @survey.results.all\n end", "def index\n @scores = Score.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @scores }\n end\n end", "def index\n @results = Admin::Result.index.paginate(page: params[:page], per_page: 20)\n end", "def results\n fetch unless @results\n @results\n end", "def index\n\n @properties = Property.search( params[:query] || \"\" )\n\n respond_to do |format|\n\n format.html\n format.json { render json: @properties }\n\n end\n\n end", "def index\n @vodcasts = Vodcast.search(params[:search])\n \n if @vodcasts.count == 0\n if params[:search]\n flash.now[:notice] = \"No results\"\n else\n flash.now[:notice] = \"No vodcasts\"\n end\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vodcasts }\n \n # external access(HTTP Service):\n # http://davidsulc.com/blog/2011/04/10/implementing-a-public-api-in-rails-3/\n # http://davidsulc.com/blog/2011/04/17/consuming-a-public-rails-api-with-jquery/\n format.js { render json: @vodcasts, callback: params[:callback] }\n end\n end", "def index\n @ptest_results = PtestResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ptest_results }\n end\n end", "def search\n render json: User.first(10)\n end", "def index\n @search = NiconicoMovie.search(params[:q])\n @niconicomovies = @search.result.order(\"id DESC\").page(params[:page]).per(25)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @niconicomovies }\n end\n end", "def index\n @stock_results = StockResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @stock_results }\n end\n end", "def search\n @collections, @total_count = Admin::Collection.search(params[:search], params[:pagination], params[:sorting])\n\n render json: { collections: @collections, totalCount: @total_count }\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def index \n artists = Artist.all \n render json: artists \n end", "def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end", "def index\n # (@response, @document_list) = search_results(params)\n set_cached_latest\n\n respond_to do |format|\n format.html { store_preferred_view }\n format.rss { render layout: false }\n format.atom { render layout: false }\n format.js\n format.json do\n render json: render_search_results_as_json\n # @presenter = Blacklight::JsonPresenter.new(@response,\n # @document_list,\n # facets_from_request,\n # blacklight_config)\n end\n # additional_response_formats(format)\n # document_export_formats(format)\n end\n end", "def index\n\n @search = House.search()\n @houses = House.order(\"country\").order(\"name\").page params[:page]\n\n if params[:q]\n @search = House.search(params[:q])\n @houses = @search.result.order(\"country\").order(\"name\")\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @houses }\n end\n end", "def search\n # bail out if doing an unauthenticated API request\n failures = []\n respond_to do |format|\n format.html do\n @test_instances, failures = \n TestInstance.query(params[:query_text]) if params[:query_text]\n if @test_instances\n @test_instances = @test_instances.page(params[:page])\n end\n unless failures.empty?\n flash.now[:warning] = 'Invalid search parameters: ' + \n failures.join(', ') + '.'\n end\n @show_instructions = @test_instances.nil?\n end\n format.json do\n if authenticated?\n @test_instances, failures = \n TestInstance.query(params[:query_text]) if params[:query_text]\n if @test_instances\n render json: {\"results\" => @test_instances,\n \"failures\" => failures}.to_json\n else\n render json: {\"results\" => [], \"failures\" => failures}.to_json\n end\n else\n fail_authenticate_json\n end\n end\n end\n end", "def results\n d = data\n if d != nil and d.has_key?('results')\n return d['results']\n end\n nil\n end", "def index\n @reloud_checks = ReloudCheck.search(params[:search])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reloud_checks }\n end\n end", "def index\n @survey_results = HTTParty.get('https://shielded-wave-66393.herokuapp.com',\n :headers =>{'Content-Type' => 'application/json'} )\n @survey_results = SurveyResults.all_(current_customer)\n end", "def index\n results = []\n if params[:bbox]\n results = VAFacility.query(bbox: params[:bbox], type: params[:type], services: params[:services])\n end\n resource = Common::Collection.new(::VAFacility, data: results)\n resource = resource.paginate(pagination_params)\n render json: resource.data,\n serializer: CollectionSerializer,\n each_serializer: VAFacilitySerializer,\n meta: resource.metadata\n end", "def get_results\n\n # An internal counter to get the next\n # set of results from the API\n @result_count = 0\n\n # An array into which the API results can\n # be collected\n @results = []\n\n # Get the first set of results from the API\n json_response = self.query\n\n while true\n\n # Exit the loop if the API doesn't return\n # any results and set the \"skip\" attribute\n # to nil\n if json_response['result_count'] == 0\n self.skip= nil\n break\n end\n\n # Add the count of the returned results to the\n # internal result counter's current value\n @result_count += json_response['result_count']\n\n # Append the current results to the results\n # array\n @results << json_response['results']\n\n # Set the \"skip\" attribute to the value\n # on the internal result counter\n self.skip= @result_count\n\n # Get the next set of results from the API\n json_response = self.query\n\n # A simple progress bar\n print \"#\"\n\n end\n\n # Print the total result count to the console\n puts \"\\nFound #{@result_count} results.\"\n\n return @results\n\n end", "def search_results\n @term = sname = request.query_parameters[\"search\"].to_s.downcase\n data = search_term(sname)\n @top = []\n @rest = []\n data[:results].each do |type|\n type[:matches].each do |hit|\n if hit[:score] >= 1.0\n @top << hit\n else\n @rest << hit\n end\n end\n end\n @top.sort! { |a, b| b[:score] <=> a[:score] }\n @rest.sort! { |a, b| b[:score] <=> a[:score] }\n render \"site/results\"\n end", "def index\n @routes = Route.where(:verified => true)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @routes }\n end\n end", "def index\n @users = User.search(params[:search]).order(\"kilometers DESC\").paginate(:per_page => 100, :page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def search\n spotyfy_client = SpotyfyClient.new(params[:search])\n spotyfy_client.perform\n items = SpotyfyService.parse_hash(spotyfy_client.body)\n render :json => items.to_json\n end", "def search_results\n @results = User.search(params[:search])\n end", "def index\n @results = @search.result.paginate(page: params[:page], per_page: 9).order(created_at: :desc)\n end", "def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end", "def index\n @quantities = Quantity.search(params[:search])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @quantities }\n end\n end", "def show\n set_meta_tags title: @application.name + ' | Collections - Repositories'\n @access_tokens = @application.access_tokens.where(resource_owner: current_user)\n @token = @access_tokens.last\n if params[:q].present?\n url = \"#{@application.url}?q=#{url_encode(params[:q])}&limit=#{params[:limit]}\"\n begin\n response = RestClient.get(url, {:Authorization => \"#{@token.try(:token_type)} #{@token.try(:token)}\"})\n rescue Errno::ECONNREFUSED\n puts \"Server at #{url} is refusing connection.\"\n flash.now[:warning] = \"Results from #{@application.name} missing. Can't connect to server.\"\n end\n @results = JSON.parse(response) if response\n end\n end", "def results\n @results ||= {}\n end", "def index\n @jobsearches = Jobsearch.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @jobsearches }\n end\n end", "def index\n @search = Species.includes(:animals).organization(current_user).search(params[:q])\n @species = @search.result.paginate(page: params[:page], per_page: 10).order('updated_at DESC')\n\n respond_with(@species)\n end", "def index\n @military_battle_faction_results = Military::BattleFactionResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @military_battle_faction_results }\n end\n end", "def index\n authorize RosterList\n params[:page] ||= 1\n meta = {}\n # RosterList.all.each { |r| r.fill_in_data }\n all_result = search_query\n meta['total_count'] = all_result.count\n result = all_result.page( params[:page].to_i).per(20)\n\n # meta['total_count'] = result.total_count\n meta['total_page'] = result.total_pages\n meta['current_page'] = result.current_page\n # result.each { |r| r.fill_in_data }\n\n final_result = format_result(result.as_json(include: [], methods: []))\n\n response_json final_result, meta: meta\n end", "def index\n # Generate sunspot search\n @records = record_default_search\n\n respond_with(@records)\n end", "def index\n @rents = Rent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rents }\n end\n end", "def search\n games_data = BoardGameAtlas::API.search(params[:name])\n render json: { games: games_data.map }\n end", "def index\n @api_v1_locations = Api::V1::Location.all\n respond_to do |format|\n format.html { @api_v1_locations }\n format.json { render json: {results: @api_v1_locations, message: 'Locations have loaded successfully.'} }\n end\n end", "def index\n @shops = Shop.all\n @search = Shop.search(params[:q])\n @shops = @search.result.page(params[:page]).per(30)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shops }\n end\n\n end", "def index\n @resources = Resource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end", "def get_results\n\t\tstage_id = params[:id]\n\t\t\n\t\tresults = Result.get_results('stage', stage_id, {}, true)\n\t\tstage = Stage.find_by_id(stage_id)\n\t\t\n\t\tdata = []\n\t\tresults.each do |ndx, result|\n\t\t\tdata.push({\n\t\t\t\t:rider_name => result[:rider_name],\n\t\t\t\t:kom_points => result[:kom_points],\n\t\t\t\t:sprint_points => result[:sprint_points],\n\t\t\t\t:disqualified => result[:disqualified],\n\t\t\t\t:rank => result[:rank],\n\t\t\t\t:time_formatted => result[:time_formatted],\n\t\t\t\t:bonus_time_formatted => result[:bonus_time_formatted],\n\t\t\t\t:gap_formatted => result[:gap_formatted]\n\t\t\t})\n\t\tend\n\t\t\n\t\tif (!@user.nil? && !@user.time_zone.nil?)\n\t\t\tstage_starts_on = stage.starts_on.gmtime.localtime(@user.time_zone)\n\t\telse\n\t\t\tstage_starts_on = stage.starts_on.gmtime\n\t\tend\n\t\tstage_data = {\n\t\t\t:name => stage.name,\n\t\t\t:description => stage.description,\n\t\t\t:profile => (stage.profile.nil? || stage.profile.empty?)?nil:stage.profile,\n\t\t\t:starts_on => stage_starts_on.strftime('%b %e, %Y, %H:%M'),\n\t\t\t:start_location => stage.start_location,\n\t\t\t:end_location => stage.end_location,\n\t\t\t:distance => stage.distance_km\n\t\t}\n\t\t\n\t\trender :json=>{:results=>data, :stage=>stage_data}\n\tend", "def search\n response = make_request\n begin\n response_hash = JSON.parse(response.body)\n rescue JSON::ParserError\n raise RequestException\n else\n response_hash\n end\n end", "def Search query\n \n APICall(path: \"search.json?query=#{query}\",method: 'GET')\n \n end", "def index\n @saved_searches = SavedSearch.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @saved_searches }\n end\n end", "def raw_results\n results\n end", "def index\n @restaurants = Restaurant.where(\"name like ?\", \"%#{params[:q]}%\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @restaurants.map(&:attributes) }\n end\n end", "def search\n render json: Consultation.first(10)\n end" ]
[ "0.7627161", "0.7400975", "0.73309505", "0.73102474", "0.7303848", "0.7197686", "0.7027008", "0.7027008", "0.70246524", "0.69998884", "0.6963856", "0.6914666", "0.6851203", "0.68335116", "0.6798052", "0.674726", "0.67325014", "0.6720427", "0.66841894", "0.66758746", "0.6674328", "0.665717", "0.66175395", "0.66037273", "0.6583996", "0.65619934", "0.6557443", "0.6553684", "0.6531629", "0.652171", "0.6512366", "0.6508113", "0.65067285", "0.6504757", "0.64999557", "0.6492001", "0.64912593", "0.6479828", "0.6478671", "0.64710385", "0.64510447", "0.6450463", "0.64349115", "0.6433843", "0.6433843", "0.6433843", "0.6433843", "0.6430756", "0.64281976", "0.642622", "0.64127535", "0.6406959", "0.63846636", "0.6378599", "0.6374044", "0.6371603", "0.63674366", "0.63505167", "0.63502336", "0.6345373", "0.6338429", "0.63348204", "0.63322455", "0.63293946", "0.63198394", "0.6316899", "0.6315704", "0.6312198", "0.63077676", "0.6305462", "0.63014096", "0.6299112", "0.6288274", "0.6275572", "0.6275042", "0.62702256", "0.6262129", "0.6261317", "0.6248247", "0.6244232", "0.6235007", "0.62345564", "0.62309825", "0.62102133", "0.6205403", "0.6205246", "0.6201295", "0.62001663", "0.61976236", "0.61936283", "0.618939", "0.6185542", "0.6176761", "0.61689645", "0.61683655", "0.6166644", "0.61666", "0.6164731", "0.615652", "0.6154962" ]
0.69354475
11
GET /results/1 GET /results/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def results(path, params = {}, opts = {})\n get(path, params, opts)['results']\n end", "def index\n get_results\n end", "def get_results\n\t\trace_id = params[:id]\n\t\t\n\t\trace = Race.find_by_id(race_id)\n\t\tresults = Result.get_race_results(race_id)\n\t\t\n\t\trender :json=>{:results=>results}\n\tend", "def index\n @results = Result.all\n @results = Result.paginate(:per_page => 15, :page => params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @results }\n end\n end", "def results\n response['data']\n end", "def index\n @results = Result.all\n end", "def index\n @results = Result.all\n end", "def results\n raw_input = params[:search].to_s\n formatted_input = raw_input.gsub(\" \", \"+\")\n\n @client = HTTParty.get(\"http://api.shopstyle.com/api/v2/products?pid=uid5001-30368749-95&fts='#{formatted_input}'&offset=0&limit=20\")\n\n render json: @client\n end", "def index\n @results = Result.all\n\n end", "def show\n @result = Result.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @result }\n end\n end", "def show\n @result = Result.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @result }\n end\n end", "def show\n @result = Result.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @result }\n end\n end", "def show\n @result = Result.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @result }\n end\n end", "def results\n with_monitoring do\n response = perform(:get, results_url, query_params)\n Search::ResultsResponse.from(response)\n end\n rescue => e\n handle_error(e)\n end", "def show\n @result1 = Result1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @result1 }\n end\n end", "def index\n @am_results = AmResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @am_results }\n end\n end", "def index\n @results = Result.all\n end", "def index\n @results = Result.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @results }\n end\n end", "def results\n index.results\n end", "def result\n results.first\n end", "def show\n @scenario = Scenario.find(params[:scenario_id])\n @result = @scenario.results.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @result }\n end\n end", "def print_results(response)\n puts response.to_json\nend", "def result\n results[0]\n end", "def index\n @evaluation_results = EvaluationResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluation_results }\n end\n end", "def results_info\n render json: {results: @experiment.results, error_reason: @experiment.error_reason}\n end", "def index\n @hits = Hit.order(\"created_at DESC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hits }\n end\n end", "def get\n @research_output = @service.get({type: params[:graph], detail: params[:detail], id: params[:id]},\n host: request.env[\"HTTP_HOST\"], limit: params[:num_results], offset: params[:start_offset], :per_project => params[:per_project], format: params[:format])\n\n respond_with @research_output\n end", "def index\n @results = Result.where(:student_id => @student.id)\n .order('result_date desc')\n .paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @results }\n end\n end", "def search\n @q = params[:q]\n @results = Series.external_search(@q)\n\n respond_to do |format|\n format.html # search.html.haml\n format.json { render json: @results.to_json }\n end\n end", "def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end", "def index\n @survey = Survey.find(params[:survey_id])\n @results = @survey.results.all\n end", "def results\n begin\n self.to_json[\"SearchResponse\"][\"Web\"][\"Results\"].map do |result_hash|\n LiveAPI::Search::Result.new(result_hash)\n end\n rescue\n self.to_json[\"SearchResponse\"]\n end\n end", "def results\n respond_to do |format|\n format.html do\n content = get_content('opportunities/results.yml')\n results = Search.new(params, limit: 500).run\n @subscription = SubscriptionForm.new(results).data\n @page = PagePresenter.new(content)\n @results = OpportunitySearchResultsPresenter.new(content, results)\n render layout: 'results'\n end\n format.any(:atom, :xml) do\n results = Search.new(params, limit: 500,\n results_only: true,\n sort: 'updated_at').run\n @query = AtomOpportunityQueryDecorator.new(results, view_context)\n render :index, formats: :atom\n end\n end\n end", "def results\n get_results(true)\n render :partial => (params[:result_partial] || 'results')\n end", "def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end", "def index\n @three_results = ThreeResult.all\n end", "def show\n @result_item = ResultItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @result_item }\n end\n end", "def get_api_results(_url)\n JSON.parse File.read('spec/inspector/stubbed_example.json')\n end", "def index\n @ptest_results = PtestResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ptest_results }\n end\n end", "def all\n response = RestClient.get(@all_url, params)\n parsed = JSON.parse(response)\n \n parsed['results']['result']\n end", "def index\n @campaign_results = CampaignResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @campaign_results }\n end\n end", "def index\n @searches = Search.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @searches }\n end\n end", "def index\n @search = Problem.search(params[:q])\n @problems = @search.result.paginate(:page => params[:page], :per_page => 10).order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @problems }\n end\n end", "def index\n @contacts = Contact.all\n @calltypes = CallType.all\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @results }\n end\n end", "def index\n @searches = @website.searches.all\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @searches }\n end\n end", "def fetch(url)\n response = RestClient.get(url)\n data = JSON.parse(response)\n @google_results = data[\"results\"].first(15).map do |result|\n {\n name: result[\"name\"],\n address: result[\"formatted_address\"],\n coordinates: {\n latitude: result[\"geometry\"][\"location\"][\"lat\"],\n longitude: result[\"geometry\"][\"location\"][\"lng\"]\n },\n opening_hours: result[\"opening_hours\"],\n type: result[\"types\"].first,\n rating: result[\"rating\"]\n }\n end\n @google_results\n end", "def search\n render json: User.first(10)\n end", "def get_results\n\n # An internal counter to get the next\n # set of results from the API\n @result_count = 0\n\n # An array into which the API results can\n # be collected\n @results = []\n\n # Get the first set of results from the API\n json_response = self.query\n\n while true\n\n # Exit the loop if the API doesn't return\n # any results and set the \"skip\" attribute\n # to nil\n if json_response['result_count'] == 0\n self.skip= nil\n break\n end\n\n # Add the count of the returned results to the\n # internal result counter's current value\n @result_count += json_response['result_count']\n\n # Append the current results to the results\n # array\n @results << json_response['results']\n\n # Set the \"skip\" attribute to the value\n # on the internal result counter\n self.skip= @result_count\n\n # Get the next set of results from the API\n json_response = self.query\n\n # A simple progress bar\n print \"#\"\n\n end\n\n # Print the total result count to the console\n puts \"\\nFound #{@result_count} results.\"\n\n return @results\n\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n puts JSON.pretty_generate(result)\n result\nend", "def json_to_results(json)\n json.map do |jr|\n uri = URI(jr['url'])\n # ignore the query string, since it may have some randomness\n uri.query = nil\n Result.new(project.name, jr['confidence'], jr['risk'], uri.to_s, jr['param'], jr['alert'])\n end\n end", "def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end", "def index\n @response = search_service.search_results\n\n respond_to do |format|\n format.html { store_preferred_view }\n format.rss { render layout: false }\n format.atom { render layout: false }\n format.json do\n @presenter = Blacklight::JsonPresenter.new(@response,\n blacklight_config)\n end\n additional_response_formats(format)\n document_export_formats(format)\n end\n end", "def results\n fetch unless @results\n @results\n end", "def results\n # lat, lng, and term from user.js AJAX get request\n p params\n @lat = params[:lat]\n @long = params[:lng]\n term = params[:term]\n yelp_params = { term: term, limit: 5, sort: 1}\n coordinates = { latitude: @lat, longitude: @long }\n new_search = Yelp.client.search_by_coordinates(coordinates, yelp_params)\n # TODO - refactor into a separate function\n p new_search\n new_search.businesses.each do |business|\n \t result_name = business.name\n result_distance = business.distance\n \t result_address = business.location.address\n \t result_lat = business.location.coordinate.latitude\n \t result_long = business.location.coordinate.longitude\n \t # result_review = business.review_count\n \t # result_rating = business.rating\n end \n render json: new_search\n end", "def index\n @experiments = Experiment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @experiments }\n end\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def search_result\n @search = params[:search]\n query = params[:search] #Query variable is the string a user enters in the search bar.\n url = Addressable::URI.parse('https://api.themoviedb.org/3/search/tv?api_key=fb6a1d3f38c3d97f67df6d141f936f29&language=en-US')\n url.query_values = url.query_values.merge(query: query)\n response = HTTParty.get(url)\n @results = JSON.parse(response.body, symbolize_names: true) \n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def search\n @tweets = TwitterClient.search(params[:query], result_type: 'recent').take(20)\n render json: @tweets\n end", "def index\n @q = params[:q]\n @q ||= \"\"\n @shops = Shop.search(@q).records\n\n\n respond_to do |format|\n format.html { render action: 'index' }\n format.json { render json: @shops, each_serializer: ShopListSerializer }\n end\n end", "def pokemon_api_caller\nresponse = RestClient.get \"https://pokeapi.co/api/v2/pokemon/?offset=0&limit=807\"\nresponse_JSON = JSON.parse(response)\nresponse_JSON[\"results\"]\nend", "def index\n @runs = Run.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @runs }\n end\n end", "def show\n @survey_result = SurveyResult.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @survey_result }\n end\n end", "def index\n @scores = Score.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @scores }\n end\n end", "def search\n render json: PersonEvent.first(10)\n end", "def result_params\n params[:results]\n end", "def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end", "def index\n @result_infos = ResultInfo.all\n end", "def index\n @researches = Research.paginate(:page => params[:page], :per_page => 10)\n\t\t@research = Research.new\n\t\t@notifications = Notification.find(:all, :order => :next_notification).first(9)\n\t\t@topics= Topic.find(:all, :order => :progress, :conditions => [\"version = ?\",'latest'], :limit => '8')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @researches }\n end\n end", "def index\n @results = FourSquare.new(foursquare_params).search\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end", "def search\n render json: Consultation.first(10)\n end", "def index\n @user = current_user\n @search = @user.loops.search(params[:q]) \n @loops = @search.result \n \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @loops }\n end\n end", "def search\n render json: PersonScantronAppointment.first(10)\n end", "def index\n index! do |format|\n format.html\n format.json do\n object = if params[:id]\n resource.increment_hits!\n resource\n else\n collection\n end\n\n render :json => object \n end\n end\n end", "def index\n # (@response, @document_list) = search_results(params)\n set_cached_latest\n\n respond_to do |format|\n format.html { store_preferred_view }\n format.rss { render layout: false }\n format.atom { render layout: false }\n format.js\n format.json do\n render json: render_search_results_as_json\n # @presenter = Blacklight::JsonPresenter.new(@response,\n # @document_list,\n # facets_from_request,\n # blacklight_config)\n end\n # additional_response_formats(format)\n # document_export_formats(format)\n end\n end", "def index\n @stock_results = StockResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @stock_results }\n end\n end", "def index\n @survey_results = HTTParty.get('https://shielded-wave-66393.herokuapp.com',\n :headers =>{'Content-Type' => 'application/json'} )\n @survey_results = SurveyResults.all_(current_customer)\n end", "def index\n @two_results = TwoResult.all\n end", "def index\n @matches = Match.all\n @recent = Match.recent\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @matches }\n end\n end", "def show\n \t@survey = Survey.find(params[:survey_id])\n \t@result = @survey.results.find(params[:id])\n end", "def show\n @test_result = TestResult.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_result }\n end\n end", "def index\n @requests = Request.where(status: -1)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @requests }\n end\n end", "def index\n\n @properties = Property.search( params[:query] || \"\" )\n\n respond_to do |format|\n\n format.html\n format.json { render json: @properties }\n\n end\n\n end", "def index\r\n @stats = Stat.all\r\n @statsu = Stat.where(calculation_id: params[:id])\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @stats }\r\n end\r\n end", "def query\n\n JSON.parse(Net::HTTP.get(self.build_uri))\n\n end", "def search_result\n query = search_params.presence && search_params\n results = query.present? ? helpers.search_query(query) :helpers.create_query(current_user)\n render json: {:data => results, :total => results.results.total}\n end", "def filtered_results\n results = PropertyResults.paginated_results(params[:facets], params[:page], params[:per_page], params[:offset], params[:query])\n respond_to do |format|\n format.json { render json: results.to_json }\n end\n end", "def index\n @requests = Request.all\n\n render json: @requests\n end", "def show\n render pretty_json: Search.of(params[:id])\n end", "def results; end", "def results; end", "def results; end", "def fetch\n fetch_response.results\n end", "def raw_results\n results\n end", "def index\n @players = Player.search(params[:team_id], params[:player_forename], params[:player_surename])\n\n respond_to do |format|\n format.html # index.html.erb\n hash = {:players => @players}\n format.json { render :json => hash }\n end\n end", "def index\n @results = Admin::Result.index.paginate(page: params[:page], per_page: 20)\n end", "def index\n @api_v1_locations = Api::V1::Location.all\n respond_to do |format|\n format.html { @api_v1_locations }\n format.json { render json: {results: @api_v1_locations, message: 'Locations have loaded successfully.'} }\n end\n end", "def index\n @distros = getmydata(\"Distro\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @distros }\n end\n end", "def index \n artists = Artist.all \n render json: artists \n end", "def index\n @requests = Request.all\n\n respond_to do |format|\n format.json { render :json => @requests}\n end\n end" ]
[ "0.73266965", "0.6979273", "0.69192237", "0.6817701", "0.67208", "0.6713047", "0.6713047", "0.66786873", "0.66508305", "0.66351783", "0.66351783", "0.66351783", "0.66351783", "0.6609092", "0.66036445", "0.65753514", "0.6566137", "0.64380974", "0.6395807", "0.63874984", "0.63825446", "0.63717514", "0.6371065", "0.6341115", "0.63237095", "0.62753654", "0.62717694", "0.6256941", "0.62498903", "0.6247879", "0.6216595", "0.620873", "0.62041825", "0.6186597", "0.6176413", "0.6176214", "0.6163217", "0.6159709", "0.61340797", "0.61243033", "0.6117008", "0.6090334", "0.6089826", "0.6085473", "0.6075838", "0.6074107", "0.60688883", "0.60662204", "0.60641646", "0.6061201", "0.6059082", "0.6049778", "0.6044316", "0.60382646", "0.6032666", "0.60309035", "0.60309035", "0.6026996", "0.60250396", "0.60229206", "0.6018585", "0.6015424", "0.60083675", "0.60081095", "0.60047644", "0.6000067", "0.599206", "0.5991236", "0.598898", "0.5982412", "0.5972443", "0.596858", "0.5965061", "0.59642553", "0.5961545", "0.59587765", "0.59576726", "0.5953421", "0.59462935", "0.5943059", "0.59389454", "0.59341717", "0.5933839", "0.5931881", "0.5930914", "0.5929737", "0.5917087", "0.5914272", "0.59106505", "0.5910614", "0.59060556", "0.59060556", "0.59060556", "0.5905401", "0.59046495", "0.5904423", "0.59028816", "0.5899051", "0.5895901", "0.58928686", "0.5886123" ]
0.0
-1
POST /results POST /results.json
def create @result = Result.new(result_params) respond_to do |format| if @result.save format.html { redirect_to @result, notice: 'Result was successfully created.' } format.json { render :show, status: :created, location: @result } else format.html { render :new } format.json { render json: @result.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end", "def create\n #TODO we need to look into the need for transactions in mongodb\n #Api::V1::Result.with_session do |session|\n #session.start_transaction\n @results = []\n result_params = params.fetch(:result, {})\n\n result_params.each do |rp|\n permitted_rp = rp.permit(*Api::V1::Result::STRONG_PARAMETERS)\n result = Api::V1::Result.new(permitted_rp)\n result.save!\n\n @results << result\n end\n\n #session.commit_transaction\n #end\n\n render json: @results\n end", "def result_params\n params[:results]\n end", "def create\n search_term = params[\"query\"][\"search_term\"]\n results = api_request_results(search_term)\n\n #movie = OwnedMovie.create(title: response[\"title\"], poster: response[\"poster_path\"], description: response[\"overview\"])\n\n #movie.save!\n\n results.each do |result|\n print result['title'] + \"\\n\"\n end \n\n @results = results\n\n\n redirect_to \"/\"\n end", "def create\n \tredirect_to results_path\n end", "def index\n @results = Result.all\n @results = Result.paginate(:per_page => 15, :page => params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @results }\n end\n end", "def index\n @results = Result.all\n end", "def index\n @results = Result.all\n end", "def index\n @results = Result.all\n\n end", "def create\n #p params\n if params[:results].present? && params[:results][:answers].present?\n answers = params[:results][:answers] \n params[:results].delete :answers\n #params[:aspects]=params[:aspects]+1\n end\n\n #p \"Array?: \" + params[:results][:aspects].is_a?(Array).to_s\n #p \"String?: \" + params[:results][:aspects].is_a?(String).to_s\n \n @results = Result.create(params[:results])\n if answers\n answers.each do |answer|\n @results.answers.build(answer)\n end\n end\n\n if @results.save\n\n # @results.send_email\n @results.delay.send_email\n end\n\n respond_with(@results)\n end", "def search_result\n query = search_params.presence && search_params\n results = query.present? ? helpers.search_query(query) :helpers.create_query(current_user)\n render json: {:data => results, :total => results.results.total}\n end", "def index\n @ptest_results = PtestResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ptest_results }\n end\n end", "def index\n @results = Result.all\n end", "def results \n if (params['location'].blank?)\n redirect_to :action => 'index'\n return\n end\n \n @venues = FoursquareVenueQuery.query(params['location']['latitude'], params['location']['longitude'])\n @reviews = {}\n \n @venues.each do |venue|\n review = Review.find_by_venue_id(venue['id'])\n \n unless (review == nil)\n @reviews[venue['id']] = review\n else\n @reviews[venue['id']] = Review.new # I don't like dealing with nils in the view\n end\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => '' }\n end\n end", "def create\n @result = Result.new(result_params)\n\n respond_to do |format|\n if @result.save\n format.html { redirect_to welcome_index_path, notice: 'Result was successfully created.' }\n format.json { render :show, status: :created, location: @result }\n else\n format.html { render :new }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def results\n # lat, lng, and term from user.js AJAX get request\n p params\n @lat = params[:lat]\n @long = params[:lng]\n term = params[:term]\n yelp_params = { term: term, limit: 5, sort: 1}\n coordinates = { latitude: @lat, longitude: @long }\n new_search = Yelp.client.search_by_coordinates(coordinates, yelp_params)\n # TODO - refactor into a separate function\n p new_search\n new_search.businesses.each do |business|\n \t result_name = business.name\n result_distance = business.distance\n \t result_address = business.location.address\n \t result_lat = business.location.coordinate.latitude\n \t result_long = business.location.coordinate.longitude\n \t # result_review = business.review_count\n \t # result_rating = business.rating\n end \n render json: new_search\n end", "def index\n @survey = Survey.find(params[:survey_id])\n @results = @survey.results.all\n end", "def create\n @result = Result.new(result_params)\n\n respond_to do |format|\n if @result.save\n format.html { redirect_to @result, notice: 'Result was successfully created.' }\n format.json { render action: 'show', status: :created, location: @result }\n else\n format.html { render action: 'new' }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @result = Result.new(result_params)\n\n respond_to do |format|\n if @result.save\n format.html { redirect_to @result, notice: 'Result was successfully created.' }\n format.json { render action: 'show', status: :created, location: @result }\n else\n format.html { render action: 'new' }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @result = Result.new(params[:result])\n\n respond_to do |format|\n if @result.save\n format.html { redirect_to @result, notice: 'Result was successfully created.' }\n format.json { render json: @result, status: :created, location: @result }\n else\n format.html { render action: \"new\" }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @result = Result.new(params[:result])\n\n respond_to do |format|\n if @result.save\n format.html { redirect_to @result, notice: 'Result was successfully created.' }\n format.json { render json: @result, status: :created, location: @result }\n else\n format.html { render action: \"new\" }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def search\n results = @test.search(test_params)\n return render json: {results: results, total: results.total_entries}\n end", "def results\n response['data']\n end", "def upload_results(yaml, results_url='http://localhost:3000/test_results')\n begin\n url = URI.parse(results_url)\n response = Net::HTTP.post_form url, {:results => yaml}\n rescue Errno::ECONNREFUSED => e\n say 'Unable to post test results. Can\\'t connect to the results server.'\n rescue => e\n say e.message\n else\n case response\n when Net::HTTPSuccess\n body = YAML::load(response.body)\n url = body[:data][0] if body[:data]\n say \"Test results posted successfully! \\n\\t#{url}\"\n when Net::HTTPRedirection\n upload_results yaml, response.fetch('Location')\n when Net::HTTPNotFound\n say %q[Unable to find where to put the test results. Try: `gem update rubygems-test`]\n when Net::HTTPClientError\n say %q[Results server didn't like the results submission. Try: `gem update rubygems-test`]\n when Net::HTTPServerError\n say %q[Oof. Something went wrong on the results server processing these results. Sorry!]\n else\n say %q[Something weird happened. Probably a bug.]\n end\n end\n end", "def results\n respond_to do |format|\n format.html do\n content = get_content('opportunities/results.yml')\n results = Search.new(params, limit: 500).run\n @subscription = SubscriptionForm.new(results).data\n @page = PagePresenter.new(content)\n @results = OpportunitySearchResultsPresenter.new(content, results)\n render layout: 'results'\n end\n format.any(:atom, :xml) do\n results = Search.new(params, limit: 500,\n results_only: true,\n sort: 'updated_at').run\n @query = AtomOpportunityQueryDecorator.new(results, view_context)\n render :index, formats: :atom\n end\n end\n end", "def redirect_to_results\n redirect_to results_path(params[:query])\n end", "def index\n get_results\n end", "def results\n send_query\n end", "def create\n @simple_search = SimpleSearch.new(simple_search_params)\n get_response(params)\n respond_to do |format|\n format.html { render :index}\n format.json { render :index, status: 200 }\n end\n end", "def publish_results\n @contestproblem.corrected!\n \n compute_new_contest_rankings(@contest)\n \n automatic_results_published_post(@contestproblem)\n \n redirect_to @contestproblem\n end", "def index\n @evaluation_results = EvaluationResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluation_results }\n end\n end", "def results\n with_monitoring do\n response = perform(:get, results_url, query_params)\n Search::ResultsResponse.from(response)\n end\n rescue => e\n handle_error(e)\n end", "def create\n @result = nil\n if (params.has_key?(:result) && params[:result][:type] == \"ResultDoubles\")\n @result = ResultDoubles.new(params[:result])\n else\n @result = Result.new(params[:result])\n end\n\n respond_to do |format|\n if @result.save\n calculate_ratings(@result)\n format.html { redirect_to :controller => \"home\", :action => \"index\", notice: 'Result was successfully created.' }\n format.json { render json: @result, status: :created, location: @result }\n else\n format.html { render action: \"new\" }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_results\n\t\trace_id = params[:id]\n\t\t\n\t\trace = Race.find_by_id(race_id)\n\t\tresults = Result.get_race_results(race_id)\n\t\t\n\t\trender :json=>{:results=>results}\n\tend", "def index\n party_results = Event.party(params[:event], params[:location],\n params[:time], params[:category])\n @results = JSON.parse(party_results)\n\n # twitter_results = Event.twitter_search(params[:event])\n # @twitter_results = Event.twitter_search(response)\n # Event.create\n end", "def filtered_results\n results = PropertyResults.paginated_results(params[:facets], params[:page], params[:per_page], params[:offset], params[:query])\n respond_to do |format|\n format.json { render json: results.to_json }\n end\n end", "def results\n send_query\n end", "def create\n @survey_result = SurveyResult.new(params[:survey_result])\n\n respond_to do |format|\n if @survey_result.save\n format.html { redirect_to @survey_result, notice: 'Survey result was successfully created.' }\n format.json { render json: @survey_result, status: :created, location: @survey_result }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @results = Result.where(:student_id => @student.id)\n .order('result_date desc')\n .paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @results }\n end\n end", "def create\n @survey_result = SurveyResult.new(survey_result_params)\n\n respond_to do |format|\n if @survey_result.save\n format.html { redirect_to @survey_result, notice: 'Survey result was successfully created.' }\n format.json { render :show, status: :created, location: @survey_result }\n else\n format.html { render :new }\n format.json { render json: @survey_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def results_info\n render json: {results: @experiment.results, error_reason: @experiment.error_reason}\n end", "def index\n @searches = Search.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @searches }\n end\n end", "def judge_results\n result = params[\"result\"]\n channel = params[\"channel\"]\n\n Danthes.publish_to channel, :result => result\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end", "def results\n index.results\n end", "def print_results(response)\n puts response.to_json\nend", "def index\n @am_results = AmResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @am_results }\n end\n end", "def index\n @submission_results = SubmissionResult.all\n end", "def report_results(result, score)\n api_token = ENV[\"API_TOKEN\"]\n test_url = ENV[\"API_URL\"]\n track_id = ENV[\"TRACK_ID\"]\n\n test_number = result.name[5..6]\n if test_number == \"58\" #final test code\n puts \"Congratulations on passing the tests!\"\n passed_tests = true\n end\n\n if api_token && test_url && (result.result_code != '.' || passed_tests)\n puts \"Reporting results...\"\n require \"net/http\"\n params = {'test_number'=> score,\n 'api_token' => api_token,\n 'track_id' => track_id\n }\n begin\n res = Net::HTTP.post_form(URI.parse(test_url), params)\n if res.code == \"200\"\n puts \"Results successfully submitted to #{test_url}\"\n end\n rescue\n puts \"Failed to submit results.\"\n end\n end\n end", "def index\n @results = Result.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @results }\n end\n end", "def search\n @q = params[:q]\n @results = Series.external_search(@q)\n\n respond_to do |format|\n format.html # search.html.haml\n format.json { render json: @results.to_json }\n end\n end", "def index\n @searches = Sunspot.search(Drug, Review, Condition) do\n fulltext params[:search]\n end\n @results=@searches.results\n @drugresults=Array.new\n @conditionresults=Array.new\n @reviewresults=Array.new\n @results.each do |result|\n if result.instance_of?Drug\n @drugresults.push(result)\n elsif result.instance_of?Condition\n @conditionresults.push(result)\n else\n @reviewresults.push(result)\n end\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @searches }\n end\n end", "def create\n @test_result = TestResult.new(test_result_params)\n\n respond_to do |format|\n if @test_result.save\n format.html { redirect_to @test_result, notice: 'Test result was successfully created.' }\n format.json { render :show, status: :created, location: @test_result }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @test_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def response(env)\n env.trace :response_beg\n\n result_set = fetch_twitter_search(env.params['q'])\n\n fetch_trstrank(result_set)\n \n body = JSON.pretty_generate(result_set)\n\n env.trace :response_end\n [200, {}, body]\n end", "def create\n rendered_time, referer, user = tracking_info\n assessment_result = user.assessment_results.create!(\n assessment_id: params[:assessment_id],\n eid: params[:eid],\n src_url: params[:src_url],\n external_user_id: params[:external_user_id],\n identifier: params['identifier'],\n rendered_datestamp: rendered_time,\n referer: referer,\n ip_address: request.ip,\n session_status: 'initial')\n\n assessment_result.keyword_list.add(params[:keywords], parse: true) if params[:keywords]\n assessment_result.objective_list.add(params[:objectives], parse: true) if params[:objectives]\n assessment_result.save! if params[:objectives] || params[:keywords]\n respond_with(:api, assessment_result)\n end", "def json_to_results(json)\n json.map do |jr|\n uri = URI(jr['url'])\n # ignore the query string, since it may have some randomness\n uri.query = nil\n Result.new(project.name, jr['confidence'], jr['risk'], uri.to_s, jr['param'], jr['alert'])\n end\n end", "def results\n get_results(true)\n render :partial => (params[:result_partial] || 'results')\n end", "def create\n @result = Result.new(result_params)\n\n respond_to do |format|\n if @result.save\n format.html do\n flash[:notice] = 'Result was successfully created.'\n\n redirect_to(@result)\n end\n format.xml { render :xml => @result, :status => :created, :location => @result }\n format.json { render :json => @result.to_json }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @result.errors, :status => :unprocessable_entity }\n format.json { render :json => @result.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @results = FourSquare.new(foursquare_params).search\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end", "def results\n raw_input = params[:search].to_s\n formatted_input = raw_input.gsub(\" \", \"+\")\n\n @client = HTTParty.get(\"http://api.shopstyle.com/api/v2/products?pid=uid5001-30368749-95&fts='#{formatted_input}'&offset=0&limit=20\")\n\n render json: @client\n end", "def populate_results(json)\n # page = json[\"page\"]\n # results = json[\"results\"].map{|r| SearchResult.new(r)}\n # start = (page - 1) * 10\n # @results[start, results.length] = results\n @results = json[\"results\"].map{|r| SearchResult.new(r)}\n end", "def create\n @result = Result.new(result_params)\n @result.status = Status.find_by_default(true)\n\n respond_to do |format|\n if @result.save\n format.html { redirect_to @result, notice: 'Result was successfully created.' }\n format.json { render json: @result, status: :created, location: @result }\n else\n format.html { render action: \"new\" }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @hits = Hit.order(\"created_at DESC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hits }\n end\n end", "def create\n @query = Query.new(params[:query])\n\n respond_to do |format|\n if @query.save\n run_query\n @results = @query.results\n \n flash[:notice] = 'Query was successfully created.'\n format.html { redirect_to(@query) }\n format.xml { render :xml => @query, :status => :created, :location => @query }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @query.errors, :status => :unprocessable_entity }\n end\n end\n end", "def addRecipe\n\n params['results'].each do |result|\n recipe = Recipe.new\n recipe.title = result[1]['name']\n if result[1]['images'] &&\n result[1]['images'].values.first[\"large_image_path\"] != '/photos/large/missing.png'\n # deal with ridiculous image nesting\n recipe.image_url = result[1]['images'].values.first[\"large_image_path\"]\n else\n recipe.image_url = nil # for recipes with no images\n end\n recipe.description = result[1]['description']\n recipe.method = result[1]['instructions']\n recipe.ingredients = result[1]['ingredients']\n recipe.cook_time = 15 + rand(26)\n recipe.nbr_times_cooked = 5 + rand(146)\n recipe.user_rating = 1 + rand(5)\n if recipe.image_url\n recipe.save\n else\n next\n end\n end\n\n redirect_to root_path # lol this don't work no good\n\n end", "def create\n @test_result = TestResult.new(params[:test_result])\n\n respond_to do |format|\n if @test_result.save\n format.html { redirect_to @test_result, notice: 'Test result was successfully created.' }\n format.json { render json: @test_result, status: :created, location: @test_result }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def results\n respond_to do |format|\n if params[:search].present?\n @search = CompatibilitySearchForm.new(search_params)\n @search.user = current_user\n if @search.save\n @compatibility_search = @search.compatibility_search\n format.html\n format.js\n else\n format.html\n format.js\n end\n else\n format.html { redirect_to find_index_path }\n end\n end\n end", "def index\n @search = Sunspot.search Generator do\n fulltext params[:query_generator]\n end\n @generators = @search.results\n respond_to do |format|\n format.html\n format.json {render :json => @generators.map(&:attributes) }\n end\nend", "def search_results\n @term = sname = request.query_parameters[\"search\"].to_s.downcase\n data = search_term(sname)\n @top = []\n @rest = []\n data[:results].each do |type|\n type[:matches].each do |hit|\n if hit[:score] >= 1.0\n @top << hit\n else\n @rest << hit\n end\n end\n end\n @top.sort! { |a, b| b[:score] <=> a[:score] }\n @rest.sort! { |a, b| b[:score] <=> a[:score] }\n render \"site/results\"\n end", "def index\n @test_results = TestResult.all\n end", "def create\n @submission_result = SubmissionResult.new(submission_result_params)\n\n respond_to do |format|\n if @submission_result.save\n format.html { redirect_to @submission_result, notice: 'Submission result was successfully created.' }\n format.json { render action: 'show', status: :created, location: @submission_result }\n else\n format.html { render action: 'new' }\n format.json { render json: @submission_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_saved_search(query)\n post(\"/saved_searches/create.json\", :query => query)\n end", "def index\n @saved_searches = SavedSearch.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @saved_searches }\n end\n end", "def results\n respond_to do |format|\n if params[:search].present?\n @search = CheckSearchForm.new(search_params)\n @search.user = current_user\n if @search.save\n @check_search = @search.check_search\n format.html\n format.js\n else\n format.html\n format.js\n end\n else\n format.html { redirect_to check_index_path }\n end\n end\n end", "def results(test_id, day, month, year, options={})\n args = {testId: test_id, day: day, month: month, year: year}\n .merge(options)\n get('testresult', args)\n end", "def new\n @result = Result.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @result }\n end\n end", "def index\n @searches = @website.searches.all\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @searches }\n end\n end", "def new\n @result = Result.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @result }\n end\n end", "def new\n @result = Result.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @result }\n end\n end", "def new\n @result = Result.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @result }\n end\n end", "def new\n @result = Result.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @result }\n end\n end", "def index\n @campaign_results = CampaignResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @campaign_results }\n end\n end", "def set_post\n \t\t@surveyresults = Surveyresult.find(params[:ResultId])\n \tend", "def create\n @result = Result.new(params[:result])\n\n respond_to do |format|\n if @result.save\n flash[:notice] = 'Result was successfully created.'\n format.html { redirect_to(@result) }\n format.xml { render :xml => @result, :status => :created, :location => @result }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @result.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n passed = true\n count = 0\n if params[:status] == \"listOfAnswers\"\n params[:answers].each do |ans|\n @answer = Answer.new(answers_params(ans))\n if @answer.save\n if @answer.correct\n count = count + 1\n # update_result ans[:user_id], ans[:quiz_id]\n end\n else\n passed = false\n end\n end\n if passed\n create_result params[:answers].first[:user_id], params[:answers].first[:quiz_id], count\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n else\n @answer = Answer.new(answer_params)\n if @answer.save\n if @answer.correct\n update_result\n end\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end\n end", "def results; end", "def results; end", "def results; end", "def create\n\n reviews = []\n params[:scores].keys.each{ |name|\n score = params[:scores][name]\n peer_review = PeerReview.new(name:name, score:score, miniproject_id:params[:project][:id])\n peer_review.save\n reviews << peer_review\n }\n\n render json: reviews\n\n end", "def results(path, params = {}, opts = {})\n get(path, params, opts)['results']\n end", "def index\n @search = Problem.search(params[:q])\n @problems = @search.result.paginate(:page => params[:page], :per_page => 10).order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @problems }\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def create\n @search = Search.new(search_params)\n\n respond_to do |format|\n if @search.save\n format.html { redirect_to action: 'new', query: @search.query }\n format.json { render :show, status: :created, location: @search }\n else\n format.html { redirect_to action: 'new' }\n format.json { render json: @search.errors, status: :unprocessable_entity }\n end\n end\n end", "def results_data\n # Load the service from the database\n load_service(false)\n\n if (!params[:resume].blank?)\n resume = params[:resume].to_sym\n resume = nil if (!Service::AVAILABLE_RESUMES.include?(resume))\n end\n \n if (!@service.blank?)\n # If a last param was received, try to locate the result with that id.\n if ((!params[:last].blank?) && (Result.where(:service => @service.id, :_id => params[:last]).count > 0))\n # Get the results obtained AFTER the one which id was received\n @results = Result.where(:service => @service.id, :_id.gt => params[:last]).desc(:created_at)\n else\n # Get all the reuslts available\n @results = Result.where(:service => @service.id).desc(:created_at)\n end\n\n if ((!params[:limit].blank?) && (params[:limit].to_i.to_s == params[:limit]))\n @results = @results.limit(params[:limit].to_i)\n end\n end\n\n @data = {}\n\n if (@service.blank?)\n # If not found, return an error\n @results = {:error => t(\"services.error.not_found\")}\n else\n # Poblate the results array\n @results = @results.to_a.map do |result|\n result = {\n \"id\" => result.id.to_s, \n \"date\" => result.created_at.to_i+result.created_at.utc_offset,\n \"result\" => result.global_value(resume)\n }\n end\n end\n\n respond_to do |format|\n format.json {\n # Render the results\n if (@service.blank?)\n render :json => @results, :status => 404\n else\n render :json => @results\n end\n }\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{uri}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def create\n @insure_results_sub = InsureResultsSub.new(params[:insure_results_sub])\n\n respond_to do |format|\n if @insure_results_sub.save\n format.html { redirect_to @insure_results_sub, :notice => 'Insure results sub was successfully created.' }\n format.json { render :json => @insure_results_sub, :status => :created, :location => @insure_results_sub }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @insure_results_sub.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @results = @search.result.paginate(page: params[:page], per_page: 9).order(created_at: :desc)\n end", "def index\n @survey_results = HTTParty.get('https://shielded-wave-66393.herokuapp.com',\n :headers =>{'Content-Type' => 'application/json'} )\n @survey_results = SurveyResults.all_(current_customer)\n end", "def new\n @survey_result = SurveyResult.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @survey_result }\n end\n end" ]
[ "0.79618156", "0.70347315", "0.6430695", "0.6363882", "0.62522346", "0.6239741", "0.60929143", "0.60929143", "0.60773784", "0.6060322", "0.6051018", "0.60151786", "0.59909177", "0.5975458", "0.59665865", "0.5965483", "0.5954307", "0.59362555", "0.59362555", "0.59213305", "0.59213305", "0.59175646", "0.59122497", "0.5908236", "0.58835727", "0.5858928", "0.58562005", "0.58500904", "0.5830769", "0.58285314", "0.5827049", "0.58188385", "0.5803584", "0.5778099", "0.5771965", "0.57493067", "0.57489365", "0.5748706", "0.57482016", "0.5739754", "0.573949", "0.573303", "0.57210207", "0.5716754", "0.5716464", "0.5699342", "0.56846976", "0.5681304", "0.5679812", "0.56776005", "0.5671153", "0.5642016", "0.56392735", "0.5638983", "0.56363493", "0.56346995", "0.5628446", "0.56269413", "0.56246597", "0.5617454", "0.56117237", "0.56092036", "0.55768067", "0.5574161", "0.5566923", "0.5559389", "0.5549191", "0.5546289", "0.5534799", "0.5520669", "0.54987633", "0.5486115", "0.548255", "0.54806525", "0.54800993", "0.54784083", "0.5469517", "0.5469517", "0.5469517", "0.5469517", "0.54515934", "0.54468733", "0.5445849", "0.5441756", "0.5440573", "0.5440573", "0.5440573", "0.54347974", "0.5429184", "0.542878", "0.54248184", "0.5418047", "0.54156744", "0.5410842", "0.54088193", "0.5401525", "0.5397798", "0.5395967" ]
0.59725726
16
PATCH/PUT /results/1 PATCH/PUT /results/1.json
def update respond_to do |format| if @result.update(result_params) format.html { redirect_to @result, notice: 'Result was successfully updated.' } format.json { render :show, status: :ok, location: @result } else format.html { render :edit } format.json { render json: @result.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update!(**args)\n @results = args[:results] if args.key?(:results)\n end", "def update!(**args)\n @results = args[:results] if args.key?(:results)\n end", "def update\n @result1 = Result1.find(params[:id])\n\n respond_to do |format|\n if @result1.update_attributes(params[:result1])\n format.html { redirect_to @result1, notice: 'Result1 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @result1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @result = Result.find(params[:id])\n\n respond_to do |format|\n if @result.update_attributes(params[:result])\n format.html { redirect_to @result, notice: 'Result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @result = Result.find(params[:id])\n\n respond_to do |format|\n if @result.update_attributes(params[:result])\n format.html { redirect_to @result, notice: 'Result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @result = Result.find(params[:id])\n\n respond_to do |format|\n if @result.update_attributes(params[:result])\n format.html { redirect_to @result, notice: 'Result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @result = Result.find(params[:id])\n\n respond_to do |format|\n if @result.update_attributes(params[:result])\n format.html { redirect_to @result, notice: 'Result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @result.update_attributes(result_params)\n format.html { redirect_to @result, notice: 'Result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @result.update(result_params)\n format.html { redirect_to @result, notice: 'Result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @result.update(result_params)\n format.html { redirect_to @result, notice: 'Result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update!(**args)\n @kind = args[:kind] if args.key?(:kind)\n @results = args[:results] if args.key?(:results)\n end", "def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n @partial_results = args[:partial_results] if args.key?(:partial_results)\n end", "def update!(**args)\n @metadata = args[:metadata] if args.key?(:metadata)\n @results = args[:results] if args.key?(:results)\n end", "def update!(**args)\n @metadata = args[:metadata] if args.key?(:metadata)\n @results = args[:results] if args.key?(:results)\n end", "def update\n @result = Result.find(params[:id])\n\n respond_to do |format|\n if @result.update_attributes(result_params)\n format.js { render :partial => @result }\n format.json { render :json => @result.to_json(:methods => [:name, :bib_number, :category_name]) }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @result.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @result.update(result_params)\n format.html { redirect_to @result, notice: 'result was successfully updated.' }\n format.json { render :show, status: :ok, location: @result }\n else\n format.html { render :edit }\n format.json { render json: @result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", {\"passed\" => success}.to_json, :content_type => :json\nend", "def update\n streak, success = jsonapi_update.to_a\n\n if success\n render_jsonapi(streak, scope: false)\n else\n render_errors_for(streak)\n end\n end", "def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend", "def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend", "def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend", "def update\n @test_result = TestResult.find(params[:id])\n\n respond_to do |format|\n if @test_result.update_attributes(params[:test_result])\n format.html { redirect_to @test_result, notice: 'Test result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n results = result_params\n unless results.nil?\n stay = true\n if results.is_a?(String) #Update comes from online testing\n parts = results.split(\"#\")\n labels = parts[0].split(\",\")\n unless @result.nil?\n @result.parse_csv(parts[1])\n @result.parse_data(labels[1, labels.length-1], parts[2, parts.length-1]) if parts.length > 2\n head 200\n end\n else\n if results.has_key?(\"students\") #Update comes from editing form\n @measurement.update_students(results[\"students\"])\n else\n results.each do |id, val|\n r = @measurement.results.find_by_student_id(id)\n unless r.nil?\n if val.is_a?(String)\n r.parse_csv(val)\n stay = false\n else\n r.parse_Hash(val)\n end\n end\n end\n end\n respond_to do |format|\n format.js {\n unless stay\n render 'assessments/show'\n else\n render :edit\n end\n }\n end\n end\n end\n end", "def update!(**args)\n @job_results = args[:job_results] if args.key?(:job_results)\n end", "def update!(**args)\n @job_results = args[:job_results] if args.key?(:job_results)\n end", "def update!(**args)\n @job_results = args[:job_results] if args.key?(:job_results)\n end", "def update\n @objective_result = ObjectiveResult.find(params[:id])\n\n respond_to do |format|\n if @objective_result.update_attributes(params[:objective_result])\n format.html { redirect_to :back}\n format.json { head :no_content }\n else\n format.html { redirect_to :back }\n format.json { render json: @objective_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @survey_result = SurveyResult.find(params[:id])\n\n respond_to do |format|\n if @survey_result.update_attributes(params[:survey_result])\n format.html { redirect_to @survey_result, notice: 'Survey result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n @result_item = ResultItem.find(params[:id])\n\n respond_to do |format|\n if @result_item.update_attributes(params[:result_item])\n format.html { redirect_to @result_item, notice: 'Result item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @result_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @completion_results = args[:completion_results] if args.key?(:completion_results)\n @metadata = args[:metadata] if args.key?(:metadata)\n end", "def update!(**args)\n @completion_results = args[:completion_results] if args.key?(:completion_results)\n @metadata = args[:metadata] if args.key?(:metadata)\n end", "def update\n respond_to do |format|\n if @external_result.update_attributes(external_result_params)\n format.html { redirect_to competition_external_results_path(@external_result.competition), notice: 'External result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @external_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @result = Result.find(params[:id])\n\n respond_to do |format|\n if @result.update_attributes(params[:result])\n flash[:notice] = 'Result was successfully updated.'\n format.html { redirect_to(@result) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @result.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n head :ok\n end", "def update\n respond_to do |format|\n if @survey_result.update(survey_result_params)\n format.html { redirect_to @survey_result, notice: 'Survey result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @survey_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @submission_result.update(submission_result_params)\n format.html { redirect_to @submission_result, notice: 'Submission result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @submission_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @result = args[:result] if args.key?(:result)\n end", "def update!(**args)\n @result = args[:result] if args.key?(:result)\n end", "def update!(**args)\n @result = args[:result] if args.key?(:result)\n end", "def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @three_result.update(three_result_params)\n format.html { redirect_to @three_result, notice: 'Three result was successfully updated.' }\n format.json { render :show, status: :ok, location: @three_result }\n else\n format.html { render :edit }\n format.json { render json: @three_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n do_patch { return } # check if patch and do submission and return early if it is a patch (submission)\n # otherwise this is a PUT of the dataset metadata\n check_status { return } # check it's in progress, clone a submitted or raise an error\n respond_to do |format|\n format.json do\n dp = if @resource\n DatasetParser.new(hash: params['dataset'], id: @resource.identifier, user: @user) # update dataset\n else\n DatasetParser.new(hash: params['dataset'], user: @user, id_string: params[:id]) # upsert dataset with identifier\n end\n @stash_identifier = dp.parse\n ds = Dataset.new(identifier: @stash_identifier.to_s) # sets up display objects\n render json: ds.metadata, status: 200\n end\n end\n end", "def update_progress_key_result\n key_result_id = params[:id]\n progress = params[:progress]\n initial_progress = params[:initial]\n contribution = params[:contribution]\n progress_decimal = BigDecimal.new(progress)\n initial_progress_decimal = BigDecimal.new(initial_progress)\n personal_key_result = PersonalKeyResult.find(key_result_id) \n\n status = PersonalKeyResult.update_progress_personal_key_result(\n key_result_id,\n progress_decimal,\n initial_progress_decimal,\n contribution,\n current_user.id\n )\n\n respond_to do |format|\n if status == 200\n format.json { render json: 'Progress of the key result is updated successfully!', status: :ok }\n else\n format.json { render json: 'Fail to update progress!', status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @result_info.update(result_info_params)\n format.html { redirect_to @result_info, notice: 'Result info was successfully updated.' }\n format.json { render :show, status: :ok, location: @result_info }\n else\n format.html { render :edit }\n format.json { render json: @result_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_with []\n end", "def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @test_result.update(test_result_params)\n format.html { redirect_to @test_result, notice: 'Test result was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_result }\n else\n format.html { render :edit }\n format.json { render json: @test_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @debug_info = args[:debug_info] if args.key?(:debug_info)\n @error_info = args[:error_info] if args.key?(:error_info)\n @facet_results = args[:facet_results] if args.key?(:facet_results)\n @has_more_results = args[:has_more_results] if args.key?(:has_more_results)\n @query_interpretation = args[:query_interpretation] if args.key?(:query_interpretation)\n @result_count_estimate = args[:result_count_estimate] if args.key?(:result_count_estimate)\n @result_count_exact = args[:result_count_exact] if args.key?(:result_count_exact)\n @result_counts = args[:result_counts] if args.key?(:result_counts)\n @results = args[:results] if args.key?(:results)\n @spell_results = args[:spell_results] if args.key?(:spell_results)\n @structured_results = args[:structured_results] if args.key?(:structured_results)\n end", "def update!(**args)\n @debug_info = args[:debug_info] if args.key?(:debug_info)\n @error_info = args[:error_info] if args.key?(:error_info)\n @facet_results = args[:facet_results] if args.key?(:facet_results)\n @has_more_results = args[:has_more_results] if args.key?(:has_more_results)\n @query_interpretation = args[:query_interpretation] if args.key?(:query_interpretation)\n @result_count_estimate = args[:result_count_estimate] if args.key?(:result_count_estimate)\n @result_count_exact = args[:result_count_exact] if args.key?(:result_count_exact)\n @result_counts = args[:result_counts] if args.key?(:result_counts)\n @results = args[:results] if args.key?(:results)\n @spell_results = args[:spell_results] if args.key?(:spell_results)\n @structured_results = args[:structured_results] if args.key?(:structured_results)\n end", "def update\n respond_to do |format|\n if @test_case_result.update(test_case_result_params)\n format.html { redirect_to @test_case_result, notice: 'Test case result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @test_case_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @test_result.update(test_result_params)\n format.html { redirect_to @test_result, notice: 'Test result was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_result }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @test_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @test_example_result.update(test_example_result_params)\n format.html { redirect_to @test_example_result, notice: 'Test example result was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_example_result }\n else\n format.html { render :edit }\n format.json { render json: @test_example_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n # respond_to do |format|\n # #if @survey_result.update(survey_result_params)\n # if @survey_result = SurveyResult.new(params[:survey_result])\n # format.html { redirect_to user_survey_results_url(survey_user,@survey_result), notice: 'Survey result was successfully updated.' }\n # format.json { head :no_content }\n # else\n # format.html { render action: 'edit' }\n # format.json { render json: @survey_result.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def update\n respond_to do |format|\n if @survey_result.update(survey_result_params)\n format.html { redirect_to @survey_result, notice: 'Survey result was successfully updated.' }\n format.json { render :show, status: :ok, location: @survey_result }\n else\n format.html { render :edit }\n format.json { render json: @survey_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @clustered_results = args[:clustered_results] if args.key?(:clustered_results)\n @debug_info = args[:debug_info] if args.key?(:debug_info)\n @metadata = args[:metadata] if args.key?(:metadata)\n @snippet = args[:snippet] if args.key?(:snippet)\n @title = args[:title] if args.key?(:title)\n @url = args[:url] if args.key?(:url)\n end", "def update!(**args)\n @clustered_results = args[:clustered_results] if args.key?(:clustered_results)\n @debug_info = args[:debug_info] if args.key?(:debug_info)\n @metadata = args[:metadata] if args.key?(:metadata)\n @snippet = args[:snippet] if args.key?(:snippet)\n @title = args[:title] if args.key?(:title)\n @url = args[:url] if args.key?(:url)\n end", "def update\n @progress = Progress.find(params[:id])\n\n respond_to do |format|\n if @progress.update_attributes(params[:progress])\n format.json { head :no_content }\n else\n format.json { render json: @progress.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_progress.update(api_v1_progress_params)\n format.html { redirect_to @api_v1_progress, notice: 'Progress was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_progress }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_progress.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @ptest_result = PtestResult.find(params[:id])\n\n respond_to do |format|\n if @ptest_result.update_attributes(params[:ptest_result])\n format.html { redirect_to @ptest_result, :notice => 'Ptest result was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @ptest_result.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @flsa_result = FlsaResult.find(params[:id])\n\n respond_to do |format|\n if @flsa_result.update_attributes(params[:flsa_result])\n format.html { redirect_to @flsa_result, notice: 'Flsa result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @flsa_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @am_result = AmResult.find(params[:id])\n\n respond_to do |format|\n if @am_result.update_attributes(params[:am_result])\n format.html { redirect_to @am_result, notice: 'Am result was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @am_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_resource.update(api_v1_resource_params)\n format.html { redirect_to @api_v1_resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_resource }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update\n results = fact_params.to_h\n results[\"tags\"] = Tag.where(id: [results[\"tags\"].split(\",\")])\n\n respond_to do |format|\n if @fact.update(results)\n format.html { redirect_to [:admin, :facts], notice: \"Fact was successfully updated.\" }\n format.json { render :show, status: :ok, location: @fact }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @fact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @job_result.update(job_result_params)\n format.html { redirect_to @job_result, notice: 'Job result was successfully updated.' }\n format.json { render :show, status: :ok, location: @job_result }\n else\n format.html { render :edit }\n format.json { render json: @job_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n# respond_to do |format|\n# if @req.update(req_params)\n format.json { render :json => {:status => 'success'}}\n# format.html { redirect_to @req, notice: 'Req was successfully updated.' }\n# format.json { render :show, status: :ok, location: @req }\n# else\n format.json { render :json => {:status => 'failed'}}\n# format.html { render :edit }\n# format.json { render json: @req.errors, status: :unprocessable_entity }\n# end\n# end\n end", "def update\n document = Document.find(params[:id])\n document.update!(update_params)\n render json: {}\n end", "def update!(**args)\n @lint_results = args[:lint_results] if args.key?(:lint_results)\n end", "def update\n respond_to do |format|\n # Everytime when progress is being updated, update the team OKR progress and company OKR progress\n if @personal_key_result.update(personal_key_result_params)\n format.html { redirect_to @personal_key_result, notice: 'Personal key result was successfully updated.' }\n format.json { render :show, status: :ok, location: @personal_key_result }\n else\n format.html { render :edit }\n format.json { render json: @personal_key_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render_json_auto @survey.update_filter(params[:id].to_i, params[:filter]) and return\n end", "def update\n respond_to do |format|\n if @check_result.update(check_result_params)\n format.html { redirect_to @check_result, notice: 'Check Result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @check_result.errors, status: :internal_server_error }\n end\n end\n\n end", "def update!(**args)\n @simple_responses = args[:simple_responses] if args.key?(:simple_responses)\n end", "def update!(**args)\n @simple_responses = args[:simple_responses] if args.key?(:simple_responses)\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\nrespond_to do |format|\nif @result.update(result_params)\nformat.html { redirect_to @result, notice: 'Zmieniono wyniki.' }\nformat.json { render :show, status: :ok, location: @result }\nelse\nformat.html { render :edit }\nformat.json { render json: @result.errors, status: :unprocessable_entity }\nend\nend\nend", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end", "def update_rest\n @entry_answer = EntryAnswer.find(params[:id])\n\n respond_to do |format|\n if @entry_answer.update_attributes(params[:entry_answer])\n flash[:notice] = 'EntryAnswer was successfully updated.'\n format.html { redirect_to(@entry_answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_answer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @result_second.update(result_second_params)\n format.html { redirect_to @result_second, notice: 'Result second was successfully updated.' }\n format.json { render :show, status: :ok, location: @result_second }\n else\n format.html { render :edit }\n format.json { render json: @result_second.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @criterion = Criterion.find(params[:id])\n\n if @criterion.update_attributes(params[:criterion])\n head :no_content\n else\n render json: @criterion.errors, status: :unprocessable_entity\n end\n end", "def partial_update(klass, id, patchset, options = {}, format = nil)\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n options = { resource: klass, id: id, format: format}.merge options\n if [FHIR::Formats::ResourceFormat::RESOURCE_XML, FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_XML\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_XML}\"\n elsif [FHIR::Formats::ResourceFormat::RESOURCE_JSON, FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_JSON\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_JSON}\"\n end\n headers[:prefer] = @return_preference if @use_return_preference\n reply = patch resource_url(options), patchset, fhir_headers(headers)\n reply.resource = parse_reply(klass, format, reply)\n reply.resource_class = klass\n reply\n end", "def update\n @result = Result.find(@given_answer.result_id)\n correctness = @given_answer.correct_answer\n respond_to do |format|\n if @given_answer.update(given_answer_params)\n if correctness.nil?\n if @given_answer.correct_answer\n @result.total_number_of_correct_answers += 1\n end\n else\n if correctness != @given_answer.correct_answer\n if correctness && !@given_answer.correct_answer\n @result.total_number_of_correct_answers -= 1\n else\n @result.total_number_of_correct_answers += 1\n end\n end\n end\n @result.save\n \n format.html { redirect_to @given_answer, notice: 'Given answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @given_answer }\n else\n format.html { render :edit }\n format.json { render json: @given_answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :manage, @vspec\n\n respond_to do |format|\n if @vspec.update(vspec_params)\n format.html { redirect_to [@vspec.metric, @vspec], notice: 'Vspec was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vspec.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def update\n respond_to do |format|\n if @status.update(isshared: params[:isshared])\n format.json { head :no_content }\n else\n format.json {\n render json: @status.errors,\n status: :unprocessable_entity\n }\n end\n end\n end", "def update\n respond_to do |format|\n if @rest.update(rest_params)\n format.html { redirect_to @rest, notice: 'Rest was successfully updated.' }\n format.json { render :show, status: :ok, location: @rest }\n else\n format.html { render :edit }\n format.json { render json: @rest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n job = Job.find(params[:id])\n job.update_attributes(job_params)\n render json: job\n end", "def update\n @pycontextnlp_result = PycontextnlpResult.find(params[:id])\n\n respond_to do |format|\n if @pycontextnlp_result.update_attributes(params[:pycontextnlp_result])\n format.html { redirect_to @pycontextnlp_result, notice: 'Pycontextnlp result was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pycontextnlp_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n put :update\n end", "def update\n @hit = Hit.find(params[:id])\n\n respond_to do |format|\n if @hit.update_attributes(params[:hit])\n format.html { redirect_to @hit, notice: 'Hit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end" ]
[ "0.6633545", "0.6633545", "0.65372896", "0.6470854", "0.6470854", "0.6470854", "0.6470854", "0.64311457", "0.6374878", "0.6374878", "0.6242018", "0.62343436", "0.622704", "0.6226439", "0.6225598", "0.61800575", "0.6157412", "0.61360973", "0.6116793", "0.61038065", "0.61038065", "0.61038065", "0.6091549", "0.60693043", "0.6062995", "0.6062995", "0.60619575", "0.60558677", "0.60289097", "0.5993298", "0.59873587", "0.59797734", "0.59797734", "0.5965066", "0.5960223", "0.5957802", "0.59432685", "0.59417367", "0.59285843", "0.59285843", "0.59285843", "0.58817565", "0.5872683", "0.5859597", "0.5846958", "0.5845277", "0.58376914", "0.58367896", "0.58363664", "0.5836354", "0.5836354", "0.58341265", "0.58333075", "0.58233076", "0.58227086", "0.5815807", "0.5798766", "0.5793163", "0.5793163", "0.5784372", "0.57789147", "0.5775935", "0.57692444", "0.57650447", "0.57645524", "0.5764295", "0.5763094", "0.5760933", "0.57489824", "0.5748272", "0.5742398", "0.573876", "0.57340276", "0.5729154", "0.57204854", "0.57104677", "0.57063025", "0.5706085", "0.56988317", "0.5697786", "0.56938124", "0.56905085", "0.56897944", "0.5679133", "0.5675194", "0.5674106", "0.56669456", "0.56665117", "0.56638926", "0.5662279", "0.5662279", "0.5655006", "0.5652853", "0.5649242", "0.5648812", "0.56432647", "0.5641391", "0.56410104" ]
0.6221451
17
DELETE /results/1 DELETE /results/1.json
def destroy @result.destroy respond_to do |format| format.html { redirect_to results_url, notice: 'Result was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @result.destroy\n\n respond_to do |format|\n format.html { redirect_to results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @result = Result.find(params[:id])\n @result.destroy\n\n respond_to do |format|\n format.html { redirect_to results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @result = Result.find(params[:id])\n @result.destroy\n\n respond_to do |format|\n format.html { redirect_to results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @result = Result.find(params[:id])\n @result.destroy\n\n respond_to do |format|\n format.html { redirect_to results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @result = Result.find(params[:id])\n @result.destroy\n\n respond_to do |format|\n format.html { redirect_to results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @result = Result.find(params[:id])\n @result.destroy\n\n respond_to do |format|\n format.html { redirect_to results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @result1 = Result1.find(params[:id])\n @result1.destroy\n\n respond_to do |format|\n format.html { redirect_to result1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @result.destroy\n respond_to do |format|\n format.html { redirect_to results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @result.destroy\n respond_to do |format|\n format.html { redirect_to results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @result = Result.find(params[:id])\n @result.destroy\n\n respond_to do |format|\n format.html { redirect_to(results_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @result = Result.find(params[:id])\n @result.destroy\n\n respond_to do |format|\n format.html { redirect_to(results_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @result = Result.find(params[:id])\n @result.destroy\n\n respond_to do |format|\n format.html { redirect_to(results_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @test_result = TestResult.find(params[:id])\n @test_result.destroy\n\n respond_to do |format|\n format.html { redirect_to test_results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @result.destroy\n respond_to do |format|\n format.html { redirect_to results_url, notice: 'result was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey_result = SurveyResult.find(params[:id])\n @survey_result.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_case_result.destroy\n respond_to do |format|\n format.html { redirect_to test_case_results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @three_result.destroy\n respond_to do |format|\n format.html { redirect_to three_results_url, notice: 'Three result was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @result = Result.find(params[:id])\n @result.destroy\n\n respond_to do |format|\n format.html { redirect_to student_results_path(@student) }\n format.json { head :no_content }\n end\n end", "def destroy\n @am_result = AmResult.find(params[:id])\n @am_result.destroy\n\n respond_to do |format|\n format.html { redirect_to am_results_url }\n format.json { head :ok }\n end\n end", "def destroy\n @survey_result.destroy\n respond_to do |format|\n format.html { redirect_to survey_results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @result_item = ResultItem.find(params[:id])\n @result_item.destroy\n\n respond_to do |format|\n format.html { redirect_to result_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @objective_result = ObjectiveResult.find(params[:id])\n @objective_result.destroy\n\n respond_to do |format|\n format.html { redirect_to objective_results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_result.destroy\n respond_to do |format|\n format.html { redirect_to test_results_url, notice: 'Test result was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_result.destroy\n respond_to do |format|\n format.html { redirect_to test_results_url, notice: 'Test result was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @flsa_result = FlsaResult.find(params[:id])\n @flsa_result.destroy\n\n respond_to do |format|\n format.html { redirect_to flsa_results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n@result.destroy\nrespond_to do |format|\nformat.html { redirect_to results_url, notice: 'Wynik został usunięty.' }\nformat.json { head :no_content }\nend\nend", "def destroy\n @test_example_result.destroy\n respond_to do |format|\n format.html { redirect_to test_example_results_url, notice: 'Test example result was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_results_from_file.destroy\n respond_to do |format|\n format.html { redirect_to uploaded_test_results_url, notice: 'Document destroyed successfully.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @ptest_result = PtestResult.find(params[:id])\n @ptest_result.destroy\n\n respond_to do |format|\n format.html { redirect_to ptest_results_url }\n format.json { head :ok }\n end\n end", "def destroy\n @submission_result.destroy\n respond_to do |format|\n format.html { redirect_to submission_results_url }\n format.json { head :no_content }\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 @two_result.destroy\n respond_to do |format|\n format.html { redirect_to two_results_url, notice: 'Two result was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n # @survey_result.destroy\n # respond_to do |format|\n # format.html { redirect_to user_survey_results_url(survey_user,@survey_results) }\n # format.json { head :no_content }\n # end\n end", "def destroy\n @insure_result = InsureResult.find(params[:id])\n @insure_result.destroy\n\n respond_to do |format|\n format.html { redirect_to insure_results_url }\n format.json { head :ok }\n end\n end", "def destroy\n @external_result.destroy\n\n respond_to do |format|\n format.html { redirect_to competition_external_results_path(@competition) }\n format.json { head :no_content }\n end\n end", "def destroy\n streak, success = jsonapi_destroy.to_a\n\n if success\n render json: { meta: {} }\n else\n render_errors_for(streak)\n end\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def destroy\n @evaluation_result = EvaluationResult.find(params[:id])\n @evaluation_result.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluation_results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n render_json_auto @survey.delete_filter(params[:id].to_i) and return\n end", "def destroy\n @user_result.destroy\n respond_to do |format|\n format.html { redirect_to user_results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @omikuji_result.destroy\n respond_to do |format|\n format.html { redirect_to omikuji_results_url, notice: 'Omikuji result was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @survey_result.destroy\n respond_to do |format|\n format.html { redirect_to survey_results_url, notice: 'Survey result was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @suite_result = SuiteResult.find(params[:id])\n @suite_result.destroy\n\n respond_to do |format|\n format.html { redirect_to suite_results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @crawl_result = Crawl.find(params[:id])\n @crawl_result.destroy\n\n respond_to do |format|\n format.html { redirect_to(crawl_results_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exam_result.destroy\n respond_to do |format|\n format.html { redirect_to exam_results_url, notice: 'Exam result was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_progress.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_progresses_url, notice: 'Progress was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_run.destroy\n respond_to do |format|\n format.html { redirect_to test_runs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fixturestat = Fixturestat.find(params[:id])\n @fixturestat.destroy\n\n respond_to do |format|\n format.html { redirect_to fixturestats_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @campaign_result = CampaignResult.find(params[:id])\n @campaign_result.destroy\n\n respond_to do |format|\n format.html { redirect_to campaign_results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @saved_query.destroy\n respond_to do |format|\n format.html { redirect_to saved_queries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @four_result.destroy\n respond_to do |format|\n format.html { redirect_to four_results_url, notice: 'Four result was successfully destroyed.' }\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 @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_run = TestRun.find(params[:id])\n @test_run.destroy\n\n respond_to do |format|\n format.html { redirect_to test_runs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @result.destroy\n respond_to do |format|\n format.html { redirect_to results_url, notice: '販売活動を削除しました。' }\n format.json { head :no_content }\n end\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @test = LoadTest.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to load_tests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @checkresult = Checkresult.find(params[:id])\n @checkresult.destroy\n\n respond_to do |format|\n format.html { redirect_to checkresults_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def destroy\n @insure_results_sub = InsureResultsSub.find(params[:id])\n @insure_results_sub.destroy\n\n respond_to do |format|\n format.html { redirect_to insure_results_subs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @result_info.destroy\n respond_to do |format|\n format.html { redirect_to result_infos_url, notice: 'Result info was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @heat_lane_result.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def delete_by_query index, query, conflicts_proceed\n conflicts = conflicts_proceed ? 'conflicts=proceed' : ''\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/_delete_by_query?#{conflicts}\")\n\n req = Net::HTTP::Post.new(uri)\n req.body = query.to_json\n run(uri, req)\n end", "def destroy\r\n @wai = WaisResult.find(params[:id])\r\n @wai.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to wais_results_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def delete(project_token = @project_token, id = @id, user = @@default_user)\n @attributes = send_request(\"test_run_results/#{id}\", :delete) do |req|\n req.body = {\n token: project_token,\n auth_token: user.auth_token\n }\n end\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 delete\n api_client.delete(url)\n end", "def destroy\n @test1.destroy\n respond_to do |format|\n format.html { redirect_to test1s_url, notice: \"Test1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @result_second.destroy\n respond_to do |format|\n format.html { redirect_to result_seconds_url, notice: 'Result second was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def delete\n render json: Post.delete(params[\"id\"])\n end", "def destroy\n @stat = Stat.find(params[:id])\n @stat.destroy\n\n respond_to do |format|\n format.html { redirect_to stats_url }\n format.json { head :ok }\n end\n end", "def destroy\n @fixture = Fixture.find(params[:id])\n @fixture.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @collect_query = CollectQuery.find(params[:id])\n @collect_query.destroy\n\n respond_to do |format|\n format.html { redirect_to collect_queries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @progress = Progress.find(params[:id])\n @progress.destroy\n\n respond_to do |format|\n format.html { redirect_to progresses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @indexed_file = IndexedFile.find(params[:id])\n @indexed_file.destroy\n\n respond_to do |format|\n format.html { redirect_to indexed_files_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @task_result.destroy\n respond_to do |format|\n format.html { redirect_to task_results_url, notice: 'Результат успешно удален.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @comparison_result.destroy\n respond_to do |format|\n format.html { redirect_to comparison_results_url, notice: 'Comparison result was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @stat = Stat.find(params[:id])\n @stat.destroy\n\n respond_to do |format|\n format.html { redirect_to stats_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test = Test.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @criterion = Criterion.find(params[:id])\n @criterion.destroy\n\n respond_to do |format|\n format.html { redirect_to criteria_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expectation = Expectation.find(params[:id])\n @expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to expectations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @query = Query.find(params[:id])\n @query.destroy\n\n respond_to do |format|\n format.html { redirect_to(queries_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @foo = Foo.find(params[:id])\n @foo.destroy\n\n respond_to do |format|\n format.html { redirect_to foos_url }\n format.json { head :ok }\n end\n end", "def destroy\n ImagesIndex.delete params[:id]\n respond_to do |format|\n format.html { redirect_to(\"/images_indices\") }\n format.xml { head :ok }\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 @pycontextnlp_result = PycontextnlpResult.find(params[:id])\n @pycontextnlp_result.destroy\n\n respond_to do |format|\n format.html { redirect_to pycontextnlp_results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ai_contest = AiContest.find(params[:id])\n @ai_contest.destroy\n\n respond_to do |format|\n format.html { redirect_to ai_contests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @query = Query.find(params[:id])\n @query.destroy\n \n respond_to do |format|\n format.html { redirect_to(queries_url) }\n format.xml { head :ok }\n end\n end", "def delete\n @res = DialResult.find(params[:id])\n\t@res.destroy\n respond_to do |format|\n format.html { redirect_to :action => 'index' }\n format.xml { head :ok }\n end\n end", "def destroy\n @contest.destroy\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @stuff = Stuff.find(params[:id])\n @stuff.destroy\n\n respond_to do |format|\n format.html { redirect_to stuff_index_url }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end" ]
[ "0.7422896", "0.7415153", "0.7415153", "0.7415153", "0.7415153", "0.7415153", "0.739529", "0.7390303", "0.7390303", "0.71879697", "0.71879697", "0.71879697", "0.71163774", "0.7045384", "0.6968828", "0.6960719", "0.6908872", "0.6899923", "0.6882427", "0.68696874", "0.6851931", "0.684448", "0.682964", "0.682964", "0.6816774", "0.6800657", "0.680055", "0.6785983", "0.6749965", "0.6730599", "0.6713877", "0.6712159", "0.670727", "0.6705184", "0.6694644", "0.66867596", "0.6671907", "0.665056", "0.6646785", "0.6644448", "0.66427165", "0.6639953", "0.6639508", "0.6635841", "0.66294307", "0.66290015", "0.6596595", "0.6595952", "0.659463", "0.65932995", "0.6577281", "0.657607", "0.65726286", "0.6560138", "0.6560138", "0.65464664", "0.65464664", "0.65320605", "0.6524082", "0.65231407", "0.65172464", "0.65117294", "0.6510953", "0.65095806", "0.65080285", "0.6501119", "0.6493591", "0.64922726", "0.6484957", "0.6473002", "0.64717007", "0.6471464", "0.64568686", "0.64549464", "0.6450216", "0.6448435", "0.644749", "0.6447395", "0.64438367", "0.64425844", "0.6441848", "0.64412177", "0.64390934", "0.6434243", "0.6433659", "0.64278764", "0.6425631", "0.6422148", "0.6421071", "0.6420105", "0.6420105", "0.64187187", "0.6414287", "0.6414025", "0.6414019", "0.64105755", "0.6408247", "0.64053506" ]
0.70385545
16
Use callbacks to share common setup or constraints between actions.
def set_result @result = Result.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def set_actions\n actions :all\n end", "def define_action_helpers?; end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def before_action \n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def after_set_callback; end", "def initialize(*args)\n super\n @action = :set\nend", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def setup(&blk)\n @setup_block = blk\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def duas1(action)\n action.call\n action.call\nend", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def call\n setup_context\n super\n end" ]
[ "0.61642385", "0.60448", "0.5945487", "0.5915654", "0.58890367", "0.58330417", "0.5776098", "0.5703048", "0.5703048", "0.5654613", "0.5620029", "0.5423114", "0.540998", "0.540998", "0.540998", "0.5393666", "0.53783023", "0.53568405", "0.53391176", "0.5339061", "0.53310865", "0.5312988", "0.529798", "0.52968603", "0.52962637", "0.52577317", "0.5244704", "0.5236856", "0.5236856", "0.5236856", "0.5236856", "0.5236856", "0.5233461", "0.52322435", "0.5227552", "0.52224743", "0.5217851", "0.521241", "0.52069896", "0.5206555", "0.5176617", "0.51738507", "0.51725876", "0.51660734", "0.51605034", "0.51571786", "0.5152762", "0.5152164", "0.5151477", "0.5145819", "0.51408994", "0.5134412", "0.5114031", "0.5113695", "0.5113695", "0.5108603", "0.5107358", "0.5090405", "0.50889385", "0.50817686", "0.5081617", "0.50658226", "0.50551206", "0.5051746", "0.5049091", "0.5049091", "0.5034681", "0.5024972", "0.5021291", "0.5016024", "0.50134826", "0.50008893", "0.50000244", "0.4999155", "0.49907947", "0.49907947", "0.49853387", "0.49796683", "0.4979596", "0.49778128", "0.49673793", "0.49662578", "0.49587822", "0.4956063", "0.49550167", "0.49523485", "0.4951614", "0.49452996", "0.49442068", "0.49336892", "0.49306205", "0.49264124", "0.49259305", "0.4925823", "0.49229056", "0.4918999", "0.49171805", "0.49167436", "0.4916559", "0.49153692", "0.49148256" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def result_params params.require(:result).permit(:name, :likes) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
class TestDefinition0 < ProcessDefinition count end def xxxx_load_0
def test_load_0 map = {} @engine.register_participant("count") do |workitem| count = map[workitem.flow_id] count = unless count 1 else count + 1 end map[workitem.flow_id] = count end n = 1000 n.times do |i| li = LaunchItem.new(TestDefinition0) li.flow_id = i @engine.launch(li) end #while @engine.get_expression_storage.size > 1 # sleep 0.001 #end @engine.join_until_idle good = true n.times do |i| c = map[i] if c == 2 #if c == 1 print "." else print c good = false end end #puts "\n__good ? #{good}" assert good, "missing count" # 100 in 1s (in memory engine) # 1'000 in 14s (in memory engine) # 10'000 in 143s (in memory engine) # 1'000 in 31s (cache engine) # 10'000 in 321s (cache engine) # 1'000 in 113s (persistence only engine) # 10'000 in 1173s (persistence only engine) # # # ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-darwin8.8.3] # # Machine Name: Mac # Machine Model: MacBook2,1 # Processor Name: Intel Core 2 Duo # Processor Speed: 2 GHz # Number Of Processors: 1 # Total Number Of Cores: 2 # L2 Cache (per processor): 4 MB # Memory: 2 GB # Bus Speed: 667 MHz # Thu Sep 13 15:38:46 JST 2007 # # 100 in 3s (in memory engine) # 1'000 in 85s (in memory engine) # 10'000 in s (in memory engine) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_process_definition\n\n pdef, prep = load_process_def\n\n [ pdef, prep.to_a.to_json ]\n end", "def initialize(process); end", "def autoload(p0, p1) end", "def autoload(p0, p1) end", "def initialize(definition)\n process_metadata(definition)\n end", "def load_processfile(model, file, the_process_class)\n model[:process_class] = BaseProcess if model[:process_class].nil?\n\n new_class = Class.new(model[:process_class])\n unless /Process$/ =~ the_process_class\n the_process_class = format('%sProcess', the_process_class)\n end\n\n Lorj.debug(1, \"Declaring Process '%s'\", the_process_class)\n model[:process_class] = Object.const_set(the_process_class, new_class)\n model[:process_class_name] = the_process_class\n BaseDefinition.current_process(model[:process_class])\n load file\n end", "def processor_count; end", "def processor_count; end", "def processor; end", "def initialize_model\n { :def_class => BaseDefinition,\n :processes => [],\n :process_class => nil, :process_class_name => nil,\n :controller_class => nil, :controller_class_name => nil }\n end", "def runtime; end", "def process; end", "def process; end", "def process; end", "def process; end", "def process; end", "def process; end", "def process; end", "def process; end", "def class_definition()\n \t_IDENTIFIER1 = nil\n\n\n\n\n \t class_def = ClassDefinition.new\n\n\n # 19:7: modifier[class_def] CLASS ( IDENTIFIER ) ( class_name_parameters[class_def] )? ( inheritance[class_def] )? ( interface[class_def] )? class_body[class_def]\n modifier(class_def)\n\n match(:CLASS)\n # 21:8: IDENTIFIER\n _IDENTIFIER1 = @input.look_ahead(1)\n match(:IDENTIFIER)\n class_def.name = _IDENTIFIER1.text \n # 22:7: ( class_name_parameters[class_def] )?\n alt2 = 2\n # 22:7: ( class_name_parameters[class_def] )?\n look_ahead2_0 = look_ahead(1)\n\n if look_ahead2_0 == :LEFT_ANGULAR_BRACKET \n alt2 = 1\n end\n case alt2\n when 1\n # 22:9: class_name_parameters[class_def]\n class_name_parameters(class_def)\n\n end\n # 23:7: ( inheritance[class_def] )?\n alt3 = 2\n # 23:7: ( inheritance[class_def] )?\n look_ahead3_0 = look_ahead(1)\n\n if look_ahead3_0 == :EXTENDS \n alt3 = 1\n end\n case alt3\n when 1\n # 23:8: inheritance[class_def]\n inheritance(class_def)\n\n end\n # 24:7: ( interface[class_def] )?\n alt4 = 2\n # 24:7: ( interface[class_def] )?\n look_ahead4_0 = look_ahead(1)\n\n if look_ahead4_0 == :IMPLEMENTS \n alt4 = 1\n end\n case alt4\n when 1\n # 24:8: interface[class_def]\n interface(class_def)\n\n end\n class_body(class_def)\n\n\n puts class_def.report\n \n\n\n\n end", "def test_multiple_classes_using_module\n other = Class.new do\n extend Puppet::Util::SubclassLoader\n handle_subclasses :other, \"puppet/other\"\n end\n Object.const_set(\"OtherLoader\", other)\n\n mk_subclass(\"multipletest\", \"puppet/other\", \"OtherLoader\")\n mk_subclass(\"multipletest\", \"puppet/fakeloaders\", \"TestPuppetUtilSubclassLoader::LoadTest\")\n #system(\"find #{@basedir}\")\n #puts File.read(File.join(@basedir, \"puppet/fakeloaders/multipletest.rb\"))\n #puts File.read(File.join(@basedir, \"puppet/other/multipletest.rb\"))\n\n othersub = mainsub = nil\n assert_nothing_raised(\"Could not look up other sub\") do\n othersub = OtherLoader.other(:multipletest)\n end\n assert_nothing_raised(\"Could not look up main sub\") do\n mainsub = LoadTest.faker(:multipletest)\n end\n assert(othersub, \"did not get other sub\")\n assert(mainsub, \"did not get main sub\")\n assert(othersub.ancestors.include?(OtherLoader), \"othersub is not a subclass of otherloader\")\n assert(mainsub.ancestors.include?(LoadTest), \"mainsub is not a subclass of loadtest\")\n end", "def definitions; end", "def definitions; end", "def initialize(process)\n self.process = process\n end", "def library_load_start(file_count)\n puts \"Compilation\"\n end", "def test_0\n\n #log_level_to_debug\n\n @engine.register_participant(:cron_event) do\n puts \" :( cron_event at #{Time.now.to_s}\"\n @tracer << \"cron_event\"\n end\n\n #puts \"start at #{Time.now.to_s}\"\n #dotest TestDefinition0, \"\", 62\n\n fei = launch TestDefinition0\n\n sleep 0.350\n\n assert_equal \"\", @tracer.to_s\n assert_not_nil @engine.process_status(fei)\n\n @engine.cancel_process fei\n\n sleep 0.350\n\n assert_nil @engine.process_status(fei)\n assert_equal 1, @engine.get_expression_storage.size\n end", "def parse_definition_list; end", "def initialize( * )\n\t\t@runcount = 0\n\t\tsuper\n\tend", "def instantiate_definitions(program, loader)\n program.definitions.each { |d| instantiate_definition(d, loader) }\n nil\n end", "def initialize\n @definitions = {}\n end", "def autoload?(p0) end", "def autoload?(p0) end", "def running_test_step; end", "def process_class exp\n exp\n end", "def classes; end", "def class() end", "def processor=(_arg0); end", "def initialize(path, pid_dictionary)\n file_lines = trace_file_lines(path)\n @total, @virtual, @s, @page_size = file_lines.shift.split(\" \").map(&:to_i)\n @lines = file_lines.map { |line| AProcess.new(line, pid_dictionary) }\n end", "def initialize\n @processes = []\n end", "def running_test_case; end", "def autoload(arg0, arg1)\n end", "def get_definition\n\n end", "def test_step; end", "def chunk_type\n\t\traise Wayground::AbstractClassUsed\n\tend", "def initialize(test_file, test_definition)\n @test_file = test_file\n @file_basename = test_file.name.gsub(\"#{YAML_FILES_DIRECTORY}/\", '')\n @description = test_definition.keys.first\n @definition = test_definition[description].select { |doc| !doc.key?('skip') }\n @definition.delete_if { |doc| doc['skip'] }\n @cached_values = {}\n skip_definitions = test_definition[description].select { |doc| doc['skip'] }.compact\n @skip = skip_definitions unless skip_definitions.empty?\n end", "def test_subclass_name\n bo1 = Pt::Boundary::MyA.new(\"\\n===\\n\")\n assert_equal \"Part::Boundary::MyA\", bo1.subclass_name\n assert_equal \"Boundary::MyA\", bo1.subclass_name(index_ini: 1)\n assert_equal \"MyA\", bo1.subclass_name(index_ini: 2)\n\n ss = PlainText::Part::Section::Subsection.new [\"abc\"]\n assert_equal \"Part::Section::Subsection\", ss.subclass_name\n assert_equal \"Section::Subsection\", ss.subclass_name(index_ini: 1)\n end", "def instance_count\n repository.files(:pattern => /.rb/).map do |file|\n content = repository.read(file)\n count_calls(:def,content)\n end.sum\n end", "def create_hdl_classes(ns, filename)\n content = File.open(filename).read \n eval \"\"\"\n module #{ns}\n require 'verilog_gen' \n # Hook to detect a subclass\n class VerilogGen::HdlModule\n @instances = []\n def self.inherited(new_subclass)\n @instances << new_subclass\n end\n def self.get\n @instances\n end\n end\n #{content}\n end\n \"\"\", binding, __FILE__, __LINE__\n return VerilogGen::HdlModule.get\nend", "def test_setup\r\n \r\n end", "def before_load(test_files); end", "def initialize(superclass = 'Object', type = 'Dynamic', _ = [], name = 'Object')\n @runtime_methods = {}\n @runtime_class = Constants['Class']\n @runtime_superclass = Constants[superclass]\n @superclass_name = superclass\n @type = type\n\n @ruby_value = type\n @name = name\n end", "def ignore_test_structs_are_inherited\n #add_bundle_dir(File.expand_path(selfdir + \"/concretedocs\"), \"concretedocs\")\n deploy(selfdir + \"app\", [selfdir + \"concretedocs/base.sd\", selfdir + \"concretedocs/usebase.sd\"])\n start\n feed(:file => selfdir + \"docs.json\")\n assert_hitcount(\"query=sddocname:usebase\", 1)\n end", "def load; end", "def load; end", "def load; end", "def instantiate_definition(definition, loader)\n case definition\n when Model::PlanDefinition\n instantiate_PlanDefinition(definition, loader)\n when Model::FunctionDefinition\n instantiate_FunctionDefinition(definition, loader)\n when Model::TypeAlias\n instantiate_TypeAlias(definition, loader)\n when Model::TypeMapping\n instantiate_TypeMapping(definition, loader)\n else\n raise Puppet::ParseError, \"Internal Error: Unknown type of definition - got '#{definition.class}'\"\n end\n end", "def process_file( file )\n #puts \"Scanning #{file}\"\n File.open(file,'r') do |f|\n f.each_line do |line|\n m = CHILD_CLASS_DECLARATION.match( line ) \n if m\n #puts \"#{m[1]} -> #{m[2]}\"\n @children[m[2]].add(m[1])\n @child.add(m[1])\n next\n end\n m = SIMPLE_CLASS_DECLARATION.match(line)\n if m\n #puts \"#{m[1]}\"\n @children[m[1]] = Set.new\n next\n end\n end\n end\n end", "def test_flatten_process1\r\n proc = @mymodel.node_list.add_node(1, 'proc1', PROCESS)\r\n \r\n assert_equal( { \"name\"=>\"proc1\", \"ident\"=>1, \"type\"=>\"process\",\r\n \"commentary\"=>\"\", \"description\"=>\"\", \"evidence\"=>\"undefined\" },\r\n proc.flatten_data)\r\n end", "def post_process; end", "def dynamic_class_declared(id, classname, file, line)\n return unless id == :new && classname == Class \n File.read(file).lines.to_a[line-1][/[A-Z][\\w_:]*/, 0]\n end", "def class_variables() end", "def get_processor; end", "def construct(loader: nil)\n loader ||= MeasureDefinitionLoader.new(data_path: self.class.data_path)\n @loader = loader\n @measure_definitions_lookup = HashWithIndifferentAccess.new\n end", "def test_start_chunk\n storable_class = new_storable_class\n storable_class.class_eval do\n def total_chunks\n 10\n end\n end\n obj = storable_class.new\n assert_equal(1, obj.start_chunk)\n end", "def test_0\n dotest(\n '''<process-definition name=\"con\" revision=\"0\">\n <concurrence>\n <print>a</print>\n <print>b</print>\n </concurrence>\n</process-definition>''',\n [ '''a\nb''',\n '''b\na'''\n ])\n end", "def initialize(args)\n\t\t\tsuper(args)\n\t\t\t\n\t\t\t@apply_to = args.fetch(:apply_to, [])\n\t\t\t@is_a = args.fetch(:is_a, nil)\n\t\t\t@mixins = args.fetch(:mixins, [])\n\t\t\t@class_uri = args.fetch(:class_uri, nil)\n\t\t\t@defining_slots = args.fetch(:defining_slots, [])\n\t\t\t@slot_usage = args.fetch(:slot_usage, [])\n\t\t\t@slots = args.fetch(:slots, [])\n\t\t\t@subclass_of = args.fetch(:subclass_of, nil)\n\t\t\t@union_of = args.fetch(:union_of, [])\n\n\t\t\t@apply_to = [@apply_to] unless @apply_to.is_a?(Array)\n\t\t\t@mixins = [@mixins] unless @mixins.is_a?(Array)\n\t\t\t@defining_slots = [@defining_slots] unless @defining_slots.is_a?(Array)\n\t\t\t@slot_usage = [@slot_usage] unless @slot_usage.is_a?(Array)\n\t\t\t@slots = [@slots] unless @slots.is_a?(Array)\n\t\t\t@union_of = [@union_of] unless @union_of.is_a?(Array)\n\t\t\t\n\t\t\t@apply_to = nil unless @apply_to.is_a?(Biolinkml::ClassDefinition)\n\t\t\t@is_a = nil unless @is_a.is_a?(Biolinkml::Definition)\n\t\t\t\n\t\t\t@apply_to.each do |a|\n\t\t\t\t@apply_to.delete(a) unless a.is_a?(Biolinkml::ClassDefinition)\n\t\t\tend\n\t\t\t@mixins.each do |a|\n\t\t\t\t@mixins.delete(a) unless a.is_a?(Biolinkml::ClassDefinition)\n\t\t\tend\n\t\t\t@defining_slots.each do |a|\n\t\t\t\t@defining_slots.delete(a) unless a.is_a?(Biolinkml::SlotDefinition)\n\t\t\tend\n\t\t\t@slot_usage.each do |a|\n\t\t\t\t@slot_usage.delete(a) unless a.is_a?(Biolinkml::SlotDefinition)\n\t\t\tend\n\t\t\t@slots.each do |a|\n\t\t\t\t@slots.delete(a) unless a.is_a?(Biolinkml::SlotDefinition)\n\t\t\tend\n\t\t\t@union_of.each do |a|\n\t\t\t\t@union_of.delete(a) unless a.is_a?(Biolinkml::ClassDefinition)\n\t\t\tend\n\t\t\t\n\t\t \t\t \n\t\tend", "def namespace_inheritance=(_arg0); end", "def namespace_inheritance=(_arg0); end", "def initialize\n @expected = Sexp\n\n # we do this on an instance basis so we can subclass it for\n # different processors.\n @processors = {}\n @context = []\n\n public_methods.each do |name|\n if name.to_s.start_with? \"process_\" then\n @processors[name[8..-1].to_sym] = name.to_sym\n end\n end\n end", "def class; end", "def class; end", "def class=(_arg0); end", "def definition\n \"class #{full_name}\"\n end", "def define; end", "def load_test(tc)\n data = Hash.new\n File.open(tc, \"r\") do |infile|\n while (line = infile.gets)\n #test = /^.*\\/(.*\\.rb)/.match(tc)[1]\n test = /^.*\\/([A-Za-z0-9_-]*[T|t]est.*)/.match(tc)[1]\n data['execute_class'] = /^([A-Za-z0-9_-]*[T|t]est.*)/.match(tc)[1]\n data['path'] = /(.*)\\/#{test}/.match(tc)[1]\n data['execute_args'] = /^#[\\s]*@executeArgs[\\s]*(.*)/.match(line)[1] if /^#[\\s]*@executeArgs/.match(line)\n data['author'] = /^#[\\s]*@author[\\s]*(.*)/.match(line)[1] if /^#[\\s]*@author/.match(line)\n data['keywords'] = /^#[\\s]*@keywords[\\s]*(.*)/.match(line)[1].gsub(/,/,'').split if /^#[\\s]*@keywords/.match(line)\n data['description'] = /^#[\\s]*@description[\\s]*(.*)/.match(line)[1] if /^#[\\s]*@description/.match(line)\n end\n end\n @tests << Test.new(data, @test_data) if data['keywords'] != nil and data['keywords'] != \"\"\nend", "def initialize(definition)\n @definition = definition\n end", "def process\n end", "def do_boot_defclass\n @content.scan(/(\\w+)\\s*=\\s*boot_defclass\\s*\\(\\s*\"(\\w+?)\",\\s*(\\w+?)\\s*\\)/) do\n |var_name, class_name, parent|\n parent = nil if parent == \"0\"\n handle_class_module(var_name, :class, class_name, parent, nil)\n end\n end", "def instantiate!; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def type_klass=(_arg0); end", "def import_exe execution\n raise \"import_exe must be redefined in children classes\"\n end", "def initialize top_level, file_name, content, options, stats\n super\n\n @known_classes = RDoc::KNOWN_CLASSES.dup\n @content = handle_tab_width handle_ifdefs_in @content\n @file_dir = File.dirname @file_name\n\n @classes = load_variable_map :c_class_variables\n @singleton_classes = load_variable_map :c_singleton_class_variables\n\n @markup = @options.markup\n\n # class_variable => { function => [method, ...] }\n @methods = Hash.new { |h, f| h[f] = Hash.new { |i, m| i[m] = [] } }\n\n # missing variable => [handle_class_module arguments]\n @missing_dependencies = {}\n\n # missing enclosure variable => [dependent handle_class_module arguments]\n @enclosure_dependencies = Hash.new { |h, k| h[k] = [] }\n @enclosure_dependencies.instance_variable_set :@missing_dependencies,\n @missing_dependencies\n\n @enclosure_dependencies.extend TSort\n\n def @enclosure_dependencies.tsort_each_node &block\n each_key(&block)\n rescue TSort::Cyclic => e\n cycle_vars = e.message.scan(/\"(.*?)\"/).flatten\n\n cycle = cycle_vars.sort.map do |var_name|\n delete var_name\n\n var_name, type, mod_name, = @missing_dependencies[var_name]\n\n \"#{type} #{mod_name} (#{var_name})\"\n end.join ', '\n\n warn \"Unable to create #{cycle} due to a cyclic class or module creation\"\n\n retry\n end\n\n def @enclosure_dependencies.tsort_each_child node, &block\n fetch(node, []).each(&block)\n end\n end", "def get_definition(codeClass, bld)\n end", "def initialize\n @expected = Sexp\n @processors = self.class.processors\n @context = []\n\n if @processors.empty?\n public_methods.each do |name|\n if name.to_s.start_with? \"process_\" then\n @processors[name[8..-1].to_sym] = name.to_sym\n end\n end\n end\n end", "def process(files) #called at end of script\n if files.class==Array \n files.each {|f| \n puts \"\\n\\n--------------------\\n#{f}:\\n\\n\"\n result=system(\"#{$PROGRAM_NAME} #{f} #{ARGV}\")\n puts \"\\n\\nERRORS IN TEST #{f}!!!\\n\\n\" unless result\n }\n else\n test_name=File.basename(files).sub(/\\..*?$/,'')\n test_case=Class.new(Test::Unit::TestCase)\n Object.const_set(:\"Test#{test_name.capitalize}\", test_case)\n mk_test_context(files, test_case)\n end\nend", "def pid; end", "def pid; end", "def pid; end", "def class_count\n repository.files(:pattern => /.rb/).map do |file|\n content = repository.read(file)\n count_calls(:defs,content)\n end.sum\n end", "def run_list; end", "def initialize(definition)\n register(definition)\n load_flags\n load_movement\n end" ]
[ "0.63024855", "0.604185", "0.58502847", "0.58502847", "0.57775867", "0.5735828", "0.564433", "0.564433", "0.5633783", "0.5589317", "0.5529081", "0.54733276", "0.54733276", "0.54733276", "0.54733276", "0.54733276", "0.54733276", "0.54733276", "0.54733276", "0.5433911", "0.5425527", "0.54182047", "0.54182047", "0.5395329", "0.5382394", "0.53357345", "0.53275293", "0.53193504", "0.5298954", "0.5293818", "0.52670175", "0.52670175", "0.52660096", "0.526115", "0.5249785", "0.5241838", "0.52387893", "0.52300197", "0.5204973", "0.5192942", "0.5191813", "0.51894164", "0.5185605", "0.51745224", "0.5165468", "0.51558894", "0.5151268", "0.5139936", "0.51395506", "0.51151764", "0.5110929", "0.5106576", "0.51011145", "0.51011145", "0.51011145", "0.50997096", "0.5099433", "0.50899863", "0.50885034", "0.50867933", "0.50806504", "0.5075996", "0.5072243", "0.5071994", "0.50634146", "0.5044858", "0.504198", "0.504198", "0.5040817", "0.50390387", "0.50390387", "0.5035623", "0.50310796", "0.5030442", "0.5024364", "0.5021912", "0.5021862", "0.5019466", "0.50136167", "0.501301", "0.501301", "0.501301", "0.501301", "0.501301", "0.501301", "0.501301", "0.501301", "0.501301", "0.5011691", "0.5005078", "0.49986175", "0.4988113", "0.49874932", "0.4983178", "0.49822637", "0.49822637", "0.49822637", "0.4982119", "0.4980541", "0.49798298" ]
0.5367531
25
GET /api/v2/source Get all sources for a customer
def list(limit = nil, cursor = nil) qs = {} qs[:limit] = limit if limit qs[:cursor] = cursor if cursor api.get('', qs) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sources(source: nil)\n params = {\n source: source\n }.compact\n\n _get(\"/account/sources\", params) { |json| json }\n end", "def account_sources(source)\n get('account/sources', {'source' => source})\n end", "def get_sources\n response = execute_get(\"/reference/source\")\n Source.from_array(decode(response))\n end", "def get_source_data(source_name:, catalog_id:)\n response = HTTParty.get(\"#{@host}/api/sources/#{source_name}\", query: {\n catalog_id: catalog_id,\n api_key: @api_key\n })\n \n return response[\"source\"]\n end", "def sources_get(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: SourceApi#sources_get ...\"\n end\n \n # resource path\n path = \"/sources\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\n query_params[:'client_id'] = opts[:'client_id'] if opts[:'client_id']\n query_params[:'name'] = opts[:'name'] if opts[:'name']\n query_params[:'created_at'] = opts[:'created_at'] if opts[:'created_at']\n query_params[:'updated_at'] = opts[:'updated_at'] if opts[:'updated_at']\n query_params[:'limit'] = opts[:'limit'] if opts[:'limit']\n query_params[:'offset'] = opts[:'offset'] if opts[:'offset']\n query_params[:'sort'] = opts[:'sort'] if opts[:'sort']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'inline_response_200_15')\n if Configuration.debugging\n Configuration.logger.debug \"API called: SourceApi#sources_get. Result: #{result.inspect}\"\n end\n return result\n end", "def index\n @sources = Source.all\n end", "def sources\n @sources ||= ApiFactory.new 'Repos::Sources'\n end", "def get_sources(opts = {})\n data, _status_code, _headers = get_sources_with_http_info(opts)\n data\n end", "def index\n @cla_sources = ClaSource.all\n end", "def get_sources\n @page.all(input_elements[:sources_list])\n end", "def index\n @city_sources = CitySource.all\n end", "def index\n @cash_sources = CashSource.all\n end", "def sources\n @sources ||= AVAILABLE_SOURCES.each_with_object({}) do |source_class, list|\n source = source_class.new\n list[source.id.to_s] = {\n 'name' => source.name,\n 'website' => source.website,\n 'notes' => source.notes,\n 'class' => source.class\n }\n end\n end", "def data_sources\n src.collect{|v| v['source']}\n end", "def sources\n @sources.names\n end", "def list_d_b_source(project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/sources'\n\t\targs[:query]['Action'] = 'ListDBSource'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tif optional.key? :source_name\n\t\t\targs[:query]['SourceName'] = optional[:source_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def get_source_and_collection\n source_uri = N::URI.from_encoded(params[:source])\n collection_uri = N::URI.from_encoded(params[:collection])\n source = TaliaCore::ActiveSource.find(source_uri)\n collection = TaliaCollection.find(collection_uri)\n @source_id = params[:source]\n @source = TaliaSource.find(source.id)\n [ source, collection ]\n end", "def customer_list\n perform_get_request('/customer/list')\n end", "def sources_data\n sources_url = Api.gnews_path('sources')\n call_gnews_url(sources_url).parse\n end", "def index\n @source_files = SourceFile.all\n end", "def customers\n ShopifyAPI::Customer.all\n end", "def process_lm_sources(customer_id, sources)\n headers = [\n 'Source Name',\n 'Source Type',\n 'IP Address',\n 'Source ID',\n 'Source Status'\n ]\n data = []\n tables = []\n sources_list = sources['sources']\n reply_head = \"/code Log Sources for customer: #{customer_id} \\n\"\n\n sources_list.each do |source|\n source.each do |type, info|\n data << [\n info['name'],\n type,\n info['metadata']['local_ipv4'],\n info['id'],\n info['status']['status']\n ]\n if check_msg_size?(build_table(data, headers))\n tables << [data, headers]\n data = []\n end\n end\n end\n\n summary = \"\\nTotal Sources: #{sources['total_count']}\"\n if tables.length > 0\n reply = [reply_head, tables, summary]\n return reply\n else\n reply = reply_head\n reply << build_table(data, headers)\n reply << summary\n return reply\n end\n end", "def index\n @portal_sources = PortalSource.all\n end", "def get_sources_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SourcesApi.get_sources ...'\n end\n if @api_client.config.client_side_validation && opts[:'query_operator'] && !['AND', 'OR'].include?(opts[:'query_operator'])\n fail ArgumentError, 'invalid value for \"query_operator\", must be one of AND, OR'\n end\n if @api_client.config.client_side_validation && opts[:'filter_operator'] && !['AND', 'OR'].include?(opts[:'filter_operator'])\n fail ArgumentError, 'invalid value for \"filter_operator\", must be one of AND, OR'\n end\n if @api_client.config.client_side_validation && opts[:'facets_interval'] && !['year', 'month', 'week', 'day'].include?(opts[:'facets_interval'])\n fail ArgumentError, 'invalid value for \"facets_interval\", must be one of year, month, week, day'\n end\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling SourcesApi.get_sources, must be smaller than or equal to 1000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling SourcesApi.get_sources, must be greater than or equal to 1.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"offset\"]\" when calling SourcesApi.get_sources, must be greater than or equal to 0.'\n end\n\n if @api_client.config.client_side_validation && opts[:'profile'] && !['full', 'list', 'minimal'].include?(opts[:'profile'])\n fail ArgumentError, 'invalid value for \"profile\", must be one of full, list, minimal'\n end\n if @api_client.config.client_side_validation && opts[:'preset'] && !['analysis', 'latest', 'minimal'].include?(opts[:'preset'])\n fail ArgumentError, 'invalid value for \"preset\", must be one of analysis, latest, minimal'\n end\n # resource path\n local_var_path = '/sources'\n\n # query parameters\n query_params = {}\n query_params[:'query[value]'] = opts[:'query_value'] if !opts[:'query_value'].nil?\n query_params[:'query[operator]'] = opts[:'query_operator'] if !opts[:'query_operator'].nil?\n query_params[:'query[fields][]'] = @api_client.build_collection_param(opts[:'query_fields'], :csv) if !opts[:'query_fields'].nil?\n query_params[:'filter[field]'] = opts[:'filter_field'] if !opts[:'filter_field'].nil?\n query_params[:'filter[value][]'] = @api_client.build_collection_param(opts[:'filter_value'], :csv) if !opts[:'filter_value'].nil?\n query_params[:'filter[operator]'] = opts[:'filter_operator'] if !opts[:'filter_operator'].nil?\n query_params[:'filter[negate]'] = opts[:'filter_negate'] if !opts[:'filter_negate'].nil?\n query_params[:'filter[conditions][]'] = @api_client.build_collection_param(opts[:'filter_conditions'], :csv) if !opts[:'filter_conditions'].nil?\n query_params[:'facets[field]'] = opts[:'facets_field'] if !opts[:'facets_field'].nil?\n query_params[:'facets[name]'] = opts[:'facets_name'] if !opts[:'facets_name'].nil?\n query_params[:'facets[limit]'] = opts[:'facets_limit'] if !opts[:'facets_limit'].nil?\n query_params[:'facets[sort]'] = opts[:'facets_sort'] if !opts[:'facets_sort'].nil?\n query_params[:'facets[filter][]'] = @api_client.build_collection_param(opts[:'facets_filter'], :csv) if !opts[:'facets_filter'].nil?\n query_params[:'facets[interval]'] = opts[:'facets_interval'] if !opts[:'facets_interval'].nil?\n query_params[:'fields[include][]'] = @api_client.build_collection_param(opts[:'fields_include'], :csv) if !opts[:'fields_include'].nil?\n query_params[:'fields[exclude][]'] = @api_client.build_collection_param(opts[:'fields_exclude'], :csv) if !opts[:'fields_exclude'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'sort[]'] = @api_client.build_collection_param(opts[:'sort'], :csv) if !opts[:'sort'].nil?\n query_params[:'profile'] = opts[:'profile'] if !opts[:'profile'].nil?\n query_params[:'preset'] = opts[:'preset'] if !opts[:'preset'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['text/plain; charset=utf-8'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Source')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SourcesApi#get_sources\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def sources\n @sources ||= []\n end", "def get_customers\n return ShopifyAPI::Customer.all\n end", "def index\n @transaction_sources = TransactionSource.all\n .order(name: :asc)\n .paginate(page: params[:page], per_page: 20)\n end", "def search_sources_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SourcesApi.search_sources ...'\n end\n # resource path\n local_var_path = '/sources'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'fields'])\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Source')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SourcesApi#search_sources\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def source_get\n db_select 'source'\n end", "def index\n @source_masters = SourceMaster.all\n end", "def index\n @source_refs = SourceRef.all\n end", "def index\n @financial_aid_sources = @financial_aid_package.sources\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @financial_aid_sources }\n end\n end", "def index\n @founding_sources = FoundingSource.all\n end", "def sources\n []\n end", "def index\n respond_with(sources)\n end", "def get_authentication_sources_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UserApi.get_authentication_sources ...'\n end\n # resource path\n local_var_path = '/api/3/authentication_sources'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json;charset=UTF-8'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ResourcesAuthenticationSource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UserApi#get_authentication_sources\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def sources\n filter.sources\n end", "def index\n @kernel_sources = KernelSource.all\n end", "def index\n @chef_att_sources = ChefAttSource.all\n end", "def get_d_b_source(project_name, source_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:path]['SourceName'] = source_name\n\t\targs[:pattern] = '/projects/[ProjectName]/sources/[SourceName]'\n\t\targs[:query]['Action'] = 'GetDBSource'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tself.run(args)\n\tend", "def sources\n\t\tKassociation.where( :source_id => self.id )\n\tend", "def sources\n @iTunes.sources.each do |source|\n @sources << source\n end\n end", "def show\n @source = Source.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @source }\n end\n end", "def v1_measurement_sources_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MeasurementsApi.v1_measurement_sources_get ...\"\n end\n # resource path\n local_var_path = \"/v1/measurementSources\".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 = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'MeasurementSource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MeasurementsApi#v1_measurement_sources_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def v1_measurement_sources_get(opts = {})\n data, _status_code, _headers = v1_measurement_sources_get_with_http_info(opts)\n return data\n end", "def index\n @data_sources = DataSource.all\n end", "def urls\n @gapi.source_uris\n end", "def get_all_customers\r\n begin\r\n @logger.info(\"get_all_customers called.\")\r\n\r\n # prepare query url\r\n @logger.info(\"Preparing query URL for get_all_customers.\")\r\n _query_builder = Configuration.get_base_uri().clone\r\n _query_builder << '/customers'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare headers\r\n @logger.info(\"Preparing headers for get_all_customers.\")\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n\r\n # prepare and execute HttpRequest\r\n @logger.info('Preparing and executing HttpRequest for get_all_customers.')\r\n _request = @http_client.get _query_url, headers: _headers\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request, name: 'get_all_customers')\r\n validate_response(_context)\r\n\r\n # return appropriate response type\r\n @logger.info(\"Returning response for get_all_customers.\")\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n return decoded.map{|element| CustomerModel.from_hash(element)}\r\n\r\n rescue Exception => e\r\n @logger.error(e)\r\n raise e\r\n end\r\n end", "def get_all_ach_funding_sources_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FundingSourcesApi.get_all_ach_funding_sources ...'\n end\n # resource path\n local_var_path = '/fundingsources/program/ach'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?\n query_params[:'start_index'] = opts[:'start_index'] if !opts[:'start_index'].nil?\n query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?\n query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'ACHListResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"FundingSourcesApi.get_all_ach_funding_sources\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FundingSourcesApi#get_all_ach_funding_sources\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_data_from_source(source)\n url = URI.parse(source.api_url)\n\n if url.respond_to?(:request_uri)\n begin\n Net::HTTP.get_response(url).body\n rescue\n end\n end\n end", "def index\n @metric_sources = MetricSource.all\n end", "def search_sources(opts = {})\n data, _status_code, _headers = search_sources_with_http_info(opts)\n data\n end", "def sources_for(r)\n return if r[:source].to_s.empty?\n [{ url: r[:source] }]\n end", "def sources\n %w[\n sample_source\n ]\nend", "def get_sources(workdir)\n @sources.each do |source|\n cur_source = Vanagon::Component::Source.source(source.url, { :ref => source.ref, :sum => source.sum }, workdir)\n cur_source.fetch\n cur_source.verify\n end\n end", "def index\n @queries = Query.all\n @sources = Source.all\n end", "def index\n @feed_sources = FeedSource.all\n end", "def index\n @student_sources = StudentSource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @student_sources }\n end\n end", "def sources\n source_paths\n end", "def list\n # 1. Ask the repo to bring all customers #all\n customers = @customer_repo.all\n # 2. Pass the customers to the view to display them\n @customer_view.display_all(customers)\n end", "def index\n @historical_sources = HistoricalSource.all\n end", "def stub_api_source_calls(source)\n stub_api_source_get(source, show(source))\n return unless source_available?(source)\n\n endpoint = endpoints(source)[source['id']]\n stub_rest_get(\"#{sources_api}/sources/#{source[\"id\"]}/endpoints\", user_tenant_header, list([endpoint]))\n\n authentication = authentications(source)[source['id']]\n stub_rest_get(\"#{sources_api}/endpoints/#{endpoint['id']}/authentications\", user_tenant_header, list([authentication]))\n\n stub_rest_get(\"#{sources_api(:internal => true)}/authentications/#{authentication['id']}?expose_encrypted_attribute[]=password\", user_tenant_header, show(credentials(source)[authentication['id']]))\n end", "def index\n @source_pages = SourcePage.all\n end", "def fetch_source(source)\n rsf = @fetcher_class.new(source, @http_proxy)\n rsf.source_index\n end", "def get_all_sources_info\n source_info = {}\n METADATA_FIELDS.keys.each { |ns|\n source_info[ns] = get_metadata_source_info(ns)\n }\n source_info\n end", "def sources(sources = nil)\n @sources.assign(sources) if sources\n @sources\n end", "def show\n @payment_source = PaymentSource.find(params[:id])\n @transactions = @payment_source.transactions\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @payment_source }\n end\n end", "def sources\n @sources ||= SourcePool.new\n end", "def show\n @customers = Customer.all\n end", "def show\n @customers = Customer.all\n end", "def sources\n sort!\n @sources\n end", "def index\n @sources = Source.paginate(:page => page, :per_page => 10, :order => \"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sources }\n end\n end", "def customers(options = {})\n perform_get_with_object('/customers', options, Epages::CustomersResponse)\n end", "def list(sources=DEFAULT_SOURCES, options)\n options = DEFAULT_OPTIONS.merge!(options)\n sources.collect do |source|\n source.list(options)\n end.flatten.uniq\n end", "def sources_id_get(id, opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: SourceApi#sources_id_get ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling sources_id_get\" if id.nil?\n \n # resource path\n path = \"/sources/{id}\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'inline_response_200_16')\n if Configuration.debugging\n Configuration.logger.debug \"API called: SourceApi#sources_id_get. Result: #{result.inspect}\"\n end\n return result\n end", "def index\n\t@customers = Customer.all()\n end", "def sources\n @_configuration.fetch('sources') { DEFAULT_SOURCES }\n end", "def get_source_by_id_with_http_info(source_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SourcesApi.get_source_by_id ...'\n end\n # verify the required parameter 'source_id' is set\n if @api_client.config.client_side_validation && source_id.nil?\n fail ArgumentError, \"Missing the required parameter 'source_id' when calling SourcesApi.get_source_by_id\"\n end\n if @api_client.config.client_side_validation && opts[:'profile'] && !['full', 'list', 'minimal'].include?(opts[:'profile'])\n fail ArgumentError, 'invalid value for \"profile\", must be one of full, list, minimal'\n end\n # resource path\n local_var_path = '/sources/{sourceId}'.sub('{' + 'sourceId' + '}', source_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'profile'] = opts[:'profile'] if !opts[:'profile'].nil?\n query_params[:'fields[include][]'] = @api_client.build_collection_param(opts[:'fields_include'], :csv) if !opts[:'fields_include'].nil?\n query_params[:'fields[exclude][]'] = @api_client.build_collection_param(opts[:'fields_exclude'], :csv) if !opts[:'fields_exclude'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['text/plain; charset=utf-8', 'application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Source')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SourcesApi#get_source_by_id\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def catalogs\n path = \"#{api_root}/index/catalogs\"\n process_api_request(:get, path)\n end", "def sources\n IITSourceCollection.new(@ole.Sources)\n end", "def sources(opts)\n if opts.edit\n path = File.expand_path(Config.instance.options['sources']['path'])\n Config.instance.open_file(path)\n else\n sources = Sources.instance\n sources.parse(@sources)\n sources_list_dl(sources, opts)\n end\n end", "def resources\n @resources ||=\n query_service.custom_queries.find_by_property(property: :source_metadata_identifier, value: [], lazy: true).select do |resource|\n id = resource.source_metadata_identifier.first\n next if /99.*3506421/.match?(id)\n next if transform_id(id).length > 18\n RemoteRecord.catalog?(id)\n end.to_a\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def index\n @customers = Customer.all\n end", "def all(params = {})\n req = WebPay::BasicListRequest.create(params)\n raw_response = @client._request(:get, 'customers', req)\n WebPay::CustomerResponseList.new(raw_response)\n end", "def index\n @customer_sets = CustomerSet.all\n end", "def find(source_id:, validate: false)\n resp = connection.get do |req|\n req.url \"#{objects_path}/find\"\n req.params['sourceId'] = source_id\n end\n raise_exception_based_on_response!(resp) unless resp.success?\n\n build_cocina_from_response(resp, validate: validate)\n end", "def index\n #@sources = Source.all\n \n @sources = Source.search(params[:search], params[:page])\n \n @title = \"Sources\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sources }\n end\n end", "def index\n @study_sources = StudySource.all\n end", "def retrieval_statuses_by_source(options={})\n if options[:source]\n source_ids = Source.where(\"lower(name) in (?)\", options[:source].split(\",\")).order(\"name\").pluck(:id)\n self.retrieval_statuses.by_source(source_ids)\n else\n self.retrieval_statuses\n end\n end", "def retrieval_statuses_by_source(options={})\n if options[:source]\n source_ids = Source.where(\"lower(name) in (?)\", options[:source].split(\",\")).order(\"name\").pluck(:id)\n self.retrieval_statuses.by_source(source_ids)\n else\n self.retrieval_statuses\n end\n end" ]
[ "0.77439713", "0.764057", "0.7515718", "0.716114", "0.6960482", "0.6799461", "0.6694224", "0.65499187", "0.653882", "0.64478236", "0.6442592", "0.6277184", "0.62686944", "0.622852", "0.62087476", "0.61819506", "0.6177918", "0.6173291", "0.6172909", "0.6166804", "0.61552924", "0.6152322", "0.615122", "0.61304384", "0.6123946", "0.611381", "0.61001134", "0.6088929", "0.6063991", "0.6050882", "0.60405034", "0.6011427", "0.5997766", "0.5985363", "0.5971528", "0.59714353", "0.5966877", "0.5961099", "0.59155136", "0.590881", "0.58975524", "0.5882857", "0.5882102", "0.5861472", "0.5845294", "0.5843381", "0.5823948", "0.58106863", "0.5810001", "0.58089554", "0.58051866", "0.57945806", "0.57746434", "0.5752225", "0.57391095", "0.57271874", "0.57186955", "0.57158786", "0.5709825", "0.57049596", "0.5702303", "0.56911016", "0.5691012", "0.5688696", "0.5686508", "0.56740654", "0.5673085", "0.56591773", "0.5652729", "0.5652729", "0.56486404", "0.56470066", "0.56457347", "0.5644339", "0.5637123", "0.5636619", "0.56274563", "0.56262195", "0.5618713", "0.5616899", "0.5601863", "0.5600229", "0.55928415", "0.55928415", "0.55928415", "0.55928415", "0.55928415", "0.55928415", "0.55928415", "0.55928415", "0.55928415", "0.55928415", "0.55928415", "0.55928415", "0.5592531", "0.558298", "0.5558308", "0.5532766", "0.5531399", "0.5527939", "0.5527939" ]
0.0
-1
POST /api/v2/source Create metadata (description or tags) for a specific source. Refer to the Swagger API docs for valid keys.
def create(body) raise ArgumentError unless body.is_a?(Hash) api.post('', body, 'application/json') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @source = Source.new(source_params)\n\n respond_to do |format|\n if @source.save\n format.html { redirect_to edit_source_path(@source), notice: 'Source was successfully created.' }\n format.json { render :show, status: :created, location: @source }\n else\n format.html { render :new }\n format.json { render json: @source.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(source:)\n resp = connection.post do |req|\n req.url workspace_path\n req.params['source'] = source\n end\n raise_exception_based_on_response!(resp, object_identifier) unless resp.success?\n end", "def create\n flash[:notice] = 'The source was successfully created.' if source.save\n respond_with(source)\n end", "def create\n @source = Source.new\n create_or_update\n end", "def create\n @source = Source.new(params[:source])\n\n respond_to do |format|\n if @source.save\n format.html { redirect_to(@source, :notice => 'Source was successfully created.') }\n format.xml { render :xml => @source, :status => :created, :location => @source }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @source.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @source = Source.new(params[:source])\n\n respond_to do |format|\n if @source.save\n track_activity @source\n format.html { redirect_to @source, notice: 'Source was successfully created.' }\n format.json { render json: @source, status: :created, location: @source }\n else\n format.html { render layout: 'form', action: \"new\" }\n format.json { render json: @source.errors, status: :unprocessable_entity }\n end\n end\n end", "def source_params\n params.require(:source).permit(:description, :link, :universe)\n end", "def sources_post(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: SourceApi#sources_post ...\"\n end\n \n # resource path\n path = \"/sources\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'body'])\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(:POST, 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 => 'inline_response_200_16')\n if Configuration.debugging\n Configuration.logger.debug \"API called: SourceApi#sources_post. Result: #{result.inspect}\"\n end\n return result\n end", "def source_params\n params.require(:source).permit(:source_name, :url, :type)\n end", "def create\n @metric_source = MetricSource.new(metric_source_params)\n\n respond_to do |format|\n if @metric_source.save\n format.html { redirect_to @metric_source, notice: 'Metric source was successfully created.' }\n format.json { render :show, status: :created, location: @metric_source }\n else\n format.html { render :new }\n format.json { render json: @metric_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @source = new_source\n respond_to do |format|\n # We must check for manually added errors first, as they\n # are lost when .valid? is called during the callback chain.\n if !@source.errors.any? && @source.save\n format.html { redirect_to url_for(@source.metamorphosize),\n notice: \"#{@source.type} successfully created.\" }\n format.json { render action: 'show', status: :created, location: @source.metamorphosize }\n else\n format.html { render action: 'new' }\n format.json { render json: @source.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @annotation_source = AnnotationSource.new(params[:annotation_source])\n\n respond_to do |format|\n if @annotation_source.save\n format.html { redirect_to @annotation_source, notice: 'Annotation source was successfully created.' }\n format.json { render json: @annotation_source, status: :created, location: @annotation_source }\n else\n format.html { render action: \"new\" }\n format.json { render json: @annotation_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params = clean_authors\n\n @source = Project.find(params[:project_id]).sources.new(source_params)\n @source.user_id = current_user.id\n\n @source.update_image\n\n respond_to do |format|\n if @source.save\n format.html { redirect_to source_path(@source), notice: 'Source was successfully created.' }\n format.json { render action: 'show', status: :created, location: @source }\n else\n format.html { render action: 'new' }\n format.json { render json: @source.errors, status: :unprocessable_entity }\n end\n end\n end", "def source_params\n params.require(:source).permit(:title, :authors, :hashtags_copy, annotations_attributes: [:id, :body, :body_source, :is_summary, :is_finding], citations_attributes: [:id, :is_read])\n end", "def create_d_b_source(project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'POST'\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/sources'\n\t\targs[:query]['Action'] = 'CreateDBSource'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :source\n\t\t\targs[:body]['Source'] = optional[:source]\n\t\tend\n\t\tself.run(args)\n\tend", "def create\n @data_source = DataSource.new(data_source_params)\n\n respond_to do |format|\n if @data_source.save\n format.html { redirect_to @data_source, notice: 'Data source was successfully created.' }\n format.json { render :show, status: :created, location: @data_source }\n else\n format.html { render :new }\n format.json { render json: @data_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_task_source_with_http_info(task_id, task_source_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TaskSourcesApi.create_task_source ...'\n end\n # verify the required parameter 'task_id' is set\n if @api_client.config.client_side_validation && task_id.nil?\n fail ArgumentError, \"Missing the required parameter 'task_id' when calling TaskSourcesApi.create_task_source\"\n end\n # verify the required parameter 'task_source_body' is set\n if @api_client.config.client_side_validation && task_source_body.nil?\n fail ArgumentError, \"Missing the required parameter 'task_source_body' when calling TaskSourcesApi.create_task_source\"\n end\n # resource path\n local_var_path = '/tasks/{task_id}/task_sources'.sub('{' + 'task_id' + '}', CGI.escape(task_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(task_source_body) \n\n # return_type\n return_type = opts[:return_type] || 'TaskSourceDown' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TaskSourcesApi#create_task_source\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n\n @report = Report.find(params[:report_id]) \n @source = @report.sources.build(name: params[:tname][:title], description: params[:source][:description], \n object_type: params[:source][:object_type], owner: params[:source][:owner])\n if @source.save\n redirect_to report_source_new_source_field_path(@report, @source)\n else\n render action: \"new\"\n end \n end", "def create\n @creator_source = CreatorSource.new(params[:creator_source])\n\n respond_to do |format|\n if @creator_source.save\n format.html { redirect_to @creator_source, notice: 'Creator source was successfully created.' }\n format.json { render json: @creator_source, status: :created, location: @creator_source }\n else\n format.html { render action: \"new\" }\n format.json { render json: @creator_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event_source = EventSource.new(params[:event_source])\n\n respond_to do |format|\n if @event_source.save\n format.html { redirect_to @event_source, :notice => 'Event source was successfully created.' }\n format.json { render :json => @event_source, :status => :created, :location => @event_source }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @event_source.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @recipesource = Recipesource.new(params[:recipesource])\n\n respond_to do |format|\n if @recipesource.save\n format.html { redirect_to @recipesource, notice: 'Recipesource was successfully created.' }\n format.json { render json: @recipesource, status: :created, location: @recipesource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipesource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @source_file = SourceFile.new(source_file_params)\n\n respond_to do |format|\n if @source_file.save\n format.html { redirect_to @source_file, notice: 'Source file was successfully created.' }\n format.json { render :show, status: :created, location: @source_file }\n else\n format.html { render :new }\n format.json { render json: @source_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n unless params[:source][:categories].blank?\n params[:source][:categories] = params[:source][:categories].split(\",\").collect{|u| u.strip}.reject{|u| u.blank?}.uniq.collect{|p| Category.new(:name => p)}\n end\n unless params[:source][:feed_urls].blank?\n params[:source][:feed_urls] = params[:source][:feed_urls].split(\",\").collect{|u| u.strip}.reject{|u| u.blank?}.uniq\n end\n @source = Source.new(params[:source])\n\n respond_to do |format|\n if @source.save\n format.html { redirect_to(@source, :notice => 'Source was successfully created. We\\'ll be doing an initial fetch of articles shortly.') }\n format.xml { render :xml => @source, :status => :created, :location => @source }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @source.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n get @resource[:source]\n validate_checksum if checksum_specified?\n end", "def apply_params_with_source(params)\n errors.add(:source, \"must be present.\") unless params[:source].present?\n\n remote_name = params.dig(:source, :remote, :name)\n remote = Remote.find_by(name: remote_name) if remote_name.present?\n source = Source.find_or_create_by(\n source_type: params.dig(:source, :source_type),\n mode: params.dig(:source, :mode),\n remote_id: remote&.id || params.dig(:source, :remote_id),\n fingerprint: params.dig(:source, :fingerprint),\n alias: params.dig(:source, :alias)\n )\n\n self.source = source\n self.bootstrappers = params[:bootstrappers]\n self.container_type = params[:container_type].upcase if params[:container_type].present?\n end", "def add_source(*source)\n unless source.blank?\n what.query.add(:sources) << source.flatten \n changed\n end\n end", "def create\n @historical_source = HistoricalSource.new(historical_source_params)\n\n respond_to do |format|\n if @historical_source.save\n format.html { redirect_to @historical_source, notice: 'Historical source was successfully created.' }\n format.json { render action: 'show', status: :created, location: @historical_source }\n else\n format.html { render action: 'new' }\n format.json { render json: @historical_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_source\n @source = Source.find params[:id]\n end", "def add_source(source)\n if has_source?(source)\n raise DuplicateSourceDefined, \"Berksfile contains two sources named '#{source.name}'. Remove one and try again.\"\n end\n @sources[source.to_s] = source\n end", "def create(source, metadata = nil, &block)\n Asset.create(source, metadata) do |asset, error|\n if asset\n block.call(asset, error)\n self << asset\n else\n raise \"Asset creation failed. #{error}\"\n end\n end\n end", "def set_source\n @source = Source.find(params[:id])\n end", "def set_source\n @source = Source.find(params[:id])\n end", "def set_source\n @source = Source.find(params[:id])\n end", "def create\n @source = Source.new(params[:source])\n \n if signed_in?\n @source.user_id = current_user.id \n else\n @source.user_id = 1\n end\n \n @source.reviewed = false\n\n respond_to do |format|\n if @source.save\n format.html { redirect_to(@source, :notice => 'Source was successfully created.') }\n format.xml { render :xml => @source, :status => :created, :location => @source }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @source.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @financial_aid_source = @financial_aid_package.sources.new(params[:financial_aid_source])\n\n respond_to do |format|\n if @financial_aid_source.save\n format.html { redirect_to [@participant, @financial_aid_package], notice: 'Financial aid source was successfully created.' }\n format.json { render json: {\n content: render_to_string(partial: 'source', object: @financial_aid_source, formats: [:html]),\n object: @financial_aid_source,\n breakdown: @financial_aid_source.breakdown(no_cents: true)\n }, status: :created, location: [@participant, @financial_aid_package] }\n else\n format.html { render action: \"new\" }\n format.json { render json: @financial_aid_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def source_params\n params.fetch(:source, {}).permit(:disabled, :feed_id, :source_type, :url, :name)\n end", "def set_source\n @source = Source.find(params[:id])\n end", "def create\n @study_source = StudySource.new(study_source_params)\n\n respond_to do |format|\n if @study_source.save\n format.html { redirect_to @study_source, notice: 'Study source was successfully created.' }\n format.json { render :show, status: :created, location: @study_source }\n else\n format.html { render :new }\n format.json { render json: @study_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @source = Source.new\n\n end", "def source_attributes=(attributes)\n self.source_id = nil if attributes['_destroy']\n end", "def create\n @source_master = SourceMaster.new(source_master_params)\n\n respond_to do |format|\n if @source_master.save\n format.html { redirect_to @source_master, notice: \"Source master was successfully created.\" }\n format.json { render :show, status: :created, location: @source_master }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @source_master.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @proxy_source = ProxySource.new(params[:proxy_source])\n\n respond_to do |format|\n if @proxy_source.save\n format.html { redirect_to @proxy_source, notice: 'Proxy source was successfully created.' }\n format.json { render json: @proxy_source, status: :created, location: @proxy_source }\n else\n format.html { render action: \"new\" }\n format.json { render json: @proxy_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def v1_measurement_sources_post_with_http_info(body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MeasurementsApi.v1_measurement_sources_post ...\"\n end\n # verify the required parameter 'body' is set\n fail ArgumentError, \"Missing the required parameter 'body' when calling MeasurementsApi.v1_measurement_sources_post\" if body.nil?\n # resource path\n local_var_path = \"/v1/measurementSources\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\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 = @api_client.object_to_http_body(body)\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MeasurementsApi#v1_measurement_sources_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @student_source = StudentSource.new(params[:student_source])\n\n respond_to do |format|\n if @student_source.save\n format.html { redirect_to student_sources_path, notice: 'Student source was successfully created.' }\n format.json { render json: @student_source, status: :created, location: @student_source }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(params[:book])\n @book.source = Source.new( :title => @book.title, :official_url => params[:source_url] )\n respond_to do |format|\n if @book.save\n format.html { redirect_to(@book, :notice => 'Book was successfully created.') }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @data_source = DataSource.new(data_source_params)\n \n dimension_translations = params[:dimension_translations]\n parsed_dimension_translations = []\n dimension_translations.each do |number, trans|\n parsed_dimension_translations << {original_name: trans[:original_name].to_sym, translated_name: trans[:translated_name], data_type: trans[:data_type]} if trans[:original_name] != \"\"\n end\n\n @data_source.dimension_translations = parsed_dimension_translations\n\n respond_to do |format|\n if @data_source.save\n format.html { redirect_to @data_source, notice: 'Data source was successfully created.' }\n format.json { render :show, status: :created, location: @data_source }\n else\n format.html { render :new }\n format.json { render json: @data_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @payment_source = PaymentSource.new(params[:payment_source])\n\n respond_to do |format|\n if @payment_source.save\n format.html { redirect_to @payment_source, notice: 'Payment source was successfully created.' }\n format.json { render json: @payment_source, status: :created, location: @payment_source }\n else\n format.html { render action: \"new\" }\n format.json { render json: @payment_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def source(source_type, source_options = {})\n @source_type = source_type\n @source_options = source_options\n end", "def create\n @game_source = GameSource.new(params[:game_source])\n\n respond_to do |format|\n if @game_source.save\n format.html { redirect_to @game_source, notice: 'Game source was successfully created.' }\n format.json { render json: @game_source, status: :created, location: @game_source }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @feed_source = FeedSource.new(feed_source_params)\n\n respond_to do |format|\n if @feed_source.save\n format.html { redirect_to @feed_source, notice: 'Feed source was successfully created.' }\n format.json { render :show, status: :created, location: @feed_source }\n else\n format.html { render :new }\n format.json { render json: @feed_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def source_record(**kwargs)\n FolioRecord.new_from_source_record(\n get_json('/source-storage/source-records', params: kwargs).dig('sourceRecords', 0), self\n )\n end", "def new\n @source = Source.new\n \n @source.event_id = params[:ref]\n \n @title = \"Add Source\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @source }\n end\n end", "def create\n @content_source = ContentSource.new(params[:content_source])\n\n respond_to do |format|\n if @content_source.save\n format.html { redirect_to(@content_source, :notice => 'Content source was successfully created.') }\n format.xml { render :xml => @content_source, :status => :created, :location => @content_source }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @content_source.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put_fundingsources_fundingsourcetoken_with_http_info(funding_source_token, body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FundingSourcesApi.put_fundingsources_fundingsourcetoken ...'\n end\n # verify the required parameter 'funding_source_token' is set\n if @api_client.config.client_side_validation && funding_source_token.nil?\n fail ArgumentError, \"Missing the required parameter 'funding_source_token' when calling FundingSourcesApi.put_fundingsources_fundingsourcetoken\"\n end\n # verify the required parameter 'body' is set\n if @api_client.config.client_side_validation && body.nil?\n fail ArgumentError, \"Missing the required parameter 'body' when calling FundingSourcesApi.put_fundingsources_fundingsourcetoken\"\n end\n # resource path\n local_var_path = '/fundingsources/paymentcard/{funding_source_token}'.sub('{' + 'funding_source_token' + '}', CGI.escape(funding_source_token.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(body)\n\n # return_type\n return_type = opts[:debug_return_type] || 'PaymentCardResponseModel'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"FundingSourcesApi.put_fundingsources_fundingsourcetoken\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FundingSourcesApi#put_fundingsources_fundingsourcetoken\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create_presentation_from_source_with_http_info(name, source_path = nil, source_password = nil, source_storage = nil, password = nil, folder = nil, storage = nil)\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SlidesApi.create_presentation_from_source ...'\n end\n\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling SlidesApi.create_presentation_from_source\"\n end\n # resource path\n local_var_path = '/slides/{name}/fromSource'\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'name', name)\n\n # query parameters\n query_params = {}\n query_params[:'sourcePath'] = @api_client.prepare_for_query(source_path) unless source_path.nil?\n query_params[:'sourceStorage'] = @api_client.prepare_for_query(source_storage) unless source_storage.nil?\n query_params[:'folder'] = @api_client.prepare_for_query(folder) unless folder.nil?\n query_params[:'storage'] = @api_client.prepare_for_query(storage) unless storage.nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'sourcePassword'] = source_password unless source_password.nil?\n header_params[:'password'] = password unless password.nil?\n\n # http body (model)\n post_body = nil\n\n # form parameters\n post_files = []\n\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :body => post_body,\n :files => post_files,\n :auth_names => auth_names,\n :return_type => 'Document')\n return data, status_code, headers\n end", "def create\n @city_source = CitySource.new(city_source_params)\n\n respond_to do |format|\n if @city_source.save\n format.html { redirect_to @city_source, notice: 'City source was successfully created.' }\n format.json { render :show, status: :created, location: @city_source }\n else\n format.html { render :new }\n format.json { render json: @city_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @source_type_metadata = args[:source_type_metadata] if args.key?(:source_type_metadata)\n end", "def create\n @cla_source = ClaSource.new(cla_source_params)\n\n respond_to do |format|\n if @cla_source.save\n format.html { redirect_to @cla_source, notice: 'Cla source was successfully created.' }\n format.json { render :show, status: :created, location: @cla_source }\n else\n format.html { render :new }\n format.json { render json: @cla_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_title(source)\n schema = config.get(:schema)\n source[:title] = schema[:name]\n source\n end", "def add_tag(key, value, source=Metadata::Source::METRIC)\n tags << Metadata.new(:key => key, :value => value, :source => source,\n :object_type => Metadata::Type::METRIC, :object_fk_id => id)\n nil\n end", "def create_or_update_ldap_identity_source_with_http_info(ldap_identity_source_id, ldap_identity_source, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi.create_or_update_ldap_identity_source ...'\n end\n # verify the required parameter 'ldap_identity_source_id' is set\n if @api_client.config.client_side_validation && ldap_identity_source_id.nil?\n fail ArgumentError, \"Missing the required parameter 'ldap_identity_source_id' when calling SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi.create_or_update_ldap_identity_source\"\n end\n # verify the required parameter 'ldap_identity_source' is set\n if @api_client.config.client_side_validation && ldap_identity_source.nil?\n fail ArgumentError, \"Missing the required parameter 'ldap_identity_source' when calling SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi.create_or_update_ldap_identity_source\"\n end\n # resource path\n local_var_path = '/aaa/ldap-identity-sources/{ldap-identity-source-id}'.sub('{' + 'ldap-identity-source-id' + '}', ldap_identity_source_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(ldap_identity_source)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PUT, 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 => 'LdapIdentitySource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SystemAdministrationSettingsUserManagementLDAPIdentitySourcesApi#create_or_update_ldap_identity_source\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def initialize(source, info_hash=Hash.new)\n @infos = info_hash\n @infos = Hash.new if @infos == nil\n raise \"The Post source file does not exist (#{source})\" if !File.exist?(source)\n # read the source\n raw = File.read(source)\n # parse the source and get the metadata and content\n parse_source(raw)\n raise \"The Post source file does not contain any metadata (YAML header)\" if @data == nil\n parse_filename(source)\n set_attributes\n end", "def create\n @lookup_source = LookupSource.new(params[:lookup_source])\n\n respond_to do |format|\n if @lookup_source.save\n format.html { redirect_to(@lookup_source, :notice => 'Lookup source was successfully created.') }\n format.xml { render :xml => @lookup_source, :status => :created, :location => @lookup_source }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lookup_source.errors, :status => :unprocessable_entity }\n end\n end\n end", "def source=(value)\n @source = value\n end", "def source=(value)\n @source = value\n end", "def update_d_b_source(project_name, source_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'PUT'\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:path]['SourceName'] = source_name\n\t\targs[:pattern] = '/projects/[ProjectName]/sources/[SourceName]'\n\t\targs[:query]['Action'] = 'UpdateDBSource'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :source\n\t\t\targs[:body]['Source'] = optional[:source]\n\t\tend\n\t\tself.run(args)\n\tend", "def generate(source)\n # return data without properties\n return source if source[:properties].nil? || source[:properties].keys.empty?\n # generates Slim template output\n generate_document(source)\n # returns source data\n source\n end", "def update\n source = Source.find_by(id: params[:source_id])\n unless source_params[:name] == source.name\n render json: {error: 'You cannot change external api for a source, you must delete that source if you wish to remove it'}, status: :unprocessable_entity\n end\n if source && all_sources.include?(source)\n source.access_token = source_params[:access_token]\n source.account_id = source_params[:account_id]\n if source.save\n render json: { id: source.id, name: source.name, access_token: source.access_token, account_id: source.account_id }, status: :found\n else\n render json: source.errors, status: :unprocessable_entity\n end\n else\n render json: {error: \"could not find source with source id of #{params[:source_id]}\"}, status: :not_found\n end\n end", "def connections_id_connection_sources_id_source_post_with_http_info(id_connection, id_source, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConnectionsApi.connections_id_connection_sources_id_source_post ...'\n end\n # verify the required parameter 'id_connection' is set\n if @api_client.config.client_side_validation && id_connection.nil?\n fail ArgumentError, \"Missing the required parameter 'id_connection' when calling ConnectionsApi.connections_id_connection_sources_id_source_post\"\n end\n # verify the required parameter 'id_source' is set\n if @api_client.config.client_side_validation && id_source.nil?\n fail ArgumentError, \"Missing the required parameter 'id_source' when calling ConnectionsApi.connections_id_connection_sources_id_source_post\"\n end\n # resource path\n local_var_path = '/connections/{id_connection}/sources/{id_source}'.sub('{' + 'id_connection' + '}', id_connection.to_s).sub('{' + 'id_source' + '}', id_source.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ConnectionSource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConnectionsApi#connections_id_connection_sources_id_source_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @rep_source = RepSource.new(params[:rep_source])\n\n respond_to do |format|\n if @rep_source.save\n format.html { redirect_to(@rep_source, :notice => 'Rep source was successfully created.') }\n format.xml { render :xml => @rep_source, :status => :created, :location => @rep_source }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @rep_source.errors, :status => :unprocessable_entity }\n end\n end\n end", "def cmd_twitt_set_source(*args)\n\t\t\t\tif args.length > 0\n\t\t\t\t\tprint_status(\"Setting the source name to #{args[0]}\")\n\t\t\t\t\t@source = args[0]\n\t\t\t\telse\n\t\t\t\t\tprint_error(\"Please provide a value\")\n\t\t\t\tend\n\t\t\tend", "def create\n @source = Source.new(params[:source])\n @source.user_id = session[:login_user_id]\n @source.dz_user_id = session[:login_user].uid\n @source.username = session[:login_user].username\n @source.source_type_id = params[:source_type]\n @source.source_lang_id = params[:source_lang]\n @source.excredits = params[:excredits].to_i\n if @source.save\n source_photo = params[:photo]\n # 如果有缩略图\n if source_photo\n logger.debug 'source has photo'\n # 创建路径\n\t\t # 初始化日期路径\n\t\t #年月日\n\t\t year_s = @source.created_at.year.to_s\n\t\t month_s = @source.created_at.month.to_s\n\t\t day_s = @source.created_at.day.to_s\n\t\t # 除去配置文件的路径\n\t\t file_folder = File.join(\"photos\",year_s, month_s, day_s,@source.id.to_s)\n\t\t source_photo_path = DOWNLOAD_THREAD_PHOTO_ROOT_PATH + \"/sources\"\n\t\t base_dir = File.join(source_photo_path, file_folder)\n\t\t base_dir_medium = File.join(source_photo_path, file_folder, \"medium\")\n\t\t base_dir_original = File.join(source_photo_path, file_folder, \"original\")\n\t\t base_dir_thumb = File.join(source_photo_path, file_folder, \"thumb\")\n\t\t if not File.exist?(base_dir)\n\t\t\t File.makedirs(base_dir_medium)\n\t\t\t File.makedirs(base_dir_original)\n\t\t\t File.makedirs(base_dir_thumb)\n\t\t end\n\t\t # 重写文件名 ,这里需要从配置文件里读取根路径,然后根据日期创建目录(如果已经存在就不创建), 用uuid重命名\n\t\t name = source_photo.original_filename\n\t\t # 文件名后缀\n\t\t ext = File.extname(name)\n\t\t new_name = UUIDTools::UUID.timestamp_create.to_s.gsub('-','') + ext\n\t\t path = File.join(base_dir_original, new_name)\n\t\t medium_path = File.join(base_dir_medium, new_name)\n\t\t thumb_path = File.join(base_dir_thumb, new_name)\n\t\t File.open(path, \"wb\") { |f| f.write(source_photo.read) }\n\t\t # 开始自动切割\n\t\t origin_img = Magick::Image.read(path)\n # 得到了图片的对象\n org_img_obj = origin_img[0]\n # 100x100的\n medium = org_img_obj.crop_resized(300,300)\n medium.write(medium_path)\n # 300x300的\n\t\t thumb = org_img_obj.crop_resized(100,100)#org_img_obj.resize(org_img_obj.columns*0.1, org_img_obj.rows*0.1)\n # 写出一个最小的缩略图\n\t\t thumb.write(thumb_path)\n\n @source.update_attributes({\n :photo_file_name => new_name,\n :photo_content_type => source_photo.content_type,\n :photo_file_size => source_photo.size\n })\n else\n logger.debug 'source has no photo'\n end\n flash[:message] = \"成功发布译文\"\n user_count = UserCount.where(\"user_id = #{session[:login_user_id].to_s} and app_name = 'source'\").first\n # 更新发布总数\n if not user_count\n user_count = UserCount.new\n user_count.user_id = session[:login_user_id]\n user_count.app_name = \"source\"\n user_count.uploads = 1\n\t\t user_count.save\n else\n user_count.update_attributes({:uploads => user_count.uploads + 1 })\n end\n # 加积分 和金币\n add_discuz_credits @source.dz_user_id, 10\n add_discuz_extcredits @source.dz_user_id, 10\n # 发全站动态\n # 发送全局动态\n source_index_url = XMAPP_MAIN_DOMAIN_URL+\"/sources\"\n source_thread_url = XMAPP_MAIN_DOMAIN_URL+\"/sources/#{@source.id}\"\n title_template = \"#{@source.username}在<a href=\\\"#{source_index_url}\\\" >译文频道<\\/a>发布了一篇文章<a href=\\\"#{source_thread_url}\\\" >#{@source.title}<\\/a>,并获得了10的金币,翻译此文章将有金币奖励,如果被评选为最佳翻译将额外获取获#{@source.excredits.to_s}的金币,快来<a href=\\\"#{source_thread_url}/translations/new\\\" >翻译<\\/a>吧\"\n\t title_data = {}\n\t require 'php_serialization'\n\t title_data = PhpSerialization.dump(title_data)\n send_dz_feed 2003, @source.dz_user_id, @source.username, title_template, title_data, '', title_data\n # end 发送全局动态\n # 记录用户操作\n user_op_log session[:login_user_id] ,@source.dz_user_id, @source.username, 'all'\n redirect_to my_sources_path\n else\n flash[:error] = \"保存错误,请重试\"\n redirect_to new_source_path\n end\n end", "def source_params\n params.require(:source).permit(all_allowed_params)\n end", "def get_source_by_id_with_http_info(source_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SourcesApi.get_source_by_id ...'\n end\n # verify the required parameter 'source_id' is set\n if @api_client.config.client_side_validation && source_id.nil?\n fail ArgumentError, \"Missing the required parameter 'source_id' when calling SourcesApi.get_source_by_id\"\n end\n if @api_client.config.client_side_validation && opts[:'profile'] && !['full', 'list', 'minimal'].include?(opts[:'profile'])\n fail ArgumentError, 'invalid value for \"profile\", must be one of full, list, minimal'\n end\n # resource path\n local_var_path = '/sources/{sourceId}'.sub('{' + 'sourceId' + '}', source_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'profile'] = opts[:'profile'] if !opts[:'profile'].nil?\n query_params[:'fields[include][]'] = @api_client.build_collection_param(opts[:'fields_include'], :csv) if !opts[:'fields_include'].nil?\n query_params[:'fields[exclude][]'] = @api_client.build_collection_param(opts[:'fields_exclude'], :csv) if !opts[:'fields_exclude'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['text/plain; charset=utf-8', 'application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Source')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SourcesApi#get_source_by_id\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def search_sources_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SourcesApi.search_sources ...'\n end\n # resource path\n local_var_path = '/sources'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'fields'])\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Source')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SourcesApi#search_sources\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def source_file_params\n params.require(:source_file).permit(:name, :library_id)\n end", "def create_record\n if @email.to_s.empty? or @server.to_s.empty? or @username.to_s.empty? or @port.to_s.empty?\n raise ArgumentError.new(\"Mandatory arguments are not set\")\n end\n \n params = {}\n params['email'] = @email.to_s\n params['server'] = @server.to_s\n params['username'] = @username.to_s\n params['use_ssl'] = @use_ssl.to_s\n params['port'] = @port.to_s\n params['type'] = @source_type.to_s\n\n # Optional parameters\n params['service_level'] = @service_level if @service_level\n params['sync_period'] = @sync_period if @sync_period\n params['password'] = @password if @password\n params['provider_token'] = @provider_token if @provider_token\n params['provider_token_secret'] = @provider_token_secret if @provider_token_secret\n params['provider_consumer_key'] = @provider_consumer_key if @provider_consumer_key\n\n response = post(\"/2.0/accounts/#{@account_id}/sources\", params)\n response['success']\n end", "def connections_id_connection_sources_id_source_put_with_http_info(id_connection, id_source, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConnectionsApi.connections_id_connection_sources_id_source_put ...'\n end\n # verify the required parameter 'id_connection' is set\n if @api_client.config.client_side_validation && id_connection.nil?\n fail ArgumentError, \"Missing the required parameter 'id_connection' when calling ConnectionsApi.connections_id_connection_sources_id_source_put\"\n end\n # verify the required parameter 'id_source' is set\n if @api_client.config.client_side_validation && id_source.nil?\n fail ArgumentError, \"Missing the required parameter 'id_source' when calling ConnectionsApi.connections_id_connection_sources_id_source_put\"\n end\n # resource path\n local_var_path = '/connections/{id_connection}/sources/{id_source}'.sub('{' + 'id_connection' + '}', id_connection.to_s).sub('{' + 'id_source' + '}', id_source.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:PUT, 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 => 'ConnectionSource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConnectionsApi#connections_id_connection_sources_id_source_put\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create name, object_type, config={}\n klass = @@sources[[name, object_type]]\n raise \"No Source registered with name #{name} and type #{object_type}.\" unless klass\n klass.new(config)\n end", "def create\n @heat_source = HeatSource.new(params[:heat_source])\n\n respond_to do |format|\n if @heat_source.save\n format.html { redirect_to @heat_source, notice: 'Heat source was successfully created.' }\n format.json { render json: @heat_source, status: :created, location: @heat_source }\n else\n format.html { render action: \"new\" }\n format.json { render json: @heat_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize source:, example_mode:, example_num:, ig_name:\n @source = source\n @failures, @successes = [], []\n @example_num = example_num\n @ig_name = ig_name\n\n if File.exist? @source\n @json_data = JSON.parse(File.read(@source))\n else\n puts \"FILE NOT FOUND #{@source}\"\n return\n end\n snapshot = @json_data.dig(\"snapshot\", \"element\").dup\n @resource_name = @json_data[\"type\"]\n @resource_id = @json_data[\"id\"]\n\n # Look for complex data types to add into the snapshot.\n snapshot_with_types = clean_snapshot snapshot\n\n @example = FieldSet.new(name: @resource_name, \n full_name: @resource_name, \n snapshot: snapshot_with_types, \n example_mode: example_mode,\n parent: self\n )\n end", "def create\n args = params[:bundle_source].merge( :user_id => @user.id )\n @bundle_source = BundleSource.new( args )\n\n respond_to do |format|\n if @bundle_source.save\n flash[:notice] = 'Your bundle source containter was successfully created. You should now add some audio files to it.'\n format.html { redirect_to(@bundle_source) }\n format.xml { render :xml => @bundle_source, :status => :created, :location => @bundle_source }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bundle_source.errors, :status => :unprocessable_entity }\n end\n end\n end", "def connectors_id_connector_sources_id_source_put_with_http_info(id_connector, id_source, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConnectionsApi.connectors_id_connector_sources_id_source_put ...'\n end\n # verify the required parameter 'id_connector' is set\n if @api_client.config.client_side_validation && id_connector.nil?\n fail ArgumentError, \"Missing the required parameter 'id_connector' when calling ConnectionsApi.connectors_id_connector_sources_id_source_put\"\n end\n # verify the required parameter 'id_source' is set\n if @api_client.config.client_side_validation && id_source.nil?\n fail ArgumentError, \"Missing the required parameter 'id_source' when calling ConnectionsApi.connectors_id_connector_sources_id_source_put\"\n end\n # resource path\n local_var_path = '/connectors/{id_connector}/sources/{id_source}'.sub('{' + 'id_connector' + '}', id_connector.to_s).sub('{' + 'id_source' + '}', id_source.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])\n\n # form parameters\n form_params = {}\n form_params['auth_mechanism'] = opts[:'auth_mechanism'] if !opts[:'auth_mechanism'].nil?\n form_params['disabled'] = opts[:'disabled'] if !opts[:'disabled'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:PUT, 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 => 'ConnectorSource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConnectionsApi#connectors_id_connector_sources_id_source_put\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def scrape_source (source_name)\n puts __method__.to_s\n if Source.find_by_name(source_name) != nil\n source = Source.find_by_name(source_name)\n source.number_of_resources = Site.where(:scraped_from => \"http://www.unesco.org\").size\n source.last_scraping = Time.now\n source.last_tagged = Time.now\n source.last_categorize = Time.now\n source.last_geolocalize = Time.now\n source.save\n else\n source = Source.new\n source.name = source_name\n source.source_type = \"Site\"\n source.number_of_resources = Site.where(:scraped_from => \"http://www.unesco.org\").size\n source.last_scraping = Time.now\n source.last_tagged = Time.now\n source.last_categorize = Time.now\n source.last_geolocalize = Time.now\n source.save\n end\n end", "def source=(source)\n self.each{|e| e.source=source}\n end", "def data_source_params\n params.require(:data_source).permit(:stil_active, :source_root_url, :startdate, :name, :desc, :license, :docker_image_location, :schedule_cron, :slug, :enddate, :measurement_ids => [])\n end", "def initialize source\n @source = source\n end", "def create\n @source_page = SourcePage.new(source_page_params)\n\n respond_to do |format|\n if @source_page.save\n format.html { redirect_to @source_page, notice: 'Source page was successfully created.' }\n format.json { render :show, status: :created, location: @source_page }\n else\n format.html { render :new }\n format.json { render json: @source_page.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @source_ref = SourceRef.new(source_ref_params)\n\n respond_to do |format|\n if @source_ref.save\n format.html { redirect_to @source_ref, notice: 'Source ref was successfully created.' }\n format.json { render :show, status: :created, location: @source_ref }\n else\n format.html { render :new }\n format.json { render json: @source_ref.errors, status: :unprocessable_entity }\n end\n end\n end", "def sources_get(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: SourceApi#sources_get ...\"\n end\n \n # resource path\n path = \"/sources\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\n query_params[:'client_id'] = opts[:'client_id'] if opts[:'client_id']\n query_params[:'name'] = opts[:'name'] if opts[:'name']\n query_params[:'created_at'] = opts[:'created_at'] if opts[:'created_at']\n query_params[:'updated_at'] = opts[:'updated_at'] if opts[:'updated_at']\n query_params[:'limit'] = opts[:'limit'] if opts[:'limit']\n query_params[:'offset'] = opts[:'offset'] if opts[:'offset']\n query_params[:'sort'] = opts[:'sort'] if opts[:'sort']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'inline_response_200_15')\n if Configuration.debugging\n Configuration.logger.debug \"API called: SourceApi#sources_get. Result: #{result.inspect}\"\n end\n return result\n end", "def update_metadata_from(new_source)\n # update to new version\n @metadata[:version] = new_source.version\n @metadata[:release] = \"1%{?dist}\"\n\n # add changelog entry\n changelog_entry = <<EOS\n* #{Time.now.strftime(\"%a %b %d %Y\")} #{RPM::Spec.current_author} - #{@metadata[:version]}-1\n- Update to version #{new_source.version}\nEOS\n @metadata[:changelog_entries] ||= []\n @metadata[:changelog_entries].unshift changelog_entry.rstrip\n end", "def update\n @source = Source.find(params[:id])\n create_or_update\n end", "def create\n @data_source_type = DataSourceType.new(data_source_type_params)\n\n respond_to do |format|\n if @data_source_type.save\n format.html { redirect_to @data_source_type, notice: 'Data source type was successfully created.' }\n format.json { render :show, status: :created, location: @data_source_type }\n else\n format.html { render :new }\n format.json { render json: @data_source_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_source_file\n @source_file = SourceFile.find(params[:id])\n end", "def source_attributes=(attributes)\n if attributes['_destroy']\n self.source_id = nil\n end\n end", "def create\n @enquiry_source = EnquirySource.new(params[:enquiry_source])\n\n respond_to do |format|\n if @enquiry_source.save\n format.html { redirect_to @enquiry_source, notice: 'Enquiry source was successfully created.' }\n format.json { render json: @enquiry_source, status: :created, location: @enquiry_source }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enquiry_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_source_string(source)\n @source = source\n end", "def create\n @temporary_source = TemporarySource.new(params[:temporary_source])\n\n respond_to do |format|\n if @temporary_source.save\n format.html { redirect_to @temporary_source, notice: 'Temporary source was successfully created.' }\n format.json { render json: @temporary_source, status: :created, location: @temporary_source }\n else\n format.html { render action: \"new\" }\n format.json { render json: @temporary_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @subject_source = SubjectSource.new(params[:subject_source])\n\n respond_to do |format|\n if @subject_source.save\n format.html { redirect_to @subject_source, notice: 'Subject source was successfully created.' }\n format.json { render json: @subject_source, status: :created, location: @subject_source }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subject_source.errors, status: :unprocessable_entity }\n end\n end\n end", "def sources_id_put(id, opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: SourceApi#sources_id_put ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling sources_id_put\" if id.nil?\n \n # resource path\n path = \"/sources/{id}\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'body'])\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(:PUT, 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 => 'inline_response_200_2')\n if Configuration.debugging\n Configuration.logger.debug \"API called: SourceApi#sources_id_put. Result: #{result.inspect}\"\n end\n return result\n end", "def source_name=(source_name)\n if source_name.nil?\n fail ArgumentError, 'source_name cannot be nil'\n end\n\n if source_name.to_s.length < 1\n fail ArgumentError, 'invalid value for \"source_name\", the character length must be great than or equal to 1.'\n end\n\n @source_name = source_name\n end" ]
[ "0.6935232", "0.68554217", "0.64222205", "0.63748235", "0.6332122", "0.6281105", "0.62593967", "0.62425154", "0.61860704", "0.61278796", "0.6104531", "0.6074531", "0.60655665", "0.6048231", "0.59781027", "0.59415144", "0.59271604", "0.5904945", "0.5894627", "0.58882636", "0.58815545", "0.5872361", "0.5832788", "0.5830176", "0.5818983", "0.58066124", "0.5784052", "0.5770695", "0.57655513", "0.5753077", "0.57483006", "0.57483006", "0.57483006", "0.5700811", "0.56834704", "0.5680502", "0.56588256", "0.56435204", "0.5642519", "0.5637617", "0.5600727", "0.55885506", "0.5585596", "0.5571107", "0.5569264", "0.55647814", "0.554657", "0.55396944", "0.55370706", "0.55333006", "0.553217", "0.5527875", "0.55251503", "0.5519942", "0.55185664", "0.55177855", "0.5512179", "0.54987913", "0.5468278", "0.54538137", "0.54350597", "0.54349715", "0.54319143", "0.5429003", "0.5429003", "0.5414324", "0.5403626", "0.53925014", "0.5383111", "0.537735", "0.5367205", "0.53662056", "0.5354516", "0.53530663", "0.5352984", "0.5350403", "0.5349537", "0.5339777", "0.53278106", "0.53266734", "0.52883714", "0.5288293", "0.5276952", "0.526869", "0.5258109", "0.52564347", "0.52551603", "0.5253381", "0.52511674", "0.5245626", "0.5240127", "0.5232743", "0.5229643", "0.52145094", "0.5214224", "0.5213196", "0.5194306", "0.51930463", "0.5182612", "0.5182499", "0.51780367" ]
0.0
-1
Convenience method to allow configuration options to be set in a block.
def configure yield self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configure(&block)\n raise ArgumentError, \"Block is required.\" unless block_given?\n yield @options\n end", "def config(&block)\n instance_eval(&block) if block_given?\n end", "def configure_with_block(&block)\n self.instance_eval(&block) if block_given?\n end", "def configure_with_block(&block)\n self.instance_eval(&block) if block_given?\n end", "def configure(&block)\n block.call Configuration\n end", "def configure &block\n configuration.tap { |conf| yield conf }\n end", "def configure( &block )\n @configuration = block\n end", "def configure(&block)\n @configure_blocks ||= []\n @configure_blocks << block\n end", "def config(&block_)\n ::Blockenspiel.invoke(block_, @config) if block_\n @config\n end", "def configure(&block)\n raise ArgumentError, \"Block required in order to configure\" unless block_given?\n \n yield @config\n end", "def configure &block\n @config_helper = ConfigHelper.new(&block)\n end", "def configure(&block)\n ConfigBlock.new(self, &block) if block_given?\n nil\n end", "def configure(&block)\n ConfigBlock.new(self, &block) if block_given?\n nil\n end", "def configure(&block)\n yield(configuration)\n end", "def configure\n yield configuration if block_given?\n end", "def configure(&block)\n yield config\n end", "def config(&block)\n if block_given?\n block.call(@config)\n else\n @config\n end\n end", "def configure\n if block_given?\n yield self\n else\n raise LocalJumpError, \"Required configuration block\"\n # TODO: allow users to pass configuration using an environment variable\n end\n end", "def configure(&block)\n yield(configuration)\n end", "def configure\n yield config if block_given?\n end", "def config(&block)\n instance_exec(&block)\n end", "def configure(&block)\n yield config\n config\n end", "def config(&block)\n yield(self)\n end", "def configure(&block)\n self.instance_eval(&block) if block_given?\n end", "def configure\n yield configuration if block_given?\n end", "def configure(config = nil, &block)\n config ||= Util::BlockHashBuilder.build(&block)\n @config = config.dup.freeze\n end", "def configure\n yield config if block_given?\n end", "def configure\n yield config if block_given?\n end", "def configure(&block)\n instance_eval(&block)\n end", "def configure(&block)\n instance_eval(&block)\n end", "def configure\n yield(self.config) if block_given?\n end", "def configure(&block)\n fail InvalidSyntax, '`configure` requires a block.' unless block_given?\n\n Vedeu::Configuration.configure(&block)\n end", "def with_options(options = {}, &block)\n return unless block\n backup_options = @stkw_config[:base_opt]\n @stkw_config[:base_opt] = @stkw_config[:base_opt].merge(options)\n begin\n instance_eval &block\n ensure\n @stkw_config[:base_opt] = backup_options\n end\n end", "def config\n yield @@config_options\n end", "def configure(&block)\n default_values!\n yield self\n end", "def configure &block\n\t\tinstance_eval &block\n\tend", "def configure &blk\n instance_eval &blk\n end", "def configure(&blk)\n @blk = blk if block_given?\n self\n end", "def configure(&block); end", "def configure(&block); end", "def configure(&block)\n self.instance_eval(&block)\n end", "def configure\n yield(configuration) if block_given?\n end", "def configure(&block)\n config.run_callbacks(:configure) do\n config.instance_eval(&block)\n end\n end", "def config(&block)\n if block_given?\n @@config = Config.new\n @@config.tap(&block)\n else\n @@config\n end\n end", "def with_options(&block); end", "def configure\n yield(config) if block_given?\n config\n end", "def configure(&blk)\n instance_eval &blk\n end", "def configure(&block)\n configurator.configure(&block)\n end", "def configure\n yield flags if block_given?\n end", "def configure\n yield self if block_given?\n end", "def configure\n yield self if block_given?\n end", "def configure\n yield self if block_given?\n end", "def configure\n configuration.enabled = true if configuration.enabled.nil?\n\n yield(configuration.configured_options)\n end", "def configure(&block)\n yield(self)\n end", "def configure(&block)\n yield(self)\n end", "def config(&block)\n @config ||= Configuration.new\n instance_exec(@config, &block) if block_given?\n @config\n end", "def config(&block)\n if block_given?\n c = Config.new\n c.instance_eval(&block)\n @config = c\n end\n\n @config ||= Config.new\n end", "def configure(&block)\n Fastfood::Configuration.instance_eval( &block )\n end", "def configure(options = nil)\n if block_given?\n yield default_options\n else\n default_options.deep_merge!(options)\n end\n end", "def configure\n yield self if block_given?\n end", "def configuration_defaults(&block)\n @configuration_defaults = block\n end", "def use\n if block_given?\n yield self.config\n end\n self.config\n end", "def configuration_option(*opts, &block)\n Autoproj.config.declare(*opts, &block)\nend", "def setup_config(config=nil, &block)\n @config = config || ConfigStruct.block_to_hash(block)\n end", "def configure validate: true, &block\n configuration.tap(&block)\n configuration.validate!(context: self) if validate\n end", "def configure\n yield self if block_given?\n self\n end", "def config(&blk)\n scope &blk\n self\n end", "def configure\n yield(self) if block_given?\n end", "def configure\n self.configuration ||= Configuration.new\n yield(configuration) if block_given?\n end", "def configure\n define_defaults\n yield(self) if block_given?\n true\n end", "def config(&block)\n Merb::Config.configure(&block) if block_given?\n Config\n end", "def config(&block)\n Merb::Config.configure(&block) if block_given?\n Config\n end", "def configure(&block)\n cfg = self.class::CONFIGURATOR.new(self)\n block.call(cfg)\n # allow configuration tuning for derived recipes\n post_configure\n end", "def initialize(&block)\n configure(&block) if block_given?\n end", "def configure\n yield(config)\n end", "def block\n options.fetch(:block)\n end", "def cxx_configuration(&block)\n @myblock = block\n @all_blocks = []\n end", "def configure(&block)\n @config = BeaconControl::Base::Config.new &block\n end", "def configure\n yield(config)\n end", "def options(*args, &block); end", "def preconfigure\n yield(configuration.configured_options)\n end", "def configure \n yield(configuration)\n end", "def configure\n yield(configuration)\n end", "def configure\n yield(configuration)\n end", "def configure\n yield(configuration)\n end", "def configure\n yield(configuration)\n end", "def configure\n yield(configuration)\n end", "def configure\n yield(configuration)\n end", "def configure\n yield(configuration)\n end", "def configure\n yield(configuration)\n end", "def configure\n yield(configuration)\n end", "def configure\n yield(configuration)\n end", "def configure\n self.configuration ||= Configuration.new\n yield(configuration) if block_given?\n end", "def configure\n yield configuration\n end", "def configure\n yield configuration\n end", "def configure\n yield configuration\n end", "def configure\n yield configuration\n end", "def configure\n yield configuration\n end", "def configure\n yield configuration\n end", "def configure\n yield configuration\n end", "def configure(&block)\n block.call(self) if block_given?\n return self if valid?\n end" ]
[ "0.8297133", "0.7910444", "0.78920984", "0.78920984", "0.7842941", "0.78338", "0.7830759", "0.78208023", "0.78043556", "0.776433", "0.77523476", "0.7743826", "0.7743826", "0.77218664", "0.77026474", "0.7700929", "0.7698305", "0.7682381", "0.76723194", "0.76678455", "0.76676685", "0.7639108", "0.7626473", "0.7625522", "0.7613473", "0.76082146", "0.7591298", "0.7591298", "0.755671", "0.755671", "0.7551882", "0.7540339", "0.7509197", "0.7487886", "0.74751484", "0.74597555", "0.74559647", "0.74558663", "0.7435094", "0.7435094", "0.74287766", "0.74141127", "0.7404776", "0.7390159", "0.7380167", "0.7353727", "0.73387825", "0.73322016", "0.73318565", "0.7321921", "0.7321921", "0.7321921", "0.72965115", "0.72747856", "0.72747856", "0.727088", "0.7262026", "0.72387344", "0.7198129", "0.71938914", "0.7190672", "0.71743983", "0.7169221", "0.70942867", "0.707954", "0.70790285", "0.707266", "0.7065263", "0.7058148", "0.70232433", "0.7020958", "0.7020958", "0.70198107", "0.69997656", "0.6976108", "0.69752395", "0.6973357", "0.69694597", "0.6961389", "0.69467723", "0.6933623", "0.6931909", "0.6925351", "0.6925351", "0.6925351", "0.6925351", "0.6925351", "0.6925351", "0.6925351", "0.6925351", "0.6925351", "0.6925351", "0.69244564", "0.69212854", "0.69212854", "0.69212854", "0.69212854", "0.69212854", "0.69212854", "0.69212854", "0.68914056" ]
0.0
-1
Create a hash of options and their values.
def options VALID_OPTIONS_KEYS.inject({}) do |option,key| option.merge!(key => send(key)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_hash\n OPTIONS.inject({}) do |hash, option|\n hash.merge(option.to_sym => send(option))\n end\n end", "def to_hash\n OPTIONS.inject({}) do |hash, option|\n hash.merge(option.to_sym => send(option))\n end\n end", "def to_hash\n OPTIONS.inject({}) do |hash, option|\n hash.merge(option.to_sym => send(option))\n end\n end", "def to_hash\n OPTIONS.inject({}) do |hash, option|\n hash.merge(option.to_sym => send(option))\n end\n end", "def to_hash\n OPTIONS.each_with_object({}) do |option, hash|\n key = option.first\n hash[key] = send(key)\n end\n end", "def to_hash\n OPTIONS.inject({}) do |hash, option|\n hash[option.to_sym] = self.send(option)\n hash\n end\n end", "def to_hash\n OPTIONS.inject({}) do |hash, option|\n hash[option.to_sym] = self.send(option)\n hash\n end\n end", "def to_hash\n OPTIONS.inject({}) do |hash, option|\n hash[option.to_sym] = self.send(option)\n hash\n end\n end", "def to_hash\n OPTIONS.inject({}) do |hash, option|\n hash[option.to_sym] = self.send(option)\n hash\n end\n end", "def to_hash\n OPTIONS.inject({}) do |hash, option|\n hash[option.to_sym] = self.send(option)\n hash\n end\n end", "def to_hash\n\t\ta = Hash.new\n\t\t@option.each_pair do |k, v|\n\t\t\ta[k] = v.value\n\t\tend\n\t\ta\n\tend", "def to_hash\n Hash[options.reject(&:null?).map { |o| [o.key, o.value] }]\n end", "def options\n Hash[VALID_OPTIONS.map { |key| [key, send(key)] }]\n end", "def options\n Hash[VALID_OPTIONS_KEYS.map {|key| [key, send(key)] }]\n end", "def options\n @options ||= Hash.new{ |h, k| h[k] = {} }\n end", "def options\n VALID_OPTIONS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end", "def options\n Hash[ * VALID_OPTIONS_KEYS.map { |key| [key, send(key)] }.flatten ]\n end", "def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end", "def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end", "def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end", "def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end", "def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end", "def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end", "def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end", "def options\n VALID_OPTIONS_KEYS.reduce({}) do |option, key|\n option.merge!(key => send(key))\n end\n end", "def options\n VALID_OPTIONS_KEYS.reduce({}) do |option, key|\n option.merge!(key => send(key))\n end\n end", "def options\n Hash[VALID_OPTIONS_KEYS.map {|key| [key, public_send(key)] }]\n end", "def options_hash\n the_hash = self.product_id.to_s + self.is_discount.to_s\n \n self.options.order(:option_group_id).each do |o|\n the_hash += \"#{o.option_group_id}#{o.value}#{o.price}\"\n end\n \n the_hash\n end", "def options(original_hash=nil, key, value)\n j = Hash.new\n j[key] = value\n j.merge(original_hash) unless original_hash.nil?\n j\n end", "def options\n hash = {}\n self.class.option_definitions.each do |option|\n hash[option.name] = send(option.name)\n end\n hash\n end", "def to_hash\n { @key => @options }\n end", "def make_option_list\n @data = @option.values\n if @data.is_a?(Hash)\n @keys = @data.keys\n @data = @data.values\n end\n end", "def make_option_list\n @data = @option.values\n if @data.is_a?(Hash)\n @keys = @data.keys\n @data = @data.values\n end\n end", "def options *options\n if options.size > 0\n @options = {}\n options.each do |a|\n a.is_a?(Hash) ?\n @options.update(a) :\n a.is_a?(Array) ?\n @options.update(Hash[a.zip(a)]) :\n @options.update(a => a)\n end\n end\n @options\n end", "def options \n options = {}\n VALID_OPTIONS_KEYS.each {|k| options[k] = send(k)}\n options\n end", "def options\n opts = {}\n self.configuration_options.each do |option|\n opts.merge!({option.name.to_sym => option.value})\n end\n opts\n end", "def get_options\n hash = Hash.new\n instance_variables.each do |var|\n hash[var[1..-1].to_sym] = instance_variable_get(var)\n end\n\n return hash\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k) }\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k) }\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k) }\n options\n end", "def options\n\t\t\toptions = {}\n\t\t\tVALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n\t\t\toptions\n\t\tend", "def options\n {}.tap do |options|\n VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}\n end\n end", "def options\n VALID_OPTIONS_KEYS.each_with_object({}) do |k, options|\n options[k] = send(k)\n end\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each {|k| options[k] = send(k)}\n options\n end", "def options\n OPTIONS_KEYS.inject({}) do |options, key|\n options.merge!(key => send(key))\n end\n end", "def to_hash\n {:name => name, :options => options}\n end", "def options\n {}.tap{ |options| VALID_OPTIONS_KEYS.each{|k| options[k] = send(k) } }\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each do |k|\n options[k] = send(k)\n end\n options\n end", "def options\n Hash[*VALID_PARAMS_KEYS.map {|key| [key, send(key)] }.flatten]\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each { |k| options[k] = send(k) }\n options\n end", "def options\n options = {}\n VALID_OPTIONS_KEYS.each { |k| options[k] = send(k) }\n options\n end", "def options\n Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]\n end", "def options\n Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]\n end", "def optionsHash(length = 12)\n # Don't want to always need this as this may be difficult to compile\n require 'sha3'\n\n # Get only hash relevant options\n # Filter out paths\n toHash = @Options.reject { |i| i =~ %r{.*/.*(/|$)}i }\n\n # Reject some known keys\n toHash.delete :epoch\n\n SHA3::Digest::SHA256.hexdigest(JSON.generate(toHash).to_s)[0..length - 1]\n end", "def to_hash\n {}.tap do |hash|\n # the \"key\" here is to call to_hash on all containers.\n [@wrapped_options.to_hash, @mutable_options.to_hash].each do |options|\n options.each { |k, v| hash[k.to_sym] = v }\n end\n end\n end", "def make_options(key, value, options)\n if value.is_a? Hash\n {}.merge value\n else\n options ||= {}\n options.merge(key => value)\n end\n end", "def options\n OPTIONS.each_with_object({}) do |name, hash|\n hash[name] = raw.fetch(name, nil)\n end\n end", "def options\n OPTIONS.each_with_object({}) do |name, hash|\n hash[name] = raw.fetch(name, nil)\n end\n end", "def to_h(options = { space: :none })\n Hash[key, value(options)]\n end", "def symbolize_options(options)\n options.inject({}) do |hash, opts|\n if opts[0].respond_to? :intern\n hash[opts[0].intern] = opts[1]\n else\n hash[opts[0]] = opts[1]\n end\n hash\n end\n end", "def to_hash\n default_options.to_hash\n end", "def to_hash\n default_options.to_hash\n end", "def option_set\n @options ||= {}\n end", "def options\n @options ||= Launchr::OrderedHash.new\n @options\n end", "def options\n OPTIONS.each_with_object({}) do |name, hash|\n hash[name] = raw.fetch(name, nil)\n end\n end", "def to_h(*keys)\n keys = ::Kernel::Array(keys).flatten\n __option_values__.select { |key,_| keys.empty? || keys.include?(key) }\n end", "def to_hash(options = T.unsafe(nil)); end", "def to_hash(options = T.unsafe(nil)); end", "def build_dict(option_specs) #:nodoc:\n @dict = {}\n keys = []\n option_specs.each do |option_spec|\n # Parse the specification\n m, label, oper, cont, arg = *option_spec.match(/([^=:]+)(?:([=:])([@])?(\\w+))?/)\n raise ParseError.new(\"invalid option format for '#{option_spec}'\") unless m\n\n # Figure out the specification type\n is_bang_arg = label.gsub!(/!$/, '')\n is_increment = label.gsub!(/\\+$/, '')\n forms = label.split('|')\n key = forms.first\n\n # Create an instance of OptionDefinition to hold metat data\n od = OptionDefinition.new(key)\n od.option_type = :boolean if is_bang_arg\n od.option_type = :increment if is_increment\n if (arg)\n od.option_type = (oper == '=') ? :required_argument : :optional_argument\n od.container_type = case cont\n when '@'; :array\n else :scalar\n end\n od.argument_type = case arg\n when 'f', 'float' ; :float\n when 'i', 'integer'; :integer\n when 's', 'string' ; :string\n else raise ParseError.new(\"unknown argument type '#{arg}'\")\n end\n end\n\n # Process alternate key names\n forms.each do |k|\n @dict[k] = od.dup\n keys << k\n end\n\n # Only support negation on long option names\n if (is_bang_arg)\n @dict[\"no-#{key}\"] = od.dup\n end\n end\n\n # Allow abbreviated long options\n keys.abbrev.each do |ab,key|\n @dict[ab] = @dict[key].dup\n @dict[ab].abbreviated = true unless (ab == key)\n end\n end", "def options\n opts = {}\n VALID_CONFIG_KEYS.each_key do |k|\n opts.merge!(k => send(k))\n end\n opts\n end", "def options\n opts = {}\n VALID_CONFIG_KEYS.each_key do |k|\n opts.merge!(k => send(k))\n end\n opts\n end", "def initialize_options\n @options = @spec.options.inject({}) do |options, (name, params)|\n options[name] = Option.new\n options[name].enabled = false\n options[name].description = params[\"description\"] || params\n options[name].files = params[\"files\"] || {}\n options\n end.to_struct if @spec.options\n end", "def options\n Hash[ *Configuration::VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]\n end", "def grouped_options\n @options.group_by { |option| option[:name] }.each_with_object({}) do |(name, group), hash|\n hash[name] ||= []\n group.each { |item| hash[name].push(item[:value]) }\n hash\n end\n end", "def options(hash)\n @options.merge! hash\n end", "def options\n Hash[\n *Configuration::VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten\n ]\n end", "def options\n opts = {}\n VALID_CONFIG_KEYS.each_key do |k|\n opts.merge!(k => send(k))\n end\n opts\n end", "def make_options\n options = Hash.new\n options[:file_type] = self.file_type\n options[:filepath] = self.file.path\n options[:compressed] = self.compressed\n options[:device_id] = self.device_id\n options[:file_ext] = File.extname(self.file.path) # Create extname lile \".gz\"\n options\n end", "def get_full_options\n options_hash = self.get_runtime_options\n [:task_list, :version, :_exponential_retry, :prefix_name, :return_on_start, :manual_completion, :data_converter].each do |attribute|\n options_hash.merge!(attribute => self.send(attribute)) if self.send(attribute)\n end\n options_hash\n end", "def options\n options = {}\n attributes_for(self).each do |p|\n option = self.send(p.to_sym) \n options[p] = option unless option.nil?\n end\n options\n end", "def to_hash(options={})\n case\n when (! @value || @value.empty?) && ! @block\n @hash = super\n when @block\n call\n @hash = { name.to_sym => @value.to_hash }\n end\n @hash\n end", "def config\n options.to_smash.deep_merge(opts.to_smash)\n end", "def config\n options.to_smash.deep_merge(opts.to_smash)\n end", "def options()\n {}\n end" ]
[ "0.7768143", "0.7768143", "0.7768143", "0.7768143", "0.77439386", "0.77399594", "0.77399594", "0.77399594", "0.77399594", "0.77399594", "0.7730182", "0.75393707", "0.7476299", "0.7427791", "0.74242526", "0.74219304", "0.7376853", "0.73295194", "0.73295194", "0.73295194", "0.73295194", "0.73295194", "0.73295194", "0.7317238", "0.72735655", "0.72719973", "0.7261139", "0.7254477", "0.7239053", "0.72248137", "0.720624", "0.7191521", "0.7191521", "0.7183207", "0.71636295", "0.7148446", "0.70888066", "0.70603716", "0.70603716", "0.70603716", "0.70603716", "0.70603716", "0.70603716", "0.70603716", "0.70603716", "0.70603716", "0.70603716", "0.70603716", "0.70603716", "0.70603716", "0.70603716", "0.70603716", "0.70603716", "0.7046684", "0.7046684", "0.7046684", "0.70402396", "0.70323545", "0.70184934", "0.70123136", "0.7007001", "0.69795346", "0.697633", "0.696864", "0.694543", "0.6936343", "0.6936343", "0.6923202", "0.6923202", "0.688965", "0.68795156", "0.6869561", "0.6850139", "0.68493086", "0.67950594", "0.6790224", "0.6783", "0.6783", "0.6721706", "0.67198694", "0.6713458", "0.6683225", "0.66746485", "0.66746485", "0.6672111", "0.6643465", "0.6643465", "0.66267306", "0.66045797", "0.65900815", "0.6576623", "0.6556901", "0.65474284", "0.65095806", "0.6504489", "0.6478181", "0.6472861", "0.6462", "0.6462", "0.6448537" ]
0.734749
17
Reset all configuration options to default.
def reset self.access_token = DEFAULT_ACCESS_TOKEN self.authorization_endpoint = DEFAULT_AUTHORIZATION_ENDPOINT self.client_id = DEFAULT_CLIENT_ID self.client_secret = DEFAULT_CLIENT_SECRET self.endpoint = DEFAULT_ENDPOINT self.proxy = DEFAULT_PROXY self.user_agent = DEFAULT_USER_AGENT end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset!\n @options = defaults\n end", "def reset!\n @options = defaults\n end", "def reset\n CONFIGURATION_DEFAULTS.each { |k, v| send(\"#{k}=\", v) }\n self\n end", "def reset\n @options = VALID_OPTIONS_KEYS.inject({}) do |opts, k|\n default_option = OnTheSnow::Config.const_get(\"DEFAULT_#{k.upcase}\")\n self.send(\"#{k}=\", default_option)\n opts[k.to_s] = default_option #unless default_option.nil?\n opts\n end\n self\n end", "def reset_options\n VALID_OPTIONS_KEYS.each do |key|\n send(\"#{key}=\", default_options[key])\n end\n end", "def reset_config\n config.reset_to_defaults\n end", "def reset!\n configure do |c|\n DEFAULTS.each { |k, v| c.send(\"#{k}=\", v) }\n end\n end", "def reset\n VALID_CONFIG_OPTIONS.each { |opt| self.send(\"#{opt}=\", nil) }\n self.logger = nil\n end", "def reset\n VALID_CONFIG_OPTIONS.each { |opt| self.reset_attribute(opt) }\n end", "def reset_options!\n @options = self::DEFAULT_OPTIONS.clone # 'self::' is necessary with ruby 1.8\n end", "def reset!\n @options = Name.defaults.dup\n end", "def reset\n self.options = nil\n self.option_processors = nil\n end", "def reset!\n tap { set_defaults }\n end", "def reset!\n @options = {}\n end", "def reset\n @config = empty_config\n end", "def reset!\n DeskApi::Configuration.keys.each do |key|\n send(\"#{key}=\", DeskApi::Default.options[key])\n end\n self\n end", "def reset\n @options = Marshal.load(@default)\nend", "def reset\n initialize(@options)\n end", "def reset\n VALID_OPTIONS_KEYS.each{|k| send(\"#{k}=\", nil)}\n self.endpoint = DEFAULT_ENDPOINT\n self.proxy = DEFAULT_PROXY\n self.api_version = DEFAULT_API_VERSION\n self\n end", "def reset(options={})\n options = {\n :clear => true\n }.merge(options)\n\n registry.each do |option|\n if option.respond_to?(:reset)\n option.reset\n end\n end\n\n config.clear if options[:clear]\n self\n end", "def reset\n reset_adapters\n reset_config\n reset_handlers\n reset_hooks\n end", "def reset\n configure({})\n end", "def reset_defaults_and_overrides\n default.clear\n override.clear\n end", "def reset_conf(&block)\n reset_conf_sub\n yield\n\n # reset again to go back to default setting later. Otherwise,\n # above setting is kept later.\n reset_conf_sub\n end", "def reset!\n @defaults.each do |k, v|\n instance_variable_set(k, v)\n end\n end", "def reset!\n @defaults.each { |key, value| instance_variable_set(key, value) }\n end", "def reset!\n @defaults.each { |key, value| instance_variable_set(key, value) }\n end", "def reset_defaults; end", "def reset!\n Foxkit::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Foxkit::Default.options[key])\n end\n self\n end", "def reset\n self.configuration = Configuration.new\n end", "def reset\n Configuration.new\n end", "def reset\n @configuration = Configuration.new\n end", "def reset!\n Gocdkit::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Gocdkit::Default.options[key])\n end\n self\n end", "def reset_configuration\n @configuration = nil\n end", "def reset\n reset_config\n reset_driver\n end", "def reset\n self.configuration = ({})\n config_contexts.values.each(&:reset)\n end", "def reset\n @config_file = nil\n set_defaults\n load_from_file if config_file\n end", "def reset_config!\n @log = nil\n @logger = nil\n @log_level = nil\n end", "def reset_config!\n @log = nil\n @logger = nil\n @log_level = nil\n end", "def reset!\n Whitehouse::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Whitehouse::Default.options[key])\n end\n self\n end", "def reset_config\n\t\t\t@config = {}\n\t\tend", "def reset\n @config = Config.new\n end", "def reset!\n @config = Configuration.new\n end", "def reset\n @config = nil\n end", "def reset!\n Unleashed::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Unleashed::Default.options[key])\n end\n\n self\n end", "def reset\n self.adapter = DEFAULT_ADAPTER\n self.endpoint = DEFAULT_ENDPOINT\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n # self.response = DEFAULT_RESPONSE\n self.faraday_options = DEFAULT_FARADAY_OPTIONS\n self.login = DEFAULT_LOGIN\n self.pass = DEFAULT_PASS\n self\n end", "def reset\n self.api_key = DEFAULT_API_KEY\n self.user_agent = DEFAULT_USER_AGENT\n self.search_query_defaults = DEFAULT_SEARCH_SETTINGS\n self\n end", "def reset\n self.user_agent = DEFAULT_USER_AGENT\n self.environment = DEFAULT_ENVIRONMENT\n self.api_version = DEFAULT_API_VERSION\n self.server_url = DEFAULT_SERVER_URL\n self.client_name = DEFAULT_CLIENT_NAME\n self.client_key = DEFAULT_CLIENT_KEY\n self.connection_options = DEFAULT_CONNECTION_OPTIONS\n self.middleware = DEFAULT_MIDDLEWARE\n self.accept = DEFAULT_ACCEPT\n self\n end", "def reset!\n Promisepay::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Promisepay::Default.options[key])\n end\n self\n end", "def reset\n @config = {}\n write_config\n end", "def reset\n set Exchange::Configuration::DEFAULTS[key]\n end", "def reset!\n CodesWholesale::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", CodesWholesale::Default.options[key])\n end\n self\n end", "def reset!\n self.configuration = Configuration.new\n end", "def reset!\n Octokit::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Octokit::Default.options[key])\n end\n self\n end", "def reset!\n Coinprism::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Coinprism::Default.options[key])\n end\n self\n end", "def reset\n self.adapter = DEFAULT_ADAPTER\n self.connection_options = DEFAULT_CONNECTION_OPTIONS\n self.client_id = DEFAULT_CLIENT_ID\n self.client_secret = DEFAULT_CLIENT_SECRET\n self.endpoint = DEFAULT_ENDPOINT\n self.authorize_endpoint = DEFAULT_AUTHORIZE_ENDPOINT\n self.token_endpoint = DEFAULT_TOKEN_ENDPOINT\n self.gateway = DEFAULT_GATEWAY\n self.access_token = DEFAULT_ACCESS_TOKEN\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n self\n end", "def reset\n VALID_CONFIG_KEYS.each do |k, v|\n send(\"#{k}=\", v)\n end\n self.rpc_spec_path = ::ENV.fetch('RPC_SPEC_PATH', DEFAULT_RSPEC_PATH).to_s\n options\n end", "def reset\n self.endpoint = DEFAULT_ENDPOINT\n self.user_agent = DEFAULT_USER_AGENT\n self.timeout = DEFAULT_TIMEOUT\n self.platform_credentials = DEFAULT_PLATFORM_CREDENTIALS\n self.disable_ssl_peer_verification = DEFAULT_DISABLE_SSL_PEER_VERIFICATION\n self\n end", "def reset\n set(default_preferences)\n end", "def reset!\n self.api_key \t = DEFAULT_API_KEY\n self.adapter = DEFAULT_ADAPTER\n self.endpoint = DEFAULT_ENDPOINT\n self.user_agent = DEFAULT_USER_AGENT\n self\n end", "def reset_all\n clear_commands\n reset_colors\n @app_info = nil\n @app_exe = nil\n @verbose_parameters = true\n @@default_method = nil\n @@class_cache = {}\n end", "def reset\n self.adapter = DEFAULT_ADAPTER\n self.endpoint = DEFAULT_ENDPOINT\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n self\n end", "def reset!\n HeiaHeia::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", HeiaHeia::Default.options[key])\n end\n self\n end", "def set_default_options\n end", "def reset\n self.adapter = DEFAULT_ADAPTER\n self.connection_options = DEFAULT_CONNECTION_OPTIONS\n self.consumer_key = DEFAULT_CONSUMER_KEY\n self.consumer_secret = DEFAULT_CONSUMER_SECRET\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n end", "def reset(scope = :all)\n configuration.reset(scope)\n end", "def reset\n self.adapter = DEFAULT_ADAPTER\n self.user_login = DEFAULT_USER_LOGIN\n self.user_password = DEFAULT_USER_PASSWORD\n self.endpoint = DEFAULT_ENDPOINT\n self.format = DEFAULT_FORMAT\n self.proxy = DEFAULT_PROXY\n self.cookie = DEFAULT_COOKIE\n self.user_agent = DEFAULT_USER_AGENT\n self\n end", "def reset!\n HabitatSupervisor::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", HabitatSupervisor::Default.options[key])\n end\n self\n end", "def reset!\n Cryptoprocessing::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Cryptoprocessing::Default.options[key])\n end\n self\n end", "def reset_to_defaults\n @config_stack = [ EnvironmentSource.new, DefaultSource.new ]\n reset_cache\n end", "def reset\n keys.each do |key|\n instance_variable_set(:\"@#{key}\", defaults[key])\n self\n end\n end", "def reset\n self.adapter = DEFAULT_ADAPTER\n self.client_id = DEFAULT_CLIENT_ID\n self.client_secret = DEFAULT_CLIENT_SECRET\n self.endpoint = DEFAULT_ENDPOINT\n self.user_agent = DEFAULT_USER_AGENT\n self\n end", "def reset\n self.adapter = DEFAULT_ADAPTER\n self.username = DEFAULT_USERNAME\n self.password = DEFAULT_PASSWORD\n self.organization = DEFAULT_ORGANIZATION\n self.endpoint = DEFAULT_ENDPOINT\n self.version = DEFAULT_VERSION\n self.path_prefix = DEFAULT_PATH_PREFIX\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n self.connection_options = DEFAULT_CONNECTION_OPTIONS\n self\n end", "def reset\n @config = nil\n @client = nil\n end", "def reset\n self.client_account = DEFAULT_CLIENT_ACCOUNT\n self.client_secret = DEFAULT_CLIENT_SECRET\n self.user_agent = DEFAULT_USER_AGENT\n self.endpoint = DEFAULT_ENDPOINT\n self.adapter = DEFAULT_ADAPTER\n self.connection_type = DEFAULT_CONNECTION\n end", "def reset!\n self.api_username = DEFAULT_API_USERNAME\n self.api_key = DEFAULT_API_KEY\n self.adapter = DEFAULT_ADAPTER\n self.endpoint = DEFAULT_ENDPOINT\n self.user_agent = DEFAULT_USER_AGENT\n self.raise_errors = DEFAULT_RAISE_ERRORS\n self\n end", "def reset!\n Netaxept::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Netaxept::Default.options[key])\n end\n\n HTTPI.logger = self.logger if self.logger\n HTTPI.log = self.log || self.debug\n HTTPI.log_level = self.log_level\n self\n end", "def clear\n reset_defaults\n self\n end", "def set_defaults!\n __load_config( DEFAULTS )\n end", "def reset\n self.adapter = DEFAULT_ADAPTER\n self.username = DEFAULT_USERNAME\n self.password = DEFAULT_PASSWORD\n self.endpoint = DEFAULT_ENDPOINT\n self.format = DEFAULT_FORMAT\n self.user_agent = DEFAULT_USER_AGENT\n self.faraday_options = DEFAULT_FARADAY_OPTIONS\n self.return_card_numbers = DEFAULT_RETURN_CARD_NUMBERS\n self\n end", "def reset\n self.mount_at = DEFAULT_MOUNT_AT\n self.dfly = DEFAULT_DFLY\n self.tabs = DEFAULT_TABS\n self.allowed_mime_types = DEFAULT_ALLOWED_MIME_TYPES\n self.icons = DEFAULT_ICONS\n self\n end", "def reset\n self.api_key = DEFAULT_API_KEY\n self.api_version = DEFAULT_API_VERSION\n self.endpoint = DEFAULT_ENDPOINT\n self.adapter = DEFAULT_ADAPTER\n end", "def clear_options(contexts = nil)\n Config::Options.clear(contexts)\n end", "def reset\n self.adapter = DEFAULT_ADAPTER\n self.connection_options = DEFAULT_CONNECTION_OPTIONS\n self.consumer_key = DEFAULT_CONSUMER_KEY\n self.consumer_secret = DEFAULT_CONSUMER_SECRET\n self.endpoint = DEFAULT_ENDPOINT\n self.xauth_username = DEFAULT_XAUTH_USERNAME\n self.xauth_password = DEFAULT_XAUTH_PASSWORD\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n self.logger = DEFAULT_LOGGER\n self\n end", "def reset!\n @setting_objects = @setting_templates.map { |k, _| [k, []] }.to_h\n @settings.values.each(&:reset!)\n end", "def reset\n self.tap do |c|\n c.base_uri = DEFAULT_BASE_URI\n c.endpoint = DEFAULT_END_POINT\n c.api_secret = DEFAULT_API_SECRET\n c.api_key = DEFAULT_API_KEY\n end\n end", "def reset!\n reset_endpoints!\n reset_routes!\n reset_validations!\n end", "def reset\n @@config_instance = nil\n end", "def clear_options\r\n\t\tself.option_values.clear\r\n\tend", "def reset\n self.api_id = DEFAULT_API_ID\n self.url = DEFAULT_API_URL\n self.api_key = DEFAULT_API_KEY\n self.certificate_chain = DEFAULT_CERTIFICATE_CHAIN\n end", "def reset\n providers.clear\n configured_providers.each { |k, v| self[k] = v }\n self.default = configured_default\n end", "def reset\n # Empty, but subclasses will override this.\n end", "def reset\n self.request_headers = DEFAULT_REQUEST_HEADERS\n self.endpoint = DEFAULT_ENDPOINT\n self.monitoringdata_endpoint = DEFAULT_MONITORINGDATA_ENDPOINT\n self.applogs_endpoint = DEFAULT_APPLOGS_ENDPOINT\n self.apikey = DEFAULT_APIKEY\n end", "def reset!\n default_tags.clear\n adapters.clear\n groups.each_key { |group| singleton_class.send(:remove_method, group) if group && respond_to?(group) }\n @groups = nil\n metrics.each_key { |metric| singleton_class.send(:remove_method, metric) if respond_to?(metric) }\n @metrics = nil\n collectors.clear\n configurators.clear\n instance_variable_set(:@configured_by, nil)\n instance_variable_set(:@debug_was_enabled_by, nil)\n end", "def reset!\n @apps = {}\n @default_params = {}\n @basic_auth = nil\n end", "def reset_options_with(options)\n set_agent_with(options[:user_agent]) if options.include? :user_agent\n @strict = options[:strict] if options.include? :strict\n if options.include? :load\n options = load_config_file(options[:load]) || {}\n options.symbolize_keys!\n end\n set_google_with(options[:google]) if options.include? :google\n @dicts = options[:dicts].symbolize_keys! if options.include? :dicts\n end", "def reset!\n @orm = @namespace = @source = @setting_class = nil\n self.config = nil\n self.raise_missing = nil\n self.report_missing = nil\n self.typecast_on_write = nil\n self.password_secret = nil\n end", "def reset\n self.time_step = DEFAULT_TIME_STEP\n self.availiable_days = DEFAULT_AVAILIABLE_DAYS\n self.availiable_steps = DEFAULT_AVAILIABLE_STEPS\n self.steps_day_shift = DEFAULT_STEPS_DAY_SHIFT\n end", "def set_default_options!\n @options ||= OpenStruct.new\n @options.skip_uncovered = false\n @options.mute = false\n @options.reports = []\n end", "def reset_configuration!\n @configuration = Auth::Configuration.new\n end" ]
[ "0.84116083", "0.84116083", "0.8322433", "0.8193893", "0.8148645", "0.8093593", "0.79255295", "0.78857106", "0.78715813", "0.7865288", "0.78531086", "0.78239715", "0.77768344", "0.7754632", "0.77183765", "0.76238275", "0.7580212", "0.74962825", "0.74686015", "0.7466416", "0.7449222", "0.743068", "0.7407004", "0.73612463", "0.7335618", "0.7317864", "0.7317864", "0.72624904", "0.7239085", "0.7219542", "0.7216796", "0.7212554", "0.720648", "0.7202454", "0.71983427", "0.7184801", "0.71810657", "0.71613735", "0.71613735", "0.7122151", "0.7114684", "0.7067453", "0.70628786", "0.7057857", "0.70480543", "0.7013055", "0.69861776", "0.69804865", "0.6960839", "0.69534546", "0.695256", "0.69421726", "0.6906048", "0.6902278", "0.6887776", "0.6883269", "0.68787205", "0.6875387", "0.6874931", "0.6852118", "0.684806", "0.68478703", "0.6833192", "0.68315786", "0.67877525", "0.67863846", "0.67852426", "0.67709345", "0.67685676", "0.67653805", "0.67588896", "0.6756133", "0.674026", "0.67400175", "0.66761625", "0.6674645", "0.6656586", "0.6655754", "0.6648019", "0.66470265", "0.6637798", "0.6625129", "0.6596083", "0.6592846", "0.65759885", "0.655474", "0.6549949", "0.6547688", "0.65471363", "0.65458137", "0.6544977", "0.6527937", "0.65257293", "0.65184003", "0.65104264", "0.6501511", "0.6497004", "0.649005", "0.64884245", "0.6470483" ]
0.6613178
82
Building the option dialogbox. Called during BasicDlgOptionsSetter.initialize main_vertical: vertical frame where to build all child controls
def on_build_vertframe(main_vertical) @widg_players_names = [] ix = 1 @settings["players"].each do |vv| hf = FXHorizontalFrame.new(main_vertical, LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH) FXLabel.new(hf, "Giocatore #{ix}:", nil, JUSTIFY_RIGHT|LAYOUT_FILL_X|LAYOUT_CENTER_Y) txt_f = FXTextField.new(hf, 2, nil, 0, (FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_CENTER_Y|LAYOUT_FILL_COLUMN)) txt_f.text = vv[:name].to_s @widg_players_names << txt_f ix += 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def InitializeComponent()\n\t\t\tself.@cancelButton = System.Windows.Forms.Button.new()\n\t\t\tself.@okButton = System.Windows.Forms.Button.new()\n\t\t\tself.SuspendLayout()\n\t\t\t# \n\t\t\t# cancelButton\n\t\t\t# \n\t\t\tself.@cancelButton.Anchor = (((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)))\n\t\t\tself.@cancelButton.CausesValidation = false\n\t\t\tself.@cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel\n\t\t\tself.@cancelButton.Location = System.Drawing.Point.new(257, 422)\n\t\t\tself.@cancelButton.Name = \"cancelButton\"\n\t\t\tself.@cancelButton.Size = System.Drawing.Size.new(72, 24)\n\t\t\tself.@cancelButton.TabIndex = 20\n\t\t\tself.@cancelButton.Text = \"Cancel\"\n\t\t\t# \n\t\t\t# okButton\n\t\t\t# \n\t\t\tself.@okButton.Anchor = (((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)))\n\t\t\tself.@okButton.Location = System.Drawing.Point.new(169, 422)\n\t\t\tself.@okButton.Name = \"okButton\"\n\t\t\tself.@okButton.Size = System.Drawing.Size.new(72, 24)\n\t\t\tself.@okButton.TabIndex = 19\n\t\t\tself.@okButton.Text = \"OK\"\n\t\t\tself.@okButton.Click { |sender, e| self.@okButton_Click(sender, e) }\n\t\t\t# \n\t\t\t# BaseOptionsDialog\n\t\t\t# \n\t\t\tself.@AutoScaleDimensions = System.Drawing.SizeF.new(6f, 13f)\n\t\t\tself.@AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font\n\t\t\tself.@ClientSize = System.Drawing.Size.new(336, 458)\n\t\t\tself.@Controls.Add(self.@cancelButton)\n\t\t\tself.@Controls.Add(self.@okButton)\n\t\t\tself.@FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog\n\t\t\tself.@HelpButton = true\n\t\t\tself.@MaximizeBox = false\n\t\t\tself.@MinimizeBox = false\n\t\t\tself.@Name = \"BaseOptionsDialog\"\n\t\t\tself.@StartPosition = System.Windows.Forms.FormStartPosition.CenterParent\n\t\t\tself.@Text = \"Options\"\n\t\t\tself.@FormClosed { |sender, e| self.@BaseOptionsDialog_FormClosed(sender, e) }\n\t\t\tself.ResumeLayout(false)\n\t\tend", "def init_vars\n @hbox = Gtk::HBox.new\n @mode_vbox = Gtk::VBox.new\n @idiom_vbox = Gtk::VBox.new\n @geral_vbox = Gtk::VBox.new\n @new_btn = Gtk::Button.new('')\n @quit_btn = Gtk::Button.new('')\n self.resizable = false\n self.modal = true\n @mode_rdo = []\n (0..4).each{|i|\n @mode_rdo[i] = OptionsRadioButton.new(@mode_rdo[0])\n }\n @mode_rdo[0].selected = true\n @idiom_rdo = []\n (0..2).each{|i|\n @idiom_rdo[i] = Gtk::RadioButton.new(@idiom_rdo[0])\n }\n end", "def on_build_vertframe(main_vertical)\r\n @curr_deck_key = @settings[\"deck_name\"]\r\n \r\n @deck_infos = {}\r\n # overwrite @deck_infos using custom mazzo_info\r\n load_deck_infos\r\n \r\n # option popup\r\n pane = FXPopup.new(self)\r\n ix_pane = 0\r\n @deck_infos.each do |k, v|\r\n opt = FXOption.new(pane, v[:name], nil, nil, 0, JUSTIFY_HZ_APART|ICON_AFTER_TEXT)\r\n opt.userData = k\r\n @deck_infos[k][:pane_ix] = ix_pane\r\n opt.connect(SEL_COMMAND) do |sender, sel, ptr|\r\n display_card_deck(sender.userData)\r\n end\r\n ix_pane += 1\r\n end\r\n @menu_deck_name = FXOptionMenu.new(main_vertical, pane, (FRAME_RAISED|FRAME_THICK|\r\n JUSTIFY_HZ_APART|ICON_AFTER_TEXT|LAYOUT_TOP|LAYOUT_LEFT))\r\n deck_info = @deck_infos[ @settings[\"deck_name\"] ]\r\n # set pane to the current select deck name\r\n @menu_deck_name.setCurrentNo(deck_info[:pane_ix]) if deck_info\r\n \r\n #canvas to display demo cards\r\n @canvas_disp = FXCanvas.new(main_vertical, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT )\r\n @canvas_disp.connect(SEL_PAINT, method(:onCanvasPaint))\r\n @color_backround = Fox.FXRGB(50, 170, 10)\r\n #@color_backround = Fox.FXRGB(255, 255, 255)\r\n @canvas_disp.backColor = @color_backround \r\n \r\n @log = Log4r::Logger[\"coregame_log\"] \r\n \r\n init_deck(@settings[\"deck_name\"])\r\n end", "def InitializeComponent()\n\t\t\tself.SuspendLayout()\n\t\t\t# \n\t\t\t# BaseOptionsPage\n\t\t\t# \n\t\t\tself.@AutoScaleDimensions = System.Drawing.SizeF.new(6f, 13f)\n\t\t\tself.@AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font\n\t\t\tself.@Name = \"BaseOptionsPage\"\n\t\t\tself.@Size = System.Drawing.Size.new(456, 336)\n\t\t\tself.ResumeLayout(false)\n\t\tend", "def create_external_text_extraction_dialog\n return if @external_text_extraction_dialog\n @external_text_extraction_dialog = JOptionPane.new\n @external_text_extraction_dialog.message = 'Select the text that you ' <<\n 'would like to extract.'\n panel = JPanel.new(GridBagLayout.new)\n c = GridBagConstraints.new\n c.gridx = 0\n c.gridy = 0\n c.anchor = GridBagConstraints::CENTER\n c.fill = GridBagConstraints::BOTH\n c.gridheight = 1\n c.weightx = 1\n c.weighty = 1\n @external_text_extraction_buttons = []\n ['Database', 'Troops', 'Common Events', 'Events', 'System',\n 'Vocabulary'].each do |t|\n b = JCheckBox.new(t)\n panel.add(b, c)\n @external_text_extraction_buttons << b\n c.gridy += 1\n end\n @external_text_extraction_dialog.add(panel)\n end", "def make_dialog_and_display\n dialog = JDialog.new(nil, @title)\n dialog.setLayout(BorderLayout.new)\n\n @center_panel = Box.create_vertical_box\n dialog.add(@center_panel, BorderLayout::CENTER)\n\n add_ok_cancel(dialog)\n \n GadgetFactory.add_gadget_list(@center_panel, '', @gadgets, @data_get_hash, @data_put_hash)\n\n @mgr = DialogDefaultsManager.new(dialog, @name, @defaults, @data_get_hash, @data_put_hash)\n dialog.add(@mgr, BorderLayout::NORTH) if @name\n\n @mgr.initialize_dialog\n \n dialog.set_modality_type(Java::java.awt.Dialog::ModalityType::APPLICATION_MODAL)\n dialog.pack\n dialog.set_location_relative_to(@parent_win)\n dialog.visible = true\n end", "def initialize(iParent, iController)\n super(iParent)\n\n @Controller = iController\n # The panel that will be instantiated dynamically to show plugins options\n @PluginOptionsPanel = nil\n # The corresponding displayed item info\n # [ String, Tag, Boolean, Object, Object ]\n @DisplayedItemInfo = nil\n\n # The context menu, created once on demand\n @NewMenu = nil\n\n # The displayed list info, stores the same info as PluginsOptions, but ensures that the order will not be altered.\n # The last object of each item is the instance info. It is used to keep track of the instantiated objects for this options.\n # list< [ String, Object, Boolean, Object, Object ] >\n @DisplayedList = []\n\n # Components\n @IPLC = InstantiatedPluginsListCtrl.new(self, @Controller)\n lBAddNew = Wx::Button.new(self, Wx::ID_ANY, 'Add new')\n\n # Sizers\n lMainSizer = Wx::BoxSizer.new(Wx::HORIZONTAL)\n\n lLeftSizer = Wx::BoxSizer.new(Wx::VERTICAL)\n lLeftSizer.add_item(@IPLC, :flag => Wx::GROW, :proportion => 1)\n lLeftSizer.add_item(lBAddNew, :flag => Wx::ALIGN_LEFT, :proportion => 0)\n\n lMainSizer.add_item(lLeftSizer, :flag => Wx::GROW|Wx::ALL, :border => 2, :proportion => 0)\n self.sizer = lMainSizer\n self.fit\n\n # Events\n evt_list_item_selected(@IPLC) do |iEvent|\n lIdxItem = iEvent.index\n # Instantiate a config panel for this type\n resetOptionsPanel\n @DisplayedItemInfo = @DisplayedList[lIdxItem]\n @PluginOptionsPanel = InstantiatedPluginOptionsPanel.new(self, @Controller, @DisplayedItemInfo, self, lIdxItem)\n # Fit everything in sizers\n lMainSizer.add_item(@PluginOptionsPanel, :flag => Wx::GROW, :proportion => 1)\n lOldSize = self.size\n self.fit\n self.size = lOldSize\n end\n evt_button(lBAddNew) do |iEvent|\n # Create a menu that proposes to create a new integration plugin\n if (@NewMenu == nil)\n computeNewMenu\n end\n popup_menu(@NewMenu)\n end\n\n end", "def InitializeComponent()\n\t\t\tself.@templatesLbl = System.Windows.Forms.Label.new()\n\t\t\tself.@topGbx = System.Windows.Forms.GroupBox.new()\n\t\t\tself.@templateListbox = System.Windows.Forms.ListBox.new()\n\t\t\tself.@engineCombox = System.Windows.Forms.ComboBox.new()\n\t\t\tself.@languageCombox = System.Windows.Forms.ComboBox.new()\n\t\t\tself.@removeBtn = System.Windows.Forms.Button.new()\n\t\t\tself.@newsaveBtn = System.Windows.Forms.Button.new()\n\t\t\tself.@fileNameTextbox = System.Windows.Forms.TextBox.new()\n\t\t\tself.@displayNameTxtbox = System.Windows.Forms.TextBox.new()\n\t\t\tself.@languageLbl = System.Windows.Forms.Label.new()\n\t\t\tself.@engineLbl = System.Windows.Forms.Label.new()\n\t\t\tself.@nameLbl = System.Windows.Forms.Label.new()\n\t\t\tself.@fileNameLbl = System.Windows.Forms.Label.new()\n\t\t\tself.@editBtn = System.Windows.Forms.Button.new()\n\t\t\tself.@openFileDialogBtn = System.Windows.Forms.Button.new()\n\t\t\tself.@noteTextLbl = System.Windows.Forms.Label.new()\n\t\t\tself.@noteLbl = System.Windows.Forms.Label.new()\n\t\t\tself.@openFileDialog = System.Windows.Forms.OpenFileDialog.new()\n\t\t\tself.@getItFromOnlineBtn = System.Windows.Forms.Button.new()\n\t\t\tself.@prefixTxtBox = System.Windows.Forms.TextBox.new()\n\t\t\tself.@prefixLbl = System.Windows.Forms.Label.new()\n\t\t\tself.@suffixLbl = System.Windows.Forms.Label.new()\n\t\t\tself.@suffixTxtBox = System.Windows.Forms.TextBox.new()\n\t\t\tself.SuspendLayout()\n\t\t\t# \n\t\t\t# templatesLbl\n\t\t\t# \n\t\t\tself.@templatesLbl.Location = System.Drawing.Point.new(9, 5)\n\t\t\tself.@templatesLbl.Name = \"templatesLbl\"\n\t\t\tself.@templatesLbl.Size = System.Drawing.Size.new(60, 16)\n\t\t\tself.@templatesLbl.TabIndex = 31\n\t\t\tself.@templatesLbl.Text = \"Templates\"\n\t\t\t# \n\t\t\t# topGbx\n\t\t\t# \n\t\t\tself.@topGbx.Anchor = ((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)))\n\t\t\tself.@topGbx.Location = System.Drawing.Point.new(80, 5)\n\t\t\tself.@topGbx.Name = \"topGbx\"\n\t\t\tself.@topGbx.Size = System.Drawing.Size.new(370, 8)\n\t\t\tself.@topGbx.TabIndex = 30\n\t\t\tself.@topGbx.TabStop = false\n\t\t\t# \n\t\t\t# templateListbox\n\t\t\t# \n\t\t\tself.@templateListbox.FormattingEnabled = true\n\t\t\tself.@templateListbox.Location = System.Drawing.Point.new(10, 30)\n\t\t\tself.@templateListbox.Name = \"templateListbox\"\n\t\t\tself.@templateListbox.Size = System.Drawing.Size.new(160, 303)\n\t\t\tself.@templateListbox.TabIndex = 1\n\t\t\tself.@templateListbox.SelectedIndexChanged { |sender, e| self.@templateListbox_SelectedIndexChanged(sender, e) }\n\t\t\t# \n\t\t\t# engineCombox\n\t\t\t# \n\t\t\tself.@engineCombox.FormattingEnabled = true\n\t\t\tself.@engineCombox.Location = System.Drawing.Point.new(262, 60)\n\t\t\tself.@engineCombox.Name = \"engineCombox\"\n\t\t\tself.@engineCombox.Size = System.Drawing.Size.new(121, 21)\n\t\t\tself.@engineCombox.TabIndex = 5\n\t\t\t# \n\t\t\t# languageCombox\n\t\t\t# \n\t\t\tself.@languageCombox.FormattingEnabled = true\n\t\t\tself.@languageCombox.Location = System.Drawing.Point.new(262, 30)\n\t\t\tself.@languageCombox.Name = \"languageCombox\"\n\t\t\tself.@languageCombox.Size = System.Drawing.Size.new(121, 21)\n\t\t\tself.@languageCombox.TabIndex = 3\n\t\t\t# \n\t\t\t# removeBtn\n\t\t\t# \n\t\t\tself.@removeBtn.Location = System.Drawing.Point.new(291, 210)\n\t\t\tself.@removeBtn.Name = \"removeBtn\"\n\t\t\tself.@removeBtn.Size = System.Drawing.Size.new(64, 23)\n\t\t\tself.@removeBtn.TabIndex = 16\n\t\t\tself.@removeBtn.Text = \"Remove\"\n\t\t\tself.@removeBtn.UseVisualStyleBackColor = true\n\t\t\tself.@removeBtn.Click { |sender, e| self.@removeBtn_Click(sender, e) }\n\t\t\t# \n\t\t\t# newsaveBtn\n\t\t\t# \n\t\t\tself.@newsaveBtn.Location = System.Drawing.Point.new(361, 210)\n\t\t\tself.@newsaveBtn.Name = \"newsaveBtn\"\n\t\t\tself.@newsaveBtn.Size = System.Drawing.Size.new(93, 23)\n\t\t\tself.@newsaveBtn.TabIndex = 17\n\t\t\tself.@newsaveBtn.Text = \"New/Save\"\n\t\t\tself.@newsaveBtn.UseVisualStyleBackColor = true\n\t\t\tself.@newsaveBtn.Click { |sender, e| self.@newsaveBtn_Click(sender, e) }\n\t\t\t# \n\t\t\t# fileNameTextbox\n\t\t\t# \n\t\t\tself.@fileNameTextbox.Location = System.Drawing.Point.new(262, 120)\n\t\t\tself.@fileNameTextbox.Name = \"fileNameTextbox\"\n\t\t\tself.@fileNameTextbox.Size = System.Drawing.Size.new(164, 20)\n\t\t\tself.@fileNameTextbox.TabIndex = 9\n\t\t\t# \n\t\t\t# displayNameTxtbox\n\t\t\t# \n\t\t\tself.@displayNameTxtbox.Location = System.Drawing.Point.new(262, 90)\n\t\t\tself.@displayNameTxtbox.MaxLength = 200\n\t\t\tself.@displayNameTxtbox.Name = \"displayNameTxtbox\"\n\t\t\tself.@displayNameTxtbox.Size = System.Drawing.Size.new(121, 20)\n\t\t\tself.@displayNameTxtbox.TabIndex = 7\n\t\t\t# \n\t\t\t# languageLbl\n\t\t\t# \n\t\t\tself.@languageLbl.Location = System.Drawing.Point.new(178, 30)\n\t\t\tself.@languageLbl.Name = \"languageLbl\"\n\t\t\tself.@languageLbl.Size = System.Drawing.Size.new(80, 13)\n\t\t\tself.@languageLbl.TabIndex = 2\n\t\t\tself.@languageLbl.Text = \"Language:\"\n\t\t\t# \n\t\t\t# engineLbl\n\t\t\t# \n\t\t\tself.@engineLbl.Location = System.Drawing.Point.new(178, 60)\n\t\t\tself.@engineLbl.Name = \"engineLbl\"\n\t\t\tself.@engineLbl.Size = System.Drawing.Size.new(80, 13)\n\t\t\tself.@engineLbl.TabIndex = 4\n\t\t\tself.@engineLbl.Text = \"Engine:\"\n\t\t\t# \n\t\t\t# nameLbl\n\t\t\t# \n\t\t\tself.@nameLbl.Location = System.Drawing.Point.new(178, 90)\n\t\t\tself.@nameLbl.Name = \"nameLbl\"\n\t\t\tself.@nameLbl.Size = System.Drawing.Size.new(80, 13)\n\t\t\tself.@nameLbl.TabIndex = 6\n\t\t\tself.@nameLbl.Text = \"DisplayName:\"\n\t\t\t# \n\t\t\t# fileNameLbl\n\t\t\t# \n\t\t\tself.@fileNameLbl.Location = System.Drawing.Point.new(178, 120)\n\t\t\tself.@fileNameLbl.Name = \"fileNameLbl\"\n\t\t\tself.@fileNameLbl.Size = System.Drawing.Size.new(80, 13)\n\t\t\tself.@fileNameLbl.TabIndex = 8\n\t\t\tself.@fileNameLbl.Text = \"File:\"\n\t\t\t# \n\t\t\t# editBtn\n\t\t\t# \n\t\t\tself.@editBtn.Location = System.Drawing.Point.new(228, 210)\n\t\t\tself.@editBtn.Name = \"editBtn\"\n\t\t\tself.@editBtn.Size = System.Drawing.Size.new(57, 23)\n\t\t\tself.@editBtn.TabIndex = 15\n\t\t\tself.@editBtn.Text = \"Edit\"\n\t\t\tself.@editBtn.UseVisualStyleBackColor = true\n\t\t\tself.@editBtn.Click { |sender, e| self.@editBtn_Click(sender, e) }\n\t\t\t# \n\t\t\t# openFileDialogBtn\n\t\t\t# \n\t\t\tself.@openFileDialogBtn.Location = System.Drawing.Point.new(430, 118)\n\t\t\tself.@openFileDialogBtn.Name = \"openFileDialogBtn\"\n\t\t\tself.@openFileDialogBtn.Size = System.Drawing.Size.new(24, 23)\n\t\t\tself.@openFileDialogBtn.TabIndex = 10\n\t\t\tself.@openFileDialogBtn.Text = \"...\"\n\t\t\tself.@openFileDialogBtn.UseVisualStyleBackColor = true\n\t\t\tself.@openFileDialogBtn.Click { |sender, e| self.@openFileDialogBtn_Click(sender, e) }\n\t\t\t# \n\t\t\t# noteTextLbl\n\t\t\t# \n\t\t\tself.@noteTextLbl.Location = System.Drawing.Point.new(246, 276)\n\t\t\tself.@noteTextLbl.Name = \"noteTextLbl\"\n\t\t\tself.@noteTextLbl.Size = System.Drawing.Size.new(210, 60)\n\t\t\tself.@noteTextLbl.TabIndex = 20\n\t\t\t# \n\t\t\t# noteLbl\n\t\t\t# \n\t\t\tself.@noteLbl.Font = System.Drawing.Font.new(\"Microsoft Sans Serif\", 7.8f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((0)))\n\t\t\tself.@noteLbl.Location = System.Drawing.Point.new(190, 275)\n\t\t\tself.@noteLbl.Name = \"noteLbl\"\n\t\t\tself.@noteLbl.Size = System.Drawing.Size.new(50, 18)\n\t\t\tself.@noteLbl.TabIndex = 19\n\t\t\tself.@noteLbl.Text = \"Note:\"\n\t\t\t# \n\t\t\t# openFileDialog\n\t\t\t# \n\t\t\tself.@openFileDialog.Filter = \"Template Text File (*.txt)|*.txt\"\n\t\t\tself.@openFileDialog.Title = \"Select Template Text File\"\n\t\t\t# \n\t\t\t# getItFromOnlineBtn\n\t\t\t# \n\t\t\tself.@getItFromOnlineBtn.Location = System.Drawing.Point.new(228, 244)\n\t\t\tself.@getItFromOnlineBtn.Name = \"getItFromOnlineBtn\"\n\t\t\tself.@getItFromOnlineBtn.Size = System.Drawing.Size.new(226, 23)\n\t\t\tself.@getItFromOnlineBtn.TabIndex = 18\n\t\t\tself.@getItFromOnlineBtn.Text = \"Get it from online\"\n\t\t\tself.@getItFromOnlineBtn.UseVisualStyleBackColor = true\n\t\t\tself.@getItFromOnlineBtn.Click { |sender, e| self.@getItFromOnlineBtn_Click(sender, e) }\n\t\t\t# \n\t\t\t# prefixTxtBox\n\t\t\t# \n\t\t\tself.@prefixTxtBox.Location = System.Drawing.Point.new(262, 150)\n\t\t\tself.@prefixTxtBox.MaxLength = 200\n\t\t\tself.@prefixTxtBox.Name = \"prefixTxtBox\"\n\t\t\tself.@prefixTxtBox.Size = System.Drawing.Size.new(121, 20)\n\t\t\tself.@prefixTxtBox.TabIndex = 12\n\t\t\t# \n\t\t\t# prefixLbl\n\t\t\t# \n\t\t\tself.@prefixLbl.Location = System.Drawing.Point.new(178, 150)\n\t\t\tself.@prefixLbl.Name = \"prefixLbl\"\n\t\t\tself.@prefixLbl.Size = System.Drawing.Size.new(80, 13)\n\t\t\tself.@prefixLbl.TabIndex = 11\n\t\t\tself.@prefixLbl.Text = \"Prefix:\"\n\t\t\t# \n\t\t\t# suffixLbl\n\t\t\t# \n\t\t\tself.@suffixLbl.Location = System.Drawing.Point.new(178, 180)\n\t\t\tself.@suffixLbl.Name = \"suffixLbl\"\n\t\t\tself.@suffixLbl.Size = System.Drawing.Size.new(80, 13)\n\t\t\tself.@suffixLbl.TabIndex = 13\n\t\t\tself.@suffixLbl.Text = \"Suffix:\"\n\t\t\t# \n\t\t\t# suffixTxtBox\n\t\t\t# \n\t\t\tself.@suffixTxtBox.Location = System.Drawing.Point.new(262, 180)\n\t\t\tself.@suffixTxtBox.MaxLength = 200\n\t\t\tself.@suffixTxtBox.Name = \"suffixTxtBox\"\n\t\t\tself.@suffixTxtBox.Size = System.Drawing.Size.new(121, 20)\n\t\t\tself.@suffixTxtBox.TabIndex = 14\n\t\t\t# \n\t\t\t# TemplateOptionsPage\n\t\t\t# \n\t\t\tself.@AutoScaleDimensions = System.Drawing.SizeF.new(6f, 13f)\n\t\t\tself.@AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font\n\t\t\tself.@Controls.Add(self.@suffixLbl)\n\t\t\tself.@Controls.Add(self.@suffixTxtBox)\n\t\t\tself.@Controls.Add(self.@prefixLbl)\n\t\t\tself.@Controls.Add(self.@prefixTxtBox)\n\t\t\tself.@Controls.Add(self.@getItFromOnlineBtn)\n\t\t\tself.@Controls.Add(self.@noteTextLbl)\n\t\t\tself.@Controls.Add(self.@noteLbl)\n\t\t\tself.@Controls.Add(self.@openFileDialogBtn)\n\t\t\tself.@Controls.Add(self.@editBtn)\n\t\t\tself.@Controls.Add(self.@fileNameLbl)\n\t\t\tself.@Controls.Add(self.@nameLbl)\n\t\t\tself.@Controls.Add(self.@engineLbl)\n\t\t\tself.@Controls.Add(self.@languageLbl)\n\t\t\tself.@Controls.Add(self.@displayNameTxtbox)\n\t\t\tself.@Controls.Add(self.@fileNameTextbox)\n\t\t\tself.@Controls.Add(self.@newsaveBtn)\n\t\t\tself.@Controls.Add(self.@removeBtn)\n\t\t\tself.@Controls.Add(self.@languageCombox)\n\t\t\tself.@Controls.Add(self.@engineCombox)\n\t\t\tself.@Controls.Add(self.@templateListbox)\n\t\t\tself.@Controls.Add(self.@templatesLbl)\n\t\t\tself.@Controls.Add(self.@topGbx)\n\t\t\tself.@Name = \"TemplateOptionsPage\"\n\t\t\tself.ResumeLayout(false)\n\t\t\tself.PerformLayout()\n\t\tend", "def InitializeComponent()\n\t\t\tresources = System.ComponentModel.ComponentResourceManager.new(AboutBox.to_clr_type)\n\t\t\tself.@dotNetVersionLabel = System.Windows.Forms.Label.new()\n\t\t\tself.@clrTypeLabel = System.Windows.Forms.Label.new()\n\t\t\tself.@copyright = System.Windows.Forms.Label.new()\n\t\t\tself.@label7 = System.Windows.Forms.Label.new()\n\t\t\tself.@label6 = System.Windows.Forms.Label.new()\n\t\t\tself.@label5 = System.Windows.Forms.Label.new()\n\t\t\tself.@label4 = System.Windows.Forms.Label.new()\n\t\t\tself.@infoLinkLabel = System.Windows.Forms.LinkLabel.new()\n\t\t\tself.@label3 = System.Windows.Forms.Label.new()\n\t\t\tself.@label2 = System.Windows.Forms.Label.new()\n\t\t\tself.@versionLabel = System.Windows.Forms.Label.new()\n\t\t\tself.@label1 = System.Windows.Forms.Label.new()\n\t\t\tself.@OkButton = System.Windows.Forms.Button.new()\n\t\t\tself.SuspendLayout()\n\t\t\t# \n\t\t\t# dotNetVersionLabel\n\t\t\t# \n\t\t\tself.@dotNetVersionLabel.Location = System.Drawing.Point.new(157, 264)\n\t\t\tself.@dotNetVersionLabel.Name = \"dotNetVersionLabel\"\n\t\t\tself.@dotNetVersionLabel.Size = System.Drawing.Size.new(284, 23)\n\t\t\tself.@dotNetVersionLabel.TabIndex = 25\n\t\t\t# \n\t\t\t# clrTypeLabel\n\t\t\t# \n\t\t\tself.@clrTypeLabel.Location = System.Drawing.Point.new(24, 264)\n\t\t\tself.@clrTypeLabel.Name = \"clrTypeLabel\"\n\t\t\tself.@clrTypeLabel.Size = System.Drawing.Size.new(102, 15)\n\t\t\tself.@clrTypeLabel.TabIndex = 24\n\t\t\tself.@clrTypeLabel.Text = \"CLR Version:\"\n\t\t\t# \n\t\t\t# copyright\n\t\t\t# \n\t\t\tself.@copyright.Location = System.Drawing.Point.new(157, 12)\n\t\t\tself.@copyright.Name = \"copyright\"\n\t\t\tself.@copyright.Size = System.Drawing.Size.new(297, 84)\n\t\t\tself.@copyright.TabIndex = 23\n\t\t\tself.@copyright.Text = \"Copyright (C) 2009-2012 Tom Deng\\r\\nAll Rights Reserved.\"\n\t\t\t# \n\t\t\t# label7\n\t\t\t# \n\t\t\tself.@label7.Location = System.Drawing.Point.new(24, 12)\n\t\t\tself.@label7.Name = \"label7\"\n\t\t\tself.@label7.Size = System.Drawing.Size.new(102, 28)\n\t\t\tself.@label7.TabIndex = 22\n\t\t\tself.@label7.Text = \"Copyright:\"\n\t\t\t# \n\t\t\t# label6\n\t\t\t# \n\t\t\tself.@label6.Location = System.Drawing.Point.new(157, 192)\n\t\t\tself.@label6.Name = \"label6\"\n\t\t\tself.@label6.Size = System.Drawing.Size.new(215, 29)\n\t\t\tself.@label6.TabIndex = 21\n\t\t\tself.@label6.Text = \"Emil Song,Richard Li\"\n\t\t\t# \n\t\t\t# label5\n\t\t\t# \n\t\t\tself.@label5.Location = System.Drawing.Point.new(24, 192)\n\t\t\tself.@label5.Name = \"label5\"\n\t\t\tself.@label5.Size = System.Drawing.Size.new(102, 29)\n\t\t\tself.@label5.TabIndex = 20\n\t\t\tself.@label5.Text = \"Thanks to:\"\n\t\t\t# \n\t\t\t# label4\n\t\t\t# \n\t\t\tself.@label4.Location = System.Drawing.Point.new(24, 104)\n\t\t\tself.@label4.Name = \"label4\"\n\t\t\tself.@label4.Size = System.Drawing.Size.new(102, 16)\n\t\t\tself.@label4.TabIndex = 19\n\t\t\tself.@label4.Text = \"Information:\"\n\t\t\t# \n\t\t\t# infoLinkLabel\n\t\t\t# \n\t\t\tself.@infoLinkLabel.LinkArea = System.Windows.Forms.LinkArea.new(0, 48)\n\t\t\tself.@infoLinkLabel.Location = System.Drawing.Point.new(157, 104)\n\t\t\tself.@infoLinkLabel.Name = \"infoLinkLabel\"\n\t\t\tself.@infoLinkLabel.Size = System.Drawing.Size.new(266, 16)\n\t\t\tself.@infoLinkLabel.TabIndex = 18\n\t\t\tself.@infoLinkLabel.TabStop = true\n\t\t\tself.@infoLinkLabel.Text = \"http://www.dengzhiwei.com/category/codebuilder\\r\\n\"\n\t\t\tself.@infoLinkLabel.LinkClicked { |sender, e| self.@infoLinkLabel_LinkClicked(sender, e) }\n\t\t\t# \n\t\t\t# label3\n\t\t\t# \n\t\t\tself.@label3.Location = System.Drawing.Point.new(157, 136)\n\t\t\tself.@label3.Name = \"label3\"\n\t\t\tself.@label3.Size = System.Drawing.Size.new(287, 48)\n\t\t\tself.@label3.TabIndex = 17\n\t\t\tself.@label3.Text = \"Tom Deng,Peter Chen,Gallop Chen,Taven Li,Chanle Chen\"\n\t\t\t# \n\t\t\t# label2\n\t\t\t# \n\t\t\tself.@label2.Location = System.Drawing.Point.new(24, 136)\n\t\t\tself.@label2.Name = \"label2\"\n\t\t\tself.@label2.Size = System.Drawing.Size.new(102, 29)\n\t\t\tself.@label2.TabIndex = 16\n\t\t\tself.@label2.Text = \"Developers:\"\n\t\t\t# \n\t\t\t# versionLabel\n\t\t\t# \n\t\t\tself.@versionLabel.Location = System.Drawing.Point.new(157, 232)\n\t\t\tself.@versionLabel.Name = \"versionLabel\"\n\t\t\tself.@versionLabel.Size = System.Drawing.Size.new(156, 23)\n\t\t\tself.@versionLabel.TabIndex = 15\n\t\t\tself.@versionLabel.Text = \"1.0.11.1210\"\n\t\t\t# \n\t\t\t# label1\n\t\t\t# \n\t\t\tself.@label1.Location = System.Drawing.Point.new(24, 232)\n\t\t\tself.@label1.Name = \"label1\"\n\t\t\tself.@label1.Size = System.Drawing.Size.new(102, 15)\n\t\t\tself.@label1.TabIndex = 14\n\t\t\tself.@label1.Text = \"Version:\"\n\t\t\t# \n\t\t\t# OkButton\n\t\t\t# \n\t\t\tself.@OkButton.DialogResult = System.Windows.Forms.DialogResult.Cancel\n\t\t\tself.@OkButton.Location = System.Drawing.Point.new(361, 296)\n\t\t\tself.@OkButton.Name = \"OkButton\"\n\t\t\tself.@OkButton.Size = System.Drawing.Size.new(96, 29)\n\t\t\tself.@OkButton.TabIndex = 13\n\t\t\tself.@OkButton.Text = \"OK\"\n\t\t\tself.@OkButton.Click { |sender, e| self.@OkButton_Click(sender, e) }\n\t\t\t# \n\t\t\t# AboutBox\n\t\t\t# \n\t\t\tself.@AcceptButton = self.@OkButton\n\t\t\tself.@AutoScaleDimensions = System.Drawing.SizeF.new(6f, 13f)\n\t\t\tself.@AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font\n\t\t\tself.@CancelButton = self.@OkButton\n\t\t\tself.@ClientSize = System.Drawing.Size.new(480, 336)\n\t\t\tself.@Controls.Add(self.@dotNetVersionLabel)\n\t\t\tself.@Controls.Add(self.@clrTypeLabel)\n\t\t\tself.@Controls.Add(self.@copyright)\n\t\t\tself.@Controls.Add(self.@label7)\n\t\t\tself.@Controls.Add(self.@label6)\n\t\t\tself.@Controls.Add(self.@label5)\n\t\t\tself.@Controls.Add(self.@label4)\n\t\t\tself.@Controls.Add(self.@infoLinkLabel)\n\t\t\tself.@Controls.Add(self.@label3)\n\t\t\tself.@Controls.Add(self.@label2)\n\t\t\tself.@Controls.Add(self.@versionLabel)\n\t\t\tself.@Controls.Add(self.@label1)\n\t\t\tself.@Controls.Add(self.@OkButton)\n\t\t\tself.@FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle\n\t\t\tself.@Icon = ((resources.GetObject(\"$this.Icon\")))\n\t\t\tself.@MaximizeBox = false\n\t\t\tself.@MinimizeBox = false\n\t\t\tself.@Name = \"AboutBox\"\n\t\t\tself.@ShowInTaskbar = false\n\t\t\tself.@StartPosition = System.Windows.Forms.FormStartPosition.CenterParent\n\t\t\tself.@Text = \"About CodeBuilder\"\n\t\t\tself.ResumeLayout(false)\n\t\tend", "def build_window\n max = @choices.size\n max = MaxChoice if max > MaxChoice\n self.height = max * default_line_height + window_builder[5] + window_builder[-1]\n refresh\n end", "def setup_gui\n \n end", "def create_browse_form\n\t\n\t\t\t# Create child form if not present\n\t\t\tif @dir_browse_form.nil?\n\t\t\t\n\t\t\t\t# Call GUI Utility Method to handle child form creation\n\t\t\t\tresult = GuiUtils.create_child_form({\n\t\t\t\t\t:class => Ui_DirBrowseForm,\n\t\t\t\t\t:flags => Qt::Tool | Qt::MSWindowsFixedSizeDialogHint, #| Qt::WindowTitleHint | Qt::CustomizeWindowHint, # << no close button\n\t\t\t\t\t:base_widget => CustomFontWidget.new(self),\n\t\t\t\t\t:show => false\n\t\t\t\t})\n\n\t\t\t\t# Center the newly created form relative to the parent form\n\t\t\t\t@dir_browse_form = result[:form]\n\t\t\t\tGuiUtils.center_relative_to({\n :widget => @dir_browse_form,\n :parent => @parent\n })\n\n\t\t\t\t# Set closed callbacks for the actual form and its dummy form\n\t\t\t\tui = result[:ui]\n\t\t\t\thandler = lambda { dir_browse_closed }\n\t\t\t\tui.closed_callback = handler\n\t\t\t\t@dir_browse_ui = ui.extension\n\t\t\t\t@dir_browse_ui.closed_callback = handler\n\t\t\tend\t\n\t\n\t\tend", "def create_popup_windows\n @popups = {}\n opt = H87Options.option_list\n y = @help_window.height\n for i in 0..opt.size-1\n if opt[i].popup\n popup = opt[i].popup.new(y, opt[i])\n popup.visible = false\n popup.set_handler(:cancel, method(:close_popup))\n popup.set_handler(:ok, method(:item_selected))\n @popups[i] = popup\n end\n end\n end", "def create_popup_windows\n @popups = {}\n opt = H87Options.option_list\n y = @help_window.height\n for i in 0..opt.size - 1\n if opt[i].popup\n popup = opt[i].popup.new(y, opt[i])\n popup.visible = false\n popup.set_handler(:cancel, method(:close_popup))\n popup.set_handler(:ok, method(:item_selected))\n @popups[i] = popup\n end\n end\n end", "def agroup_components\n (0..4).each{|i|\n @mode_vbox.pack_start(@mode_rdo[i])\n }\n (@idiom_rdo[0].group).reverse_each{|rdo_btn|\n @idiom_vbox.pack_start(rdo_btn)\n }\n @hbox.pack_start(@mode_vbox)\n @hbox.pack_start(@idiom_vbox)\n @geral_vbox.pack_start(@hbox)\n @geral_vbox.pack_start(@new_btn)\n @geral_vbox.pack_start(@quit_btn)\n self.add(@geral_vbox)\n end", "def create_dialog(ctx)\n awt_prefix = 'com.sun.star.awt'\n smgr = ctx.getServiceManager\n dlg = smgr.createInstanceWithContext(\"#{awt_prefix}.UnoControlDialog\", ctx)\n dlg_model = smgr.createInstanceWithContext(\"#{awt_prefix}.UnoControlDialogModel\", ctx)\n #mri = smgr.createInstanceWithContext('mytools.Mri', ctx)\n #Runo.invoke(mri, 'inspect', [dlg])\n dlg.setModel(dlg_model)\n dlg_model.setPropertyValues(\n ['Height', 'PositionX', 'PositionY', 'Width'], \n [55, 100, 100, 80])\n \n btn_model = dlg_model.createInstance(\"#{awt_prefix}.UnoControlButtonModel\")\n edit_model = dlg_model.createInstance(\"#{awt_prefix}.UnoControlEditModel\")\n btn_model.setPropertyValues(\n ['Height', 'Label', 'PositionX', 'PositionY', 'Width'], \n [20, '~Push', 5, 30, 70])\n edit_model.setPropertyValues(\n ['Height', 'PositionX', 'PositionY', 'Width'], \n [20, 5, 5, 70])\n dlg_model.insertByName('btn', btn_model)\n dlg_model.insertByName('edit', edit_model)\n \n # set button listener\n dlg.getControl('btn').addActionListener(ButtonListener.new)\n dlg.setVisible(true)\n dlg.execute\n dlg.dispose # call dispose method to destroy adapter to ensure free\nend", "def create_option_window\n @option_window = Window_GameOptions.new(@help_window.y + @help_window.height)\n @option_window.help_window = @help_window\n @option_window.set_handler(:cancel, method(:return_scene))\n @option_window.activate\n end", "def create_option_window\n @option_window = Window_GameOptions.new(@help_window.y + @help_window.height)\n @option_window.help_window = @help_window\n @option_window.set_handler(:cancel, method(:return_scene))\n @option_window.activate\n end", "def InitializeComponent()\n\t\t\tself.@ouputPathTxtbox = System.Windows.Forms.TextBox.new()\n\t\t\tself.@ouputPathLbl = System.Windows.Forms.Label.new()\n\t\t\tself.@label2 = System.Windows.Forms.Label.new()\n\t\t\tself.@label1 = System.Windows.Forms.Label.new()\n\t\t\tself.@generationLbl = System.Windows.Forms.Label.new()\n\t\t\tself.@groupBox3 = System.Windows.Forms.GroupBox.new()\n\t\t\tself.@ouputPathBtn = System.Windows.Forms.Button.new()\n\t\t\tself.@folderBrowserDialog = System.Windows.Forms.FolderBrowserDialog.new()\n\t\t\tself.@templatePathBtn = System.Windows.Forms.Button.new()\n\t\t\tself.@templatePathTxtbox = System.Windows.Forms.TextBox.new()\n\t\t\tself.@templatePathLbl = System.Windows.Forms.Label.new()\n\t\t\tself.SuspendLayout()\n\t\t\t# \n\t\t\t# ouputPathTxtbox\n\t\t\t# \n\t\t\tself.@ouputPathTxtbox.Location = System.Drawing.Point.new(105, 43)\n\t\t\tself.@ouputPathTxtbox.Name = \"ouputPathTxtbox\"\n\t\t\tself.@ouputPathTxtbox.Size = System.Drawing.Size.new(311, 20)\n\t\t\tself.@ouputPathTxtbox.TabIndex = 2\n\t\t\t# \n\t\t\t# ouputPathLbl\n\t\t\t# \n\t\t\tself.@ouputPathLbl.Location = System.Drawing.Point.new(19, 46)\n\t\t\tself.@ouputPathLbl.Name = \"ouputPathLbl\"\n\t\t\tself.@ouputPathLbl.Size = System.Drawing.Size.new(80, 13)\n\t\t\tself.@ouputPathLbl.TabIndex = 1\n\t\t\tself.@ouputPathLbl.Text = \"Output path:\"\n\t\t\t# \n\t\t\t# label2\n\t\t\t# \n\t\t\tself.@label2.Location = System.Drawing.Point.new(102, 127)\n\t\t\tself.@label2.Name = \"label2\"\n\t\t\tself.@label2.Size = System.Drawing.Size.new(345, 76)\n\t\t\tself.@label2.TabIndex = 8\n\t\t\tself.@label2.Text = \"Generationed code files will be save to Output Path directory .\\r\\nCode template fi\" + \"les will be write to/read from Template Path directory.\"\n\t\t\t# \n\t\t\t# label1\n\t\t\t# \n\t\t\tself.@label1.Font = System.Drawing.Font.new(\"Microsoft Sans Serif\", 7.8f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((0)))\n\t\t\tself.@label1.Location = System.Drawing.Point.new(22, 127)\n\t\t\tself.@label1.Name = \"label1\"\n\t\t\tself.@label1.Size = System.Drawing.Size.new(77, 40)\n\t\t\tself.@label1.TabIndex = 7\n\t\t\tself.@label1.Text = \"Note:\"\n\t\t\t# \n\t\t\t# generationLbl\n\t\t\t# \n\t\t\tself.@generationLbl.Location = System.Drawing.Point.new(9, 5)\n\t\t\tself.@generationLbl.Name = \"generationLbl\"\n\t\t\tself.@generationLbl.Size = System.Drawing.Size.new(60, 16)\n\t\t\tself.@generationLbl.TabIndex = 37\n\t\t\tself.@generationLbl.Text = \"General\"\n\t\t\t# \n\t\t\t# groupBox3\n\t\t\t# \n\t\t\tself.@groupBox3.Anchor = ((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)))\n\t\t\tself.@groupBox3.Location = System.Drawing.Point.new(80, 5)\n\t\t\tself.@groupBox3.Name = \"groupBox3\"\n\t\t\tself.@groupBox3.Size = System.Drawing.Size.new(370, 8)\n\t\t\tself.@groupBox3.TabIndex = 36\n\t\t\tself.@groupBox3.TabStop = false\n\t\t\t# \n\t\t\t# ouputPathBtn\n\t\t\t# \n\t\t\tself.@ouputPathBtn.Font = System.Drawing.Font.new(\"Microsoft Sans Serif\", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((0)))\n\t\t\tself.@ouputPathBtn.Location = System.Drawing.Point.new(422, 40)\n\t\t\tself.@ouputPathBtn.Name = \"ouputPathBtn\"\n\t\t\tself.@ouputPathBtn.Size = System.Drawing.Size.new(25, 23)\n\t\t\tself.@ouputPathBtn.TabIndex = 3\n\t\t\tself.@ouputPathBtn.Text = \"...\"\n\t\t\tself.@ouputPathBtn.TextAlign = System.Drawing.ContentAlignment.TopCenter\n\t\t\tself.@ouputPathBtn.UseVisualStyleBackColor = true\n\t\t\tself.@ouputPathBtn.Click { |sender, e| self.@ouputPathBtn_Click(sender, e) }\n\t\t\t# \n\t\t\t# templatePathBtn\n\t\t\t# \n\t\t\tself.@templatePathBtn.Font = System.Drawing.Font.new(\"Microsoft Sans Serif\", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((0)))\n\t\t\tself.@templatePathBtn.Location = System.Drawing.Point.new(422, 79)\n\t\t\tself.@templatePathBtn.Name = \"templatePathBtn\"\n\t\t\tself.@templatePathBtn.Size = System.Drawing.Size.new(25, 23)\n\t\t\tself.@templatePathBtn.TabIndex = 6\n\t\t\tself.@templatePathBtn.Text = \"...\"\n\t\t\tself.@templatePathBtn.TextAlign = System.Drawing.ContentAlignment.TopCenter\n\t\t\tself.@templatePathBtn.UseVisualStyleBackColor = true\n\t\t\tself.@templatePathBtn.Click { |sender, e| self.@templatePathBtn_Click(sender, e) }\n\t\t\t# \n\t\t\t# templatePathTxtbox\n\t\t\t# \n\t\t\tself.@templatePathTxtbox.Location = System.Drawing.Point.new(105, 82)\n\t\t\tself.@templatePathTxtbox.Name = \"templatePathTxtbox\"\n\t\t\tself.@templatePathTxtbox.Size = System.Drawing.Size.new(311, 20)\n\t\t\tself.@templatePathTxtbox.TabIndex = 5\n\t\t\t# \n\t\t\t# templatePathLbl\n\t\t\t# \n\t\t\tself.@templatePathLbl.Location = System.Drawing.Point.new(19, 85)\n\t\t\tself.@templatePathLbl.Name = \"templatePathLbl\"\n\t\t\tself.@templatePathLbl.Size = System.Drawing.Size.new(80, 13)\n\t\t\tself.@templatePathLbl.TabIndex = 4\n\t\t\tself.@templatePathLbl.Text = \"Template path:\"\n\t\t\t# \n\t\t\t# CodeGeneralOptionsPage\n\t\t\t# \n\t\t\tself.@AutoScaleDimensions = System.Drawing.SizeF.new(6f, 13f)\n\t\t\tself.@AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font\n\t\t\tself.@Controls.Add(self.@templatePathBtn)\n\t\t\tself.@Controls.Add(self.@templatePathTxtbox)\n\t\t\tself.@Controls.Add(self.@templatePathLbl)\n\t\t\tself.@Controls.Add(self.@ouputPathBtn)\n\t\t\tself.@Controls.Add(self.@ouputPathTxtbox)\n\t\t\tself.@Controls.Add(self.@ouputPathLbl)\n\t\t\tself.@Controls.Add(self.@label2)\n\t\t\tself.@Controls.Add(self.@label1)\n\t\t\tself.@Controls.Add(self.@generationLbl)\n\t\t\tself.@Controls.Add(self.@groupBox3)\n\t\t\tself.@Name = \"CodeGeneralOptionsPage\"\n\t\t\tself.ResumeLayout(false)\n\t\t\tself.PerformLayout()\n\t\tend", "def layout_fields\n @options.controls.each do | control |\n label = Label.new(control.name)\n label.rect.topleft = [@fieldX, @fieldY]\n \n button = Button.new(control.to_s) { self.capture_event(control) }\n button.rect.topleft = [ label.rect.right + @spacing, @fieldY ]\n \n # TODO: Like in the original, there's no column creation\n @fieldY = label.rect.bottom + @spacing\n \n self << label\n self << button\n end\n end", "def in_vbox\n @vbox.pack_start(@cantidad, false,false,0)\n @vbox.pack_start(@guardar, false, false, 0)\n @vbox.pack_start(@buscar_alias, false, false, 0)\n @vbox.pack_start(@seguir, false, false, 0)\n end", "def create_advanced_options\n option_separator\n option_separator 'Advanced options:'\n option_results_archive\n option_run_id\n option_observers\n option_property\n\n option_separator\n option_results_database\n end", "def createChannelAreaWidget\n VBoxLayoutWidget.new do |vb|\n @channelTypeToolBox = createChannelListToolBox\n vb.addWidget(@channelTypeToolBox)\n vb.addLayout(createListTypeButtons)\n end\n end", "def initialize form, config={}, &block\n\n # setting default first or else Widget will place its BW default\n #@color, @bgcolor = ColorMap.get_colors_for_pair $bottomcolor\n super\n @height = 1\n @color_pair = get_color $datacolor, @color, @bgcolor\n @scroll_pair = get_color $bottomcolor, :green, :white\n #@window = form.window\n @editable = false\n # you can set to true upon creation, or use F3 on vimsplit to\n # toggle focusable\n @focusable = false\n @repaint_required = true\n @_events.push(:DRAG_EVENT)\n map_keys\n unless @parent\n raise ArgumentError, \"row col and length should be provided\" if !@row || !@col || !@length\n end\n #if @parent\n #@parent.bind :ENTER_ROW do |p|\n ## parent must implement row_count, and have a @current_index\n #raise StandardError, \"Parent must implement row_count\" unless p.respond_to? :row_count\n #self.current_index = p.current_index\n #@repaint_required = true #requred otherwise at end when same value sent, prop handler\n ## will not be fired (due to optimization).\n #end\n #end\n end", "def createChannelListToolBox\n toolBox = Qt::ToolBox.new do |w|\n w.objectName = 'channelToolBox'\n end\n\n # default value\n toolBox.currentIndex = 2\n\n # TV & Radio Channels selector\n# @tvChannelListBox = KDE::ListWidget.new\n# # TV Channels\n# @tvChannelListBox.addItems( BBCNet::TVChannelRssTbl.map do |w| w[0] end )\n# toolBox.addItem( @tvChannelListBox, 'TV Channels' )\n\n\n # Radio Channels\n @radioChannelListBox = KDE::ListWidget.new\n @radioChannelListBox.addItems( BBCNet::RadioChannelRssTbl.map do |w| w[0] end )\n toolBox.addItem( @radioChannelListBox, 'Radio Channels' )\n\n # Category selector\n @categoryListBox = KDE::ListWidget.new\n @categoryListBox.addItems( BBCNet::CategoryRssTbl.map do |w| w[0] end )\n toolBox.addItem( @categoryListBox, 'Radio Categories' )\n\n toolBox\n end", "def build_notify_command_area\n Qt::HBoxLayout.new do |box|\n add_layout(box)\n @sel = Qt::Label.new\n box.add_widget(@sel)\n @notify_button = Qt::PushButton.new('Notifier ?')\n box.add_widget(@notify_button)\n connect(@notify_button, SIGNAL_CLICKED) { confirm }\n end\n end", "def InitializeComponent()\n\t\t\tself.@checkFilesExistCheckBox = System.Windows.Forms.CheckBox.new()\n\t\t\tself.@filesInMenuLbl = System.Windows.Forms.Label.new()\n\t\t\tself.@recentFilesCountTextBox = System.Windows.Forms.TextBox.new()\n\t\t\tself.@listLbl = System.Windows.Forms.Label.new()\n\t\t\tself.@topGbox = System.Windows.Forms.GroupBox.new()\n\t\t\tself.@recentFilesLbl = System.Windows.Forms.Label.new()\n\t\t\tself.SuspendLayout()\n\t\t\t# \n\t\t\t# checkFilesExistCheckBox\n\t\t\t# \n\t\t\tself.@checkFilesExistCheckBox.AutoSize = true\n\t\t\tself.@checkFilesExistCheckBox.Location = System.Drawing.Point.new(27, 72)\n\t\t\tself.@checkFilesExistCheckBox.Name = \"checkFilesExistCheckBox\"\n\t\t\tself.@checkFilesExistCheckBox.Size = System.Drawing.Size.new(185, 17)\n\t\t\tself.@checkFilesExistCheckBox.TabIndex = 4\n\t\t\tself.@checkFilesExistCheckBox.Text = \"Check that files exist before listing\"\n\t\t\tself.@checkFilesExistCheckBox.UseVisualStyleBackColor = true\n\t\t\t# \n\t\t\t# filesInMenuLbl\n\t\t\t# \n\t\t\tself.@filesInMenuLbl.Location = System.Drawing.Point.new(147, 33)\n\t\t\tself.@filesInMenuLbl.Name = \"filesInMenuLbl\"\n\t\t\tself.@filesInMenuLbl.Size = System.Drawing.Size.new(96, 24)\n\t\t\tself.@filesInMenuLbl.TabIndex = 3\n\t\t\tself.@filesInMenuLbl.Text = \"files in menu\"\n\t\t\t# \n\t\t\t# recentFilesCountTextBox\n\t\t\t# \n\t\t\tself.@recentFilesCountTextBox.Location = System.Drawing.Point.new(91, 33)\n\t\t\tself.@recentFilesCountTextBox.MaxLength = 50\n\t\t\tself.@recentFilesCountTextBox.Name = \"recentFilesCountTextBox\"\n\t\t\tself.@recentFilesCountTextBox.Size = System.Drawing.Size.new(40, 20)\n\t\t\tself.@recentFilesCountTextBox.TabIndex = 2\n\t\t\tself.@recentFilesCountTextBox.Text = \"3\"\n\t\t\t# \n\t\t\t# listLbl\n\t\t\t# \n\t\t\tself.@listLbl.Location = System.Drawing.Point.new(27, 33)\n\t\t\tself.@listLbl.Name = \"listLbl\"\n\t\t\tself.@listLbl.Size = System.Drawing.Size.new(55, 16)\n\t\t\tself.@listLbl.TabIndex = 1\n\t\t\tself.@listLbl.Text = \"List\"\n\t\t\t# \n\t\t\t# topGbox\n\t\t\t# \n\t\t\tself.@topGbox.Anchor = ((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)))\n\t\t\tself.@topGbox.Location = System.Drawing.Point.new(80, 5)\n\t\t\tself.@topGbox.Name = \"topGbox\"\n\t\t\tself.@topGbox.Size = System.Drawing.Size.new(370, 8)\n\t\t\tself.@topGbox.TabIndex = 35\n\t\t\tself.@topGbox.TabStop = false\n\t\t\t# \n\t\t\t# recentFilesLbl\n\t\t\t# \n\t\t\tself.@recentFilesLbl.Location = System.Drawing.Point.new(9, 5)\n\t\t\tself.@recentFilesLbl.Name = \"recentFilesLbl\"\n\t\t\tself.@recentFilesLbl.Size = System.Drawing.Size.new(70, 16)\n\t\t\tself.@recentFilesLbl.TabIndex = 36\n\t\t\tself.@recentFilesLbl.Text = \"Recent Files\"\n\t\t\t# \n\t\t\t# RecentFilesOptionsPage\n\t\t\t# \n\t\t\tself.@AutoScaleDimensions = System.Drawing.SizeF.new(6f, 13f)\n\t\t\tself.@AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font\n\t\t\tself.@Controls.Add(self.@checkFilesExistCheckBox)\n\t\t\tself.@Controls.Add(self.@filesInMenuLbl)\n\t\t\tself.@Controls.Add(self.@recentFilesCountTextBox)\n\t\t\tself.@Controls.Add(self.@listLbl)\n\t\t\tself.@Controls.Add(self.@topGbox)\n\t\t\tself.@Controls.Add(self.@recentFilesLbl)\n\t\t\tself.@Name = \"RecentFilesOptionsPage\"\n\t\t\tself.ResumeLayout(false)\n\t\t\tself.PerformLayout()\n\t\tend", "def on_build_vertframe(main_vertical)\n @widg_players_names = []\n ix = 1\n @settings[\"players\"].each do |vv|\n hf = FXHorizontalFrame.new(main_vertical, LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH)\n FXLabel.new(hf, \"Giocatore #{ix}:\", nil, JUSTIFY_RIGHT|LAYOUT_FILL_X|LAYOUT_CENTER_Y)\n txt_f = FXTextField.new(hf, 2, nil, 0, (FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_CENTER_Y|LAYOUT_FILL_COLUMN))\n txt_f.text = vv[:name].to_s\n @widg_players_names << txt_f\n ix += 1 \n end\n end", "def build_selection_area\n update_classification\n @check_buttons = []\n @numbers = []\n @pending_notifications.each_pair.with_index do |(key, _), idx|\n line = Qt::HBoxLayout.new\n add_layout(line)\n add_variable_elements(line, idx)\n line.add_widget(Qt::Label.new(format_key(key)))\n line.addStretch\n end\n end", "def initialize(main_window)\n\t\tsuper()\n\t\t@main_window = main_window\n\t\t@grid_sensitive_spin_button_list = Array.new\n\t\tself.enable_popup = true\n\t\tself.add(w = Box_Widget.new(self), :tab_label => 'Box')\n\t\tself.set_tab_reorderable(w, true)\n\t\tself.add(w = Net_Widget.new(self), :tab_label => 'Net')\n\t\tself.set_tab_reorderable(w, true)\n\t\tself.add(w = Pin_Widget.new(self), :tab_label => 'Pin')\n\t\tself.set_tab_reorderable(w, true)\n\t\tself.add(w = Path_Widget.new(self), :tab_label => 'Path')\n\t\tself.set_tab_reorderable(w, true)\n\t\tself.add(w = Sym_Widget.new(self), :tab_label => 'Sym')\n\t\tself.set_tab_reorderable(w, true)\n\tend", "def create_gui\n \n # The root\n \n root = TkRoot.new { title \"Camera Control\" }\n TkGrid.columnconfigure root, 0, :weight => 1\n TkGrid.rowconfigure root, 0, :weight => 1\n\n # Enclosing frame\n\n content = Tk::Tile::Frame.new(root) { padding \"5 5 12 12\" }\n content.grid :sticky => 'nsew'\n\n # -------------- Controller Details frame --------------\n\n details = Tk::Tile::Labelframe.new(content) { text 'Image Control' }\n details.grid :column => 0, :row => 0, :sticky => 'nsew', :columnspan => 4\n details['borderwidth'] = 2\n\n # Entries in the details frame\n\n row = 0\n\n @slider_controls.keys.sort.each do |key|\n control = @slider_controls[key]\n $vars[key] = TkVariable.new\n $vars[key].value = control.default\n @labels[key] = Tk::Tile::Label.new(details) { text \"#{key}:\" }\n @labels[key].grid :column => 0, :row => row, :sticky => 'ew'\n @entries[key] = Tk::Tile::Scale.new(details, variable: $vars[key]) {\n orient 'horizontal';\n length 300;\n from control.min.to_f;\n to control.max.to_f;\n command { tk_callback('sliding_bar', key) }\n }\n @entries[key].grid :column => 1, :row => row, :sticky => 'ew'\n\n val = Tk::Tile::Entry.new(details, :width => 6, :textvariable => $vars[key] )\n val.grid :column => 3, :row => row, :sticky => 'ew'\n row += 1\n end # each controls\n TkWinfo.children(details).each {|w| TkGrid.configure w, :padx => 5, :pady => 3}\n TkGrid.columnconfigure(content, 0,\t:weight => 1) \n \n # -------------- Toggle frame ---------------\n\n tf = Tk::Tile::Labelframe.new(content) { \n text 'Options';\n padding \"5 5 12 12\"\n }\n tf.grid :column => 0, :row => 2, :sticky => 'nsew', :columnspan => 6\n tf['borderwidth'] = 2\n\n column = 1\n row = 1\n @toggle_controls.keys.sort.each do |key|\n control = @toggle_controls[key]\n $vars[key] = TkVariable.new\n $vars[key].value = control.default\n @entries[key] = Tk::Tile::CheckButton.new(tf) {\n text key;\n command { tk_callback('toggle_button', key) }\n onvalue 1;\n offvalue 0;\n variable $vars[key]\n }\n @entries[key].grid :column => column, :row => row, :sticky => 'ew'\n row += 1\n end # toggle controls\n\n @choice_controls.keys.sort.each do |key|\n control = @choice_controls[key]\n\n # the label\n\n l = Tk::Tile::Label.new(tf) { text key }\n\n # the combo box\n\n $vars[key] = TkVariable.new\n $vars[key].value = control.choices[control.default.to_i.to_s]\n @entries[key] = Tk::Tile::Combobox.new(tf) { \n textvariable $vars[key];\n values control.choices.values \n }\n @entries[key].bind(\"<ComboboxSelected>\") { combo_box(key) }\n l.grid :column => 2, :row => row, :sticky => 'ew'\n @entries[key].grid :column => 1, :row => row, :sticky => 'ew'\n row += 1\n end # choice controls\n\n # -------------- Motor control frame --------------\n\n # Only show this part if the camera supports motor controls\n\n if @motor_controls.size > 0\n \n mcf = Tk::Tile::Labelframe.new(content) { text 'Motor Controls' }\n mcf.grid :column => 0, :row => 3, :sticky => 'nsew', :columnspan => 6\n mcf['borderwidth'] = 4\n\n image_path = File.dirname(__FILE__) + '/imgs/'\n\n au = TkPhotoImage.new(:file => image_path + 'Arrow-Up-icon.gif')\n ad = TkPhotoImage.new(:file => image_path + 'Arrow-Down-icon.gif')\n al = TkPhotoImage.new(:file => image_path + 'Arrow-Left-icon.gif')\n ar = TkPhotoImage.new(:file => image_path + 'Arrow-Right-icon.gif')\n ri = TkPhotoImage.new(:file => image_path + 'reset.gif')\n\n tu = Tk::Tile::Button.new(mcf) {\n image au;\n command { tk_callback('tilt_up') }\n }\n tu.grid :column => 2, :row => 1, :stick => 'ew'\n\n td = Tk::Tile::Button.new(mcf) {\n image ad;\n command { tk_callback('tilt_down') }\n }\n td.grid :column => 2, :row => 3, :stick => 'ew'\n\n pl = Tk::Tile::Button.new(mcf) {\n image al;\n command { tk_callback('pan_left') }\n }\n pl.grid :column => 1, :row => 2, :stick => 'ew'\n\n pr = Tk::Tile::Button.new(mcf) {\n image ar;\n command { tk_callback('pan_right') }\n }\n pr.grid :column => 3, :row => 2, :stick => 'ew'\n\n ro = Tk::Tile::Button.new(mcf) {\n image ri;\n command { tk_callback('reset_to_origin') }\n }\n ro.grid :column => 2, :row => 2, :stick => 'ew'\n end\n\n # -------------- Message frame --------------\n\n mf = Tk::Tile::Labelframe.new(content) { text 'Messages' }\n mf.grid :column => 0, :row => 4, :sticky => 'nsew', :columnspan => 6\n mf['borderwidth'] = 2\n\n \n TkGrid.columnconfigure(mf, 0, :weight => 1)\n TkGrid.rowconfigure(mf, 0, :weight => 1)\n\n @msg_text = TkText.new(mf) { height 10; background \"white\" }\n @msg_text.grid :column => 0, :row => 2\n @msg_text['state'] = :normal\n\n TkWinfo.children(content).each {|w| TkGrid.configure w, :padx => 5, :pady => 5}\n# TkWinfo.children(data).each {|w| TkGrid.configure w, :padx => 5, :pady => 3}\n\n end", "def multiple_parameter_set_box\n view = Box.create_vertical_box\n top_row = Box.create_horizontal_box\n top_row.add(collapse_button)\n top_row.add(parameter_set_selection_combo)\n view.add(top_row)\n bottom_row = multi_buttons\n view.add(bottom_row)\n view.add(JSeparator.new)\n view.add(JSeparator.new)\n view\n end", "def initialize(parent)\n @gtkObject = Gtk::Box.new :vertical\n @gtkObject.set_name 'test'\n\t\t@cb = Gtk::ComboBoxText.new\n @cb.append_text 'Général'\n @cb.append_text 'Contre La Montre'\n @cb.append_text 'Mode Facile'\n @cb.append_text 'Mode Moyen'\n @cb.append_text 'Mode Difficile'\n\t\t@gtkObject.add(@cb)\n\t\tstore = Gtk::ListStore.new(String, Integer)\n\t\ttreeview = Gtk::TreeView.new(store)\n\t\tsetup_tree_view(treeview)\n\t\tdata = desereliseJoueurs\n\n\t\t\tif(data != nil)\n\t\t\t\tdata.each_with_index do |e, i|\n\t\t \t \t\titer = store.append\n\t\t \t\t\tstore.set_value(iter, 0, data[i].donneNom)\n\t\t \t\t\tstore.set_value(iter, 1, data[i].donneScore)\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\n\t\t\tboxTree = Gtk::Box.new(:vertical, 10)\n\t\t\tboxTree.border_width = 10\n\t\t\t@gtkObject.pack_start(boxTree,:expand => true, :fill => true, :padding => 0)\n\n\t\t\tscrolled_win = Gtk::ScrolledWindow.new\n\t\t\tscrolled_win.add_with_viewport(treeview)\n\t\t\tscrolled_win.set_policy(:automatic,:automatic)\n\t\t\tboxTree.pack_start(scrolled_win,:expand => true, :fill => true, :padding => 0)\n\n\t\t\tseparator = Gtk::Separator.new(:horizontal)\n\t\t\t@gtkObject.pack_start(separator, :expand => false, :fill => true, :padding => 0)\n\t\t\tseparator.show\n\n\n\t\t\tbRetour = MenuItemUi.new(:back,MenuAssets.getInstance())\n\t\t\tbRetour.setOnClickEvent(Proc.new{\n\t\t\t\tparent.changeBackground(\"menuPrincipal\")\n\t\t\t\tparent.display(parent.mainMenu)\n\t\t\t})\n\t\t\t@gtkObject.add(bRetour.gtkObject)\n\t\t\t\n\t\t\tif(data != nil)\n\t\t\t\t@cb.signal_connect \"changed\" do |w, z|\n\t\t \t\t\tselectn(w,z,data,store)\n\t\t\t\tend\n\t\t\tend\n\tend", "def configure_component component\n #component.set_form @parent <<--- definitely NOT\n component.form = @parent\n component.rows_panned = component.cols_panned = 0\n component.parent_component = self # added 2010-02-27 so offsets can go down ?\n component.should_create_buffer = true \n component.row = @row + TAB_ROW_OFFSET # 2\n component.col = @col + TAB_COL_OFFSET\n\n # current_form likely to be nil XXX\n scr_top = component.row # for Pad, if Pad passed as in SplitPane\n scr_left = component.col # for Pad, if Pad passed as in SplitPane\n ho = TAB_ROW_OFFSET + 2 # 5\n component.set_buffering(:target_window => @target_window || @parentwin, :form => @current_form, :bottom => @height-ho, :right => @width-2, :screen_top => scr_top, :screen_left => scr_left)\n # if left nil, then we expand the comp\n component.height ||= @height - (ho - 1) # 1 keeps lower border inside by 1\n component.width ||= @width - 0 # 0 keeps it flush on right border\n\n\n end", "def create_player_options\n\t\tnames = std_player_names\n\t\tcolours = std_player_colours\n\t\tcontrols = ControlMapper.new.controls()\n\n\t\tfor i in 0...Constants::MAX_PLAYERS\n\t\t\tentry = PlayerEntry.new(@window,\n\t\t\t\t\t\t\t\t\t@main,\n\t\t\t\t\t\t\t\t\t@text_input,\n\t\t\t\t\t\t\t\t\tnames[i], \n\t\t\t\t\t\t\t\t\tcolours[i],\n\t\t\t\t\t\t\t\t\tcontrols[i],\n\t\t\t\t\t\t\t\t \tself)\n\t\t\t\t\t\t\t\t\t \n\t\t\tentry.x = 100\n\t\t\tentry.y = 100 * (i+1)\n\t\t\tadd_component(entry)\n\t\t\t@entries << entry\n\t\tend\n\tend", "def create_container_and_configuration(p_args)\n\n # Create container\n tool_container = GuiUtils.create_child_form({\n\t\t\t\t:class => Ui_ToolDescriptionWidget,\n :flags => 0,\n\t\t\t\t:base_widget => CustomFontWidget.new(@tools_form),\n\t\t\t})\n\n # Create configuration\n tool_config = ToolConfiguration.new(p_args)\n\n # Return results\n { :container => tool_container, :config => tool_config }\n end", "def build_options(selected, options = T.unsafe(nil)); end", "def init_vars\n self.resize(200,250)\n @new_btn = Gtk::Button.new('')\n @default_size_btn = Gtk::Button.new('')\n @quit_btn = Gtk::Button.new('')\n end", "def main_window\r\n super\r\n # Make help window\r\n @help_window = Window_Help.new\r\n @help_window.set_text(@help_text)\r\n # Make save file window\r\n @savefile_windows = []\r\n for i in 0..3\r\n @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))\r\n end\r\n @savefile_windows[@file_index].selected = true\r\n end", "def build_report_area\n Qt::HBoxLayout.new do |box|\n add_layout(box)\n @report = Qt::TextEdit.new\n box.add_widget(@report)\n @report.append(\"<b>Mode #{@mode ? 'réel' : 'simulé'}</b>\")\n end\n end", "def agroup_components\n table = Gtk::Table.new(11,8)\n (0..8).each{|i|\n x = $glob.btns[i].x\n y = $glob.btns[i].y\n table.attach($glob.btns[i],(x*2)+1,(x*2)+2,(y*2)+1,(y*2)+2)\n }\n (0..3).each{|i|\n table.attach(Gtk::VSeparator.new,i*2,(i*2)+1,0,8)\n table.attach(Gtk::HSeparator.new,0,8,i*2,(i*2)+1) \n }\n table.attach(@new_btn,0,8,8,9) \n table.attach(@default_size_btn,0,8,9,10)\n table.attach(@quit_btn,0,8,10,11)\n self.add(table)\n end", "def set_windows\n set_title \"R-Bloggyn::#{@usuario.alias}\" #nombre de la ventana\n set_default_size 640, 480 #tamaño de la ventana\n set_skip_taskbar_hint true\n set_window_position Gtk::Window::POS_CENTER #posicion de la ventana\n self.set_attributes\n add @hbox\n show_all #muestra todo\n end", "def init_gui\r\n pathFile = \"\"\r\n pathCreate = \"\"\r\n fixed = Gtk::Fixed.new\r\n add fixed\r\n label = Gtk::Label.new(\"Xml - File Path:\")\r\n label.set_size_request 100,30\r\n button = Gtk::FileChooserButton.new(\"Search\", Gtk::FileChooser::ACTION_OPEN)\r\n button.set_size_request 280,30\r\n filter = Gtk::FileFilter.new\r\n filter.add_pattern('*.xml')\r\n button.add_filter(filter)\r\n button.signal_connect('selection_changed') do |w|\r\n pathFile = w.filename.to_s\r\n arrayPath = pathFile.split('\\\\')\r\n pathCreate = \"\"\r\n for i in 0..arrayPath.length-2\r\n pathCreate+=arrayPath[i]+\"\\\\\"\r\n end\r\n pathCreate+=\"files\\\\\"\r\n end\r\n labelDB = Gtk::Label.new(\"Name Database:\")\r\n entryDB = Gtk::Entry.new\r\n entryDB.set_width_chars 45\r\n entryDB.set_text \"\"\r\n labelDBServer = Gtk::Label.new(\"Server Database:\")\r\n entryDBServer = Gtk::Entry.new\r\n entryDBServer.set_width_chars 45\r\n entryDBServer.set_text \"\"\r\n labelDBUser = Gtk::Label.new(\"User Database:\")\r\n entryDBUser = Gtk::Entry.new\r\n entryDBUser.set_width_chars 45\r\n entryDBUser.set_text \"\"\r\n labelDBPass = Gtk::Label.new(\"Pass Database:\")\r\n entryDBPass = Gtk::Entry.new\r\n entryDBPass.set_width_chars 45\r\n entryDBPass.visibility = false\r\n entryDBPass.invisible_char = 42\r\n labelEmail = Gtk::Label.new(\"Admin Email:\")\r\n entryEmail = Gtk::Entry.new\r\n entryEmail.set_width_chars 45\r\n entryEmail.set_text \"\"\r\n btGenerate = Gtk::Button.new \"Generate\"\r\n btGenerate.signal_connect \"clicked\" do\r\n if pathFile == \"\" or pathCreate == \"\"\r\n showMessage(\"Debe seleccionar el archivo de origen\",Gtk::MessageDialog::ERROR,self)\r\n elsif entryDB.text.strip == \"\"\r\n showMessage(\"Debe Ingresar el nombre de la base de datos\",Gtk::MessageDialog::ERROR,self)\r\n elsif entryDBServer.text.strip == \"\"\r\n showMessage(\"Debe Ingresar el servidor de la base de datos\",Gtk::MessageDialog::ERROR,self)\r\n elsif entryDBUser.text.strip == \"\"\r\n showMessage(\"Debe Ingresar el nombre de usuario de la base de datos\",Gtk::MessageDialog::ERROR,self)\r\n elsif entryEmail.text.strip == \"\"\r\n showMessage(\"Debe Ingresar el email del administrador\",Gtk::MessageDialog::ERROR,self)\r\n else\r\n readPollFileXml(pathFile,pathCreate,entryDB.text.strip, entryDBServer.text.strip,entryDBUser.text.strip,entryDBPass.text.strip,entryEmail.text.strip)\r\n showMessage(\"Se ha creado el formulario Satisfactoriamente en la ruta: \"+pathCreate,Gtk::MessageDialog::INFO,self)\r\n Gtk.main_quit\r\n end\r\n end\r\n btCancel = Gtk::Button.new \"Cancel\"\r\n btCancel.signal_connect \"clicked\" do\r\n Gtk.main_quit\r\n end\r\n fixed.put label,10,10\r\n fixed.put labelDB,15,58\r\n fixed.put labelDBServer,15,103\r\n fixed.put labelDBUser,24,148\r\n fixed.put labelDBPass,24,193\r\n fixed.put labelEmail,30,238\r\n fixed.put button,105,10\r\n fixed.put entryDB,105,55\r\n fixed.put entryDBServer,105,100\r\n fixed.put entryDBUser,105,145\r\n fixed.put entryDBPass,105,190\r\n fixed.put entryEmail,105,235\r\n fixed.put btGenerate,145,275\r\n fixed.put btCancel,205,275\r\n end", "def initialize(iParent, iSC, iRootTag, iController, iType = nil, iInitialTag = nil)\n if (iSC == nil)\n @Type = iType\n else\n @Type = iSC.Type\n end\n\n super(iParent,\n :title => \"Edit Shortcut (#{@Type.pluginDescription[:PluginName]})\",\n :style => Wx::DEFAULT_DIALOG_STYLE|Wx::RESIZE_BORDER|Wx::MAXIMIZE_BOX\n )\n\n # First create all the panels that will fit in this dialog\n require 'pbs/Windows/ContentMetadataPanel'\n @ContentMetadataPanel = ContentMetadataPanel.new(self, @Type, iController)\n if (iSC == nil)\n lTags = {}\n if (iInitialTag != nil)\n lTags[iInitialTag] = nil\n end\n createTagsPanel(self, iRootTag, lTags)\n @ContentMetadataPanel.setData(iType.createEmptyContent, {'title' => 'New Shortcut', 'icon' => nil})\n else\n createTagsPanel(self, iRootTag, iSC.Tags)\n @ContentMetadataPanel.setData(iSC.Content, iSC.Metadata)\n end\n lButtonsPanel = createButtonsPanel(self)\n # Fit them all now, as we will use their true sizes to determine proportions in the sizers\n @ContentMetadataPanel.fit\n @TagsPanel.fit\n\n # Then put everything in place using sizers\n\n # Create the main sizer\n lMainSizer = Wx::BoxSizer.new(Wx::VERTICAL)\n self.sizer = lMainSizer\n\n # First sizer item is the group of 3 panels (content, metadata and tags)\n l3PanelsSizer = Wx::BoxSizer.new(Wx::HORIZONTAL)\n\n l3PanelsSizer.add_item(@ContentMetadataPanel, :flag => Wx::GROW, :proportion => @ContentMetadataPanel.size.width)\n # A little space\n l3PanelsSizer.add_item([8,0], :proportion => 0)\n # The second part of the 3 Panels sizer is the panel of tags\n l3PanelsSizer.add_item(@TagsPanel, :flag => Wx::GROW, :proportion => @TagsPanel.size.width)\n\n lMainSizer.add_item(l3PanelsSizer, :flag => Wx::GROW|Wx::ALL, :border => 8, :proportion => 1)\n # The second part of the main sizer is the panel containing the buttons\n lMainSizer.add_item(lButtonsPanel, :flag => Wx::GROW|Wx::ALL, :border => 8, :proportion => 0)\n\n self.fit\n\n end", "def set_controls_help\n @control_help_window.clear\n set_status_controls if @status_window.active\n set_slots_controls if @slot_window.active \n set_item_controls if @item_window.active\n @control_help_window.refresh\n end", "def init_dialogs\n @entity_dialog = EntityDialog.new self, true\n @entity_dialog.set_visible false\n\n @connection_dialog = ConnectionDialog.new self, true\n @connection_dialog.set_visible false\n end", "def build_ui\n\t\treturn if @toolbars_enabled\n\t\t@config['UI'].each { |host_id, item|\n\t\t\ttype, name = item['Host'].split(':')\n\t\t\tif type == 'Toolbar'\n\t\t\t\t# Create Toolbar\n\t\t\t\ttoolbar = UI::Toolbar.new(name)\n\t\t\t\t# Add buttons\n\t\t\t\titem.each { |id, button|\n\t\t\t\t\tnext unless button.is_a?(JSON)\n\t\t\t\t\tadd_item(toolbar, id)\n\t\t\t\t}\n\t\t\t\t# Show only if the toolbar was shown last time\n\t\t\t\t# Seems to be a bug related. When a toolbar is created for the first time\n\t\t\t\t# Sketchup will list it under View->Toolbars ticked of, like it's been shown.\n\t\t\t\t# So if we don't show it when it has never been shown, then the user must\n\t\t\t\t# untick then tick it again. Confusing for the user.\n\t\t\t\t#toolbar.restore if toolbar.get_last_state == TB_VISIBLE\n\t\t\t\tif toolbar.get_last_state == TB_VISIBLE\n\t\t\t\t\ttoolbar.restore\n\t\t\t\t\tUI.start_timer( 0.1, false ) { toolbar.restore } # SU bug 2902434\n\t\t\t\tend\n\t\t\telsif type == 'Menu'\n\t\t\t\tnext if @menus_added\n\t\t\t\tif name == 'Context'\n\t\t\t\t\tUI.add_context_menu_handler { |menu|\n\t\t\t\t\t\tbuild_menus(menu, item)\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tmenu = UI.menu(name)\n\t\t\t\t\tnext if menu.nil? # (?) Error?\n\t\t\t\t\tbuild_menus(menu, item)\n\t\t\t\tend\n\t\t\tend\n\t\t}\n\t\t# We set this flag true as we might run this method again when toolbars are enabled.\n\t\t@menus_added = true\n\t\t@toolbars_added = toolbars_enabled?\n\tend", "def initialize_dialog\n set_name = current_selection_name\n vals = @dialog_defaults[set_name]\n @data_puts.each do |k, v|\n if vals[k]\n v.call(vals[k])\n else\n v.call('')\n end\n end\n end", "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 make_vagrant_basebox(options)\n @colour.notify 'Creating Vagrant basebox'\n @colour.notify 'Executing packer build (this may take a while)'\n# TODO: Sort out verbose mode for Packer\n exit 0 unless system \"cd '#{options[:project_dir]}' && #{'PACKER_LOG=1' if options[:verbose]} packer build #{'--debug' if options[:debug]} #{'-color=false' if options[:disable_colour]} Packerfile\"\n\n return options\nend", "def build_child_chooser_options(forums, options)\n forums.each do |key, val|\n options.push([\"#{depth_char(key.depth)} #{key.title}\", key.id])\n unless val.empty?\n build_child_chooser_options(val, options)\n end\n end\n \n return options\n end", "def create\r\n @icons_app.each do |k,v|\r\n v.create\r\n end\r\n # local variables\r\n \r\n refresh_settings\r\n \r\n #splitter position\r\n gfxgui_settings = @app_settings['guigfx']\r\n \r\n # window size\r\n ww = gfxgui_settings[:ww_mainwin]\r\n hh = gfxgui_settings[:hh_mainwin]\r\n \r\n # continue to insert item into giochi menu\r\n FXMenuSeparator.new(@giochimenu)\r\n FXMenuCommand.new(@giochimenu, \"Opzioni\").connect(SEL_COMMAND, method(:mnu_cuperativa_options))\r\n FXMenuSeparator.new(@giochimenu)\r\n FXMenuCommand.new(@giochimenu, \"&Esci\").connect(SEL_COMMAND, method(:onCmdQuit))\r\n \r\n # Reposition window to specified x, y, w and h\r\n position(0, 0, ww, hh)\r\n \r\n # Create the main window and canvas\r\n super \r\n # Show the main window\r\n show(PLACEMENT_SCREEN)\r\n \r\n # default game or last selected\r\n game_type = @app_settings[\"curr_game\"]\r\n #p @supported_game_map\r\n # initialize only an enabled game. An enabled game is a supported game.\r\n # Game disabled are not in the @supported_game_map. This to avoid to build poperties and\r\n # custom widgets\r\n if @supported_game_map[game_type]\r\n if @supported_game_map[game_type][:enabled]\r\n initialize_current_gfx(game_type)\r\n end\r\n else\r\n # default game is not supported, initialize the first enable game\r\n @log.debug(\"Default game not enabled, look for the first enabled one\")\r\n @supported_game_map.each do |k, game_info_h|\r\n game_type = k\r\n if game_info_h[:enabled]\r\n initialize_current_gfx(game_type)\r\n break\r\n end\r\n end\r\n end\r\n log_sometext(\"Benvenuta/o nella Cuperativa versione #{VER_PRG_STR}\\n\")\r\n @log.info(\"TheApp Create OK\") \r\n end", "def cb_charged\n if combo_main.active==0 then\n cb_newPark\n else\n #Vidage des frames\n framePan.each{|child| framePan.remove(child)}\n framePar.each{|child| framePar.remove(child)}\n\n #Recuperation des vues panneau et parking utile\n nomPark =self.combo_main.active_text\n builder.get_object(\"label_nomPark1\").text=nomPark\n vues=self.ctrl.get_park_views nomPark #Recup des \n\n #Ajout des vues\n framePar.add_child(builder,vues[0],nil)\n framePan.add_child(builder,vues[1],nil)\n\n #Mise a jour des info du parking affichés\n _change_park_property(self.ctrl.get_park_info nomPark)\n end\n #Show all\n @window.show_all\n end", "def add_ok_cancel(parent)\n panel = JPanel.new\n panel.border = LineBorder.createBlackLineBorder\n @result = nil\n # \n # OK button.\n ok = JButton.new(\"OK\")\n ok.add_action_listener do |e|\n @result = 1\n parent.set_visible(false)\n end\n panel.add(ok)\n \n # \n # Cancel button.\n cancel = JButton.new(\"Cancel\")\n cancel.add_action_listener do |e|\n @result = 0\n parent.set_visible(false)\n end\n panel.add(cancel)\n # \n # Help button, but just for things with a name.\n if @name\n help = JButton.new(\"Help\")\n help.tool_tip_text = 'View or edit the setup instructions.'\n help.add_action_listener do |e|\n UserIO.show_help(@name, panel)\n end\n panel.add(help)\n end\n #\n # Always On Top checkbox\n ontop = JCheckBox.new('Keep on top', true)\n ontop.tool_tip_text = 'Keep this dialog always on top.'\n frame = SwingUtilities.getWindowAncestor(parent)\n frame.always_on_top = true\n ontop.add_item_listener do |event|\n frame.always_on_top = (event.get_state_change == ItemEvent::SELECTED)\n end\n panel.add(ontop)\n\n parent.add(panel, BorderLayout::SOUTH)\n parent.get_root_pane.set_default_button(ok)\n end", "def build_example_ui\n ui_class = UIConfig.build_subclass(\"Example UI\")\n\n handler = ContextHandler.new\n handler.context_class = Configurable.build_subclass(\"dummy context\")\n handler.ui_class = ui_class\n handler.plugins = @plugins\n\n handler.backfill_options_to_context\n handler.apply_to_ui\n\n handler.ui_class\n end", "def init_gui\n # Set Window Title Defaults and so on\n update_window_title_and_progressbar\n @window.signal_connect \"destroy\" do quit_application end\n\n # Center us for non-tiling WMs\n @window.set_window_position Gtk::Window::POS_CENTER\n @window.set_default_size(500, 600)\n\n # Keyboard Shortcuts\n init_accelerators\n\n # Setup GUI elements in order of appearance\n toolbar = init_toolbar\n\n @statusbar = Gtk::Statusbar.new\n\n @area = Gtk::DrawingArea.new\n @area.signal_connect \"expose_event\" do draw_image_to_screen end\n\n help = \"Quick Help:\\n\"\n help << \"ARROW KEYS: select answer\\n\"\n help << \"ENTER: next question\\n\"\n help << \"TOP LEFT BOX: choose if result ambiguous (e.g. 2 checkmarks)\\n\"\n help << \"BORDER COLORS: cyan = barely checked, blue = nice checkmark, purple = overfull\"\n @quickHelp = Gtk::Label.new(help)\n @quickHelp.set_wrap true\n\n # Now lets put it all together\n vbox = Gtk::VBox.new false\n vbox.pack_start toolbar, false\n vbox.pack_start @area, true, true, 1\n vbox.pack_start @quickHelp, false, false, 2\n vbox.pack_start @statusbar, false\n @window.add vbox\n\n # All done. Let's display it.\n @window.show_all\n\n while (Gtk.events_pending?)\n Gtk.main_iteration\n end\n\n # try to find failed question\n find_failed_question\n end", "def initialize(win)\n\n # init des composants\n\n @win = win\n @map = \"../Grilles/grille_chapitre1.txt\"\n @boite = Gtk::Fixed.new()\n @container = Gtk::Box.new(:vertical)\n\n retourMenu = Gtk::Button.new(:label => \"\")\n nouvellePartie = Gtk::Button.new(:label => \"\")\n reprendre = Gtk::Button.new(:label => \"\")\n defilerChapitres = Gtk::Button.new(:label => \"\")\n\n # Création tableau de boutons\n\n btnChapitre = [\n Gtk::Button.new(),\n Gtk::Button.new(),\n Gtk::Button.new(),\n Gtk::Button.new(),\n Gtk::Button.new()\n ]\n\n # Création tableau de labels\n\n lblChapitre = [\n Gtk::Label.new(\"\"),\n Gtk::Label.new(\"\"),\n Gtk::Label.new(\"\"),\n Gtk::Label.new(\"\"),\n Gtk::Label.new(\"\")\n ]\n\n # Chargement background\n\n @boite.add(Gtk::Image.new(:file => \"../maquettes/menu-libre.png\"))\n @container.add(@boite)\n \n # Ajout des composants du menu\n\n ajouteBouton(@boite, nouvellePartie, 2, 420, 40, 310, 620, method(:nouvellePartie_VersJeu), nil, nil)\n ajouteBouton(@boite, reprendre, 2, 265, 40, 790, 620, method(:vers_jeu), nil, nil)\n\n # Création css texte labels\n cssChapitre = ajouteTexte(3)\n\n # Ajout des boutons dans la sidebar\n\n addChapitre(btnChapitre[0], lblChapitre[0], 13, 20, cssChapitre)\n addChapitre(btnChapitre[1], lblChapitre[1], 13, 155, cssChapitre)\n addChapitre(btnChapitre[2], lblChapitre[2], 13, 285, cssChapitre)\n addChapitre(btnChapitre[3], lblChapitre[3], 13, 420, cssChapitre)\n addChapitre(btnChapitre[4], lblChapitre[4], 13, 550, cssChapitre)\n\n # Ajout boutons retour vers menu et défiler chapitres\n\n ajouteBouton(@boite, defilerChapitres, 2, 45, 45, 230, 620, method(:actualiserChapitres), lblChapitre, nil)\n ajouteBouton(@boite, retourMenu, 2, 60, 60, 20, 5, method(:vers_menu), @win, @container)\n\n # Ajoute label pour chrono des grilles sauvegardées\n\n @chronoLabel = Gtk::Label.new(\"\")\n ajouteTexteProvider(@chronoLabel, cssChapitre)\n @boite.put(@chronoLabel, 1050, 70)\n\n\n\n\n @win.add(@container)\n\n # Chargement de la grille 1\n # Regarde si une sauvegarde existe, si oui, la charge, sinon, nouvelle partie\n\n if (Grille_jeu_charger.exist?(@map, 'Libre'))\n @grille = Grille_jeu_charger.creer(false, Array.new, @map, nil, 'Libre')\n @chronoLabel.label = @grille.getChrono()\n else\n @grille = Grille_jeu.creer(false, nil, @map)\n @chronoLabel.label = \"0' 0''\"\n end\n @boite.put(@grille.grille, ($widthEcran *0.37), $heightEcran * 0.16)\n\n # Charge les chapitres\n\n file = File.open(\"chapitres.txt\")\n lignes = file.readlines\n @nbLignes = lignes.size\n @file_data = lignes.map(&:chomp)\n\n file.close\n\n @i_chap = 0\n\n # Placement des bons labels de chapitres\n actualiserChapitres(lblChapitre)\n\n @win.show_all\n Gtk.main\n\n return self\n end", "def add_options; end", "def make_option_list\n end", "def make_option_list\n end", "def creationHBoxCLM( box, position , remove , positionOtherDifficulty , btnOtherMode )\n\n if box.children[positionOtherDifficulty] != btnOtherMode\n box.remove( box.children[positionOtherDifficulty] )\n box.add(btnOtherMode)\n box.reorder_child(btnOtherMode, positionOtherDifficulty)\n end\n\n box.remove(remove) #DELETE\n\n hBox = Gtk::Box.new(:horizontal)\n hBox.set_height_request(60); hBox.set_homogeneous(true)\n hBox.add ( setmargin( Gtk::Button.new(),0,0,0,5 ) )\n hBox.add ( setmargin( Gtk::Button.new(),0,0,0,5 ) )\n hBox.add ( Gtk::Button.new() )\n\n # gestion des evenements des boutons de choix de niveau\n hBox.children[0].signal_connect(\"clicked\"){\n Fenetre.remove(box);\n\n nbGrille = SauvegardeGrille.getInstance.getNombreGrille\n gridsId = (1..(nbGrille/3)).to_a.shuffle\n indiceRand = -1\n gridsId.each{ |id|\n if(Sauvegardes.getInstance.getSauvegardeScore.scoresContreLaMontre[id][1] == 0)\n indiceRand = id\n break\n end\n }\n\n if(indiceRand == -1 )\n gridsId.each{ |id|\n if(Sauvegardes.getInstance.getSauvegardeScore.scoresContreLaMontre[id][1] == 1)\n indiceRand = id\n break\n end\n }\n end\n\n if(indiceRand == -1 )\n gridsId.each{ |id|\n if(Sauvegardes.getInstance.getSauvegardeScore.scoresContreLaMontre[id][1] == 2)\n indiceRand = id\n break\n end\n }\n end\n\n if(indiceRand == -1 )\n indiceRand = gridsId[0]\n end\n\n\n FenetrePartie.afficheToiSelec(FenetreMenu, PartieContreLaMontre.creer(SauvegardeGrille.getInstance.getGrilleAt(indiceRand)))\n }\n hBox.children[1].signal_connect(\"clicked\"){\n Fenetre.remove(box);\n\n\n nbGrille = SauvegardeGrille.getInstance.getNombreGrille\n gridsId = ((1 + nbGrille/3)..(2*nbGrille/3)).to_a.shuffle\n\n indiceRand = -1\n gridsId.each{ |id|\n if(Sauvegardes.getInstance.getSauvegardeScore.scoresContreLaMontre[id][1] == 0)\n indiceRand = id\n break\n end\n }\n\n if(indiceRand == -1 )\n gridsId.each{ |id|\n if(Sauvegardes.getInstance.getSauvegardeScore.scoresContreLaMontre[id][1] == 1)\n indiceRand = id\n break\n end\n }\n end\n\n if(indiceRand == -1 )\n gridsId.each{ |id|\n if(Sauvegardes.getInstance.getSauvegardeScore.scoresContreLaMontre[id][1] == 2)\n indiceRand = id\n break\n end\n }\n end\n\n if(indiceRand == -1 )\n indiceRand = gridsId[0]\n end\n\n\n\n FenetrePartie.afficheToiSelec(FenetreMenu, PartieContreLaMontre.creer(SauvegardeGrille.getInstance.getGrilleAt(indiceRand)))\n }\n\n hBox.children[2].signal_connect(\"clicked\"){\n Fenetre.remove(box);\n\n\n nbGrille = SauvegardeGrille.getInstance.getNombreGrille\n gridsId = ((1 + 2*nbGrille/3)..nbGrille).to_a.shuffle\n\n indiceRand = -1\n gridsId.each{ |id|\n if(Sauvegardes.getInstance.getSauvegardeScore.scoresContreLaMontre[id][1] == 0)\n indiceRand = id\n break\n end\n }\n\n if(indiceRand == -1 )\n gridsId.each{ |id|\n if(Sauvegardes.getInstance.getSauvegardeScore.scoresContreLaMontre[id][1] == 1)\n indiceRand = id\n break\n end\n }\n end\n\n if(indiceRand == -1 )\n gridsId.each{ |id|\n if(Sauvegardes.getInstance.getSauvegardeScore.scoresContreLaMontre[id][1] == 2)\n indiceRand = id\n break\n end\n }\n end\n\n if(indiceRand == -1 )\n indiceRand = gridsId[0]\n end\n\n\n FenetrePartie.afficheToiSelec(FenetreMenu, PartieContreLaMontre.creer(SauvegardeGrille.getInstance.getGrilleAt(indiceRand)))\n }\n\n setBold( hBox.children[0] , @@lg.gt(\"FACILE\") )\n setBold( hBox.children[1] , @@lg.gt(\"MOYEN\") )\n setBold( hBox.children[2] , @@lg.gt(\"DIFFICILE\") )\n\n box.add( setmargin(hBox,0,15,70,70) ) #ADD\n box.reorder_child( hBox , position ) #REORDER\n Fenetre.show_all\n end", "def initialize\n @gui = Gtk::Builder.new\n @gui.add(\"#{File.dirname(__FILE__)}/ui/main.ui\")\n @gui.connect_signals { |handler| method(handler) }\n\n @window = @gui[:window]\n winsetting = GtkSettingsWindow.new(@window, \"win_main\")\n\n @nb_dbs = @gui[:nbDbs]\n @nb_dbs.connect_after(\"switch-page\", [self, \"ChangeActiveDB\"])\n\n @window.show_all\n end", "def create_selection_window\r\r\n @command_window = CSCA_Window_AchievementSelect.new(0,@head_window.height,\r\r\n Graphics.width/2,Graphics.height-@head_window.height-48)\r\r\n @command_window.viewport = @viewport\r\r\n @command_window.help_window = @achievement_window\r\r\n @command_window.set_handler(:cancel, method(:return_scene))\r\r\n @command_window.activate\r\r\n end", "def items_for_select_menu(options = {}) \n # clean out the various parts\n html_options = options.slice(:prompt, :divider, :show_root, :root_text)\n sql_options = options.except(:prompt, :divider, :show_root, :root_text)\n \n # defaults\n html_options = {\n :prompt => \"Select #{self.name}\",\n :divider => true,\n :show_root => true,\n :root_text => \"Top Level #{self.name}\",\n }.merge(html_options)\n \n sql_options = {\n :order => [self.select_field.to_sym],\n }.merge(sql_options)\n \n mi = self.select_options[:is_tree] ? all({ :parent_id => nil }.merge(sql_options) ) : all(sql_options)\n \n res = []\n if html_options[:prompt]\n res << [nil, html_options[:prompt]] \n res << ['nil', \" ------ \"] if html_options[:divider]\n if self.select_options[:is_tree]\n if html_options[:show_root]\n res << [0, html_options[:root_text]] \n res << ['nil',\" ------ \"] if html_options[:divider]\n end\n end\n end\n \n if self.select_options[:is_tree]\n mi.each do |x|\n res << [x.send(self.value_field), x.send(self.select_field)]\n unless x.children.blank?\n x.children.each do |child|\n res << [child.send(self.value_field), \"-- #{child.send(self.select_field)}\"]\n child.children.each do |grand_child| \n res << [ grand_child.send(self.value_field), \"-- -- #{grand_child.send(self.select_field)}\"] \n end unless child.children.blank?\n end\n end\n end\n else\n mi.each do |x|\n res << [x.send(self.value_field), x.send(self.select_field)]\n end\n end\n res\n end", "def create_contents\n @shell.layout = GridLayout.new(6, true)\n\n Label.new(@shell, SWT::NONE).text = \"Your name:\"\n\n @name_box = Text.new(@shell, SWT::BORDER)\n layout_data = GridData.new(GridData::FILL_HORIZONTAL)\n layout_data.horizontalSpan = 4\n @name_box.layout_data = layout_data\n\n @status_label = Label.new(@shell, SWT::BORDER)\n layout_data = GridData.new(GridData::FILL_HORIZONTAL)\n layout_data.horizontalSpan = 3\n @status_label.layout_data = layout_data \n\n\n\t\t@button = Button.new(@shell, SWT::PUSH)\n\t\t@button.text = \"Click me!\"\n\t\tlayout_data = GridData.new(GridData::END, GridData::CENTER, false, false)\n\t\tlayout_data.horizontalSpan = 6\n\t\t@button.layout_data = layout_data\n @button.addSelectionListener do\n handle_click\n end\n end", "def config\r\n\t\t\tr = \"<table class=\\\"option-gui\\\"><tr><td>\"\r\n\t\t\tr += \"<select name=\\\"values[]\\\" multiple=\\\"multiple\\\" size=\\\"7\\\">\"\r\n\t\t\tr += values.collect { |v| \"<option value=\\\"#{v.id}\\\">#{v.value}</option>\" }.join\r\n\t\t\tr += \"</select><br />\"\r\n\t\t\tr += \"</td><td>\"\r\n\t\t\tr += \"<input class=\\\"button\\\" type=\\\"submit\\\" name=\\\"up\\\" value=\\\"Move Up\\\" onclick=\\\"$('do-#{id}').value='up'\\\" /><br />\"\r\n\t\t\tr += \"<input class=\\\"button\\\" type=\\\"submit\\\" name=\\\"down\\\" value=\\\"Move Down\\\" onclick=\\\"$('do-#{id}').value='down'\\\" /><br />\"\r\n\t\t\tr += \"<input class=\\\"button\\\" type=\\\"submit\\\" name=\\\"delete\\\" value=\\\"Delete\\\" onclick=\\\"$('do-#{id}').value='delete_value'\\\" />\"\r\n\t\t\tr += \"</td></tr><tr><td colspan=\\\"2\\\">\"\r\n\t\t\tr += \"<input class=\\\"text\\\" type=\\\"text\\\" name=\\\"new_value\\\" />\"\r\n\t\t\tr += \"<input class=\\\"button\\\" type=\\\"submit\\\" name=\\\"add\\\" value=\\\"Add\\\" onclick=\\\"$('do-#{id}').value='add'\\\" />\"\r\n\t\t\tr += \"</td></tr></table>\"\r\n\t\tend", "def initialize(parent, opt)\n @parent = parent\n @c_window = @parent.subwin(\n opt[:h] || @parent.maxy,\n opt[:w] || @parent.maxx,\n opt[:y] || 0,\n opt[:x] || 0\n )\n @cursor = Cursor.new\n @top = 0\n update\n end", "def initialize_options\n return if $game_system.options_initialized\n $game_system.options_initialized = true\n for option in H87Options.option_list\n next unless option.for_game?\n option.value = option.default if option.default != nil\n option.toggle if option.type == :bar\n end\n end", "def setupWidgets\n # Create a frame which in which widgets will be ordered horisontally:\n frame = Qt::Frame.new\n frameLayout = Qt::HBoxLayout.new(frame)\n @imageWidget = ImageWidget.new(self)\n @treeView = Qt::TreeView.new\n # Add the two widgets (tree view and image) to the frame:\n frameLayout.addWidget(@treeView)\n frameLayout.addWidget(@imageWidget)\n setCentralWidget(frame)\n end", "def add_button_clicked\n\t\t\n\t\t\t# Eventually create browse form\n\t\t\tcreate_browse_form\n\t\t\n\t\t\t# Show and activate the child window\n\t\t\tshow_browse_form\n\t\tend", "def show_prop_dialog\r\n # puts \"wall = \" + @wall.inspect\r\n # puts \"window = \" + @obj.inspect\r\n case @objtype\r\n when \"Window\"\r\n\t\twindowtool = WindowTool.new\r\n results = MM_HouseBuilder.display_dialog(\"Window Properties\", @selected_obj, windowtool.properties)\r\n when \"Door\"\r\n\t\tdoortool = DoorTool.new\r\n results = MM_HouseBuilder.display_dialog(\"Door Properties\", @selected_obj, doortool.properties)\r\n end\r\n\tif (results)\r\n draw_obj\r\n end\r\n #Sketchup.active_model.select_tool(nil)\r\nend", "def make_option_list\n @data = H87Options.option_list\n end", "def make_option_list\n @data = H87Options.option_list\n end", "def set_selectbox_options\n set_kind_option\n set_scheduled_times_option\n set_user_option\n end", "def initialize(iParent)\n super(iParent)\n\n # This attribute will be changed only if the icon is changed.\n # It is used instead of the Wx::BitmapButton::bitmap_label because it can be nil, and in this case we don't want to replace it with the default icon internally.\n @Icon = nil\n \n # Create all components\n lSTTitle = Wx::StaticText.new(self, Wx::ID_ANY, 'Title')\n @TCTitle = Wx::TextCtrl.new(self)\n @TCTitle.min_size = [300, @TCTitle.min_size.height]\n lSTIcon = Wx::StaticText.new(self, Wx::ID_ANY, 'Icon')\n @BBIcon = Wx::BitmapButton.new(self, Wx::ID_ANY, Wx::Bitmap.new)\n evt_button(@BBIcon) do |iEvent|\n # display the icon chooser dialog\n require 'pbs/Windows/ChooseIconDialog'\n showModal(ChooseIconDialog, self, @BBIcon.bitmap_label) do |iModalResult, iDialog|\n case iModalResult\n when Wx::ID_OK\n lNewIcon = iDialog.getSelectedBitmap\n if (lNewIcon != nil)\n @Icon = lNewIcon\n setBBIcon\n end\n end\n end\n end\n\n # Put them in sizers\n lMainSizer = Wx::BoxSizer.new(Wx::VERTICAL)\n lMainSizer.add_item([0,0], :proportion => 1)\n lMainSizer.add_item(lSTTitle, :flag => Wx::ALIGN_CENTRE, :proportion => 0)\n lMainSizer.add_item(@TCTitle, :flag => Wx::GROW, :proportion => 0)\n lIconSizer = Wx::BoxSizer.new(Wx::HORIZONTAL)\n lIconSizer.add_item(lSTIcon, :flag => Wx::ALIGN_CENTRE, :proportion => 0)\n lIconSizer.add_item([8,0], :proportion => 0)\n lIconSizer.add_item(@BBIcon, :flag => Wx::ALIGN_CENTRE, :proportion => 0)\n lMainSizer.add_item([0,8], :proportion => 0)\n lMainSizer.add_item(lIconSizer, :flag => Wx::ALIGN_CENTRE, :proportion => 0)\n lMainSizer.add_item([0,0], :proportion => 1)\n self.sizer = lMainSizer\n\n end", "def build(*args)\n # create the container they ask for with these args\n @container = @container_class.new *args\n # tack on the layout they wanted\n @container.layout = layout if layout\n\n # go through all the children, add them on and tack on the callbacks\n @children.each {|child|\n if @contents[child]\n # if this component answers the each call then go through all\n component = @contents[child]\n each_or_one(component) {|c| @container.add(c) }\n\n configure_interactions_for child, component\n end\n }\n\n # yield to the caller so that they can configure more before\n # we make it visible and pack it\n yield @container if block_given?\n\n # even though swing doesn't do this, we do\n @container.pack if @container.respond_to? :pack\n @container.visible = true if @container.respond_to? :visible\n\n # and now they can do whatever they want to the container\n @container\n end", "def create_dialogs\n @open_dialog = OpenDialog.new self.method(:open)\n @save_dialog = SaveDialog.new self.method(:save)\n \n @segment_color_dialog = ColorDialog.new do |c| \n @drawer.segments_color = c\n print\n end\n \n @graph_color_dialog = ColorDialog.new do |c| \n @drawer.graph_color = c\n print\n end\n\n @trapezoid_color_dialog = ColorDialog.new do |c| \n @drawer.trapezoid_base_fill_color = c\n print\n end\n \n @robot_color_dialog = ColorDialog.new do |c| \n @drawer.robot_color = c\n print\n end\n \n @robot_line_color = ColorDialog.new do |c| \n @drawer.robot_line_color = c\n print\n end\n \n @trapezoids_segment_color = ColorDialog.new do |c| \n @drawer.trapezoid_segment_color = c\n print\n end\n \n @new_trapezoides = ColorDialog.new do |c| \n @drawer.new_trapezoid_color = c\n end\n \n @destroied_trapezoids = ColorDialog.new do |c| \n @drawer.old_trapezoid_color = c\n end\n \n end", "def run\r\n @log.debug \"Run the tester...\"\r\n settings = YAML::load_file(File.join(ResourceInfo.get_dir_appdata(), 'app_options.yaml'))\r\n dlg = NamesOptionsDlg.new(@main_app, settings, @main_app)\r\n dlg.execute\r\n end", "def initialize(path_or_data, root = nil, domain = nil, localedir = nil, flag = GladeXML::FILE)\n bindtextdomain(domain, localedir, nil, \"UTF-8\")\n @glade = GladeXML.new(path_or_data, root, domain, localedir, flag) {|handler| method(handler)}\n \n #Filters used on the choosers widgets\n @filter = Gtk::FileFilter.new\n @filter.name = 'Supported Files'\n @filter.add_pattern('*.in')\n @filter.add_pattern('*.rtf')\n @filter.add_pattern('*.xml')\n @filter.add_pattern('*.txt')\n\n @mainWindow = self\n\n #array with the texts\n @texts = []\n @scrolls = []\n @number_of_texts = 0\n\n # Manage the project\n @project = Project.new\n\n #Tag Manager\n @tagManager = TagManager.new\n \n #Manage the table and texts\n @main_table = @glade.get_widget('mainTable')\n\n #Manage the tree view\n @treeView = TreeV.new @project, @mainWindow\n @glade.get_widget('mainDiv').pack_start @treeView.view, false, false, 0\n @glade.get_widget('mainDiv').reorder_child @treeView.view, 0\n @glade.get_widget('mainDiv').show_all\n end", "def index\n super\n use_widgets do |root|\n root << jqg_top_widget('degree', :cell_class => 'degrees_select', :widget_id => 'degrees_select') do |degwid|\n jqg_child_widget(degwid, 'program', :cell_class => 'program_lookup', :selector_for => :program_id)\n end\n end\n render\n end", "def createWidgets\n @topTab = KDE::TabWidget.new\n\n @mainTabPageHSplitter = Qt::Splitter.new\n @topTab.addTab(@mainTabPageHSplitter, 'Channels')\n\n @mainTabPageHSplitter.addWidget(createChannelAreaWidget)\n\n # Main Tab page. programme table area\n @progTableFrame = Qt::Splitter.new(Qt::Vertical)\n @progTableFrame.addWidget(createProgrammeAreaWidget)\n @progTableFrame.addWidget(createProgrammeSummaryWidget)\n @mainTabPageHSplitter.addWidget(@progTableFrame)\n\n # parameter : Qt::Splitter.setStretchFactor( int index, int stretch )\n @mainTabPageHSplitter.setStretchFactor( 0, 0 )\n @mainTabPageHSplitter.setStretchFactor( 1, 1 )\n\n # dock\n createPlayerDock\n\n\n # Top Tab - Task Page\n @taskWin = TaskWindow.new\n @topTab.addTab(@taskWin, 'Task')\n\n # Top Tab - Schedule Page\n @scheduleWin = ScheduleWindow.new\n @topTab.addTab(@scheduleWin, 'Schedule')\n\n # Top Tab - Log Page\n @logWin = LogWindow.new\n @topTab.addTab(@logWin, 'Log')\n\n\n # set Top Widget & Layout\n setCentralWidget(@topTab)\n end", "def set_controls_help\n @control_help_window.clear\n set_status_controls if @status_window.active\n set_titles_controls if @title_window.active\n set_input_controls if @input_window.active\n @control_help_window.refresh\n end", "def single_parameter_set_box\n box = Box.create_horizontal_box\n box.add(expand_button)\n box.add(Box.create_horizontal_glue)\n box\n end", "def build_ui(file_name)\n gtk_builder_add_from_file(@builder, file_name, FFI::MemoryPointer::NULL)\n connect_signals\n end", "def create_widgets\n top_box = Gtk::HBox.new(false, 0)\n @start_button = Gtk::Button.new(\"Start\")\n top_box.pack_start(@start_button, true, true, 5)\n @time_label = Gtk::Label.new\n @time_label.set_markup(\"<span size='xx-large'>00:00:00</span>\") \n top_box.pack_end(@time_label, false, false, 5)\n \n mid_vert_box = Gtk::VBox.new(false, 0)\n \n project_box = Gtk::HBox.new(false, 0)\n @project_combo = Gtk::ComboBox.new\n project_box.pack_start(@project_combo, true, true, 5)\n \n task_box = Gtk::HBox.new(false, 0)\n @task_combo = Gtk::ComboBox.new\n task_box.pack_start(@task_combo, true, true, 5)\n \n comment_box = Gtk::HBox.new(false, 0)\n @comment_entry = Gtk::Entry.new\n comment_box.pack_start(@comment_entry, true, true, 5)\n \n mid_vert_box.add(project_box)\n mid_vert_box.add(task_box)\n mid_vert_box.add(comment_box)\n mid_vert_box.spacing = 5\n \n bottom_box = Gtk::HBox.new\n bottom_box.spacing = 5\n @post_button = Gtk::Button.new(\"Post Timer\")\n bottom_box.pack_end(@post_button, false, 0)\n @reset_button = Gtk::Button.new(\"Clear Timer\")\n bottom_box.pack_end(@reset_button, false, 0)\n \n main_box = Gtk::VBox.new(false, 0)\n main_box.spacing = 20\n main_box.add(top_box)\n main_box.add(mid_vert_box)\n main_box.add(bottom_box)\n \n @window.add(main_box)\n end", "def initialize(parent, skin = {})\n super(parent, :opts => LAYOUT_FILL)\n @mouse_down = false\n @cmds = []\n @cmd_time = nil\n @colors = { 'R' => 0xff0000ff,\n 'B' => 0xfff0000f,\n 'G' => 0xff00aa00,\n 'D' => 0xff000000 }\n @color = 'D'\n\n # We may want a 2-pixel border on the inside-top of this pane, otherwise\n # no borders.\n self.padLeft = self.padBottom = self.padRight = self.padTop = 0\n\n # Draw the top-level board\n frames = FXPacker.new(self, :opts => LAYOUT_FILL)\n\n # Buttons go on the right\n button_list = FXPacker.new(frames, :opts => LAYOUT_FILL_Y |\n LAYOUT_SIDE_RIGHT | LAYOUT_FIX_WIDTH, :width => BUTTON_WIDTH)\n button_clear = FXButton.new(button_list, \"Clear\", :opts => FRAME_RAISED |\n FRAME_THICK | LAYOUT_FILL_X | LAYOUT_SIDE_TOP)\n button_clear.connect(SEL_COMMAND) { clear_board }\n\n # Now draw the color buttons\n @colors.each do |c,v|\n button = FXButton.new(button_list, \" \", :opts => FRAME_RAISED |\n FRAME_THICK | LAYOUT_FILL_X | LAYOUT_SIDE_TOP)\n button.connect(SEL_COMMAND) { @color = c }\n button.backColor = v\n end\n\n # Exit button at the bottom all by itself\n button_bye = FXButton.new(button_list, \"Close\", :opts => FRAME_RAISED |\n FRAME_THICK | LAYOUT_FILL_X | LAYOUT_SIDE_BOTTOM)\n button_bye.connect(SEL_COMMAND) { @on_line_block.call('/leave') }\n\n # Drawing area goes on the left\n cframe = FXHorizontalFrame.new(frames, :opts => LAYOUT_FILL | FRAME_SUNKEN |\n FRAME_THICK | LAYOUT_SIDE_LEFT, :padLeft => 0, :padRight => 0,\n :padTop => 0, :padBottom => 0, :hSpacing => 0, :vSpacing => 0)\n @canvas = FXCanvas.new(cframe, :opts => LAYOUT_FILL)\n @canvas.connect(SEL_PAINT, method(:board_draw))\n @canvas.connect(SEL_LEFTBUTTONPRESS, method(:left_button_down))\n @canvas.connect(SEL_LEFTBUTTONRELEASE, method(:left_button_up))\n @canvas.connect(SEL_MOTION, method(:mouse_motion))\n\n # Backup of the canvas on which we're drawing\n @image = FXImage.new(app, :width => 1920, :height => 1080)\n @image.create\n FXDCWindow.new(@image) do |dc|\n dc.foreground = BACK_COLOR\n dc.fillRectangle(0, 0, 1920, 1080)\n end\n end", "def setup(*)\n # Used to be in an after_add, updated for apotomo 1.2.\n self.respond_to_event :form_submitted, :from => self.name\n self.respond_to_event :revert, :from => self.name\n self.respond_to_event :display_form, :from => self.name\n\n self.where = nil\n self.dom_id = options[:dom_id]\n self.grid_options = {}\n # Guesses that you will use the resource name for the form template.\n self.form_template = options[:resource]\n # Assume that the form is not a multipart (uploader) form\n self.multipart_form = false\n # The orphan template is used when a parent record is needed but not selected\n self.orphan_template = 'orphan'\n # Ensure that we always have a record of some sort\n self.record = resource_model.new\n # Set the name of this resource for public display\n self.human_resource = options[:resource].humanize\n # Set the spokesfield to nil, this needs to be set explicitly\n self.spokesfield = nil\n \n @columns = []\n @sortable_columns = {}\n @default_sort = nil \n\n @filters = {}\n @filter_sequence = []\n @filter_default = {}\n \n @flash_widget = self.dom_id + '_flash'\n self << widget(:grid_flash, @flash_widget)\n \n if options[:form_only]\n @list_widget = nil\n @filters_widget = nil\n self.form_buttons = [\n ['remain', 'Save', 'Add'],\n ]\n else\n @list_widget = self.dom_id + '_list'\n @filters_widget = self.dom_id + '_filters'\n self << widget(:grid_list, @list_widget) do |lw|\n lw << widget(:grid_filters, @filters_widget)\n end\n \n self.form_buttons = [\n ['submit', 'Save+Close', 'Add+Close'],\n ['remain', 'Save', 'Add'],\n ['cancel', 'Cancel', 'Cancel'],\n ]\n end\n end", "def initialize(dsl, parent)\n dsl.opts[:width] ||= 200\n dsl.opts[:height] ||= 20\n @dsl = dsl\n @parent = parent\n @real = ::Swt::Widgets::Combo.new(\n @parent.real,\n ::Swt::SWT::DROP_DOWN | ::Swt::SWT::READ_ONLY\n )\n @real.set_size dsl.opts[:width], dsl.opts[:height]\n @real.add_selection_listener do |event|\n @dsl.call_change_listeners\n end\n end", "def new\n @menu = \"option\"\n @board = \"option\"\n @section = \"new\"\n \n @option = Option.new\n @select_main_option = Option.all(:order => [ :priority.asc ]) \n\n render 'admin/options/option'\n end", "def initialize(dbpage)\n @dbpage = dbpage\n @dbconn = @dbpage.dbconn\n\n @gui = Gtk::Builder.new\n @gui.add(\"#{File.dirname(__FILE__)}/ui/win_runsql.ui\")\n @gui.connect_signals { |handler| method(handler) }\n\n @cb_type = @gui[:cbType]\n combobox_init(@cb_type)\n @cb_type.get_model.append([\"Auto\"])\n @cb_type.get_model.append([\"One-liners\"])\n @cb_type.get_model.append([\"phpMyAdmin dump\"])\n @cb_type.set_active(0)\n\n @window = @gui[:window]\n winsetting = GtkSettingsWindow.new(@window, \"win_runsql\")\n @window.show_all\n end", "def docopt_options(width)\n @options['Options'] = {} unless @options['Options']\n @options['Options']['-h --help'] = 'Show this screen'\n @options['Options']['--version'] = 'Show version number' if @version\n\n doc = []\n @options.each do |scope, values|\n doc << \"#{scope}:\"\n values.each do |flag, text|\n helpline = \" #{text}\"\n wrapped = word_wrap helpline, width\n doc << \" #{flag}\\n#{wrapped}\\n\"\n end\n end\n doc\n end", "def creationHBoxSurvie( box, position , remove , positionOtherDifficulty , btnOtherMode )\n\n if box.children[positionOtherDifficulty] != btnOtherMode\n box.remove( box.children[positionOtherDifficulty] )\n box.add(btnOtherMode)\n box.reorder_child(btnOtherMode, positionOtherDifficulty)\n end\n\n box.remove(remove) #DELETE\n\n hBox = Gtk::Box.new(:horizontal)\n hBox.set_height_request(60); hBox.set_homogeneous(true)\n hBox.add ( setmargin( Gtk::Button.new(),0,0,0,5 ) )\n hBox.add ( setmargin( Gtk::Button.new(),0,0,0,5 ) )\n hBox.add ( Gtk::Button.new() )\n\n # gestion des evenements des boutons de choix de niveau\n hBox.children[0].signal_connect(\"clicked\"){\n Fenetre.remove(box);\n\n nbGrille = SauvegardeGrille.getInstance.getNombreGrille\n indiceRand = rand(1..(nbGrille/3))\n\n FenetrePartie.afficheToiSelec(FenetreMenu, PartieSurvie.creer(SauvegardeGrille.getInstance.getGrilleAt(indiceRand)))\n }\n hBox.children[1].signal_connect(\"clicked\"){\n Fenetre.remove(box);\n\n nbGrille = SauvegardeGrille.getInstance.getNombreGrille\n indiceRand = rand((1+nbGrille/3)..(2*nbGrille/3))\n\n\n FenetrePartie.afficheToiSelec(FenetreMenu, PartieSurvie.creer(SauvegardeGrille.getInstance.getGrilleAt(indiceRand)))\n }\n\n hBox.children[2].signal_connect(\"clicked\"){\n Fenetre.remove(box);\n\n nbGrille = SauvegardeGrille.getInstance.getNombreGrille\n indiceRand = rand((1+2*nbGrille/3)..nbGrille)\n\n FenetrePartie.afficheToiSelec(FenetreMenu, PartieSurvie.creer(SauvegardeGrille.getInstance.getGrilleAt(indiceRand)))\n }\n\n setBold( hBox.children[0] , @@lg.gt(\"FACILE\") )\n setBold( hBox.children[1] , @@lg.gt(\"MOYEN\") )\n setBold( hBox.children[2] , @@lg.gt(\"DIFFICILE\") )\n\n box.add( setmargin(hBox,0,15,70,70) ) #ADD\n box.reorder_child( hBox , position ) #REORDER\n Fenetre.show_all\n end", "def initialize(manager,ic)\n\t\tsuper(manager.win)\n\t\t@manager = manager\n\t\t#Chargement de la campagne\n\t\t@adventure = manager.session\n\t\tscreen = Constants::SCREEN\n\t\t@pad=Constants::BUTTON_PADDING\n\t\t@ic=ic\n\t\t@gtkObject = Gtk::Table.new(3,3)\n\t\t@scrol=ScrollableArea.new(:vertical)\n\t\t@boxV=Gtk::Box.new(:vertical)\n\t\t@overAllStars = @adventure.overAllStars.to_s\n\n\t\t@etoileTotal=Gtk::Box.new(:horizontal)\n\t\ta=Gtk::Alignment.new(0.5,0,0.5,1)\n\t\ta.add(@boxV)\n\t\t@gtkObject.attach(a,0,1,1,2)\n\n\t\t@boxV.pack_start(@etoileTotal ,expand: false, fill: true, padding:@pad)\n\t\t@st=Star.new(1,1,@ic)\n\t\t@etoileTotal.pack_start(@st.stars,expand: false, fill: true, padding:@pad)\n\t\tnbEtoile=Text.new(@overAllStars)\n\n\t\tnbEtoile.title\n\t\t@etoileTotal.pack_start(nbEtoile.gtkObject,expand: false, fill: true, padding:@pad)\n\n\t\t@boxV.pack_start(@scrol.gtkObject,expand: true, fill: true, padding: @pad)\n\n\t\t@nbNiveau=@adventure.adventureInfo.levels.length\n\t\tl=@ic.iconAsset(:loc)\n\n @b=Gtk::Box.new(:horizontal, 25)\n\t\t@scrol.add(@b)\n\n\t\t@icones=LevelNumbers.new(manager,@adventure ,@adventure.overAllStarsHash,@ic)\n\t\t@b.pack_start(@icones.im,expand: false, fill: true, padding: @pad)\n @menuR=Gtk::Box.new(:horizontal, 25)\n\t\t@scrol.add(@menuR)\n\n\t\tretour=Text.new(@textManager.getButtonLabel(\"adventure\", \"back\"))\n @boxV.pack_start(retour.gtkObject ,expand: false, fill: true, padding:@pad)\n \tretour.onClick{\n\t\t\tmanager.session.updateSave\n\t\t\tmanager.updateSave\n \tmanager.mainScreen.applyOn(@parent)\n\t\t}\n @gtkObject.attach(Gtk::Image.new(pixbuf: @buffer),0,3,0,3)\n\tend", "def read_cfg(event)\r\n\t\tfd = FileDialog.new(nil)\r\n\t\tfd.show_modal\r\n\t\tpath = fd.get_path # included the filename\r\n\t\t# filename = fd.get_filename\r\n\t\t@file_loc_txt.write_text(path)\r\n\t\t@steps = load_steps_from_master_cfg(path) # TODO: info (line_num, step name, on/off status)\r\n\t\t# ===== inspect section =====\r\n\t\tstr = \"\"\r\n\t\t@steps.each do |step|\r\n\t\t\tstr += \"#{step.name} , #{step.status}\\n\"\r\n\t\tend\r\n\t\t@file_loc_txt.write_text(str)\r\n\t\t# ==============================\r\n\t\t@steps.each do | step |\r\n\t\t\t# TODO: shall I maintain the status in memory?\r\n\t\t\tstep_cbx = CheckBox.new(@mid_panel, -1 , \"Step \"+ step.name)\r\n\t\t evt_checbox(step_cbx.get_id) { | event | maintain_map(event) }\r\n\t\t\t@cbx_map_step.store(step_cbx , step)\r\n\t\t\tstep_cbx.set_value(false) if step.status == false\r\n\t\t\tstep_cbx.set_value(true) if step.status == true\r\n\t\t\t@boxes << step_cbx\r\n\t\tend\t\r\n\r\n\t\t# paint on graphic\r\n\t\t@boxes.each do | step_cbx |\r\n\t\t\t@mid_sizer.add(step_cbx, 1, GROW , 1, nil)\r\n\t\tend\r\n\r\n\t\t# produce collections of checkboxes, TODO, is there MVC code, javabean protocal I can follow?\r\n\t\t\r\n\tend", "def CreateGearDialog _args\n \"CreateGearDialog _args;\" \n end", "def parent_command_options_presentation\n return nil unless command.parent\n Presenter.new(command.parent).options_presentation\n end", "def run\r\n @log.debug \"Run the tester...\"\r\n @dlg_box = CupSingleGameWin.new(@options)\r\n @dlg_box.create\r\n end", "def build_scene\n boards = TicTacToeEngine::TTT::CONFIG.boards\n scene.build do\n menu do\n label\n board_selection do\n boards.keys.each do |key|\n if boards[key][:active]\n if key == :'3x3'\n board_3x3 :id => 'board_3x3', :players => 'board_type'\n end\n if key == :'4x4'\n board_4x4 :id => 'board_4x4', :players => 'board_type'\n end\n end\n end\n end\n end\n __install \"options_scene/partial_options.rb\"\n end\n end", "def build_voyage_port_form(voyage_port,action,caption,is_edit = nil,is_create_retry = nil)\n#\t--------------------------------------------------------------------------------------------------\n#\tDefine a set of observers for each composite foreign key- in effect an observer per combo involved\n#\tin a composite foreign key\n#\t--------------------------------------------------------------------------------------------------\n\tsession[:voyage_port_form]= Hash.new\n\tvoyage_port_codes = VoyagePortType.find_by_sql('select distinct id,voyage_port_type_code from voyage_port_types').map{|g|[g.voyage_port_type_code,g.id]}\n\tvoyage_port_codes.unshift(\"<empty>\")\n\n\tport_codes = Port.find_by_sql('select distinct id,port_code from ports').map{|g|[g.port_code, g.id]}\n\tport_codes.unshift(\"<empty>\")\n\n voyage_ids = Voyage.find_by_sql('select distinct id,voyage_code from voyages').map{|g|[g.voyage_code,g.id]}\n\tvoyage_ids.unshift(\"<empty>\")\n#\t---------------------------------\n#\t Define fields to build form from\n#\t---------------------------------\n\t field_configs = Array.new\n combos_js_for_voyage_port_type = gen_combos_clear_js_for_combos([\"voyage_port_voyage_port_type_id\", \"voyage_port_is_destination_port\"])\n voyage_port_type_observer = {:updated_field_id => \"is_destination_port_cell\",\n :remote_method =>'voyage_port_type_changed',\n :on_completed_js => combos_js_for_voyage_port_type[\"voyage_port_voyage_port_type_id\"]\n }\n \n\n\tfield_configs[field_configs.length()] = {:field_type => 'DropDownField',\n\t\t\t\t\t\t:field_name => 'port_id',\n\t\t\t\t\t\t:settings => {:label_caption=>'port_code',\n :list => port_codes}}\n\n\n\tfield_configs[field_configs.length()] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'quay'}\n\n\n\tfield_configs[field_configs.length()] = {:field_type => 'DropDownField',\n\t\t\t\t\t\t:field_name => 'voyage_port_type_id',\n\t\t\t\t\t\t:settings => {:label_caption => 'voyage_port_type',:show_label=> true,\n :list => voyage_port_codes}}#,:observer => voyage_port_type_observer}\n\n\n\n field_configs[field_configs.length()] = {:field_type => 'PopupDateSelector',\n\t\t\t\t\t\t:field_name => 'departure_date'}\n\n\tfield_configs[field_configs.length()] = {:field_type => 'PopupDateSelector',\n\t\t\t\t\t\t:field_name => 'arrival_date'}\n\n\tfield_configs[field_configs.length()] = {:field_type => 'PopupDateSelector',\n\t\t\t\t\t\t:field_name => 'departure_open_stack'}\n\n\tfield_configs[field_configs.length()] = {:field_type => 'PopupDateSelector',\n\t\t\t\t\t\t:field_name => 'departure_close_stack'}\n\n\tfield_configs[field_configs.length()] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'port_sequence'}\n field_configs[field_configs.length] = {:field_type => \"CheckBox\",:field_name => \"is_destination_port\"}\n\n\n build_form(voyage_port,field_configs,action,'voyage_port',caption,is_edit)\n\nend", "def build_widget\r\n Qt::Widget.new do\r\n # Widget Properties\r\n self.window_title = \"QR Generator Qt\"\r\n self.maximum_size = Qt::Size.new(500, 500)\r\n self.minimum_size = Qt::Size.new(300, 400)\r\n\r\n self.resize self.minimum_size\r\n \r\n self.set_window_icon Qt::Icon.new(MAIN_ICON_PATH)\r\n # Widget layout\r\n self.layout = Qt::VBoxLayout.new\r\n end\r\n end" ]
[ "0.68018395", "0.62683225", "0.6173676", "0.60522115", "0.5985287", "0.59040827", "0.58755624", "0.5806343", "0.5801407", "0.5783906", "0.5754165", "0.57329005", "0.56534535", "0.5620609", "0.5589882", "0.55841845", "0.55837333", "0.55837333", "0.55813587", "0.5580656", "0.5566339", "0.552637", "0.5487553", "0.5482735", "0.542636", "0.5355568", "0.534178", "0.53367406", "0.53288186", "0.5325412", "0.53244406", "0.5324376", "0.52854013", "0.52637386", "0.52431124", "0.5208021", "0.51720893", "0.51644486", "0.5154199", "0.51422834", "0.5116169", "0.50817883", "0.50667405", "0.50645757", "0.50620687", "0.5051897", "0.50434476", "0.5038692", "0.50268066", "0.5024557", "0.5019532", "0.50079465", "0.4995044", "0.4992226", "0.49900028", "0.498444", "0.49841672", "0.49794146", "0.4973389", "0.4973389", "0.49691194", "0.4949969", "0.49477044", "0.49415752", "0.49342936", "0.4927521", "0.49228716", "0.49180332", "0.49180028", "0.49048874", "0.49024045", "0.49014646", "0.49014646", "0.48977652", "0.48942277", "0.48824516", "0.48818916", "0.48787966", "0.48695695", "0.48650888", "0.4863738", "0.48626217", "0.485585", "0.48452535", "0.48377395", "0.4832366", "0.48252475", "0.4810089", "0.48086405", "0.48024482", "0.4799627", "0.47969165", "0.47909153", "0.478189", "0.477767", "0.47687", "0.47562373", "0.47559303", "0.47556362", "0.47540885" ]
0.534452
26
Method called from TestRunnerDialogBox when go button is pressed
def run @log.debug "Run the tester..." settings = YAML::load_file(File.join(ResourceInfo.get_dir_appdata(), 'app_options.yaml')) dlg = NamesOptionsDlg.new(@main_app, settings, @main_app) dlg.execute end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\r\n @log.debug \"Run the tester...\"\r\n @dlg_box = CupSingleGameWin.new(@options)\r\n @dlg_box.create\r\n end", "def go_go_go\n \n # Catch errors so the GUI doesn't just mysteriously disappear\n begin\n \n # Make sure they have a RDT username and password\n unless get_regkey_val('username') && get_regkey_val('password')\n return false unless ask_for_details( 'RDT Details:' )\n end\n \n # Let's do this thing!\n m = MechReporter.new\n \n key = MechReporter.cntxify( @input.text )\n \n labelfile = m.save_labels( [ key ], 3 )\n \n m.print_label( labelfile )\n \n # Catch and report errors\n rescue => e\n error \"#{ e.to_s.scan(/(.{1,200}\\s?.{1,200}+)/).first.join($/) }\\n\\n#{ e.backtrace.first }\"\n end\n \n # Quit\n #Gtk.main_quit\n end", "def continue\n frm.button(:value=>\"Continue\").click\n TakeAssessmentList.new(@browser)\n end", "def te_st_099_WIP\r\n\r\n sTestCase_Name = \"test_099_WIP\"\r\n puts2(\"Starting Testcase: #{sTestCase_Name}\")\r\n\r\n puts2(\"Close the window\")\r\n\r\n # Set the flag to close the $browser after the last test case runs\r\n @@bCloseBrowser = true\r\n\r\nend", "def go_back\r\n command 'goBack'\r\n end", "def go_back\r\n command 'goBack'\r\n end", "def test_int_page\n open_new_tab(Constants::INT_PAGE)\n sleep 5\n button_click(LOCATOR['RWDS_TAB'])\n switch_frame\n button_click(LOCATOR['ERN_PTS'])\n p text_displayed?(LOCATOR['ACT_NM'], 'Account Creation')\n switch_back\n @driver.close\n end", "def click_continue_button\n click_button(@continue_button_text)\n end", "def next\n frm.button(:value=>\"Next\").click\n BeginAssessment.new(@browser)\n end", "def go_forward\n @browser.forward\n end", "def test_03()\n\t\tputs \"Inside test 3\"\n\t\t$browser.stop\n\t\t\n\tend", "def click; end", "def click; end", "def click; end", "def go()\n\t@selenium.open @url\n end", "def lets_go\n get_elem_and_click(:xpath, LETS_GO_BUTTON)\n end", "def continue_button\n\tfind(\".btn--large\").click\nend", "def go_to_where_you_belong\n \n end", "def test_NeedHelpLink\n\n loginpage = Hudl_Login_Page.new @@driver\n\n loginpage.ClickNeedHelp()\n\n end", "def see_your_tank\n display_tank_view_selection\n display_my_fish_tank\n puts display_tank_owners\n\n prompt = TTY::Prompt.new\n go_back = prompt.select(\"Select Main Menu to go back\") do |menu|\n menu.choice \"Main Menu\"\n end\n if go_back == \"Main Menu\"\n main_menu\n end\n end", "def next\n puts 'Clicked next'\n go_to_next_diff_or_build_page\n # Navigate to the next diff that needs approval\n end", "def go_back\n @browser.back\n end", "def go()\n\n if block_given? then\n\n @window.activate(); sleep 1; yield(self); carriage_return()\n\n end\n\n end", "def next\n next_button.click\n end", "def next\n next_button.click\n end", "def next\n next_button.click\n end", "def next\n next_button.click\n end", "def goto\n end", "def testing_ui\n Cork::Board.new(silent: true)\nend", "def go\n require 'pashua'\n pagetmp = wikipage_selector(\"Jump to which page?\")\n exit unless pagetmp\n @chrome.windows[1].get.tabs[@chrome.windows[1].get.active_tab_index.get].get.URL.set(\"http://localhost/wiki/#{pagetmp}\")\nend", "def onClick(dialog, which)\n end", "def navigate(direction)\n if direction==\"back\"\n\t $driver.navigate.back\n else\n $driver.navigate.forward\n end\nend", "def test_02()\n\t\t\n\t\tputs \"************** START : Login to Redmine ****************\"\t\n\t\t\n\t\tputs \"Inside test 2\"\n\t\tsleep 4\n\t\t@loginbutton_topposition = $browser.get_element_position_top \"link=Log in\"\n\t\tputs \"Login button Top position : #{@loginbutton_topposition}\"\n\t\tif @loginbutton_topposition == '9'\n\t\t\tputs \"UI Check : Pass. Login link is present at the correct position.\"\n\t\telse\n\t\t\tputs \"UI Check : Fail. Login link is not present at the correct position.\"\n\t\tend\n\t\t\n\t\t\n\t\t\n\t\t@loginbutton_leftposition = $browser.get_element_position_left \"link=Log in\"\n\t\tputs \"Login button Left position : #{@loginbutton_leftposition}\"\n\t\tif @loginbutton_leftposition == '1091'\n\t\t\tputs \"UI Check : Pass. Login link is present at the correct position.\"\n\t\telse\n\t\t\tputs \"UI Check : Fail. Login link is not present at the correct position.\"\n\t\tend\n\t\t@loginbutton_width = $browser.get_element_width \"link=Log in\"\n\t\tputs \"Login button Width : #{@loginbutton_width}\"\n\t\tif @loginbutton_width == '40'\n\t\t\tputs \"UI Check : Pass. Login link is present at the correct position.\"\n\t\telse\n\t\t\tputs \"UI Check : Fail. Login link is not present at the correct position.\"\n\t\tend\n\t\t\n\t\t@browse_topposition = $browser.get_element_position_top \"//div[2]/div/a/em\"\n\t\tputs \"Browse button Top position : #{@browse_topposition}\"\n\t\t@signupbutton_leftposition = $browser.get_element_position_left \"link=Sign up\"\n\t\tputs \"Signup button Left position : #{@signupbutton_leftposition}\"\n\t\t@signupbutton_width = $browser.get_element_width \"link=Sign up\"\n\t\tputs \"Signup button Width : #{@signupbutton_width}\"\n\t\t\n\t\t\t\t\n\t\t#~ #$browser.click_at \"link=Log in\", \"916,10\"\n\t\t#~ #$browser.break()\n\t\t#~ $browser.wait_for_page_to_load \n\t\t#~ puts \"Step 1 : Entering valid User credintials - User Name as #{email_id} and Password as #{pass_word}\"\n\t\t#~ $browser.type \"user_session_email\", email_id \n\t\t#~ $browser.type \"user_session_password\", pass_word\n\t\t#~ $browser.click \"//button[@type='submit']\"\n\t\t#~ $browser.wait_for_page_to_load \n\t\t\n\t\t#~ # FOR LOOP\n\t\t#~ for row in 1..10\n\t\t\t#~ print row, \"Hello\\n\"\n\t\t#~ end\n\t\t\n\t\t#~ puts \"----------------------------\"\n\t\t#~ # ARRAY\n\t\t#~ $players = \"www.google.com/test \"\n\t\t#~ print $players.strip, \"\\n\"\n\t\t#~ $splitvalue = $players.split(\"/\", 5)\n\t\t#~ print $splitvalue[0], \"\\n\"\n\t\t#~ print $players, \"\\n\"\n\t\t#~ print $players.length, \"\\n\"\n\t\t\n\t\t#~ puts \"----------------------------\"\n\t\t#~ #ANOTHER METHOD\n\t\t#~ $players = [\"sachin\",\"dravid\",\"ganguly \"]\n\t\t#~ $players.pop\n\t\t#~ $players.push(\"Sheryln\")\n\t\t#~ $players.each { |i| print i, \"\\n\"}\n\t\t\n\t\t#~ puts \"----------------------------\"\n\t\t#~ presidents = [\"Ford\", \"Carter\", \"Reagan\", \"Bush1\", \"Clinton\", \"Bush2\"]\n\t\t#~ for ss in 0...presidents.length\n\t\t#~ print ss, \": \", presidents[-ss -1], \"\\n\";\n\t\t#~ end\n\t\t#~ puts \"----------------------------\"\n\t\t\n\t\t#~ string1 = \"Steve was here\"\n\t\t#~ print \"e.*e found\", \"\\n\" if string1 =~ /e.*e/\n\n\t\t#~ puts \"----------------------------\"\n\t\t#~ mystring = \"wew_1234\"\n\t\t#~ regex = Regexp.new(/we../)\n\t\t#~ matchdata = regex.match(mystring)\n\t\t#~ if matchdata\n\t\t\t#~ puts matchdata[0]\n\t\t#~ else\n\t\t\t#~ puts \"NO MATCH\"\n\t\t#~ end\n\t\t\n\t\t\t\n\t\t#~ $browser.click \"link=Sign in\"\n\t\t#~ $browser.wait_for_page_to_load \n\t\t#~ $browser.type \"username\", email_id\n\t\t#~ $browser.type \"password\", pass_word\n\t\t#~ $browser.click \"login\"\n\t\t#~ $browser.wait_for_page_to_load \n\n\t\tputs \"************** END : Login to Redmine ****************\"\t\n\tend", "def on_status_ok\n @slot_window.activate.select(0)\n set_controls_help\n end", "def go_to(url)\n @browser.navigate.to url\n end", "def go_back\n back\n wait { !exists { id 'ArrowButton' } } # successfully transitioned back\n end", "def go_back\n back\n wait { !exists { id 'ArrowButton' } } # successfully transitioned back\n end", "def test_home\n @current_test_name = \"Arch - Testing Home Page\"\n each_driver do\n each_view_redirects do\n common_elements?\n end\n end\n end", "def click\n @mech.click self\n end", "def question_classic_button_click\n MenuControllerContracts.invariant(self)\n @alert_view = @help_view = Views::ConnectInstructionsAlertView.new(@window, self)\n MenuControllerContracts.invariant(self)\n end", "def forward\n driver.navigate.forward\n end", "def forward\n driver.navigate.forward\n end", "def continue_checkout_button\n $tracer.trace(__method__)\n #unit_test_no_generate: continue_checkout_button, button(\"/Continue Checkout/\")\n return ToolTag.new(button(\"/Continue Checkout/\"), __method__, self)\n end", "def visit\n @browser.goto(URL)\n end", "def test_JSDialog_003_Prompt\n\n puts2(\"\")\n puts2(\"###############################\")\n puts2(\"# BEGIN: test_JSDialog_003_Prompt #\")\n puts2(\"###############################\")\n\n # Only run if NOT using Watir-WebDriver\n if(is_webdriver? == true)\n puts2(\"Not supported with WebDriver\")\n return\n end\n\n # Only run on windows\n if(is_win?() == true)\n\n # Text on the buttons to select\n sButtonCaption = \"Display a Prompt\"\n\n # Define components of the URL\n sProtocol = \"file:///\"\n sRootURL =Dir.pwd\n sPage = \"data/html/jsdialogs.html\"\n\n # Construct the URL\n sURL = sProtocol + sRootURL + \"/\" + sPage\n\n begin # Prompt Dialog\n\n # Start a browser,\n #browser = Watir::Browser.new\n browser = start_browser($sDefaultBrowser)\n\n # Load a blank page (Workaround for issues with click_no_wait)\n browser.goto(\"about:blank\")\n\n # Load the page\n browser.goto(sURL)\n\n if(browser.is_ie?)\n sDialogTitle = \"Explorer User Prompt\"\n elsif(browser.is_firefox?)\n sDialogTitle = \"[JavaScript Application]\"\n end\n\n puts2(\" Selecting button \\\"#{sButtonCaption}\\\" \")\n\n # Raise a popup JS Dialog by using the method - click_no_wait\n browser.button(:value, /#{sButtonCaption}/).click_no_wait\n #\n if(browser.is_firefox?)\n # Use this workaround until click_no_wait is fixed in firewatir\n #pause(\"Manually select the button: \" + sButtonCaption + \"\\nThen dismiss this pause dialog\")\n end\n\n # Define the text on the control that AutoIt should select\n sControlID = \"Cancel\"\n\n # Dismiss the JS-Dialog\n puts2(\"Dismissing JS Confirmation dialog via the #{sControlID} button...\")\n browser.handle_win_dialog_generic_modal(sDialogTitle, sControlID)\n\n #\n # Do it again but dismiss the JS dialog by selecting the other button after entering some text\n #\n\n sButtonCaption = \"Display a Prompt\"\n puts2(\" Selecting button \\\"#{sButtonCaption}\\\" \")\n\n # Raise a JS-Prompt-Dialog\n #\n browser.button(:value, /#{sButtonCaption}/).click_no_wait\n #\n if(browser.is_firefox?)\n # Use this workaround until click_no_wait is fixed in firewatir\n #pause(\"Manually select the button: \" + sButtonCaption + \"\\nThen dismiss this pause dialog\")\n end\n\n sInputTextControlID=\"Edit1\"\n sInputText = random_sentence(5)\n\n # Define the text on the control that AutoIt should select\n sControlID = \"OK\"\n\n # Dismiss the JS-Dialog\n puts2(\"Dismissing JS Confirmation dialog via the #{sControlID} button...\")\n browser.handle_win_dialog_generic_modal(sDialogTitle, sControlID, sInputTextControlID, sInputText)\n\n rescue => e\n\n puts2(\"*** ERROR and Backtrace: \" + e.message + \"\\n\" + e.backtrace.join(\"\\n\"), \"ERROR\")\n\n # Raise the error with a custom message after the rest of the rescue actions\n raise(\"*** TESTCASE - test_JSDialog_003_Prompt\")\n\n ensure\n\n # Close the browser\n browser.close()\n\n end # Confirmation Dialog\n\n else\n puts2(\"*** Skipping - Non-Windows platform\")\n end # Only run on windows\n\n end", "def add_button_clicked\n\t\t\n\t\t\t# Eventually create browse form\n\t\t\tcreate_browse_form\n\t\t\n\t\t\t# Show and activate the child window\n\t\t\tshow_browse_form\n\t\tend", "def begin_assessment\n frm.button(:value=>\"Begin Assessment\").click\n end", "def go\n catch(:quit) do\n loop do\n step\n end\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 goForward(sender)\n web_view.goForward\n end", "def go_home\n wait_for_home_button\n home_button.click\n end", "def next_menu_ok_tb \n @showing_temp_hls = false\n @menu_ok_tb = true\n end", "def question_otto_button_click\n MenuControllerContracts.invariant(self)\n @alert_view = @help_view = Views::OttoInstructionsAlertView.new(@window, self)\n MenuControllerContracts.invariant(self)\n end", "def test_start_new_game\n @qtquickmemory.start\n @qtquickmemory.verify_pairs_open\n @qtquickmemory.verify_clock_timer\n @qtquickmemory.pause_game\n @qtquickmemory.exit\n end", "def question_login_button_click\n MenuControllerContracts.invariant(self)\n @alert_view = @help_view = Views::LoginAlertView.new(@window, self)\n MenuControllerContracts.invariant(self)\n end", "def main_menu\n main_menu_options = {'Interact with Existing Kits' => :list_and_select_kit,\n 'Create a new Kit' => :prompt_kit_params, \n 'Quit' => :quit}\n \n op = @io.select_from_options(\"What would you like to do?\", main_menu_options)\n @operation_stack.unshift op\n \n # return nil, because there's nothing to pass onto the next method\n return\n end", "def on_mdButton(e)\n\t \t \n\t dd = Wx::DirDialog.new(self, \"choose daysim materials directory\", @mdTC.get_value())\n\t if dd.show_modal == 5100\n\t @mdTC.set_value(dd.get_path)\n else\n return\n end\n \n end", "def navigate(direction)\n if direction == 'back'\n\t $driver.navigate.back\n else\n $driver.navigate.forward\n end\nend", "def move\n frm.button(:value=>\"Move\").click\n end", "def confirmation\n load_step\n wizard_end\n end", "def setup_gui\n \n end", "def on_pdButton(e)\n\t \t \n\t dd = Wx::DirDialog.new(self, \"choose project directory\", @pdTC.get_value())\n\t if dd.show_modal == 5100\n\t @pdTC.set_value(dd.get_path)\n else\n return\n end\n \n end", "def on_pdButton(e)\n\t \t \n\t dd = Wx::DirDialog.new(self, \"choose project directory\", @pdTC.get_value())\n\t if dd.show_modal == 5100\n\t @pdTC.set_value(dd.get_path)\n else\n return\n end\n \n end", "def done\n frm.button(:name=>\"takeAssessmentForm:_id5\").click\n EditAssessment.new(@browser)\n end", "def go_to_url (url)\n\t\t@browser.goto (url)\n\tend", "def test_00010_profilepage_profile_option\n @profile_page.user_dropdown.when_present.click\n assert @profile_page.profile_link.present?\n ensure\n # close up the context menu\n @profile_page.user_dropdown.click if @profile_page.profile_link.present?\n end", "def goto_dir\n return\nend", "def click\n @_node.click\n @_node.getPage.getWebClient.waitForBackgroundJavaScriptStartingBefore(3000)\n end", "def homeandnewuser(driver)\n #Open page\n loggEr(\"Log: Open page #{URL_HOME}\")\n driver.get(URL_HOME)\n matchUrl(URL_HOME, driver)\n\n #Choose create a new user button and\n loggEr(\"Log: Click on the Create a new user button\")\n driver.find_element(:link, \"Create a new user\").click\nend", "def go_to(url)\n @browser.goto(url)\n end", "def goto\n navigate_application_to \"Report=>Custom Views\"\n end", "def back\n driver.navigate.back\n end", "def back\n driver.navigate.back\n end", "def click_next_gallery\n click NEXT_GALLERY_BUTTON\n end", "def back\n @driver.navigate.back\n @after_hooks.run\n end", "def clicked\n router.navigated\n end", "def on_click\n\t\tend", "def click_run_file_dialog_popup(title)\n click_button_popup(title, \"&Run\")\nend", "def after_win\n\n end", "def redirect_to_finish_wizard(options = nil)\n redirect_to @setup, notice: \"You are ready to show your setup off to the world!\"\n end", "def finish() #method\n puts \"Menu cooked successfully.\"\n exit\n end", "def go\n catch(:quit) do\n loop do\n step\n end\n end\n end", "def go\n catch(:quit) do\n loop do\n step\n end\n end\n end", "def button_comprar_go_to_cart\n\n click_button 'Comprar Ahora'\nend", "def back\r\n @browser.navigate.back\r\n end", "def goto_end_of_history\r\n end", "def action\n trigger :click\n end", "def go_home\n self.homelink.click\n end", "def verifyInformationScreen()\n clickOnMoreTab()\n clickOnInformation()\n verifyMeeting()\n end", "def test_p1_00010_profilepage_profile_option\n if !@profilepage.profile_activity.present?\n @profilepage.goto_profile\n end\n if @profilepage.profile_pic_modal.present?\n @profilepage.profile_pic_cancel_button.click\n @browser.wait_until($t) { !@profilepage.profile_pic_modal.present? }\n end\n \t@profilepage.check_profile_in_user_dropdown\n \tassert @profilepage.profile_link.present? \n @profilepage.newline\n end", "def button_down_game_replay_presenter(id, window, state)\n if id == Gosu::KbSpace\n navigate_back(window) if id == Gosu::KbSpace\n end\n level_up(state) if id == Gosu::KbRight\n level_down(state) if id == Gosu::KbLeft\nend", "def chkout_continue_checkout_button\n $tracer.trace(__method__)\n #unit_test_no_generate: chkout_continue_checkout_button, button(\"/Continue Checkout/\")\n return ToolTag.new(button(\"/Continue Checkout/\"), __method__, self)\n end", "def forward\n @driver.navigate.forward\n @after_hooks.run\n end", "def show_return_option\n puts \"\\n000 - Return to main Screen\"\n print \":>\"\n end", "def choose_first_click; end", "def exit_clicked()\n GeneralEvent.log(\"BUTTON_CLICK\", \"Admin Exit Button Clicked\")\n emit change_screen(Environment::LOGIN)\n end", "def goto_url(url)\r\n @browser.navigate.to url\r\n end", "def click\n p [ :app_click ]\n view.click\n end", "def goToNextStep\n case @step\n when :unlockReset\n @step = :unlockHelps\n setHelpOnClick\n\n when :unlockFreezers\n @step = :unlockReset\n setResetOnClick\n\n when :unlockRedo\n @step = :unlockFreezers\n setFreezersOnClick\n\n when :unlockUndo\n @step = :unlockRedo\n setRedoOnClick\n\n when :unlockGrid\n @step = :unlockUndo\n setUndoOnClick\n\n when :unlockPause\n @step = :unlockGrid\n setGridOnClick\n\n when :intro\n @step = :unlockPause\n setPauseOnClick\n end\n end", "def go direction\n act \"go #{direction}\"\n end" ]
[ "0.63644606", "0.62964433", "0.62464285", "0.60698146", "0.60617983", "0.60617983", "0.60419524", "0.5927684", "0.58906287", "0.5877357", "0.583677", "0.5819967", "0.5819967", "0.5819967", "0.5804068", "0.57518095", "0.5742062", "0.573307", "0.57323927", "0.57088983", "0.56954026", "0.56927574", "0.56539106", "0.5644633", "0.5644633", "0.5644633", "0.5644633", "0.5638158", "0.5635642", "0.5634221", "0.56169355", "0.5615742", "0.5614903", "0.56026447", "0.55995196", "0.5597523", "0.5597523", "0.5596044", "0.5594789", "0.55597585", "0.5555854", "0.5555854", "0.55539834", "0.55533385", "0.55412537", "0.5539813", "0.5539772", "0.55343175", "0.55270725", "0.5526098", "0.55209494", "0.5517279", "0.55142653", "0.55033565", "0.5500774", "0.5491749", "0.54883796", "0.54725456", "0.54661435", "0.5461149", "0.5457793", "0.54468966", "0.54468966", "0.5445938", "0.54451144", "0.5439434", "0.5438519", "0.5433478", "0.5427775", "0.542584", "0.5425035", "0.54149306", "0.54149306", "0.5411707", "0.540351", "0.5403365", "0.5402951", "0.5400938", "0.5400574", "0.5398909", "0.5395906", "0.53930616", "0.53930616", "0.5387465", "0.5387216", "0.5384579", "0.5379884", "0.53672755", "0.5366977", "0.5341648", "0.53385234", "0.5338263", "0.53330487", "0.53288573", "0.5326518", "0.5325491", "0.53235", "0.5321041", "0.5320447", "0.5320241" ]
0.5581627
39
Retrieve plugin specific configuration from the global configuration file gets passed to the plugin instance upon initilization.
def plugin_config(plugin) Jerakia::Lookup::PluginConfig.new(plugin) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pluginconf(plugin)\n @pluginconfig[plugin]\n end", "def config\n @config ||= YAML.load_file @options[:config_file]\n end", "def config\n @bot.config.plugins.options[self.class] || {}\n end", "def config\n @bot.config.plugins.options[self.class] || {}\n end", "def config\n @bot.config.plugins.options[self.class] || {}\n end", "def config\n @config ||= load_config\n end", "def plugin_config(plugin_name)\n\t\t\tplugin_ns = player_config['plugins'] ||= {}\n\t\t\treturn plugin_ns[plugin_name.to_s] ||= {}\n\t\tend", "def get_plugin_config(plugin)\n unless @plugin_config[plugin]\n hash = {}\n def hash.method_missing(name, *args)\n name = name.to_s\n if /=$/ =~ name\n self[name[0..-2]] = args[0]\n else\n self[name]\n end\n end\n @plugin_config[plugin] = hash\n end\n @plugin_config[plugin]\n end", "def config\n @config ||= Config.create ConfigLoader.new(root, CONFIG_FILE).to_hash, options.merge_config\n end", "def config\n @config ||= read_config\n end", "def config\n @config ||= YAML::load_file(File.join(@cwd, \"config\", \"settings.yml\"))\n end", "def load_config\n # Nothing in base class. This should be used to load the configuration from\n # disk if saved to a file.\n configuration || {}\n end", "def config\n @config_file\n end", "def load_config!\n cfg_data = begin\n YAML.load(File.open(CONFIG_DIR + GLOBAL_CONFIG))\n rescue Errno::ENOENT\n Hash.new\n end\n __load_config(DEFAULTS.merge(cfg_data))\n end", "def method_missing(method_name, *args, &block)\n config = Loquacious::Configuration.for method_name, &block\n raise Adhearsion::Configuration::ConfigurationError.new \"Invalid plugin #{method_name}\" if config.nil?\n config\n end", "def method_missing(method_name, *args, &block)\n config = Loquacious::Configuration.for method_name, &block\n raise Adhearsion::Configuration::ConfigurationError.new \"Invalid plugin #{method_name}\" if config.nil?\n config\n end", "def config\n @config ||= YAML.load File.read(@config_file)\n end", "def get_config\n\t\tend", "def config\n @config ||= YAML.load_file(@config_file_path)\n end", "def plugin_config_file\n File.join(@dir, Config::FILE_NAME)\n end", "def config\n @options[:config]\n end", "def set_config_plugin\n @config_plugin = ConfigPlugin.find(params[:id])\n end", "def load_config()\n self.config = Kitchenplan::Config.new().config\n end", "def config\n App.instance.load_project_config\n App.instance.config\n end", "def config\n\t\t\t@config ||= begin\n\t\t\t\tfile = File.join(self.location, \"config.yaml\")\n\t\t\t\tif File.exists?(file)\n\t\t\t\t\tYAML::load_file(file)\n\t\t\t\telse\n\t\t\t\t\t{}\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def config\n @config ||= @module_config || {}\n end", "def plugin_conf\n inspec_config.fetch_plugin_config(\"inspec-chef\")\n end", "def config\n ensure_config_exists\n @config ||= (YAML.load_file(config_file) || {})\n end", "def global_config\n @@global_config\n end", "def config\n @config ||= @module_config || {}\n end", "def config(name = nil, &block)\n if name.nil?\n name = self.plugin_name\n else\n self.plugin_name = name\n end\n\n if block_given?\n opts = {}\n opts[:after] ||= configs.last.name unless configs.empty?\n ::Loquacious::Configuration.defaults_for plugin_name, &Proc.new(&block)\n initializer = Initializer.new(plugin_name, self, opts) do\n ::Loquacious.configuration_for plugin_name, &block\n end\n Adhearsion::Plugin.configs << initializer\n else\n ::Loquacious.configuration_for plugin_name\n end\n end", "def conf\n begin\n @conf ||= JSON.parse(File.read(config_file))\n rescue\n @conf ||= {}\n end\n end", "def conf\n begin\n @conf ||= JSON.parse(File.read(config_file))\n rescue\n @conf ||= {}\n end\n end", "def load_config(global)\n config_file_path = File.join(Dir.home, CONFIG_FILE_NAME)\n\n if File.exists?(config_file_path)\n require 'yaml'\n file_settings = YAML.load_file(config_file_path)\n global[:config].merge!(file_settings)\n end\n\nend", "def load_config\n @log.debug \"loading validator-specific configuration\"\n config = Autosign::Config.new\n\n if config.settings.to_hash[self.name].nil?\n @log.warn \"Unable to load validator-specific configuration\"\n @log.warn \"Cannot load configuration section named '#{self.name}'\"\n return {}\n else\n @log.debug \"Set validator-specific settings from config file: \" + config.settings.to_hash[self.name].to_s\n return config.settings.to_hash[self.name]\n end\n end", "def configuration\n\t\t\t\tconfiguration = Configuration.new\n\t\t\t\t\n\t\t\t\tself.resolved_paths.each do |path|\n\t\t\t\t\tpath = File.expand_path(path)\n\t\t\t\t\t\n\t\t\t\t\tconfiguration.load_file(path)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn configuration\n\t\t\tend", "def method_missing(missing_method_name, *args, &block)\n if 'cfg' == missing_method_name.to_s\n self.config.settings\n else\n super\n end\n end", "def configuration\n @config ||= setup\n end", "def configuration\n @configuration ||= begin\n config = {}\n\n if protoc_options[:configuration]\n require \"yaml\"\n\n config = YAML.load_file protoc_options[:configuration]\n config.merge! config\n end\n\n config\n end\n end", "def config\n @config ||= YAML.load_file(BASE_PATH + '/local.config.yml')\nend", "def load_configuration!\n unless @configured\n load Rails.root.join( *Parametrization::Config::DEFAULT_CONFIG_PATH )\n end\n end", "def load_plugin_settings!\n @sorcery_config.plugins.each do |plugin|\n # TODO: Find a better name than \"klass\"\n @sorcery_config.plugin_settings[plugin].each do |klass, plugin_settings|\n next unless klass == :controller\n\n plugin_settings.each do |key, value|\n # TODO: This method of assigning keys can probably be improved.\n config_method = \"#{key}=\".to_sym\n if @sorcery_config.respond_to?(config_method)\n @sorcery_config.__send__(config_method, value)\n else\n raise Sorcery::Errors::ConfigError,\n \"Invalid plugin setting provided! `#{key}` is not a valid \"\\\n \"option for the Sorcery `#{plugin}` plugin.\"\n end\n end\n end\n end\n end", "def config\n PrcLib.runtime_fail 'No config object loaded.' unless @config\n @config\n end", "def config\n configuration\n end", "def config\n @config ||= {}\n end", "def config\n @config ||= {}\n end", "def load_config\n\t\t# load conifg\n\t\tend", "def config\n XConfig::Core.fetch(self)\n end", "def configuration\n Configuration::get\n end", "def configuration\n Configuration::get\n end", "def config\n @config ||= begin\n if File.exist?(@config_file)\n begin\n YAML.load_file(@config_file) || {}\n rescue Psych::SyntaxError => e\n raise PgSync::Error, e.message\n end\n else\n {}\n end\n end\n end", "def configuration\n config = {}\n tag_configuration_plugins.each do |p|\n # the first submodule listed is the one which accepts the configuration\n key = p.plugin.modules.first.submodule_name\n config[key] = p.parameters;\n end\n config\n end", "def config\n @_config ||= self.class.config.inheritable_copy\n end", "def config(for_plugin: nil, for_command: nil)\n if for_plugin && for_command\n fail ArgumentError, \"Cannot get config for plug-in and command together\"\n elsif for_plugin\n @config.dig(:plugins, for_plugin.to_sym) || OpenStruct.new\n elsif for_command\n @config.dig(:commands, for_command.to_sym) || OpenStruct.new\n else\n @config\n end\n end", "def load_config()\n Kitchenplan::Log.debug \"Loading configs from #{self.options[:config_dir]} ...\"\n #Kitchenplan::Log.debug self.platform.ohai.inspect\n self.config = Kitchenplan::Config.new(self.platform.ohai, parse_configs=true,config_path=self.options[:config_dir]).config()\n end", "def config\n machined.config\n end", "def load_config!\n if options[:config]\n config_inst = Config.new(options[:config])\n elsif self.class.const_defined?(:DEFAULT_CONFIGURATION_FILES)\n path = self.class.const_get(:DEFAULT_CONFIGURATION_FILES).detect do |check|\n full_check = File.expand_path(check)\n File.exists?(full_check)\n end\n config_inst = Config.new(path) if path\n end\n if config_inst\n options.delete(:config)\n defaults_inst = Smash[\n config_class.new(\n defaults.to_smash\n ).to_smash.find_all do |key, value|\n defaults.key?(key)\n end\n ]\n config_data = config_inst.data\n config_inst = Smash[\n config_inst.to_smash.find_all do |key, value|\n config_data.key?(key)\n end\n ]\n options_inst = Smash[\n config_class.new(\n options.to_smash\n ).to_smash.find_all do |key, value|\n options.key?(key)\n end\n ]\n @options = config_class.new(\n defaults_inst.to_smash.deep_merge(\n config_inst.to_smash.deep_merge(\n options_inst.to_smash\n )\n )\n ).to_smash\n else\n @options = config_class.new(\n defaults.to_smash.deep_merge(\n options.to_smash\n )\n ).to_smash\n end\n options\n end", "def config_file\n CONFIG_FILE\n end", "def initialize\n super\n \n run_hook :before_configuration\n \n # Search the root of the project for required files\n $LOAD_PATH.unshift(root)\n \n # Check for and evaluate local configuration\n local_config = File.join(root, \"config.rb\")\n if File.exists? local_config\n puts \"== Reading: Local config\" if logging?\n instance_eval File.read(local_config)\n end\n \n run_hook :build_config if build?\n run_hook :development_config if development?\n \n run_hook :after_configuration\n \n # Add in defaults\n default_extensions.each do |ext|\n activate ext\n end\n \n if logging?\n self.class.extensions.each do |ext|\n puts \"== Extension: #{ext}\"\n end\n end\n end", "def global_config\n # This entire VM Pooler config\n @config\n end", "def config\r\n @configuration\r\n end", "def load\n $LOG.debug \"Config::load\"\n\n filepath = cfgFilePath(\"pdconfig.yml\")\n if(!File.exists?( filepath )) # TODO: This needs to be moved into KtCfg.\n $LOG.debug \"Config file does not exist. Returning default config obj.\"\n return @cfg\n end\n\n @cfg = read(\"pdconfig.yml\")\n end", "def load_config!\n if(options[:config])\n config_inst = config_class.new(options[:config])\n elsif(self.class.const_defined?(:DEFAULT_CONFIGURATION_FILES))\n path = self.class.const_get(:DEFAULT_CONFIGURATION_FILES).detect do |check|\n full_check = File.expand_path(check)\n File.exists?(full_check)\n end\n config_inst = config_class.new(path) if path\n end\n if(config_inst)\n options.delete(:config)\n @options = config_class.new(\n defaults.to_smash.deep_merge(\n config_inst.to_smash.deep_merge(\n options.to_smash\n )\n )\n ).to_smash\n else\n @options = config_class.new(\n defaults.to_smash.deep_merge(\n options.to_smash\n )\n ).to_smash\n end\n options\n end", "def config\n @config ||= YAML.load_file(config_file)[environment]\n end", "def load_config\n @configuration = Configuration.find :first\n end", "def actual_config\n Config.instance\n end", "def initialize\n create_config unless File.exists?(config_file)\n load_settings\n set_domain\n end", "def config\n path = config_path\n @config ||= path.exist? ? JSON.parse(path.read) : {}\n end", "def config\n @config || QuestBack.default_configuration || fail(QuestBack::Error, 'No configuration given or found on QuestBack.default_configuration.')\n end", "def config\n @config ||= OpenStruct.new(YAML.load_file(self.config_path))\n end", "def initialize\n @config = config_from_file || empty_config\n end", "def config\n @config\n end", "def config\n @config\n end", "def config\n @config\n end", "def get_config(context)\n context.registers[:site].config\n end", "def config\n if Config.config.nil? or Config.config.empty?\n begin\n Config.config = Configuration.load_config(Config.config_file,\n Config.config_options)\n rescue Errno::ENOENT\n Config.config = {}\n end\n end\n\n return Config.config\n end", "def get_config\n global_config = {\n 'pubnub_subscribe_key'=> Settings.pubnub.subscribe_key\n }\n\n static_config = {\n 'name'=> self.name\n }\n\n #Manually inject the analytics from the account into the unit\n if self.admo_account and not self.admo_account.analytics.empty?\n #We hide the secret away from the clients for now.\n static_config['analytics'] = self.admo_account.analytics\n static_config['analytics'].delete(:mixpanel_api_secret)\n end\n\n account_config = self.admo_account.try(:config) || {}\n global_config.merge(account_config).merge(self.config).merge(static_config)\n end", "def config(opts=nil)\n if opts\n @config = @config.merge(get_subhash(opts, DEFAULTS.keys))\n else\n @config\n end\n end", "def config\n site.config\n end", "def config_meta\n Hash[*plugins.map {|p| [p, p.config] }.flatten(1) ]\n end", "def config_file\n @config_file\n end", "def configuration\n provider.configuration\n end", "def config\n\n end", "def configuration\n @configuration ||= case configuration_path.split(\"/\").last\n when \"database.yml\" then database_yml_config\n when \"mongoid.yml\" then mongoid_yml_config\n end\n end", "def parsed_options\n config\n end", "def config\n self\n end", "def read_project_configuration\n if file = detect_configuration_file\n Compass.configuration.parse(file)\n end\n end", "def config\n Cloudtasker.config\n end", "def optional_config_file\n if ::File.exists?(@options.to_s)\n @options = @global.load_ruby_config(::File.expand_path(@options))\n end\n end", "def load_overrides\n if ENV['PARAMS_FILE'] && ENV['PARAMS_FILE'] != ''\n if File.readable?(ENV['PARAMS_FILE'])\n project_root = self.instance_variable_get(\"@project_root\")\n packaging_root = self.instance_variable_get(\"@packaging_root\")\n self.config_from_yaml(ENV['PARAMS_FILE'])\n self.instance_variable_set(\"@project_root\", project_root) if project_root\n self.instance_variable_set(\"@packaging_root\", packaging_root) if packaging_root\n else\n fail \"PARAMS_FILE was set, but not to the path to a readable file.\"\n end\n end\n end", "def ext_config\n config[:ext_config] || {}\n end", "def conf\n unless @conf\n if @db_url || @db # skip loading config if db set explicitly\n @conf = {}\n else\n parse_command_line unless @args\n\n raise \"No configuration file defined (-c <config>).\" if @args[\"config\"].nil?\n raise \"Couldn't read #{@args[\"config\"]} file.\" unless @args['config'] && @conf = YAML::load(File.new(@args[\"config\"]).read)\n # setting default options that should be written along with all the records to process_items\n if @conf['default_options']\n @conf['default_options'].each do |k,v|\n default_options.send(\"#{k}=\", v)\n end\n end\n\n if @args['params']\n @args['params'].each do |k, v|\n default_options.send(\"#{k}=\", v)\n end\n end\n end\n end\n @conf\n end", "def config\n @config ||= Config.new\n end", "def config\n @config ||= Config.new\n end", "def config\n boot.config\n end", "def load_config\n file = root+CONFIG_FILE_NAME\n @config = file.file? ? YAML.load_file(file) : { :shared_directories => [], :core_modules => [] }\n end", "def global_yaml\n parse_yaml_string(yaml_string(global_config_file), global_config_file)\n end", "def setup_config\n # To be Extended\n end", "def config\n info['Config']\n end", "def read_configuration\n\t\t@config = YAML.load_file(\"config.yml\")\n\t\treturn @config\n\tend" ]
[ "0.7281502", "0.71163803", "0.7108594", "0.7108594", "0.7108594", "0.7061733", "0.69594187", "0.69156677", "0.6878163", "0.6849345", "0.67562926", "0.6725543", "0.66451824", "0.6644665", "0.66232985", "0.66232985", "0.65981066", "0.6595", "0.65789443", "0.6577961", "0.6564013", "0.6560098", "0.65341544", "0.6520024", "0.64848644", "0.64834785", "0.6483151", "0.6466178", "0.6455416", "0.642806", "0.64093024", "0.6394733", "0.6394733", "0.63817286", "0.6378266", "0.636227", "0.6361986", "0.6359122", "0.6342326", "0.6339033", "0.6338332", "0.63326865", "0.6318884", "0.63165367", "0.6293125", "0.6293125", "0.629305", "0.62661034", "0.6264964", "0.6264964", "0.6260632", "0.625591", "0.6253842", "0.62505656", "0.6247599", "0.62396556", "0.6234284", "0.62251014", "0.6217247", "0.6207782", "0.62025845", "0.62011707", "0.61816823", "0.6177864", "0.61731344", "0.6169679", "0.6166347", "0.61598504", "0.6159725", "0.6157442", "0.6155832", "0.6153582", "0.6153582", "0.6153582", "0.614517", "0.6144962", "0.61309993", "0.61289024", "0.6127912", "0.6126273", "0.6125466", "0.6123957", "0.6123295", "0.611841", "0.61183566", "0.61159146", "0.61142087", "0.61134875", "0.6111092", "0.6110087", "0.61085844", "0.60984886", "0.60953057", "0.60953057", "0.60899234", "0.608602", "0.6085858", "0.6083823", "0.6073671", "0.60709035" ]
0.6665647
12
lookup function: continue Will cause Jerakia to continue to the next lookup in the policy which is the default behaviour
def continue @proceed = true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resolve(records, lookup_chain, domain)\n # check if key exists\n count = 0\n\n for keyHash in records[:ADDRESS]\n if keyHash.has_key? domain.to_sym\n count=1\n end\n end\n\n for keyHash in records[:CNAME]\n if keyHash.has_key? domain.to_sym\n count=1\n end\n end\n\n if count == 0\n puts \"Error: record not found for #{domain}\"\n exit\n end\n\n # flag to exit when it enters ADDRESS key\n flag = 0\n\n # Access the Keys in ADDRESS key from records\n for keyHash in records[:ADDRESS]\n if keyHash.has_key? domain.to_sym\n lookup_chain.push(keyHash[domain.to_sym][0])\n flag = 1\n break\n end\n end\n\n\n if flag == 0\n\n for keyHash in records[:CNAME]\n if keyHash.has_key? domain.to_sym\n lookup_chain.push(keyHash[domain.to_sym][0])\n resolve(records, lookup_chain, keyHash[domain.to_sym][0])\n else\n flag = 1\n #Recursion till it enters :ADDRESS key\n resolve(records, lookup_chain, keyHash[domain.to_sym][0])\n break\n end\n end\n if lookup_chain.length == 1\n puts \"Error: record not found for #{lookup_chain}\"\n else\n return lookup_chain\n end\n else\n if lookup_chain.length == 1\n puts \"Error: record not found for #{lookup_chain}\"\n else\n return lookup_chain\n end\n end\nend", "def requires_lookup!( local_index )\n \n @requires_lookup[ local_index ] = true\n \n return self\n \n end", "def continue_routing\n if block_given?\n original_env = @env.dup\n begin\n yield\n rescue NotMatchedError\n @env = original_env\n end\n else\n create_chain_proxy(:continue_routing)\n end\n end", "def continue_on_exists_proc=(_arg0); end", "def continue_on_exists_proc; end", "def resolve(dns_records, lookup_chain, domain)\n record_A = dns_records[:A]\n record_CNAME = dns_records[:CNAME]\n\n #if domain in recordA\n #add destination to lookup_chain\n if record_A[:source].include?(domain)\n lookup_chain.push(record_A[:ip][record_A[:source].index(domain)])\n\n #if domain in recordCNAME\n #add destination to lookup_chain\n #update domain with destination\n #call the funtion again with new domain(Recursion)\n elsif record_CNAME[:source].include?(domain)\n lookup_chain.push(record_CNAME[:alias][record_CNAME[:source].index(domain)])\n domain = record_CNAME[:alias][record_CNAME[:source].index(domain)]\n resolve(dns_records, lookup_chain, domain)\n else\n return lookup_chain\n end\nend", "def continue!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n type = CONTINUE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 330:11: 'continue'\n match( \"continue\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n end", "def continue!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 38 )\n\n type = CONTINUE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 159:12: 'continue'\n match( \"continue\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 38 )\n\n end", "def continue; end", "def continue; end", "def lookups; end", "def get_lookup(name)\n @lookups = {} unless defined?(@lookups)\n @lookups[name] = spawn_lookup(name) unless @lookups.include?(name)\n @lookups[name]\n end", "def looked_up!( local_index )\n \n @requires_lookup[ local_index ] = false\n \n return self\n \n end", "def requires_lookup?( local_index )\n \n return @requires_lookup ? @requires_lookup[ local_index ] || false : false\n \n end", "def lookup(label, limit=nil)\n $stderr.puts \"DEBUG: #{self.class.name}.lookup(#{label})\" if @debug\n recs = []\n Timeout::timeout(@timeout) {\n url = @url+\"/\"+label\n $stderr.puts \"DEBUG: #{self.class.name} url = #{url}\" if @debug\n begin\n url = URI.parse url\n rescue URI::InvalidURIError\n $stderr.puts \"ERROR: Invalid address: #{url}\"\n return recs\n end\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = (url.scheme == 'https')\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n http.verify_depth = 5\n request = Net::HTTP::Get.new(url.request_uri)\n request.add_field(\"User-Agent\", \"Ruby/#{RUBY_VERSION} passivedns-client rubygem v#{PassiveDNS::Client::VERSION}\")\n if @username\n request.basic_auth(@username, @password)\n end\n if @auth_token\n request.add_field(\"Authorization\", @auth_token)\n end\n t1 = Time.now\n 0.upto(9) do\n response = http.request(request)\n body = response.body\n if body == \"Rate Limit Exceeded\"\n $stderr.puts \"DEBUG: Rate Limit Exceeded. Retrying #{label}\" if @debug\n else\n t2 = Time.now\n recs = parse_json(response.body, label, t2-t1)\n break\n end\n end\n if limit\n recs[0,limit]\n else\n recs\n end\n }\n rescue Timeout::Error\n $stderr.puts \"#{self.class.name} lookup timed out: #{label}\"\n recs\n end", "def continue_statement\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 22 )\n return_value = ContinueStatementReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n\n _last = _first_0 = nil\n string_literal93 = nil\n __ID94__ = nil\n\n tree_for_string_literal93 = nil\n tree_for_ID94 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 122:5: ^( 'continue' ( ID )? )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal93 = match( CONTINUE, TOKENS_FOLLOWING_CONTINUE_IN_continue_statement_685 )\n\n tree_for_string_literal93 = @adaptor.copy_node( string_literal93 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal93, root_1 )\n\n\n\n if @input.peek == DOWN\n match( DOWN, nil )\n # at line 122:19: ( ID )?\n alt_25 = 2\n look_25_0 = @input.peek( 1 )\n\n if ( look_25_0 == ID )\n alt_25 = 1\n end\n case alt_25\n when 1\n # at line 122:19: ID\n _last = @input.look\n __ID94__ = match( ID, TOKENS_FOLLOWING_ID_IN_continue_statement_687 )\n\n tree_for_ID94 = @adaptor.copy_node( __ID94__ )\n\n @adaptor.add_child( root_1, tree_for_ID94 )\n\n\n\n end\n\n match( UP, nil )\n end\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 22 )\n\n end\n \n return return_value\n end", "def lookup(street,from_number,to_number,number_step) \n if @properties.include?(street)\n return @properties[street]\n end\n qry=URI::encode(street) \n#query the street name to get the SifID\n url = \"http://ags2.lojic.org/ArcGIS/rest/services/External/Address/MapServer/exts/AddressRestSoe/ValidateStreetName?StreetName=\"+ qry + \n \"&token=XByufiRcTeZJOARKuu3jJV2mNkBRSCD--D1YqeBZDCuEij4BnbkuzNL3QcE-l3mwAnR7Rs9CoaKo-Xp8j4Tsuw..\" +\n '&f=json&dojo.preventCache=1365987076181&callback=dojo.io.script.jsonp_dojoIoScript49._jsonpCallback'\n# load the url\n html = cache street + \"\",url\n#convert jsonp into json\n data= /jsonpCallback\\(([^\\)]+)\\);$/.match(html)\n html=data[1]\n json = JSON.parse(html)\n if json \n if json.include?('Candidates') \n json['Candidates'].each{ |street_obj|\n $current_number = from_number\n while $current_number < to_number do \n print \"going to lookup \"+ $current_number.to_s + \"\\n\"\n lookup_housenumbers(street, street_obj[\"SifID\"],$current_number)\n $current_number = $current_number + number_step\n end\n }\n else\n warn \"nothing for \" + street + \"\\n\"\n return nil\n end \n end\n return p\n end", "def lookup_action; end", "def setup\n @lookup = ::Parfait::Dictionary.new\n end", "def lookup(label, limit=nil)\n $stderr.puts \"DEBUG: #{self.class.name}.lookup(#{label})\" if @debug\n Timeout::timeout(@timeout) {\n url = nil\n if label =~ /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(\\/\\d{1,2})?$/\n label = label.gsub(/\\//,',')\n url = \"#{@base}/rdata/ip/#{label}\"\n else\n url = \"#{@base}/rrset/name/#{label}\"\n end\n url = URI.parse url\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = (url.scheme == 'https')\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n http.verify_depth = 5\n path = url.path\n if limit\n path << \"?limit=#{limit}\"\n end\n request = Net::HTTP::Get.new(path)\n request.add_field(\"User-Agent\", \"Ruby/#{RUBY_VERSION} passivedns-client rubygem v#{PassiveDNS::Client::VERSION}\")\n request.add_field(\"X-API-Key\", @key)\n request.add_field(\"Accept\", \"application/json\")\n t1 = Time.now\n response = http.request(request)\n if response.code.to_i == 404\n $stderr.puts \"DEBUG: empty response from server\" if @debug\n return\n end \n t2 = Time.now\n $stderr.puts response.body if @debug\n parse_json(response.body,t2-t1)\n }\n rescue Timeout::Error\n $stderr.puts \"#{self.class.name} lookup timed out: #{label}\"\n end", "def lookup\n title = params[:kase][:title]\n klass = kase_class.klass(params[:kase][:kind]) || kase_class\n \n @kases = if @tier\n @tier.kases.find(:all, klass.find_options_for_query(title, :limit => 5))\n else\n klass.find_by_query(:all, title, :limit => 5)\n end\n \n if @kases.blank?\n render :update do |page|\n page.redirect_to(member_path([@tier, @topic, klass], :new, {:title => title}))\n end\n return\n else\n # return lookup results\n render :update do |page|\n page.replace_html dom_class(Kase, :lookup_results), :partial => 'kases/lookup_results'\n page << probono_visual_effect(:blind_down, dom_class(Kase, :lookup_results))\n \n page[dom_class(Kase, :lookup_spinner)].hide\n page[dom_class(Kase, :lookup_start)].show\n page[dom_class(Kase, :lookup_cancel)].show\n \n page.select(\"##{dom_class(Kase, :lookup_start)} a\").first.write_attribute('href',\n member_path([@tier, @topic, klass], :new, {:title => title}))\n end\n end\n end", "def lookup(label, limit=nil)\n $stderr.puts \"DEBUG: #{self.class.name}.lookup(#{label})\" if @debug\n Timeout::timeout(@timeout) {\n url = nil\n params = {\"rrType\" => \"\", \"maxResults\" => limit || 1000}\n \n if label =~ /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/\n url = @url+\"/dns/data\"\n params[\"ip\"] = label \n else\n resource = api_settings[@version][:resource]\n param = api_settings[@version][:param]\n url = @url+\"/dns/#{resource}\"\n params[param] = label\n end\n url << \"?\"\n params.each do |k,v|\n url << \"#{k}=#{v}&\"\n end\n url.gsub!(/\\&$/,\"\")\n \n $stderr.puts \"DEBUG: #{self.class.name} url = #{url}\" if @debug\n url = URI.parse url\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = (url.scheme == 'https')\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n http.verify_depth = 5\n request = Net::HTTP::Get.new(url.request_uri)\n request.add_field(\"User-Agent\", \"Ruby/#{RUBY_VERSION} passivedns-client rubygem v#{PassiveDNS::Client::VERSION}\")\n request.add_field('Accept', 'Application/JSON')\n request.add_field('Content-Type', 'Application/JSON')\n request.basic_auth(@token, @privkey)\n t1 = Time.now\n response = http.request(request)\n t2 = Time.now\n recs = parse_json(response.body, label, t2-t1)\n if limit\n recs[0,limit]\n else\n recs\n end\n }\n rescue Timeout::Error\n $stderr.puts \"#{self.class.name} lookup timed out: #{label}\"\n end", "def continue\n\n inventory_with_leisure = expected_inventory.dup\n inventory_with_leisure[:leisure] = 1\n\n inventory_with_fishing = expected_inventory.dup\n # TODO: DRY up this logic with Person#catch_fish\n inventory_with_fishing[:fish] += @skills[:fish]\n\n #p '@'*88\n #p inventory_with_fishing\n #p rank_potential_inventory(inventory_with_fishing)\n #p '@'*88\n #p inventory_with_leisure\n #p rank_potential_inventory(inventory_with_leisure)\n #p '@'*88\n if rank_potential_inventory(inventory_with_fishing) < rank_potential_inventory(inventory_with_leisure)\n catch_fish\n @last_activity = :catch_fish\n else\n @last_activity = :leisure\n end\n\n\n eat # or starve\n end", "def fetch_trips(origin_city)\r\n return if origin_city.nil?\r\n\r\n airport_type = AIRPORT_TYPE_MEDIUM_KEY\r\n\r\n case\r\n when origin_city.downcase == 'helsinki'\r\n # Helsinki-Vantaa on ainoa poikkeus!\r\n airport_type = AIRPORT_TYPE_LARGE_KEY\r\n end\r\n\r\n # Suomesta tapahtuvien lähtöjen lentokentät ovat pääsääntöisesti medium-luokkaa.\r\n journey_airports = AIRPORTS.find({MUNICIPALITY_KEY => origin_city.capitalize, AIRPORT_TYPE_KEY => airport_type})\r\n unless journey_airports.nil?\r\n journey_airports.each do |airport|\r\n\r\n fetch_origin_country(airport)\r\n\r\n @trips = TRIPS.find({AIRPORT_ORIGIN_CITY => airport[MUNICIPALITY_KEY]})\r\n end\r\n end\r\n\r\n #@wikipedia_link = COUNTRIES.find(\r\n\r\nend", "def resolve(dns_records, lookup_chain, domain)\n value = dns_records[domain]\n if(value == nil)\n puts \"Error: record not found for #{domain}\"\n exit\n\n elsif(value[:type] == \"A\")\n lookup_chain.push(value[:target])\n return lookup_chain\n\n elsif(value[:type] == \"CNAME\")\n lookup_chain.push(value[:target])\n return resolve(dns_records, lookup_chain, value[:target])\n \n end\n end", "def define(word_lookup)\n index=hash(word_lookup)\n list=@buckets[index]\n counter=0\n while counter<list.counter\n current_node=list.find_node(counter)\n if current_node.word == word_lookup\n puts \"Searched #{counter+1} nodes.\"\n puts \"Found definition for #{word_lookup}: #{current_node.definition}\" \n return\n end\n counter +=1\n end\n puts \"Searched #{counter+1} nodes.\"\n puts \"#{word_lookup} not found\"\n end", "def lookup_context; end", "def lookup_context; end", "def lookup_context; end", "def do_lookup(args)\n if args[\"qname\"] == \"example.com\" and args[\"qtype\"].downcase == \"soa\"\n @result = [\n record(\"example.com\", \"SOA\", \"sns.dns.icann.org noc.dns.icann.org 2013012485 7200 3600 1209600 3600\"),\n ]\n elsif args[\"qname\"] == \"example.com\" and args[\"qtype\"].downcase == \"any\"\n @result = [ \n record(\"example.com\", \"SOA\", \"sns.dns.icann.org noc.dns.icann.org 2013012485 7200 3600 1209600 3600\"),\n record(\"example.com\", \"NS\", \"sns.dns.icann.org\"),\n record_prio(\"example.com\", \"MX\", \"test.example.com\",10)\n ]\n elsif args[\"qname\"] == \"test.example.com\" and args[\"qtype\"].downcase == \"any\"\n @result = [\n record(\"test.example.com\", \"A\", \"127.0.0.1\")\n ]\n elsif args[\"qname\"] =~ /(.*)\\.example\\.com$/ and args[\"qtype\"].downcase == \"any\"\n ip = 0\n $1.downcase.each_byte do |b| ip = ip + b end\n ip_2 = ip/256\n ip = ip%256\n @result = [\n record(args[\"qname\"], \"A\", \"127.0.#{ip_2}.#{ip}\")\n ]\n end\n end", "def lookup(name)\n all.lookup(name)\n end", "def lookup_context=(_arg0); end", "def lookup\n \n # We're not going to add code to check for the existence of files because this is\n # just an example, so we'll keep it short.\n\n files = options[:files]\n\n # The request object has methods for returning the lookup key and namespace for this\n # request\n\n key = request.key\n namespace = request.namespace\n\n # The datasource does not need to be aware if this is a cascading lookup or not, that\n # is to say, whether or not we should continue through the hierarchy or stop at the first\n # result. To return responses we call the answer method as a code block. The answer\n # block will provide an iterator to accept one or many responses depending on the nature\n # of the lookup strategy.\n #\n # Here, for every iteration of answer we will take the next file from the :files array\n # and attempt to lookup and return the value, we do this until the answer iterator\n # finishes (Jerakia does not require further answers) or until we have nothing left to\n # search, in which case we just break from the block.\n #\n\n answer do |response|\n\n filename = files.shift\n\n\n # If filename is nil, there is nothing left to search, we break here and end\n break unless filename\n\n # Load in the JSON document\n data = JSON.load(File.read(filename))\n\n # If the value for the requested key exists in the namespace (see example JSON above)\n # then we return this data by calling the submit method of the response object in\n # this block\n\n if data.has_key(namespace)\n if data[namespace].has_key(key)\n response.submit data[namespace][key]\n end\n end\n\n end\n end", "def issue_found(script, rule, pair); end", "def continue?; end", "def test_prefetch_target\n prov = mkprovider\n\n prov.filetype = :ram\n target = :yayness\n prov.target_object(target).write \"yay b d\"\n\n records = nil\n assert_nothing_raised do\n records = prov.prefetch_target(:yayness)\n end\n\n # Now make sure we correctly got the hash\n record = records.find { |r| r[:name] == \"yay\" }\n assert(record, \"Did not get record in prefetch_target\")\n assert_equal(\"b\", record[:one])\n assert_equal(\"d\", record[:two])\n end", "def next_unattempted\n fewest_potential_pairs(unattempted_people)\n end", "def resume_loop(resumes)\n resumes.each do |r|\n keyword_search(r)\n end\nend", "def look_up(term='')\n\n NSLog(\"Something just tried to look up the term #{term}\")\n false\n\n end", "def lookup_uncached(val); end", "def lookup_uncached(val); end", "def visitLookup(elem, data)\r\n @@log.debug(\"XmlRuleVisitor::visitLookup\")\r\n @@log.debug(elem.inspect)\r\n\r\n lkName = elem.attributes['Name']\r\n lkParams = @context.getLookupParamNames(lkName)\r\n\r\n data += @template.lookup(lkName, lkParams[\"xparam\"], lkParams[\"yparam\"])\r\n\r\n return data\r\n\r\n lkup = @context.lookups[lkName]\r\n\r\n #puts lkup.inspect\r\n\r\n x = nil\r\n y = nil\r\n\r\n if (isPpmVar(lkup.xParam))\r\n x = @context.ppms[lkup.xParam.alias]\r\n else\r\n x = @context.dpms[lkup.xParam.alias]\r\n end # if PPM\r\n\r\n #puts x.inspect\r\n\r\n if (isPpmVar(lkup.yParam))\r\n y = @context.ppms[lkup.yParam.alias]\r\n else\r\n y = @context.dpms[lkup.yParam.alias]\r\n end # if PPM\r\n\r\n #puts y.inspect\r\n\r\n if (nil == x)\r\n raise \"Unable to find xParam (#{lkup.xParam.alias}) in lookup #{lkName}\"\r\n end # if nil\r\n\r\n if (nil == y)\r\n raise \"Unable to find yParam (#{lkup.yParam.alias}) in lookup #{lkName}\"\r\n end # if nil\r\n\r\n# data += lkup.toGdlRef()\r\n data += @template.lookup(lkName, x.name, y.name)\r\n\r\n return data\r\n end", "def searchpolicy\n eval @policy_key\n end", "def lookup\n @constituency = @request.get.first\n\n redirect_to constituency_path(@constituency.graph_id)\n end", "def process_rule_chain(rule_chain, context)\n catch do |ball|\n context.stop = ball\n rule_chain.each do |key, arg|\n klass = Dagger::Generate.const_get(camelize(key))\n klass[context, arg, &->(value) { throw context.result, value }]\n end\n end\n end", "def lookup_specific(words)\n words = @delimiter_handler.split_path(words.first) if words.size == 1\n load_for_prefix(words)\n tool = @mutex.synchronize { get_tool_data(words, false)&.cur_definition }\n finish_definitions_in_tree(words) if tool\n tool\n end", "def lookup(label, limit=1000)\n $stderr.puts \"DEBUG: #{self.class.name}.lookup(#{label})\" if @debug\n\n token = getAuthToken()\n $stderr.puts \"TOKEN IS: #{token}\" if @debug\n\n Timeout::timeout(@timeout) {\n url = nil\n if label =~ /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(\\/\\d{1,2})?$/\n url = \"#{@base}/_search/rdata/#{label}?stype=em\"\n else\n url = \"#{@base}/_search/rrset/#{label}?stype=rm\"\n end\n\n urlp = URI.parse url\n http = Net::HTTP.new(urlp.host, urlp.port)\n http.use_ssl = (urlp.scheme == 'https')\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n http.verify_depth = 5\n path = url\n if limit\n path << \"&limit=#{limit}\"\n end\n\n after = Date.today.prev_year.to_time.to_i\n path << \"&last_seen_gt=#{after}\"\n\n request = Net::HTTP::Get.new(path)\n request.add_field(\"User-Agent\", \"Ruby/#{RUBY_VERSION} passivedns-client rubygem v#{PassiveDNS::Client::VERSION}\")\n request.add_field(\"Accept\", \"application/json\")\n request.add_field(\"Authorization\", token)\n t1 = Time.now\n response = http.request(request)\n t2 = Time.now\n $stderr.puts response.body if @debug\n ret = parse_json(response.body, t2 - t1)\n ret\n }\n rescue Timeout::Error => e\n $stderr.puts \"#{self.class.name} lookup timed out: #{label}\"\n end", "def fetch_origin_country(airport)\r\n unless airport.nil?\r\n COUNTRIES.find({COUNTRY_CODE => airport[AIRPORT_ORIGIN_COUNTRY]}, :fields => [\"wikipedia_link\"]).each do |country|\r\n @wikipedia_link = country['wikipedia_link']\r\n end\r\n end\r\nend", "def resolve_name(lookup_name, lookup_types=[Dnsruby::Types::A, Dnsruby::Types::CNAME, Dnsruby::Types::PTR])\n resolve_names(lookup_name,lookup_types).first\n end", "def continue?\n if self.suggest_another == \"1\"\n self.suggest_possibility\n elsif self.suggest_another == \"2\"\n self.where_are_you_at?\n elsif self.suggest_another == \"3\"\n exit\n end\n end", "def lookup_object(obj, name)\n # this scans the source during the recursive calls, \n # then follows the same path in the target on the way out\n raise \"Keys cannot be null\" if obj.nil?\n #puts \"Looking up #{obj}\"\n rel_key_field = SchemaSchema.keyRel(obj.schema_class)\n if rel_key_field.nil?\n raise \"Keys should connect to root but stop at #{obj}\" if obj != @source_root\n return @target_root\n else\n key_field = SchemaSchema.key(obj.schema_class)\n\n raise \"Key relationship fields must have inverses\" if rel_key_field.inverse.nil?\n raise \"A relationship key must have a data key as well\" if key_field.nil?\n\n base = lookup_object(obj[rel_key_field.name], name)\n key = obj[key_field.name] #[1..-1]\n #puts \"IDENTIFY #{key_field.name}/#{rel_key_field.name} key #{key}\"\n return base[rel_key_field.inverse.name][name]\n end\n end", "def create_lookups( nodes )\n\t\t\treturn nodes.each_with_object( {} ) do |(identifier, node), hash|\n\t\t\t\tself.log.debug \"Creating lookup for node: %p\" % [ node ]\n\t\t\t\tname = node['name'] or next\n\t\t\t\trecord_type = node['record_type'] || 'A'\n\t\t\t\trecord_class = Resolv::DNS::Resource::IN.const_get( record_type ) or\n\t\t\t\t\traise \"Unsupported record type %p!\" % [ record_type ]\n\n\t\t\t\tself.log.debug \"Looking up %s record for %s (%s)\" % [ record_type, name, identifier ]\n\t\t\t\tthr = Thread.new do\n\t\t\t\t\tself.resolver.getresources( name, record_class )\n\t\t\t\tend\n\t\t\t\thash[ thr ] = identifier\n\t\t\tend\n\t\tend", "def lookup(name)\n @index.fetch(name) do\n yield\n end\n end", "def call(*lookup)\n\t\treturn KeyDialler.new(self, *lookup).call\n\tend", "def resolve_name(lookup_name, lookup_types=[Dnsruby::Types::AAAA, Dnsruby::Types::A, Dnsruby::Types::CNAME, Dnsruby::Types::PTR])\n resolve_names(lookup_name,lookup_types).first\n end", "def lookup force_reprocess = false\n logger.info \"searching #{self.doc_id}\"\n\n raise \"not saved yet\" unless self.id\n\n # Check if the last image search was more than a day ago\n if (\n self.last_search.nil? ||\n self.last_search < (DateTime.current - LOOKUP_LIMIT) ||\n force_reprocess\n ) &&\n !self.locked\n\n self.last_search = DateTime.current\n\n if self.music?\n MusicBrainzWorker.perform_async self.id\n # fails over to LastFM\n\n elsif self.ht_id.present?\n # Check Hathi Trust 1st when available.\n # this will fail over to google if necessary\n HathiTrustWorker.perform_async self.id\n\n else\n SyndeticsWorker.perform_async self.id\n\n # if syndetics fails, it kicks off google\n # if google fails, it kicks off the OpenLibrary job\n end\n end\n\n # Used to stop the after_commit callback\n self.run_lookup = false\n save\n\n rescue StandardError => e\n self.status = 'error'\n self.response_data = e\n end", "def resolve(link); end", "def lookUpVoid(name)\n path = @currentPath.clone\n globalPath = findGlobalPath\n if ! path.empty? then\n cEntry = get(path)\n entry = checkEntry(cEntry.lookUpLocal(name))\n return entry if entry\n while path != globalPath\n path.exitName\n cEntry = get(path)\n entry = checkEntry(cEntry.lookUpLocal(name)) if entry\n return entry if entry\n end\n if path.empty?\n entry = self[name] if self.keys.include? name\n entry = checkEntry(entry)\n return entry if entry\n end\n else\n entry = self[name] if self.keys.include? name\n entry = checkEntry(entry)\n return entry if entry\n end\n nil\n end", "def goto_next_case\n @report_key_control.goto_next_case\n end", "def add_forward_lookup(_ip, _hostname)\n end", "def next_in_chain\n @_next_in_chain ||= nil\n @_next_in_chain\n end", "def lookup_new_swimmer\n \n end", "def next_step(resource, mikyung)\n conditions.each do |c|\n if c.should_run_for(resource, self)\n return c.execute(resource, self, mikyung)\n end\n end\n nil\n end", "def process(name, resource_class, *args)\n\t\t\t@logger.debug \"Searching for #{name} #{resource_class.name}\"\n\n\t\t\t@rules.each do |rule|\n\t\t\t\t@logger.debug \"Checking rule #{rule}...\"\n\n\t\t\t\tcatch (:next) do\n\t\t\t\t\t# If the rule returns true, we assume that it was successful and no further rules need to be evaluated.\n\t\t\t\t\treturn true if rule.call(self, name, resource_class, *args)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif @otherwise\n\t\t\t\t@otherwise.call(*args)\n\t\t\telse\n\t\t\t\t@logger.warn \"Failed to handle #{name} #{resource_class.name}!\"\n\t\t\tend\n\t\tend", "def explore \n current_link = @source_link\n while(current_link.downcase != \"[[philosophy]]\")\n link_in_database = Link.first(:link_name => current_link) \n #If already in database then break the loop.\n unless link_in_database.nil?\n update_hash_from_db(link_in_database)\n break;\n end\n \n #if link already encountered then its a cycle. \n unless path_hash[current_link].nil?\n @type = \"cycle\"\n break;\n end \n #Get the page and its contents.\n page = Wikipedia.find(current_link.gsub(/\\[/,'').gsub(/\\]/,''))\n if page.nil?\n @type = \"dead-end\"\n break;\n end \n content = page.content\n if content.nil?\n @type = \"dead-end\"\n break;\n end\n #Get the first link from the content.\n next_link = get_first_link(content)\n if next_link.nil?\n @type = \"dead-end\"\n break;\n end\n \n insert_link_update_path_hash(current_link, next_link)\n current_link = next_link\n next_link = nil\n end #end while\n\n #If type is nil then it succesfully found philosophy.\n if @type.nil?\n @type = \"philosophy\"\n end\n \n save_to_db\n \n unless link_in_database.nil?\n get_database_path(link_in_database)\n @type = @database_path.first.type\n end\n end", "def match\n extract!\n policy_failure_match! || self\n end", "def resolve(_session, _map, opts = {})\n target = opts[:target] || @target\n battle = opts[:battle]\n raise 'target is a required option for :first_aid' if target.nil?\n\n medicine_check = @source.medicine_check!(battle)\n\n @result = if medicine_check.result >= 10\n [{\n source: @source,\n target: target,\n type: :first_aid,\n success: true,\n battle: battle,\n roll: medicine_check\n }]\n else\n [{\n source: @source,\n target: target,\n type: :first_aid,\n success: false,\n battle: battle,\n roll: medicine_check\n }]\n end\n end", "def getNext(next_val, restriction, next_restriction)\n #if restriction.to_i == -20 && !session[:is_business_home] \n # next_restriction\n \tif restriction.to_i == -20 && session[:uso_de_suelo]\n \t\tnext_restriction\n \telse\n \t\tnext_val\n \tend\n end", "def set_continue(name, action, seqno, value)\n cmds = [\"route-map #{name} #{action} #{seqno}\"]\n cmds << 'no continue'\n cmds << \"continue #{value}\"\n configure(cmds)\n end", "def lookup(default = 'Unknown')\n data = Origen.ldap.lookup(self)\n if block_given?\n if data\n yield data\n else\n default\n end\n else\n data\n end\n end", "def next_in_chain\n @_next_in_chain ||= nil\n @_next_in_chain\n end", "def lookup_chain = locale(true).lookup", "def go\n captured = query_by_referrer\n return captured if captured.found?\n\n default_ordered_query\n end", "def lookup_sequence\n fail 'LookupUndefinedSequenceError'\n end", "def rep_lookup\n 20.times do\n line = @file.readline\n\n representative = \"unknown\"\n #API lookup goes Here\n legislators = Sunlight::Legislator.all_in_zipcode(clean_zipcodes(line[:zipcode]))\n names = legislators.collect do |leg|\n first_name = leg.firstname\n first_initial = first_name[0]\n last_name = leg.lastname\n party = leg.party\n party_initial = party[0]\n title = leg.title\n title_abbr = title[0..2]\n title_abbr +\" \"+ first_initial + \". \" + last_name +\" (\"+party_initial+\")\"\n end\n\n puts \"#{line[:last_name]}, #{line[:last_name]}, #{line[:zipcode]}, #{names.join(\", \")}\"\n end\n end", "def goto\n <<-CODE\n next_int;\n c->ip = _int;\n cpu_cache_ip(c);\n CODE\n end", "def resolve(pattern, parents)\n keymap_result = keymap[pattern]\n\n case keymap_result\n when Incomplete # try to find a full or longer match in parents\n resolve_incomplete(pattern, parents, keymap_result)\n when Impossible # anything better than that.\n resolve_impossible(pattern, parents, keymap_result)\n else\n # full match from us, so get the action out.\n return keymap_result\n end\n end", "def getVar(tape, name)\n\tmFoundEnv = SubMachine.stub 'lookup3'\n\tmFoundEnv.simpleMerge copy(:env, tape)\n\tmFoundEnv.simpleMerge writeConstant(:ra, 0)\n\n\t# Scan to end of env\n\tmNotFound = scan(:env, :right, BlankSymbol)\n\n\t# look for this in env\n\tmNotFound.simpleMerge scanBefore(:env, :left, :this)\n\n\t# copy reference to current class\n\tmNotFound.simpleMerge copy(:env, tape)\n\n\t# scan to front of objects\n\tmNotFound.simpleMerge scanBefore(:objects, :left, BlankSymbol)\n\n\t# Scans for the right reference\n\tmNF2 = SubMachine.empty 'lookupThis'\n\n\t# checks if we're at the right reference\n\tcheckLoc = eq(tape, :objects)\n\tlink(checkLoc.states[checkLoc.lastFalse], mNF2.first)\n\tcheckLoc.mergeTrue writeConstant(:ra, 1)\n\tlink(checkLoc.states[checkLoc.lastTrue], mNF2.last)\n\n\terrorState = SubMachine.empty 'lookupError'\n\terrorState.simpleMerge writeConstant(:output, 1)\n\terrorState.simpleMerge invert(:output)\n\terrorState.simpleMerge output(:output)\n\tes2 = SubMachine.empty 'lookupErrorHalt'\n\tes2.states[es2.first].transitions = [\n\t\tTransition.new( Hash.new, [Action.new(:halt, nil)], es2.last)]\n\terrorState.simpleMerge es2\n\t\n\tmNF2.states[mNF2.first].transitions = [\n\t\tTransition.new({:objects=>:loc}, [Action.new(:right, :objects)], checkLoc.first ),\n\t\tTransition.new({:objects=>BlankSymbol}, Array.new, errorState.first ),\n\t\tTransition.new(Hash.new, [Action.new(:right, :objects)], mNF2.first)]\n\t\n\tmNF2.merge errorState\n\tmNF2.merge checkLoc\n\n\n\t# at this point mNotFound goes to the object that we're in\n\tmNotFound.simpleMerge mNF2\n\n\tmFoundObjects = copy(:objects, tape)\n\n\tmNF3 = SubMachine.empty 'lookupInObject'\n\tmNF3.states[mNF3.first].transitions = [\n\t\tTransition.new( {:objects => name}, [Action.new(:right, :objects)], mFoundObjects.first),\n\t\tTransition.new( Hash.new, [Action.new(:right, :objects)], mNF3.first)]\n\tmNF3.merge mFoundObjects\n\tlink(mFoundObjects.states[mFoundObjects.last], mNF3.last)\n\n\tmNotFound.simpleMerge mNF3\n\n\t# Go to end of env\n\tm = SubMachine.stub \"getVar-#{tape},#{name}\"\n\tm.simpleMerge scanBefore(:env, :right, BlankSymbol)\n\n\t# look for var in env\n\tm2 = SubMachine.empty 'lookup2'\n\tm2.merge mFoundEnv\n\tlink(mFoundEnv.states[mFoundEnv.last], m2.last)\n\tm2.merge mNotFound\n\tlink(mNotFound.states[mNotFound.last], m2.last)\n\tm2.states[m2.first].transitions = [\n\t\tTransition.new( {:env=> :methodScope}, Array.new, mNotFound.first),\n\t\tTransition.new( {:env=> name}, [Action.new(:right, :env)], mFoundEnv.first),\n\t\tTransition.new( Hash.new, [Action.new(:left, :env)], m2.first)]\n\tm.simpleMerge m2\n\n\tm\n\nend", "def look token\n if @cached_decisions[root_union.parse_context.tic]\n @cached_decisions[root_union.parse_context.tic].response\n else\n throw :wip_look, {\n :pid => target_parse_id,\n :callback => lambda{|*args|\n step_2_look_again(*args)\n }\n }\n end\n end", "def resolve(link)\n self.debug \"starting to resolve #{link}\"\n links, status = @api.list(link)\n return self.push_error_result(link, status) unless links or status.should_probe?\n\n if links\n # if it was a folder or crypter, resolve all found links\n self.debug \"folder/crypter contained #{links}. recursing\"\n threads = links.map do |link|\n Thread.new do\n self.resolve(link)\n end\n end\n threads.each do |thread|\n thread.join\n end\n else\n self.debug \"resolving single link #{link}\"\n info, status = @api.probe(link)\n return self.push_error_result(link, status) unless info\n\n self.debug \"found #{info}\"\n resolvable = Plowshare::Resolvable.new(link, info)\n @results << resolvable\n end\n end", "def get_next_entry; end", "def run\n @stopped = false\n until @stopped do\n if (Time.now.to_i - @last_lookup.to_i) > @lookupd_poll_interval\n # Do lookupd\n end\n @selector.select(@timer.next_interval) { |m| m.value.call }\n end\n end", "def lookup\n @lock.with_read_lock do\n recalculate unless @options[:lookup]\n @lookup ||= @options[:lookup].map { |code| self.class.new(code) }.uniq\n end\n end", "def look_up(variable)\n \ti = @@scope\n \twhile(i>=@@scope_base.last)\n \tif @@variables[i][variable] != nil\n \t\treturn @@variables[i][variable][0]\n \t\tputs \"#{@@variables[i][variable]} is found\" if (@@Debug)\n \t\t#return var[0]\n \tend\n \ti -= 1\n \tend\n \tputs \"Variable '#{variable}' does not exist.\"\n \t:FALSE\nend", "def lookup(predicate)\n hash = crosswalk_hash\n result = hash.select(&find(predicate))\n return result.first unless result.empty?\n end", "def reset_continue\n construct_context { |context|\n next context unless context.key?(:continue)\n\n context.reject { |k, _v| :continue == k }\n }\n end", "def find_single_item(hash,lookup)\n if hash[lookup]==nil\n return nil\n else\n return hash[lookup][:item]\n end\nend", "def crosswalk_record_for_a_reason_code_at_site_level(reason_code_object)\n facility_level_crosswalk_record = nil\n crosswalk_records = get_reason_code_and_crosswalk_records(reason_code_object.id)\n if crosswalk_records.present?\n crosswalk_records.each do |crosswalk_record|\n if crosswalk_record.facility_id.present?\n rcc_log.debug \"Obtaining Site Level Record\"\n facility_level_crosswalk_record = crosswalk_record\n rcc_log.debug \"Site Level Record ID: #{crosswalk_record.crosswalk_record_id if crosswalk_record}\"\n break\n end\n end\n end\n facility_level_crosswalk_record\n end", "def lookup_completion(name)\n @completions.fetch(name.to_s) { |k| @parent ? @parent.lookup_completion(k) : nil }\n end", "def parsetitle( titles, type, parentid )\n\n apiurl='http://en.wikipedia.org/w/api.php'\n\n ## resulthash\n links=Hash.new\n\n #### First query, no plcontinue\n query = { \n 'action'=>'query',\n 'prop'=>'info',\n 'redirects'=>'',\n 'inprop'=>'url',\n 'format'=>'json',\n }\n\n ### Separate by type\n case type\n when 0 \n #### seed\n continueterm='incontinue'\n query['titles'] = titles\n\n when 1 \n #### links\n continueterm='gplcontinue'\n linksterm='links'\n query['generator']=linksterm\n query['titles'] = titles\n query['gplnamespace'] = '0'\n query['gpllimit'] = 'max'\n \n when 2\n #### backlinks\n continueterm='gblcontinue'\n linksterm='backlinks'\n query['gbltitle'] = titles\n query['generator'] = 'backlinks'\n query['gblnamespace'] = '0'\n query['gbllimit'] = 'max'\n\n else \n puts \"This shouldn't happen.\"\n exit -1\n end\n # puts query\n # exit;\n \n\n postData = Net::HTTP.post_form(URI.parse(apiurl), query);\n \n ## parse and save result\n result = JSON.parse(postData.body)\n pages=result[\"query\"][\"pages\"].keys\n<<<<<<< HEAD\n \n=======\n\n i=0\n>>>>>>> ff128337f961ce2c8d1c7273ff20bd093e5188a6\n result[\"query\"][\"pages\"].each do |page|\n if page[1][\"title\"] != nil and page[1][\"length\"] != nil\n links[page[1][\"title\"]] = { \n \"length\" => page[1][\"length\"], \n \"url\"=>page[1][\"fullurl\"],\n \"pageid\"=>page[1][\"pageid\"],\n \"parentid\"=>parentid \n }\n<<<<<<< HEAD\n=======\n i=i+1;\n # if i>5 \n # break\n # end\n>>>>>>> ff128337f961ce2c8d1c7273ff20bd093e5188a6\n end\n end\n \n ### Keep going?\n while true\n if result[\"query-continue\"] == nil\n ##puts \"breaking\"\n break\n end\n ##puts \"didn't break\" \n \n plcontinue=result[\"query-continue\"][linksterm][continueterm]\n ## puts plcontinue\n query[continueterm] = plcontinue\n\n postData = Net::HTTP.post_form(URI.parse(apiurl), query);\n result = JSON.parse(postData.body)\n \n pages=result[\"query\"][\"pages\"].keys\n\n result[\"query\"][\"pages\"].each do |page|\n if page[1][\"title\"] != nil and page[1][\"length\"] != nil\n links[page[1][\"title\"]] = { \n \"length\" => page[1][\"length\"], \n \"url\"=>page[1][\"fullurl\"],\n \"pageid\"=>page[1][\"pageid\"],\n \"parentid\"=>parentid \n }\n end\n end\n end\n \n return links\nend", "def k_get!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 62 )\n\n\n\n type = K_GET\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 501:3: 'get'\n match( \"get\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 62 )\n\n\n end", "def sourcelookup\n all_matching_records = []\n if params[:doi]\n msg = \"Sourcelookup of doi #{params[:doi]}\"\n logger.info(msg)\n all_matching_records += DoiSearch.search(params[:doi].strip)\n elsif params[:pmid]\n msg = \"Sourcelookup of pmid #{params[:pmid]}\"\n logger.info(msg)\n all_matching_records += Pubmed::Fetcher.search_all_sources_by_pmid(params[:pmid].strip)\n elsif params[:title].presence\n title = params[:title].delete('\"')\n msg = \"Sourcelookup of title '#{title}'\"\n logger.info(msg)\n if Settings.WOS.enabled\n query = \"TI=\\\"#{title}\\\"\"\n query += \" AND PY=#{params[:year]}\" if params[:year]\n wos_matches = WebOfScience::Queries.new('WOS').user_query(query).next_batch.to_a # limit: only 1 batch and only to WOS database\n all_matching_records += wos_matches\n logger.debug(\" -- WOS (#{wos_matches.length})\")\n end\n # lastly, always check for manual\n results = Publication.joins(:user_submitted_source_records)\n .where(UserSubmittedSourceRecord.arel_table[:title].matches(\"%#{params[:title]}%\"))\n results = results.where(year: params[:year]) if params[:year]\n logger.debug(\" -- manual source (#{results.length})\")\n all_matching_records += results\n else # no search terms provided\n head :bad_request\n return\n end\n # When params[:maxrows] is nil/zero, -1 returns everything\n matching_records = all_matching_records[0..params[:maxrows].to_i - 1]\n render json: wrap_as_bibjson_collection(msg, matching_records)\n end", "def dns_find(key)\n \n end", "def handle_backtrack\n\t\tend", "def lookup(options)\n raise 'todo'\n end", "def my_matching\n redirect_to matching_kases_person_path(@person), :status => :moved_permanently\n return\n end", "def resolve\n end", "def perform\n @timeout_start = Time.now\n puts \"Searching for #{@target}\"\n prime = SearchEntry.new(nil, @target, whole_trie, nil)\n debug \"priming: #{prime}\"\n debug ''\n ticked = 0\n frontier.push prime, prime.score\n\n @results = Set.new\n\n begin\n search_entry = frontier.pop\n @visited.push search_entry, search_entry.score\n\n status = \"#{@visited.size}/#{@frontier.size} - #{search_entry}\"\n debug status\n\n seconds_since_start = (Time.now - @timeout_start).to_i\n if seconds_since_start > ticked\n puts status\n ticked += 1\n end\n\n\n # If we've reached the end of a word, continue with a pointer to the\n # top of the whole trie and enqueue this in the frontier\n if search_entry.subtrie[:terminal]\n new_entry = SearchEntry.new(\n '',\n search_entry.target,\n whole_trie,\n search_entry,\n )\n debug \"+ found terminal entry: #{new_entry}\"\n frontier.push(new_entry, new_entry.score)\n end\n\n search_entry.subtrie.each do |key, subtrie|\n next if key == :path\n next if key == :depth\n next if key == :terminal\n\n new_entry = SearchEntry.new(\n \"#{search_entry.match}#{key}\",\n @target,\n subtrie,\n search_entry.previous_entry,\n )\n debug \"- iterating: #{search_entry.match.inspect}+#{key.inspect} #{new_entry}\"\n frontier.push(new_entry, new_entry.score)\n end\n end until frontier.empty? || timeout? #&& collected?)\n\n require 'pry'\n binding.pry\n nil\n end", "def getNext(next_val, restriction, next_restriction)\n if restriction.to_i == -3 && session[:impacto_usuario] == -2\n next_restriction\n elsif restriction.to_i == 50 && session[:aforo] != nil && session[:aforo].to_i > 49\n next_restriction\n else\n next_val\n end\n end", "def traverse(element, evaluation_context)\n if element.nil?\n add_error(element, \"Can't parse nil element\")\n return nil\n end\n\n add_debug(element) { \"ec: #{evaluation_context.inspect}\" }\n\n # local variables [7.5 Step 1]\n recurse = true\n skip = false\n new_subject = nil\n typed_resource = nil\n current_object_resource = nil\n uri_mappings = evaluation_context.uri_mappings.clone\n namespaces = evaluation_context.namespaces.clone\n incomplete_triples = []\n language = evaluation_context.language\n term_mappings = evaluation_context.term_mappings.clone\n default_vocabulary = evaluation_context.default_vocabulary\n list_mapping = evaluation_context.list_mapping\n\n xml_base = element.base\n base = xml_base.to_s if xml_base && ![:xhtml1, :html4, :html5].include?(@host_language)\n add_debug(element) {\"base: #{base.inspect}\"} if base\n base ||= evaluation_context.base\n\n # Pull out the attributes needed for the skip test.\n attrs = {}\n %w(\n about\n content\n datatype\n datetime\n href\n id\n inlist\n property\n rel\n resource\n rev\n role\n src\n type\n typeof\n value\n vocab\n ).each do |a|\n attrs[a.to_sym] = element.attributes[a].to_s.strip if element.attributes[a]\n end\n\n add_debug(element) {\"attrs \" + attrs.inspect} unless attrs.empty?\n\n # If @property and @rel/@rev are on the same elements, the non-CURIE and non-URI @rel/@rev values are ignored. If, after this, the value of @rel/@rev becomes empty, then the then the processor must act as if the attribute is not present.\n if attrs.has_key?(:property) && @version == :\"rdfa1.1\" && (@host_language == :html5 || @host_language == :xhtml5 || @host_language == :html4)\n [:rel, :rev].each do |attr|\n next unless attrs.has_key?(attr)\n add_debug(element) {\"Remove non-CURIE/non-IRI @#{attr} values from #{attrs[attr].inspect}\"}\n attrs[attr] = attrs[attr].\n split(/\\s+/).\n select {|a| a.index(':')}.\n join(\" \")\n add_debug(element) {\" => #{attrs[attr].inspect}\"}\n attrs.delete(attr) if attrs[attr].empty?\n end\n end\n\n # Default vocabulary [7.5 Step 2]\n # Next the current element is examined for any change to the default vocabulary via @vocab.\n # If @vocab is present and contains a value, its value updates the local default vocabulary.\n # If the value is empty, then the local default vocabulary must be reset to the Host Language defined default.\n if attrs[:vocab]\n default_vocabulary = if attrs[:vocab].empty?\n # Set default_vocabulary to host language default\n add_debug(element) {\n \"[Step 3] reset default_vocaulary to #{@host_defaults.fetch(:vocabulary, nil).inspect}\"\n }\n @host_defaults.fetch(:vocabulary, nil)\n else\n # Generate a triple indicating that the vocabulary is used\n add_triple(element, base, RDF::RDFA.usesVocabulary, uri(attrs[:vocab]))\n\n uri(attrs[:vocab])\n end\n add_debug(element) {\n \"[Step 2] default_vocaulary: #{default_vocabulary.inspect}\"\n }\n end\n\n # Local term mappings [7.5 Step 3]\n # Next, the current element is then examined for URI mapping s and these are added to the local list of URI mappings.\n # Note that a URI mapping will simply overwrite any current mapping in the list that has the same name\n extract_mappings(element, uri_mappings, namespaces)\n\n # Language information [7.5 Step 4]\n language = element.language || language\n language = nil if language.to_s.empty?\n add_debug(element) {\"HTML5 [3.2.3.3] lang: #{language.inspect}\"} if language\n\n # Embedded scripts\n if element.name == 'script'\n text = element.inner_html.sub(%r(\\A\\s*\\<!\\[CDATA\\[)m, '').sub(%r(\\]\\]>\\s*\\Z)m, '')\n\n extract_script(element, text, attrs[:type], **@options.merge(base_uri: base)) do |statement|\n @repository << statement\n end\n end\n\n # From HTML5, if the property attribute and the rel and/or rev attribute exists on the same element, the non-CURIE and non-URI rel and rev values are ignored. If, after this, the value of rel and/or rev becomes empty, then the processor must act as if the respective attribute is not present.\n if [:html5, :xhtml5].include?(@host_language) && attrs[:property] && (attrs[:rel] || attrs[:rev])\n old_rel, old_rev = attrs[:rel], attrs[:rev]\n if old_rel\n attrs[:rel] = (attrs[:rel]).split(/\\s+/m).select {|r| !r.index(':').nil?}.join(\" \")\n attrs.delete(:rel) if attrs[:rel].empty?\n add_debug(element) {\"HTML5: @rel was #{old_rel}, now #{attrs[:rel]}\"}\n end\n if old_rev\n attrs[:rev] = (attrs[:rev]).split(/\\s+/m).select {|r| !r.index(':').nil?}.join(\" \")\n attrs.delete(:rev) if attrs[:rev].empty?\n add_debug(element) {\"HTML5: @rev was #{old_rev}, now #{attrs[:rev]}\"}\n end\n end\n\n # rels and revs\n rels = process_uris(element, attrs[:rel], evaluation_context, base,\n uri_mappings: uri_mappings,\n term_mappings: term_mappings,\n vocab: default_vocabulary,\n restrictions: TERMorCURIEorAbsIRI.fetch(@version, []))\n revs = process_uris(element, attrs[:rev], evaluation_context, base,\n uri_mappings: uri_mappings,\n term_mappings: term_mappings,\n vocab: default_vocabulary,\n restrictions: TERMorCURIEorAbsIRI.fetch(@version, []))\n\n add_debug(element) do\n \"rels: #{rels.join(\" \")}, revs: #{revs.join(\" \")}\"\n end unless (rels + revs).empty?\n\n if !(attrs[:rel] || attrs[:rev])\n # Establishing a new subject if no rel/rev [7.5 Step 5]\n\n if @version == :\"rdfa1.0\"\n new_subject = if attrs[:about]\n process_uri(element, attrs[:about], evaluation_context, base,\n uri_mappings: uri_mappings,\n restrictions: SafeCURIEorCURIEorIRI.fetch(@version, []))\n elsif attrs[:resource]\n process_uri(element, attrs[:resource], evaluation_context, base,\n uri_mappings: uri_mappings,\n restrictions: SafeCURIEorCURIEorIRI.fetch(@version, []))\n elsif attrs[:href] || attrs[:src]\n process_uri(element, (attrs[:href] || attrs[:src]), evaluation_context, base, restrictions: [:uri])\n end\n\n # If no URI is provided by a resource attribute, then the first match from the following rules\n # will apply:\n new_subject ||= if [:xhtml1, :xhtml5, :html4, :html5].include?(@host_language) && element.name =~ /^(head|body)$/\n # From XHTML+RDFa 1.1:\n # if no URI is provided, then first check to see if the element is the head or body element.\n # If it is, then act as if the new subject is set to the parent object.\n uri(base)\n elsif element == root && base\n # if the element is the root element of the document, then act as if there is an empty @about present,\n # and process it according to the rule for @about, above;\n uri(base)\n elsif attrs[:typeof]\n RDF::Node.new\n else\n # otherwise, if parent object is present, new subject is set to the value of parent object.\n skip = true unless attrs[:property]\n evaluation_context.parent_object\n end\n\n # if the @typeof attribute is present, set typed resource to new subject\n typed_resource = new_subject if attrs[:typeof]\n else # rdfa1.1\n # If the current element contains no @rel or @rev attribute, then the next step is to establish a value for new subject.\n # This step has two possible alternatives.\n # 1. If the current element contains the @property attribute, but does not contain the @content or the @datatype attributes, then\n if attrs[:property] && !(attrs[:content] || attrs[:datatype])\n # new subject is set to the resource obtained from the first match from the following rule:\n new_subject ||= if attrs[:about]\n # by using the resource from @about, if present, obtained according to the section on CURIE and IRI Processing;\n process_uri(element, attrs[:about], evaluation_context, base,\n uri_mappings: uri_mappings,\n restrictions: SafeCURIEorCURIEorIRI.fetch(@version, []))\n elsif [:xhtml1, :xhtml5, :html4, :html5].include?(@host_language) && element.name =~ /^(head|body)$/\n # From XHTML+RDFa 1.1:\n # if no URI is provided, then first check to see if the element is the head or body element. If it is, then act as if the new subject is set to the parent object.\n evaluation_context.parent_object\n elsif element == root && base\n # otherwise, if the element is the root element of the document, then act as if there is an empty @about present, and process it according to the rule for @about, above;\n uri(base)\n end\n\n # if the @typeof attribute is present, set typed resource to new subject\n typed_resource = new_subject if attrs[:typeof]\n\n # otherwise, if parent object is present, new subject is set to the value of parent object.\n new_subject ||= evaluation_context.parent_object\n\n # If @typeof is present then typed resource is set to the resource obtained from the first match from the following rules:\n\n # by using the resource from @about, if present, obtained according to the section on CURIE and IRI Processing; (done above)\n # otherwise, if the element is the root element of the document, then act as if there is an empty @about present and process it according to the previous rule; (done above)\n\n if attrs[:typeof] && typed_resource.nil?\n # otherwise,\n typed_resource ||= if attrs[:resource]\n # by using the resource from @resource, if present, obtained according to the section on CURIE and IRI Processing;\n process_uri(element, attrs[:resource], evaluation_context, base,\n uri_mappings: uri_mappings,\n restrictions: SafeCURIEorCURIEorIRI.fetch(@version, []))\n elsif attrs[:href] || attrs[:src]\n # otherwise, by using the IRI from @href, if present, obtained according to the section on CURIE and IRI Processing;\n # otherwise, by using the IRI from @src, if present, obtained according to the section on CURIE and IRI Processing;\n process_uri(element, (attrs[:href] || attrs[:src]), evaluation_context, base,\n restrictions: [:uri])\n else\n # otherwise, the value of typed resource is set to a newly created bnode.\n RDF::Node.new\n end\n\n # The value of the current object resource is set to the value of typed resource.\n current_object_resource = typed_resource\n end\n else\n # otherwise (ie, the @content or @datatype)\n new_subject =\n process_uri(element, (attrs[:about] || attrs[:resource]),\n evaluation_context, base,\n uri_mappings: uri_mappings,\n restrictions: SafeCURIEorCURIEorIRI.fetch(@version, [])) if attrs[:about] ||attrs[:resource]\n new_subject ||=\n process_uri(element, (attrs[:href] || attrs[:src]), evaluation_context, base,\n restrictions: [:uri]) if attrs[:href] || attrs[:src]\n\n # If no URI is provided by a resource attribute, then the first match from the following rules\n # will apply:\n new_subject ||= if [:xhtml1, :xhtml5, :html4, :html5].include?(@host_language) && element.name =~ /^(head|body)$/\n # From XHTML+RDFa 1.1:\n # if no URI is provided, then first check to see if the element is the head or body element.\n # If it is, then act as if the new subject is set to the parent object.\n evaluation_context.parent_object\n elsif element == root\n # if the element is the root element of the document, then act as if there is an empty @about present,\n # and process it according to the rule for @about, above;\n uri(base)\n elsif attrs[:typeof]\n RDF::Node.new\n else\n # otherwise, if parent object is present, new subject is set to the value of parent object.\n # Additionally, if @property is not present then the skip element flag is set to 'true'.\n skip = true unless attrs[:property]\n evaluation_context.parent_object\n end\n\n # If @typeof is present then typed resource is set to the resource obtained from the first match from the following rules:\n typed_resource = new_subject if attrs[:typeof]\n end\n end\n\n add_debug(element) {\n \"[Step 5] new_subject: #{new_subject.to_ntriples rescue 'nil'}, \" +\n \"typed_resource: #{typed_resource.to_ntriples rescue 'nil'}, \" +\n \"current_object_resource: #{current_object_resource.to_ntriples rescue 'nil'}, \" +\n \"skip = #{skip}\"\n }\n else\n # [7.5 Step 6]\n # If the current element does contain a @rel or @rev attribute, then the next step is to\n # establish both a value for new subject and a value for current object resource:\n new_subject = process_uri(element, attrs[:about], evaluation_context, base,\n uri_mappings: uri_mappings,\n restrictions: SafeCURIEorCURIEorIRI.fetch(@version, []))\n new_subject ||= process_uri(element, attrs[:src], evaluation_context, base,\n uri_mappings: uri_mappings,\n restrictions: [:uri]) if @version == :\"rdfa1.0\"\n\n # if the @typeof attribute is present, set typed resource to new subject\n typed_resource = new_subject if attrs[:typeof]\n\n # If no URI is provided then the first match from the following rules will apply\n new_subject ||= if element == root && base\n uri(base)\n elsif [:xhtml1, :xhtml5, :html4, :html5].include?(@host_language) && element.name =~ /^(head|body)$/\n # From XHTML+RDFa 1.1:\n # if no URI is provided, then first check to see if the element is the head or body element.\n # If it is, then act as if the new subject is set to the parent object.\n evaluation_context.parent_object\n elsif attrs[:typeof] && @version == :\"rdfa1.0\"\n RDF::Node.new\n else\n # if it's null, it's null and nothing changes\n evaluation_context.parent_object\n # no skip flag set this time\n end\n\n # Then the current object resource is set to the URI obtained from the first match from the following rules:\n current_object_resource = process_uri(element, attrs[:resource], evaluation_context, base,\n uri_mappings: uri_mappings,\n restrictions: SafeCURIEorCURIEorIRI.fetch(@version, [])) if attrs[:resource]\n current_object_resource ||= process_uri(element, attrs[:href], evaluation_context, base,\n restrictions: [:uri]) if attrs[:href]\n current_object_resource ||= process_uri(element, attrs[:src], evaluation_context, base,\n restrictions: [:uri]) if attrs[:src] && @version != :\"rdfa1.0\"\n current_object_resource ||= RDF::Node.new if attrs[:typeof] && !attrs[:about] && @version != :\"rdfa1.0\"\n\n # and also set the value typed resource to this bnode\n if attrs[:typeof]\n if @version == :\"rdfa1.0\"\n typed_resource = new_subject\n else\n typed_resource = current_object_resource if !attrs[:about]\n end\n end\n\n add_debug(element) {\n \"[Step 6] new_subject: #{new_subject}, \" +\n \"current_object_resource = #{current_object_resource.nil? ? 'nil' : current_object_resource} \" +\n \"typed_resource: #{typed_resource.to_ntriples rescue 'nil'}, \"\n }\n end\n\n # [Step 7] If in any of the previous steps a typed resource was set to a non-null value, it is now used to provide a subject for type values;\n if typed_resource\n # Typeof is TERMorCURIEorAbsIRIs\n types = process_uris(element, attrs[:typeof], evaluation_context, base,\n uri_mappings: uri_mappings,\n term_mappings: term_mappings,\n vocab: default_vocabulary,\n restrictions: TERMorCURIEorAbsIRI.fetch(@version, []))\n add_debug(element, \"[Step 7] typeof: #{attrs[:typeof]}\")\n types.each do |one_type|\n add_triple(element, typed_resource, RDF[\"type\"], one_type)\n end\n end\n\n # Create new List mapping [step 8]\n #\n # If in any of the previous steps a new subject was set to a non-null value different from the parent object;\n # The list mapping taken from the evaluation context is set to a new, empty mapping.\n if (new_subject && (new_subject != evaluation_context.parent_subject || list_mapping.nil?))\n list_mapping = {}\n add_debug(element) do\n \"[Step 8]: create new list mapping(#{list_mapping.object_id}) \" +\n \"ns: #{new_subject.to_ntriples}, \" +\n \"ps: #{evaluation_context.parent_subject.to_ntriples rescue 'nil'}\"\n end\n end\n\n # Generate triples with given object [Step 9]\n #\n # If in any of the previous steps a current object resource was set to a non-null value, it is now used to generate triples and add entries to the local list mapping:\n if new_subject && current_object_resource && (attrs[:rel] || attrs[:rev])\n add_debug(element) {\"[Step 9] rels: #{rels.inspect} revs: #{revs.inspect}\"}\n rels.each do |r|\n if attrs[:inlist]\n # If the current list mapping does not contain a list associated with this IRI,\n # instantiate a new list\n unless list_mapping[r]\n list_mapping[r] = RDF::List.new\n add_debug(element) {\"list(#{r}): create #{list_mapping[r].inspect}\"}\n end\n add_debug(element) {\"[Step 9] add #{current_object_resource.to_ntriples} to #{r} #{list_mapping[r].inspect}\"}\n list_mapping[r] << current_object_resource\n else\n # Predicates for the current object resource can be set by using one or both of the @rel and the @rev attributes but, in case of the @rel attribute, only if the @inlist is not present:\n add_triple(element, new_subject, r, current_object_resource)\n end\n end\n\n revs.each do |r|\n add_triple(element, current_object_resource, r, new_subject)\n end\n elsif attrs[:rel] || attrs[:rev]\n # Incomplete triples and bnode creation [Step 10]\n add_debug(element) {\"[Step 10] incompletes: rels: #{rels}, revs: #{revs}\"}\n current_object_resource = RDF::Node.new\n\n # predicate: full IRI\n # direction: forward/reverse\n # lists: Save into list, don't generate triple\n\n rels.each do |r|\n if attrs[:inlist]\n # If the current list mapping does not contain a list associated with this IRI,\n # instantiate a new list\n unless list_mapping[r]\n list_mapping[r] = RDF::List.new\n add_debug(element) {\"[Step 10] list(#{r}): create #{list_mapping[r].inspect}\"}\n end\n incomplete_triples << {list: list_mapping[r], direction: :none}\n else\n incomplete_triples << {predicate: r, direction: :forward}\n end\n end\n\n revs.each do |r|\n incomplete_triples << {predicate: r, direction: :reverse}\n end\n end\n\n # Establish current object literal [Step 11]\n #\n # If the current element has a @inlist attribute, add the property to the\n # list associated with that property, creating a new list if necessary.\n if attrs[:property]\n properties = process_uris(element, attrs[:property], evaluation_context, base,\n uri_mappings: uri_mappings,\n term_mappings: term_mappings,\n vocab: default_vocabulary,\n restrictions: TERMorCURIEorAbsIRI.fetch(@version, []))\n\n properties.reject! do |p|\n if p.is_a?(RDF::URI)\n false\n else\n add_warning(element, \"[Step 11] predicate #{p.to_ntriples} must be a URI\")\n true\n end\n end\n\n datatype = process_uri(element, attrs[:datatype], evaluation_context, base,\n uri_mappings: uri_mappings,\n term_mappings: term_mappings,\n vocab: default_vocabulary,\n restrictions: TERMorCURIEorAbsIRI.fetch(@version, [])) unless attrs[:datatype].to_s.empty?\n begin\n current_property_value = case\n when datatype && ![RDF.XMLLiteral, RDF.HTML].include?(datatype)\n # typed literal\n add_debug(element, \"[Step 11] typed literal (#{datatype})\")\n RDF::Literal.new(attrs[:content] || attrs[:datetime] || attrs[:value] || element.inner_text.to_s, datatype: datatype, validate: validate?, canonicalize: canonicalize?)\n when @version == :\"rdfa1.1\"\n case\n when datatype == RDF.XMLLiteral\n # XML Literal\n add_debug(element) {\"[Step 11] XML Literal: #{element.inner_html}\"}\n\n # In order to maintain maximum portability of this literal, any children of the current node that are\n # elements must have the current in scope XML namespace declarations (if any) declared on the\n # serialized element using their respective attributes. Since the child element node could also\n # declare new XML namespaces, the RDFa Processor must be careful to merge these together when\n # generating the serialized element definition. For avoidance of doubt, any re-declarations on the\n # child node must take precedence over declarations that were active on the current node.\n begin\n c14nxl = element.children.c14nxl(\n library: @library,\n language: language,\n namespaces: {nil => XHTML}.merge(namespaces))\n RDF::Literal.new(c14nxl,\n library: @library,\n datatype: RDF.XMLLiteral,\n validate: validate?,\n canonicalize: canonicalize?)\n rescue ArgumentError => e\n add_error(element, e.message)\n end\n when datatype == RDF.HTML\n # HTML Literal\n add_debug(element) {\"[Step 11] HTML Literal: #{element.inner_html}\"}\n\n # Just like XMLLiteral, but without the c14nxl\n begin\n RDF::Literal.new(element.children.to_html,\n library: @library,\n datatype: RDF.HTML,\n validate: validate?,\n canonicalize: canonicalize?)\n rescue ArgumentError => e\n add_error(element, e.message)\n end\n when attrs[:value]\n # Lexically scan value and assign appropriate type, otherwise, leave untyped\n # See https://www.w3.org/2001/sw/wiki/RDFa_1.1._Errata#Using_.3Cdata.3E.2C_.3Cinput.3E_and_.3Cli.3E_along_with_.40value\n add_debug(element, \"[Step 11] value literal (#{attrs[:value]})\")\n v = attrs[:value].to_s\n # Figure it out by parsing\n dt_lit = %w(Integer Decimal Double).map {|t| RDF::Literal.const_get(t)}.detect do |dt|\n v.match(dt::GRAMMAR)\n end || RDF::Literal\n dt_lit.new(v)\n when attrs[:datatype]\n # otherwise, as a plain literal if @datatype is present but has an empty value.\n # The actual literal is either the value of @content (if present) or a string created by\n # concatenating the value of all descendant text nodes, of the current element in turn.\n # typed literal\n add_debug(element, \"[Step 11] datatyped literal (#{datatype})\")\n RDF::Literal.new(attrs[:content] || element.inner_text.to_s, language: language, validate: validate?, canonicalize: canonicalize?)\n when attrs[:content]\n # plain literal\n add_debug(element, \"[Step 11] plain literal (content)\")\n RDF::Literal.new(attrs[:content], language: language, validate: validate?, canonicalize: canonicalize?)\n when element.name == 'time'\n # HTML5 support\n # Lexically scan value and assign appropriate type, otherwise, leave untyped\n v = (attrs[:content] || attrs[:datetime] || element.inner_text).to_s\n datatype = %w(Date Time DateTime Year YearMonth Duration).map {|t| RDF::Literal.const_get(t)}.detect do |dt|\n v.match(dt::GRAMMAR)\n end || RDF::Literal\n add_debug(element) {\"[Step 11] <time> literal: #{datatype} #{v.inspect}\"}\n datatype.new(v, language: language)\n when (attrs[:resource] || attrs[:href] || attrs[:src]) &&\n !(attrs[:rel] || attrs[:rev]) &&\n @version != :\"rdfa1.0\"\n add_debug(element, \"[Step 11] resource (resource|href|src)\")\n res = process_uri(element, attrs[:resource], evaluation_context, base,\n uri_mappings: uri_mappings,\n restrictions: SafeCURIEorCURIEorIRI.fetch(@version, [])) if attrs[:resource]\n res ||= process_uri(element, (attrs[:href] || attrs[:src]), evaluation_context, base, restrictions: [:uri])\n when typed_resource && !attrs[:about] && @version != :\"rdfa1.0\"\n add_debug(element, \"[Step 11] typed_resource\")\n typed_resource\n else\n # plain literal\n add_debug(element, \"[Step 11] plain literal (inner text)\")\n RDF::Literal.new(element.inner_text.to_s, language: language, validate: validate?, canonicalize: canonicalize?)\n end\n else # rdfa1.0\n if element.text_content? || (element.children.length == 0) || attrs[:datatype] == \"\"\n # plain literal\n add_debug(element, \"[Step 11 (1.0)] plain literal\")\n RDF::Literal.new(attrs[:content] || element.inner_text.to_s, language: language, validate: validate?, canonicalize: canonicalize?)\n elsif !element.text_content? and (datatype == nil or datatype == RDF.XMLLiteral)\n # XML Literal\n add_debug(element) {\"[Step 11 (1.0)] XML Literal: #{element.inner_html}\"}\n recurse = false\n c14nxl = element.children.c14nxl(\n library: @library,\n language: language,\n namespaces: {nil => XHTML}.merge(namespaces))\n RDF::Literal.new(c14nxl,\n library: @library,\n datatype: RDF.XMLLiteral,\n validate: validate?,\n canonicalize: canonicalize?)\n end\n end\n rescue ArgumentError => e\n add_error(element, e.message)\n end\n\n # add each property\n properties.each do |p|\n # Lists: If element has an @inlist attribute, add the value to a list\n if attrs[:inlist]\n # If the current list mapping does not contain a list associated with this IRI,\n # instantiate a new list\n unless list_mapping[p]\n list_mapping[p] = RDF::List.new\n add_debug(element) {\"[Step 11] lists(#{p}): create #{list_mapping[p].inspect}\"}\n end\n add_debug(element) {\"[Step 11] add #{current_property_value.to_ntriples} to #{p.to_ntriples} #{list_mapping[p].inspect}\"}\n list_mapping[p] << current_property_value\n elsif new_subject\n add_triple(element, new_subject, p, current_property_value)\n end\n end\n end\n\n if !skip and new_subject && !evaluation_context.incomplete_triples.empty?\n # Complete the incomplete triples from the evaluation context [Step 12]\n add_debug(element) do\n \"[Step 12] complete incomplete triples: \" +\n \"new_subject=#{new_subject.to_ntriples}, \" +\n \"completes=#{evaluation_context.incomplete_triples.inspect}\"\n end\n\n evaluation_context.incomplete_triples.each do |trip|\n case trip[:direction]\n when :none\n add_debug(element) {\"[Step 12] add #{new_subject.to_ntriples} to #{trip[:list].inspect}\"}\n trip[:list] << new_subject\n when :forward\n add_triple(element, evaluation_context.parent_subject, trip[:predicate], new_subject)\n when :reverse\n add_triple(element, new_subject, trip[:predicate], evaluation_context.parent_subject)\n end\n end\n end\n\n # Create a new evaluation context and proceed recursively [Step 13]\n if recurse\n if skip\n if language == evaluation_context.language &&\n uri_mappings == evaluation_context.uri_mappings &&\n term_mappings == evaluation_context.term_mappings &&\n default_vocabulary == evaluation_context.default_vocabulary &&\n base == evaluation_context.base &&\n list_mapping == evaluation_context.list_mapping\n new_ec = evaluation_context\n add_debug(element, \"[Step 13] skip: reused ec\")\n else\n new_ec = evaluation_context.clone\n new_ec.base = base\n new_ec.language = language\n new_ec.uri_mappings = uri_mappings\n new_ec.namespaces = namespaces\n new_ec.term_mappings = term_mappings\n new_ec.default_vocabulary = default_vocabulary\n new_ec.list_mapping = list_mapping\n add_debug(element, \"[Step 13] skip: cloned ec\")\n end\n else\n # create a new evaluation context\n new_ec = EvaluationContext.new(base, @host_defaults)\n new_ec.parent_subject = new_subject || evaluation_context.parent_subject\n new_ec.parent_object = current_object_resource || new_subject || evaluation_context.parent_subject\n new_ec.uri_mappings = uri_mappings\n new_ec.namespaces = namespaces\n new_ec.incomplete_triples = incomplete_triples\n new_ec.language = language\n new_ec.term_mappings = term_mappings\n new_ec.default_vocabulary = default_vocabulary\n new_ec.list_mapping = list_mapping\n add_debug(element, \"[Step 13] new ec\")\n end\n\n element.children.each do |child|\n # recurse only if it's an element\n traverse(child, new_ec) if child.element?\n end\n\n # Step 14: after traversing through child elements, for each list associated with\n # a property\n (list_mapping || {}).each do |p, l|\n # if that list is different from the evaluation context\n ec_list = evaluation_context.list_mapping[p] if evaluation_context.list_mapping\n add_debug(element) {\"[Step 14] time to create #{l.inspect}? #{(ec_list != l).inspect}\"}\n if ec_list != l\n add_debug(element) {\"[Step 14] list(#{p}) create #{l.inspect}\"}\n # Generate an rdf:List with the elements of that list.\n l.each_statement do |st|\n add_triple(element, st.subject, st.predicate, st.object) unless st.object == RDF.List\n end\n\n # Generate a triple relating new_subject, property and the list BNode,\n # or rdf:nil if the list is empty.\n if l.empty?\n add_triple(element, new_subject, p, RDF.nil)\n else\n add_triple(element, new_subject, p, l.subject)\n end\n end\n end\n\n # Role processing\n # @id is used as subject, bnode otherwise.\n # Predicate is xhv:role\n # Objects are TERMorCURIEorAbsIRIs.\n # Act as if the default vocabulary is XHV\n if attrs[:role]\n subject = attrs[:id] ? uri(base, \"##{attrs[:id]}\") : RDF::Node.new\n roles = process_uris(element, attrs[:role], evaluation_context, base,\n uri_mappings: uri_mappings,\n term_mappings: term_mappings,\n vocab: \"http://www.w3.org/1999/xhtml/vocab#\",\n restrictions: TERMorCURIEorAbsIRI.fetch(@version, []))\n\n add_debug(element) {\"role: about: #{subject.to_ntriples}, roles: #{roles.map(&:to_ntriples).inspect}\"}\n roles.each do |r|\n add_triple(element, subject, RDF::URI(\"http://www.w3.org/1999/xhtml/vocab#role\"), r)\n end\n end\n end\n end" ]
[ "0.57202727", "0.54853976", "0.5467896", "0.54602116", "0.5413731", "0.5364005", "0.5354218", "0.53466433", "0.5250838", "0.5250838", "0.52301514", "0.5221761", "0.5200316", "0.5151956", "0.5128227", "0.51147974", "0.5102329", "0.50931597", "0.50682104", "0.5019007", "0.5017566", "0.5017503", "0.49794003", "0.49786782", "0.49673882", "0.49536934", "0.4946577", "0.4946577", "0.4946577", "0.49325624", "0.49048227", "0.48886287", "0.48782587", "0.48729953", "0.4865541", "0.48596695", "0.48330662", "0.483177", "0.4819254", "0.48161948", "0.48161948", "0.4807671", "0.47945225", "0.47914794", "0.47904077", "0.4780753", "0.47766775", "0.47632912", "0.47533143", "0.4749882", "0.47417894", "0.4736665", "0.47247308", "0.47193667", "0.47153616", "0.4711893", "0.47117186", "0.46966958", "0.46944487", "0.46829158", "0.4678155", "0.46750754", "0.46479023", "0.46382073", "0.46243453", "0.4621769", "0.46169534", "0.4615118", "0.46138692", "0.4601076", "0.4599612", "0.45991606", "0.45934904", "0.45765808", "0.4570922", "0.45701525", "0.45694435", "0.45654073", "0.4563774", "0.45608366", "0.45575777", "0.4549626", "0.45354027", "0.45326376", "0.45264632", "0.4524611", "0.45230547", "0.45193133", "0.4504766", "0.45017016", "0.44995126", "0.4497531", "0.448709", "0.4486936", "0.44829878", "0.4481771", "0.4477623", "0.447406", "0.44661012", "0.44600296" ]
0.5330119
8
lookup function: invalidate Setting invalidate will mean this lookup will be skipped in the policy
def invalidate @valid = false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lookup_uncached(val); end", "def lookup_uncached(val); end", "def invalidate\n @invalid=true\n end", "def write_invalidation(offset:)\n invalidate! if offset.between?(@cache_offset_begin, @cache_offset_end)\n end", "def invalidate\r\n @invalid=true\r\n end", "def invalidate\n @invalid = true\n end", "def requires_lookup!( local_index )\n \n @requires_lookup[ local_index ] = true\n \n return self\n \n end", "def on_invalidate(&block); end", "def invalidate(*args)\n alloc(*args).invalidate\n end", "def invalidate!(*args)\n alloc(*args).invalidate!\n end", "def resident_key?; end", "def expire_match(key)\n true\n end", "def invalidate_cache\n accessor.cache_manager.invalidate(resource.uri)\n end", "def lookup!(mac)\n lookup(mac, raising: true)\n end", "def looked_up!( local_index )\n \n @requires_lookup[ local_index ] = false\n \n return self\n \n end", "def known_invalid_idref(mapkey, oldid)\n\treturn false;\n\t# \treturn ( ((mapkey==:version or mapkey==:fixfor) and oldid==21907 or oldid==21881 or oldid==21743) or\n\t# \t\t\t(mapkey==:version and (oldid==21240 or oldid==21743)) or \n\t# \t\t\t(mapkey==:issuestatus and (oldid==2 or oldid==-3)) or\n\t# \t\t\t(mapkey==:resolution and oldid==6)\n\t# \t )\nend", "def invalidate_cache! now\n end", "def invalidate\n @cache_version ||= 0\n @cache_version += 1\n end", "def invalidate!\n @cache = MiniCache::Store.new\n return nil\n end", "def lookup_apiweb_key key\n apiweb_key_table_exists!\n \n entry = DB[:apiweb_key][:key => key]\n ## check project_id and user_id\n \n if Time.now > entry[:expiration]\n ## remove the entry?\n return nil ## what effect does this have on the client side?\n end\n \n entry\n end", "def invalidate(_object, _attribute, _message, _values = T.unsafe(nil)); end", "def state(key, refetch_time, invalid_time)\n if @store.exists?(key)\n if !@store.expired?(key, refetch_time)\n :current\n elsif (invalid_time == :forever) || !@store.expired?(key, invalid_time)\n :refetch\n else\n :invalid\n end\n else\n :missing\n end\n end", "def invalidate(msg = nil, &block)\n field = @field\n add_callback(:validate) do |from, to|\n if block\n msg = instance_exec(from, to, &block)\n if msg\n self.errors[field] << msg\n end\n else\n self.errors[field] << msg || 'is an invalid'\n end\n end\n end", "def resident_key; end", "def invalidate(uri)\n @memcache.delete(uri_hash(uri))\n end", "def devise_password_expired(mapping, controllers)\n resource :password_expired, :only => [:show, :update], :path => mapping.path_names[:password_expired], :controller => controllers[:password_expired]\n end", "def invalidate_cache!\n @cache_valid_from = Time.now\n end", "def invalidate\n self.result = Automation::Result::Ignored\n self.save\n end", "def black_list_check_expire(name_of_list)\n list_check_expire(\"#{BLACK_LIST_NAMED}:#{name_of_list}\")\n end", "def remove_forward_lookup(_fqdn)\n end", "def attribute_transition_for(object, invalidate = T.unsafe(nil)); end", "def invalidated_accounts\n self.accounts.find(:all, :conditions => ['validated = false'])\n end", "def patient_lookup\n return unless patient_identifier_changed?\n self.patient = patient_lookup_entity_id || patient_lookup_id\n end", "def lookup(request)\n resp = cache_entries_for(request)[request]\n return if resp.nil?\n\n resp.authoritative = false\n\n resp\n end", "def [](key)\n val = @store[key]\n \n if val\n if val.expired?\n prune\n nil\n else\n val.value\n end\n else\n nil\n end\n end", "def ensure_account_is_not_pending_recovery\n self.match.is_not_pending_recovery!\n end", "def dns_find(key)\n \n end", "def clean_cache\n node.normal['cloudflare']['threat_control']['status_cache'].reject! { |ip, data| is_stale? data['datetime'] }\nend", "def devise_password_expired(mapping, controllers)\n resource :password_expired, only: %i(show update), path: mapping.path_names[:password_expired],\n controller: controllers[:password_expired]\n end", "def resident_key=(_arg0); end", "def invalidate(&block)\n yield\n ensure\n @attributes = nil\n end", "def invalidate_link link\n @links.delete(link.condition)\n \n end", "def reg_resolve!(key)\n return key unless Utils.ident?(key)\n spec = reg_resolve(key)\n\n if spec\n spec\n else\n raise \"Unable to resolve spec: #{key}\"\n end\n end", "def lookup\n InternalId.find_by(**scope, usage: usage_value)\n end", "def lookup(name)\n @registry.fetch(name) { raise CheckNotRegistered, \"Check '#{name}' is not registered\" }\n end", "def invalidate(*args)\n error = SpreadsheetWrangler::ValidationError.new(*args)\n @errors << error\n end", "def [](key)\n\t\t\t\tr = nil\n\t\t\t\t@mutex.lock\n\t\t\t\t\tif @lookup.has_key? key\n\t\t\t\t\t\tr = super\n\t\t\t\t\telsif @l2.include?(key)\n\t\t\t\t\t\tself[key] = r = @l2[key]\n\t\t\t\t\t\t@l2.delete(key)\n\t\t\t\t\tend\n\t\t\t\t@mutex.unlock\n\t\t\t\tr\n\t\t\tend", "def call_to(name)\n @validators.delete(name.to_s)\n end", "def expire=(_); end", "def definition_lookup_blocked=(value)\n @definition_lookup_blocked = value\n end", "def invalidate(key)\n full_key = namespaced(key)\n announce_cache_invalidate(full_key)\n\n storage.delete(full_key)\n end", "def revoke!\n self.used = true\n self.save\n end", "def status_from_cache ip\n clean_cache\n node['cloudflare']['threat_control']['status_cache'].fetch(ip)['status'].to_sym\nrescue KeyError\n # not found\n :none\nend", "def lookup_action; end", "def verify_or_update_firewall_rule(rule)\n verify_or_update_firewall_hash(rule2hash(rule), rule.firewall_name)\n end", "def requires_lookup?( local_index )\n \n return @requires_lookup ? @requires_lookup[ local_index ] || false : false\n \n end", "def invalidate!\n unless @invalidated\n @invalidated = true\n\n queue_flush! unless @stopped\n\n invalidations = @invalidations\n @invalidations = []\n\n invalidations.each(&:call)\n end\n end", "def expire!\n expire_faults!\n expire_perfs!\n end", "def bypass_validation(validate_name)\n bypass_arr = hhash['bypass_validate']\n bypass_arr ? bypass_arr.include?(validate_name) : false\n end", "def lookup(key)\n return nil if @capacity <= 0\n\n @cache_mutex.synchronize do\n return nil unless @map.include?(key)\n\n element = @map.delete(key)\n return nil if element.stale?(@timeout)\n\n @map[key] = element\n\n element.value\n end\n end", "def expire_cache(key)\n end", "def invalid; end", "def invalidate!\n free_resources\n @display_list.rebuild!\n end", "def invalidate_token model\n case invalidation_strategy\n when :new then set_token! model\n when :nullify then model[challenge_column] = nil ; model.save!\n when :destroy then model.destroy\n when :delete then model.class.delete model.id\n else raise ArgumentError, \"unknown token invalidation strategy\"\n end\n nil\n end", "def evict_tenant\n\t\t#if @is_rental?\n\tend", "def claim!(claim_id)\n claims[claim_id] or raise NotFound.new\n end", "def defineEviction(&block)\n\t \traise SwapDmi::CacheReconfigureError.new if @readyFlag\n @evict = block\n self\n end", "def lookup(options)\n raise 'todo'\n end", "def lookups; end", "def check_cache(policies, key)\n already_run = []\n policies.each do |p|\n cached_result = policy_cache[p][key]\n if cached_result # return if it passed\n return true \n else \n # Reject the policy from the policies if it's false, i.e. previously failed\n already_run << p unless cached_result.nil?\n end \n end\n already_run\n end", "def invalidate_others!\n self.class.where.not(:id => self.id).where(:user => self.user).each do |s|\n s.invalidate!\n end\n end", "def lookup_new_swimmer\n \n end", "def definition_lookup_blocked\n return @definition_lookup_blocked\n end", "def renewal_eligiblity_determination\n end", "def refresh_if_near_expiration; end", "def rule\n @rule ||= resolve!\n end", "def rule\n @rule ||= resolve!\n end", "def invalid_factories; end", "def expire_cache!(key)\n raise 'The expire_cache method must be implemented'\n end", "def failing_rules\n @failing_rules ||= rules.dup.failing\n end", "def cache_result(policy, result, key)\n policy_cache[policy][key] = result\n end", "def miss_reason; end", "def white_list_check_expire(name_of_list)\n list_check_expire(\"#{WHITE_LIST_NAMED}:#{name_of_list}\")\n end", "def cache_generate(cache_key); ::Regexp.closed_match(cache_key); end", "def fire_entity_not_found(entity); end", "def cache_removal_key\n \"#{self.study.accession}\"\n end", "def is_not_pending_recovery!\n self.update_attribute(:verification_key, nil) if self.is_pending_recovery?\n end", "def setex(key, ttl, value); end", "def setex(key, ttl, value); end", "def rekey_as_needed; end", "def fail_on_unevaluated\n fail_on_unevaluated_overrides\n fail_on_unevaluated_resource_collections\n end", "def verify_expiration; end", "def verify_expiration; end", "def treat_reserved_as_conflict; end", "def indirect\n @indirect ||= reject(&direct_predicate)\n end", "def decline\n request = ErrandRequest.find params[:id]\n if not request.nil? and request.errand.user_id == env['warden'].user.id\n request.declined = true\n request.save!\n render json: {ok: true}\n else\n render json: \"\", status: 404\n end\n end", "def invalidate_path\n @path_calculated = false\n @path = nil\n @path_index = 0\n end", "def forget_value(retractor)\n if @informant==retractor then\n @has_value=false\n @value=false\n @informant=false\n @logger.debug(\"#{self} lost value\")\n others=(@constraints-[retractor])\n @logger.debug(\"Notifying #{others}\") unless others == []\n others.each { |c| c.lost_value(self) }\n \"ok\"\n else\n @logger.debug(\"#{self} ignored request\")\n end\n end", "def reverse_get mapping\n (@map.rassoc(mapping) || (raise \"#{mapping} is not a mapping of a registered id\"))[0]\n end", "def not_found; end" ]
[ "0.575935", "0.575935", "0.57536674", "0.5741196", "0.5685166", "0.5545014", "0.5320189", "0.53179014", "0.52834135", "0.5212399", "0.5208969", "0.51370835", "0.5130603", "0.51212955", "0.51132417", "0.5112048", "0.5111466", "0.50882965", "0.5083123", "0.5074901", "0.50724643", "0.5058494", "0.50227314", "0.49862456", "0.4984727", "0.49755996", "0.49532816", "0.4942205", "0.49108317", "0.49093142", "0.49032158", "0.4885081", "0.48794585", "0.48714837", "0.48689312", "0.48657304", "0.4862149", "0.48409674", "0.48372445", "0.48368916", "0.48250875", "0.48194638", "0.48092407", "0.48021838", "0.4800818", "0.47776657", "0.47726122", "0.47539896", "0.47375345", "0.47296184", "0.47201872", "0.46987915", "0.46933705", "0.469114", "0.46854082", "0.46795008", "0.46653298", "0.4661744", "0.46530125", "0.46517244", "0.46466014", "0.46397856", "0.4639445", "0.46227765", "0.4622276", "0.46206358", "0.46168932", "0.46149972", "0.4607556", "0.4597412", "0.459435", "0.45889124", "0.45737183", "0.45709246", "0.45657897", "0.45617867", "0.45617867", "0.4558854", "0.45568368", "0.45538592", "0.45471588", "0.45436412", "0.45426908", "0.45409372", "0.45382372", "0.45323032", "0.45298994", "0.45222723", "0.45222723", "0.45208156", "0.4519726", "0.45196468", "0.45196468", "0.451366", "0.45127067", "0.45095897", "0.45047843", "0.44894734", "0.44883585", "0.44878286" ]
0.55245936
6
Display a specific order
def show @order = Order.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_order_contents\n\t\t@orders.each {|item| print item, \" -- \"}\n\tend", "def order\n \"Order nr. #{number}\"\n end", "def order\n \"Order nr. #{number}\"\n end", "def print_order(order)\n\tputs \"Here are the items you've ordered:\"\n\torder.each {|food| puts \"#{food.item}: $#{food.price}\\n\\tcalories: #{food.calories}\\tfat: #{food.fat} g\\tcarbs: #{food.carbs} g\"}\nend", "def display_resource(order)\n \"Order ##{order.number}\"\n end", "def print_order\n p \"@@@@@@@@@ Order id: ##{order.attrs['id']}\"\n p \"Name: #{order.attrs['name']} Email: #{order.attrs['email']}\"\n p \"Status: #{order.attrs['status']}\"\n\n conn = DatabaseConnector.new.connect\n rs = conn.exec \"select li.*, products.name from line_items as li INNER JOIN products on li.product_id = products.id where li.order_id = '#{order.attrs['id']}'\"\n\n char_len = 30\n rs.each do |row|\n prod_name = \"#{row['id']} : #{row['name']}\"\n\n p \"#{prod_name} #{'-'*(char_len - prod_name.length)}---> #{row['amount']} X #{row['quantity']} = #{row['amount'].to_f * row['quantity'].to_i}\"\n end\n p '-'*55\n if order.attrs['discont_desc'] != ''\n p \"Sub Total #{'-'*25} -> #{order.attrs['sub_total']}\"\n p \"Coupon #{'-'*25} -> #{order.attrs['discont_desc']}\"\n p \"You Saved #{'-'*25} -> #{order.attrs['amount'].to_i - order.attrs['sub_total'].to_i}\"\n p '-'*55\n end\n p \"Total #{'-'*25} -> #{order.attrs['amount']}\"\n end", "def show\n @subprocesses = @order.subprocesses\n @has_leftovers = @order.has_leftovers\n @comment = OrderComment.new\n @modification = Modification.new\n @modifications = @order.modifications\n end", "def show\n @include_order_items = true\n end", "def print_ordering(ordering)\n\t\tordering.each do |item|\n\t\t\tif item.model == \"Node\"\n\t\t\t\tnode = Node.find(item.id)\n\t\t\t\tputs \".\" + node.depth.to_s + node.title\n\t\t\telsif item.model == \"Note\"\n\t\t\t\tnote = Note.find(item.id)\n\t\t\t\tputs \"-\" + note.depth.to_s + note.body\n\t\t\tend\n\t\tend\n\tend", "def show\n @line_items = @order.line_items\n end", "def print_order\n puts \"This #{dog.choice} hot dog with a #{bun.choice} bun, and #{condiment.choice} is beautiful. You should go into hot dog art.\"\n end", "def order\n end", "def vieworder\n end", "def show\n @order_items = current_order.order_items\n end", "def order\n @order || \"99_99\"\n end", "def show\n @title = \" - Order#\" + @order.id.to_s\n @print_sections = PrintSection.all\n @order_data = eval(@order.data)\n # parts_arr = []\n # options_arr = []\n\n # strhash = eval(@order.data).with_indifferent_access\n\n # strhash[:part].each do |key, val|\n # parts_arr << Part.find(key)\n # options_arr << Option.find(val[:option])\n # end\n\n # @parts_options = parts_arr.zip(options_arr)\n\n if params[:view] == 'print'\n render action: 'print', :layout => 'application'\n return\n end\n end", "def show\n\t\trespond_with @order\n\tend", "def display_order_list(orders)\n list = orders.map do |o| \n res = { 'order_url' => url(:display_from_id, o.order_id) }\n o.add_to_hash(res)\n res\n end\n \n standard_page(\"Matching Orders\", {'list' => list}, ORDER_LIST)\n end", "def orders\n @title = t('views.account.title.page_orders')\n @page = :order\n render :index\n end", "def show\n require_user()\n add_breadcrumb \"Orders\", orders_path\n add_breadcrumb @order.display_id, order_path\n end", "def show\n\t\t@order = Order.find(params[:id])\n\tend", "def edit\r\n @order = current_order(true)\r\n end", "def show\n @order = Order.scopied.find_by_id(params[:id].to_s)\n add_breadcrumb t(\"menu.order\") + \"#\" + @order.nr.to_s,'order_path(@order,:vendor_id => salor_user.meta.vendor_id)'\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @order }\n end\n end", "def generate_order\n p \"#{client}: #{total}\"\n end", "def show_orders\n @promotion = Promotion.find(params[:id])\n @title = t(:orders_for) + \" \" + @promotion.code\n @orders = Order.paginate(\n :order => 'created_on DESC',\n :conditions => [\"promotion_id = ?\", @promotion.id],\n :page => params[:page],\n :per_page => 30\n )\n end", "def display_from_id(order_id)\n order = Order.with_id(order_id)\n if order\n display_order_status(order)\n else\n error \"Missing order\"\n @session.pop\n end\n end", "def show\n @usr = current_user\n @count = @order.count_line_items\n @line_items = @order.line_items\n @total_price = @order.total_price\n end", "def display_order_status(order)\n values = order.add_to_hash({})\n\n user = User.with_id(order.order_user_id)\n if user\n user.add_to_hash(values)\n else\n error \"Unknown user\"\n find_common\n end\n\n pays_list = PaysPayment.list_for_order(order)\n unless pays_list.empty?\n values['pays_list'] = pays_list.map do |p| \n res = {\n 'payment_url' => @context.url(PaymentStatus, :display_from_id, p.pys_pay_id)\n }\n p.add_to_hash(res)\n end\n end\n\n values['print_statement'] = url(:print_statement, order.order_id)\n\n standard_page(\"Order Status\", values, ORDER_STATUS)\n end", "def order\n @num\n end", "def processOrder\n \n end", "def order; end", "def order; end", "def show\n search_order_per_customer()\n end", "def output\n puts \"\\n\"\n 0.upto(@order - 1) do |r|\n row_for(@order, r)\n puts \"\\n\\n\"\n end\n end", "def orders\n \"staffgrade_id ASC\"\n end", "def orders\n \"staffgrade_id ASC\"\n end", "def index\n \t@orders = Order.order('id desc')\n \t#since line items belong to orders, we don't have to do anything to specify line items\n end", "def define_order(s_order)\n s_order=='Crescente' ? :asc : :desc\n end", "def show\n @order.update_attribute(:seen, true) unless @order.seen\n @line_items = @order.line_items.includes(:product)\n end", "def display_order_detail\n if current_user and (current_user.role_id == 1 or current_user.id == Order.find(params[:order_id]).user_id)\n @order = Order.find(params[:order_id])\n @items = Item.find_all_by_order_id(params[:order_id])\n render :action => \"display_order_detail\"\n else\n redirect_to(root_url, :notice => 'You cannot view the order detail!')\n end\n end", "def list\n order_items\n end", "def order\n return @order\n end", "def toggle_order(order)\n (@current_order = order;@list = 1;@message = nil;return true) if order.match('ascending')\n (@current_order = order;@list = uids;@message = nil;return true) if order.match('descending')\n end", "def orders\n \"intake, matrixno ASC\"\n # \"course_id, intake, matrixno ASC\"\n end", "def orders\n \"assetcode ASC\"# \"staffgrade_id ASC\"\n end", "def show\n @order = Order.find @customer.order_id\n end", "def show\n #render text: @music_order.order_items.length and return\n end", "def order(value)\n\t\t\tparam(\"order\", value)\n\t\tend", "def order=(value)\n @order = value\n end", "def order\n @order || index\n end", "def first_order(order)\n\t\tif self.first_order_number.empty?\n\t\t\treturn '&nbsp;'\n\t\telse\n\t\t\treturn first_order_number\t\n\t\tend\t\nend", "def show\n respond_with(@order) do |format|\n if current_user.has_role?(\"admin\")\n format.html {render}\n else\n format.html {render :action => :summary}\n end\n end\n end", "def mangopay_order_tag\n \" - Order: #{id} - User: #{user.id}, #{user.first_name.first}.#{user.last_name} -Slot: #{slot.id} du #{slot.date.strftime('%d/%m/%y')} - Course: #{slot.course.id}, #{slot.course.name} - Coach: #{slot.course.coach_id}/User_id: #{slot.course.coach.user.id}, #{slot.course.coach.user.first_name.first}.#{slot.course.coach.user.last_name} \"\n end", "def set_Order(value)\n set_input(\"Order\", value)\n end", "def set_Order(value)\n set_input(\"Order\", value)\n end", "def set_Order(value)\n set_input(\"Order\", value)\n end", "def set_Order(value)\n set_input(\"Order\", value)\n end", "def set_Order(value)\n set_input(\"Order\", value)\n end", "def set_Order(value)\n set_input(\"Order\", value)\n end", "def set_Order(value)\n set_input(\"Order\", value)\n end", "def set_Order(value)\n set_input(\"Order\", value)\n end", "def set_Order(value)\n set_input(\"Order\", value)\n end", "def set_Order(value)\n set_input(\"Order\", value)\n end", "def set_order\n @order = Order.friendly.find(params[:id])\n end", "def set_order\n @order = Order.friendly.find(params[:id])\n end", "def total\n calculate_total\n display_order\n end", "def show\n @order = Order.includes(:items).find(params[:id])\n end", "def render_order(entity, other)\n entity.id <=> other.id\n end", "def to_label\n \"Order ##{id}\"\n end", "def show\n @order_line = OrderLine.new\n @article_list = Article.all\n @article_list.each do |option|\n @article_id = option.id\n @article_description = option.description\n end\n end", "def show_orders\n @promotion = Promotion.find(params[:id])\n @title = \"Orders for #{@promotion.code}\"\n @orders = Order.paginate(\n :order => 'created_on DESC',\n :conditions => [\"#{Order.connection.quote_column_name(\"promotion_id\")} = ?\", @promotion.id],\n :page => params[:page],\n :per_page => 30\n )\n end", "def show\n \n @product = []\n @order.product_id.each do |z|\n a = Product.find(z[0])\n @product << a\n end\n @product\n @order\n end", "def show\n if @order.pmo_grab_id.present?\n pmo_grab = PmoGrab[@order.pmo_grab_id]\n pmo_item = PmoItem[pmo_grab.pmo_item_id]\n\n one_money = OneMoney[@order.one_money_id]\n @one_more_time = pmo_grab.seeds.any? { |seed| \"pending\" == seed.status }\n one_money_type = one_money.try(:type) || \"one_money\"\n redirect_url = one_money.try(:publish_url) || \"/#{one_money_type}/#{ one_money.start_at.strftime('%Y-%m-%d') }/index.html\"\n @redirect_url = \"#{redirect_url}#/detail/#{ pmo_grab.pmo_item_id }\"\n end\n # @order.items.includes(:orderable)\n end", "def show\n @order_view = Order.find(params[:id])\n end", "def order1 \n puts(\"\\n\\n- - - - - - - - - - - - - - - -\\n[SHOP] Executing order 1: ABCDABA should be $13.25\\n\\n\") \n @shop.reset_order\n @shop.add_product_to_order_by_name('A')\n @shop.add_product_to_order_by_name('B')\n @shop.add_product_to_order_by_name('C')\n @shop.add_product_to_order_by_name('D')\n @shop.add_product_to_order_by_name('A')\n @shop.add_product_to_order_by_name('B')\n @shop.add_product_to_order_by_name('A')\nend", "def show_ordenation(field)\n content_tag(:span, :class => 'pull-right') do \n link_to(\"<i class='icon-arrow-up'></i>\".html_safe, {:order_by => field, :ordem => 'ASC'}, :class => 'ordem_asc') +\n link_to(\"&nbsp;<i class='icon-arrow-down'></i>\".html_safe, {:order_by => field, :order => 'DESC'}, :class => 'ordem_desc')\n end\n end", "def display_name\n ActionController::Base.helpers.number_to_currency(total_price) + \n \" - Order ##{number} (#{customer.try(:name)})\"\n end", "def update_order\r\n @order = @cards.collect {|card| card.to_s}\r\n end", "def cur_ordering\r\n @orderings\r\n end", "def order_coffee(cafe_name, coffee_type)\n puts \"I'd like to order a #{coffee_type} here at #{cafe_name}\"\n end", "def order_print_out\n puts \"Your order is #{@the_order[0][:item_name]} with a side of #{@the_order[1][:item_name]} and #{@the_order[2][:item_name]}.\"\n puts \"Your total is $#{@the_order[0][:price] + @the_order[1][:price] + @the_order[2][:price]}.\"\n puts \"Thank you for your order.\"\n exit\nend", "def index\n @ordereds = Ordered.all\n end", "def send_when_ordered(order)\n @order = order\n mail to: \t order.email,\n \t subject: '注文を承りました'\n end", "def preview_order_items\n [\n {title: 'Item One', quantity: 2, price: 999, tax_exempt: false},\n {title: 'Item Two', quantity: 1, price: 25000, tax_exempt: false},\n {title: 'Item Three', quantity: 1, price: 8999, tax_exempt: false},\n {title: 'Item Four', quantity: 1, price: 100000, tax_exempt: false}\n ]\n end", "def take_order(item)\n $menu[item].nil? ? \"So sorry we don't have #{item}\" : \"I will take your order straight to the kitchen\"\n end", "def show\n @ordereds=Ordered.all\n @preparats=Preparat.all\n @order.ordereds.build\n end", "def show\n @order = Order.where(id: params[:id], user: current_user).first\n end", "def show\n @location = Consumable.all\n @line_item = LineItem.new\n @order_select = Order.where.not(finalized: true)\n logger.info @order_select\n @user = User.all\n end", "def order(order, options = {})\n id = epages_id(order)\n perform_get_with_object(\"/orders/#{id}\", options, Epages::Order)\n end", "def show\n @tasks = @order.tasks\n end", "def show\n @order = Order.find(params[:id])\n #TODO comnpany se debe sacar de la informacion del order\n \n @company = current_user.companies ? current_user.companies.first : nil || Company.new\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @order }\n end\n end", "def calculate(calculator, order)\n super\n draw(Diagram::Focused, format('%05d', order), calculator.model)\n\n true\n end", "def order3\n puts(\"\\n\\n- - - - - - - - - - - - - - - -\\n[SHOP] Executing order 3: ABCD should be $7.25\\n\\n\") \n @shop.reset_order\n @shop.add_product_to_order_by_name('A')\n @shop.add_product_to_order_by_name('B')\n @shop.add_product_to_order_by_name('C')\n @shop.add_product_to_order_by_name('D')\nend", "def show\n @order = Order.find(params[:id])\n @title = \"#{order_name} Receipt\"\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @order }\n end\n end", "def order_info_link\n h.link_to 'Информация о заказе', h.admin_order_path(order.id)\n end", "def show\n @order = get_pending_order\n @food_item = @order == nil ? nil : FoodItem.find(@order.food_item_id)\n end", "def show\n @order = Order.find(params[:id]) \n @order_items = @order.order_items\n @address = @order.address\n render layout: 'third_party'\n end" ]
[ "0.7749917", "0.74519897", "0.74519897", "0.7245423", "0.71778303", "0.7019009", "0.6999654", "0.6932858", "0.68941724", "0.68030185", "0.6752615", "0.67449087", "0.6617434", "0.6616171", "0.65817136", "0.6533804", "0.65170544", "0.64989656", "0.6470312", "0.64503807", "0.6404235", "0.64022106", "0.6378218", "0.637245", "0.63597184", "0.6295234", "0.62903744", "0.6290299", "0.6282373", "0.6278833", "0.62725484", "0.62725484", "0.62677956", "0.62382764", "0.623806", "0.623806", "0.62355494", "0.6229367", "0.62265646", "0.6211298", "0.6211213", "0.6209279", "0.6171198", "0.61622155", "0.6150929", "0.61290085", "0.61285394", "0.61252993", "0.6110512", "0.60949284", "0.60720235", "0.60479146", "0.6042311", "0.602256", "0.602256", "0.602256", "0.602256", "0.602256", "0.602256", "0.602256", "0.602256", "0.602256", "0.602256", "0.6017003", "0.6017003", "0.60111034", "0.60061854", "0.5996793", "0.59895545", "0.5982177", "0.5977439", "0.59699816", "0.59588945", "0.5949128", "0.59153455", "0.5913489", "0.5913223", "0.5911702", "0.59060633", "0.59002745", "0.5890506", "0.5887427", "0.5884482", "0.58806354", "0.5878487", "0.58720106", "0.5871242", "0.5869409", "0.58671564", "0.5864661", "0.5863214", "0.5858927", "0.5854201", "0.584038", "0.5839477", "0.5836492", "0.5823119" ]
0.6234985
40
Convert a cart into an order go through and check each cart entry, if in stock and valid then convert to an order entry. If the order is valid after the creation of the entry then ammend stock levels. Once all valid entries are generated save the whole thing and clear the shopping cart
def create candidateOrder = Order.new(email: params[:order][:Email], totalCost: cart_total, user: curr_user) cart.each do |pId, info| if (prod = Product.find_by(id: pId)) if prod.stockCount > info["Num"].to_i candidateOrder.order_entries.new( product: prod, quantity: info["Num"].to_i, unitprice: prod.price, totalprice: prod.price * info["Num"].to_i, order_id: candidateOrder.id ) candidateOrder.order_entries.last.validate! if candidateOrder.valid? prod.stockCount -= info["Num"].to_i Product.update(prod.id, stockCount: prod.stockCount) end end end end if candidateOrder.save! clear_cart redirect_to order_path(candidateOrder), notice: t(:order_placed) else redirect_to carts_path, error: t(:order_failed) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n # create new order object from form parameters\n @order = Order.new(order_params)\n\n # get the contents of the cart\n @cart = Cart.find(current_user.cart_id)\n\n # for security reasons, calculate the total amount from the actual cart (instead of taking a parameter)\n @total_amount, @total_discount, @discounts = calculate_total_amount(@cart.cart_items)\n @order.total_amount = @total_amount\n\n authorize @order\n\n # check if there is enough stock of all items to be ordered\n # if not, respond with error\n # if yes, go on\n # note: we can't do this in the transaction because it's a different model (CartItem, not Order)\n @cart.cart_items.each do |cart_item|\n if cart_item.product.stock_level < cart_item.amount\n @order.errors.add(:base, \"We do not have enough items of #{cart_item.product.name} left: #{cart_item.amount} requested, #{cart_item.product.stock_level} in stock.\")\n respond_to do |format|\n format.html { render :checkout }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n format.js { render :checkout, content_type: 'text/javascript' }\n end\n return\n end\n end\n\n respond_to do |format|\n begin\n ActiveRecord::Base.transaction do\n begin\n # save order object without running validations yet, so we get the object ID\n # validations will be run below\n @order.save!(:validate => false)\n # create order_items out of all cart_items\n # decrease stock level of all cart_items by amount ordered\n # it's no problem if we encounter a problem at one of the latter cart_items because the transaction will\n # roll back completely in case of failure\n @cart.cart_items.each do |cart_item|\n cart_item.becomes!(OrderItem)\n cart_item.update!(order_id: @order.id, cart_id: nil)\n cart_item.product.stock_level -= cart_item.amount\n cart_item.product.save!\n end\n StatusMailer.status_update(@order.user_id, @order.id, \"We have received your order\", \"Your order was received. Please note that this is not an order confirmation. You will receive a confirmation shortly.\").deliver\n # final save so all validations are run\n @order.save!\n format.html { redirect_to @order, notice: 'Your order has been placed.' }\n format.json { render json: @order, status: :created, location: @order }\n rescue ActiveRecord::ActiveRecordError\n format.html { render :checkout }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n format.js { render :checkout, content_type: 'text/javascript' }\n end\n end\n end\n end\n end", "def transfer cart\n \t\tself.order_items.destroy_all\n \t\tcart.cart_items.each do |item|\n \t\t\t@order_item = order_items.build(price: item.price, quantity: item.quantity, sku_id: item.sku_id, weight: item.weight, order_id: id)\n \t\t\t@order_item.build_order_item_accessory(accessory_id: item.cart_item_accessory.accessory_id, price: item.cart_item_accessory.price, quantity: item.cart_item_accessory.quantity) unless item.cart_item_accessory.nil?\n \t\t\t@order_item.save!\n \t\tend\n \tend", "def convert_to_order\n @order = self.wholesale_profile.orders.create(status: :draft)\n self.cart_items.each do |ci|\n pv = ProductVariant.find(ci.product_variant_id)\n @order.order_items.create(product_variant_id: pv.id, quantity: ci.quantity, line_item_total: (ci.quantity * pv.price_in_cents))\n end\n @invoice = @order.create_invoice\n if @order.update(status: :processing)\n self.cart_items.destroy_all\n end\n return @order\n end", "def fetch_cart_and_check_inventory\n @cart = Cart.find_or_create_by user_id: @current_user.id\n\n # Check user's line items against current inventory levels\n updated_line_items = []\n\n @cart.line_items.each do |item|\n if item.quantity > item.product_size.quantity\n update_qty = item.get_update_qty item.quantity\n item.update quantity: update_qty\n updated_line_items << item\n end\n end\n\n # If items in the user's cart had to be adjusted,\n # redirect to carts#user_cart and set flash error\n if updated_line_items.length > 0\n flash[:item_error] = \"Sorry, stock is running low. Your shopping basket has been adjusted accordingly.\"\n redirect_to cart_path\n return\n end\n end", "def validate_product_quantity_in_stock\n init_order_and_order_item\n session[:cart].values.each do |item|\n product = Product.find_by id: item[\"product_id\"].to_i\n next if conditional_checking(product, item)\n @order.errors.add(:unit_in_stock, add_flash_danger(product))\n end\n return if @order.errors.blank?\n render :new\n end", "def process_cart_items()\n \torder = self.customer.orders.create\n \tself.cart_items.each do |item|\n \t\torder.order_items.create :product_id => item.product_id\n \tend\n \tself.cart_items = [] #clear the cart\n \treturn order\n end", "def create\n notice = \"\"\n if current_member.disabled\n flash[:notice] = \"Account is disabled. Cannot order until re-enabled.\"\n redirect_to(root_path)\n return\n end\n params[:order][:order_details_attributes].each{ |k,v|\n params[:order][:order_details_attributes].delete(k) if v[:quantity].to_f == 0.0 or v[:quantity].strip == ''\n }\n\n # combine same-stock entries\n stock_quantities = {}\n params[:order][:order_details_attributes].each{ |k,v|\n sid = v[:stock_id].to_i\n q = v[:quantity].to_f\n if stock_quantities[sid].nil?\n stock_quantities[sid] = q\n else\n stock_quantities[sid] += q\n OrderDetail.find(v[:id]).destroy unless v[:id].nil?\n params[:order][:order_details_attributes].delete(k)\n end\n }\n params[:order][:order_details_attributes].each{ |k,v|\n params[:order][:order_details_attributes][k][:quantity] = stock_quantities[v[:stock_id].to_i]\n }\n\n @order = Order.new(params[:order])\n unless current_member.admin\n @order.member = current_member\n end\n\n # first check to make sure there is enough stock available\n @order.order_details.each{ |od|\n if od.stock.limited and od.stock.quantity < od.quantity\n unless current_member.admin\n @order.errors.add \"Limited Stock Item:\",\"Sorry, there are only #{od.stock.quantity} #{od.stock.product.units} #{od.stock.name} remaining\"\n respond_to do |format|\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n return false\n else\n notice = \"Limited Stock Item: There were only #{od.stock.quantity} \n #{od.stock.product.units} #{od.stock.name} remaining, \n but I let you do it anyway since you're the boss!\"\n end\n elsif od.stock.quantity < od.quantity and !od.stock.limited\n notice = \"You have ordered more than is currently in stock. There may be some delay in filling this order-item.\"\n end\n }\n\n respond_to do |format|\n if @order.save\n # calculate costs and update stock\n @order.order_details.each{ |od|\n od.stock.quantity -= od.quantity\n od.stock.save\n }\n format.html { redirect_to(orders_path, :notice => \"Order was successfully created. #{notice}\") }\n format.xml { render :xml => @order, :status => :created, :location => @order }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n unless logged_in?\n session[:checking_out] = true\n redirect_to login_path, notice: t('orders.must_log_in') # \"You must log in before placing an order.\"\n else\n @order = current_user.orders.new(order_params)\n @order.earliest_pickup_date = calculate_earliest_pickup_date(:create)\n # User could have place product in cart days ago, make sure still available\n okay = true\n index = (session[:shopping_cart].size - 1)\n while (index >= 0)\n element = session[:shopping_cart][index]\n product = Product.find(element[:product_id])\n quantity = element[:quantity]\n if (product.quantity_in_stock == 0)\n okay = false if (okay)\n session[:shopping_cart].delete_at(index)\n # If cart empty as a result of the deletion, redirect user to product index\n redirect_to(products_path, notice: t('orders.not_in_stock')) and return if session[:shopping_cart].empty? # \"The product(s) ordered are no longer in stock; order cannot be placed.\"\n elsif (product.quantity_in_stock < quantity)\n okay = false if (okay)\n # Update quantity in shopping cart based on quantity available\n new_product_hash = { product_id: product.id, quantity: product.quantity_in_stock }\n session[:shopping_cart][index] = new_product_hash\n end\n index -= 1\n end\n redirect_to(new_order_path, notice: t('orders.please_review')) and return if (!okay) # \"One or more of the products you selected is either out of stock or not available in the desired quantity. Please review the updated order and resubmit if okay.\"\n # Proceed to save order\n respond_to do |format|\n if @order.save\n @order.update_attributes(order_date: Date.today, order_status_id: 1) # set order date to today, status to New\n session[:shopping_cart].each do |element| # create an order_product record for each product in the shopping cart and update quantity in stock of products\n product = Product.find(element[:product_id])\n quantity = element[:quantity]\n @order.order_products.create(product_id: product.id, quantity: quantity)\n new_quantity_in_stock = (product.quantity_in_stock - quantity)\n product.update_attributes(quantity_in_stock: new_quantity_in_stock)\n end\n session[:shopping_cart].clear\n format.html { redirect_to root_path, notice: t('orders.create') } # \"Your order was successfully submitted!\"\n format.json { render action: 'index', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def update\n notice = ''\n @order = Order.find(params[:id])\n unless current_member.admin or (!@order.paid and !@order.taken)\n store_location\n flash[:notice] = \"Too late to edit that one, bro.\"\n redirect_to orders_path\n end\n\n # remove empty items\n params[:order][:order_details_attributes].each{ |k,v|\n if v[:id].nil?\n params[:order][:order_details_attributes].delete(k) if v[:quantity].to_f == 0.0 or v[:quantity].strip == ''\n next\n end\n\n if v[:quantity].to_f == 0.0 or v[:quantity].strip == ''\n OrderDetail.find(v[:id]).destroy\n params[:order][:order_details_attributes].delete(k)\n end\n }\n\n # combine same-stock entries\n stock_quantities = {}\n params[:order][:order_details_attributes].each{ |k,v|\n sid = v[:stock_id].to_i\n q = v[:quantity].to_f\n if stock_quantities[sid].nil?\n stock_quantities[sid] = q\n else\n stock_quantities[sid] += q\n OrderDetail.find(v[:id]).destroy unless v[:id].nil?\n params[:order][:order_details_attributes].delete(k)\n end\n }\n params[:order][:order_details_attributes].each{ |k,v|\n params[:order][:order_details_attributes][k][:quantity] = stock_quantities[v[:stock_id].to_i]\n }\n \n unless current_member.admin\n @order.member = current_member\n end\n\n old_stock_quantities = {}\n @order.order_details.each{ |od|\n next if od.stock.nil?\n old_stock_quantities[od.stock.id] = od.quantity\n } \n\n # first check to make sure there is enough stock available\n stock_quantities.each{ |sid,q|\n s = Stock.find(sid)\n old_stock_quantities[sid] = 0.0 if old_stock_quantities[sid].nil?\n qmax = s.quantity + old_stock_quantities[sid]\n if s.limited and qmax < stock_quantities[sid]\n unless current_member.admin\n @order.errors.add \"Limited Stock Item:\",\"Sorry, there are only #{qmax} #{s.product.units} #{s.name} remaining and you have tried to order #{stock_quantities[sid]}.\"\n respond_to do |format|\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n return false\n else\n notice = \"Limited Stock Item: There were only #{qmax} \n #{s.product.units} #{s.name} remaining, \n but I let you do it anyway since you're the boss!\"\n end\n elsif !s.limited and qmax < stock_quantities[sid]\n notice = \"You ordered more #{s.name} than is currently in stock. It may be some delay before this order item is available for pick up.\"\n end\n }\n\n # add back quantity and then subtract it off again\n @order.order_details.each{ |od|\n next if od.stock.nil?\n od.stock.quantity += od.quantity\n od.stock.save\n }\n if !@order.paid and params[:order][:paid].to_i == 1\n @order.paid_at = Time.now\n @order.marked_paid_by = current_member\n @order.save\n end\n\n if !@order.taken and params[:order][:taken].to_i == 1\n @order.taken_at = Time.now\n @order.archived = true\n @order.save\n end\n\n # delete items before we add back the new ones\n @order.order_details = []\n @order.save \n\n respond_to do |format|\n \n if @order.update_attributes(params[:order])\n @order.order_details.each{ |od|\n next if od.stock.nil?\n od.stock.quantity -= od.quantity\n od.stock.save\n if @order.archived\n od.archived_name = od.stock.name\n od.archived_cost = od.stock.final_cost\n od.archived_supplier = od.stock.supplier\n od.archived_product = od.stock.product\n od.archived_markup_pct = od.stock.markup_pct\n od.archived_markup_const = od.stock.markup_const\n end\n od.save\n }\n format.html { redirect_to(orders_path, :notice => \"Order was successfully updated. #{notice}\") }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end", "def use_cart(cart)\n cart.cart_items.each do |cart_item|\n order_items.build(item_id: cart_item.item.id, price: cart_item.item.send(item_price_method_name), quantity: cart_item.quantity) if cart_item.quantity.to_i > 0\n end\n end", "def update_quantities!\n @products = products.reduce([]) do |products, product|\n # If product is not published\n if !product.variant.published\n set_error(:item_not_for_sale, item: product.variant.name)\n # If product is not in stock\n elsif !product.variant.in_stock?\n set_error(:item_out_of_stock, item: product.variant.name)\n # If product's available stock is less than required quantity\n elsif !product.variant.available_for(product.quantity)\n set_error(\n :not_enough_stock_for_item,\n item: product.variant.name, stock: product.variant.in_stock\n )\n product.quantity = product.variant.in_stock\n products << product if product.quantity > 0\n # Else, keep product as is in cart\n else product.variant.unlimited_stock || product.variant.in_stock >= product.quantity\n products << product\n end\n\n products\n end\n\n # TODO: Doesn't work, think in something else ...\n if discount_code == false\n set_error(:invalid_discount_code)\n end\n\n reset! if @products.length == 0\n end", "def create\n order = Order.find_by(id: session[:order_id])\n \n if session[:order_id].nil? || order.nil?\n order = Order.create\n session[:order_id] = order.id\n end\n \n order_items = {\n product_id: params[:product_id].to_i,\n quantity: params[:quantity].to_i,\n order_id: session[:order_id],\n }\n \n order = Order.find(session[:order_id])\n # if order item already exists in cart, increase quantity.\n order.order_items.each do |oi|\n if oi.product.id == order_items[:product_id]\n if oi.quantity + order_items[:quantity] > oi.product.stock\n flash[:failure] = \"Sorry, there are not enough items in stock.\"\n redirect_to product_path(order_items[:product_id])\n return\n else\n oi.quantity += order_items[:quantity]\n oi.save\n \n flash[:success] = \"Successfully updated quantity.\"\n redirect_to product_path(order_items[:product_id])\n return\n end\n end\n end\n \n order_item = OrderItem.new(order_items)\n if order_item.save\n flash[:success] = \"Successfully added item to your cart.\"\n redirect_to product_path(order_items[:product_id])\n return\n else\n flash[:failure] = \"Item could not be added to your cart.\"\n redirect_to product_path(order_items[:product_id])\n return\n end\nend", "def convert_to_global\n return false unless self.has_stocks\n\n\t\tActiveRecord::Base.transaction do\n\t\t\titemlog =\tcreate_log(\"convert_to_global\", 0)\n\t\t\tself.stocks.each do |f|\n\t\t\t\tsil = StockItemLog.new(:item_log_id => itemlog, :stock_id => f.id, :curr_serial_tag => f.serial_tag)\n\t\t\t\tsil.save!\n\t\t\tend\n\t\n\t Stock.destroy_all(item_id: self.id)\n \t self.has_stocks = false\n \tself.save!\n\t\tend\n\n end", "def make_cart_compatible\n return if session[:cart].items.is_a? Hash\n session[:cart] = Cart.new\n end", "def confirm\n elements=CartItem.where(:cart_id=>current_user.cart.id)\n\n # if there are no items in the cart, the order will not be placed\n if elements.length==0\n redirect_to carts_path, :notice => \"EMPTY CART!!!\"\n end\n\n # Checks to see if any item in the cart is low in stock. If so, abort. If not, update the sales, and stock quantity of the items\n out_of_stock_items=Item.check_validity(elements)\n\n # This actually checks if any items are below stock\n if out_of_stock_items.length!=0\n redirect_to carts_path, :notice => Item.show_low_stock_message(out_of_stock_items)\n else\n # Save the changes in sales and stocks.\n Item.save_sales(elements)\n #after all the validations are processed, the pre-place order view will be rendered\n @item_list=CartItem.where(:cart_id => current_user.cart.id)\n end\n end", "def update_quantities\n if params[:quantities]\n params[:quantities].each do |id, num|\n li = @cart.update_quantity(id, num)\n\n if !li\n p = @cart.line_items.find(id) rescue nil\n if p\n (flash[:notice] ||= '') << \"Unable to change quantity of \" +\n \"#{p.name} to #{num}, there are not \"+\n \"enough available at this time.\"\n end\n else #updated quantity\n # update any coupon generated lines for this line\n if cl = li.coupon_line\n cl.coupon.update_quantity_of_coupon_line(cl)\n end \n end\n end\n\n # if any master lines for coupon lines were destroyed,\n # remove their coupon lines as well\n @cart.line_items.select{|x| x.custom_double_line_id}.each do |cl|\n unless @cart.line_items.find_by_id(cl.custom_double_line_id)\n cl.destroy\n end\n end\n\n # (and their coupons)\n @cart.coupons.each do |x|\n @cart.coupons.delete(x) unless x.applies_to?(@cart)\n end\n\n end\n\n # update comments as well\n if params[:cart] and params[:cart][:comments]\n @cart.comments = params[:cart][:comments]\n end\n\n # build the redirect Url Options based on submitted action and\n # what already exists in the session\n uo = {}\n if params[:commit] == 'Checkout'\n uo = build_url_options_for_checkout\n else # just update\n uo = {:controller => 'cart', :action => 'show'}\n end\n\n # save the cart, so we know when the last action was taken on it\n unless @cart.save\n flash[:warning] = \"Unable to save cart: <ul><li>\" +\n \"#{@cart.errors.full_messages.join('</li><li>')}\" + \n \"</li></ul>\"\n end\n\n redirect_to uo\n end", "def add_stock_to_customer_cart\n # get params\n @customer_projected_rating_id = params[:id]\n @customer_drink_quantity = params[:quantity].to_i\n \n # get drink info\n if user_signed_in?\n @user = current_user\n @user_projected_ratings = ProjectedRating.where(user_id: current_user.id)\n else\n # first create an account\n @account = Account.create!(account_type: \"consumer\", number_of_users: 1)\n \n # next create fake user profile\n @fake_user_email = Faker::Internet.unique.email\n @generated_password = Devise.friendly_token.first(8)\n \n # create new user\n @user = User.create(account_id: @account.id, \n email: @fake_user_email, \n password: @generated_password,\n password_confirmation: @generated_password,\n role_id: 4,\n getting_started_step: 0,\n unregistered: true)\n \n if @user.save\n # Sign in the new user by passing validation\n bypass_sign_in(@user)\n #Rails.logger.debug(\"Current user: #{current_user.inspect}\")\n end\n end #end of check whether user is already \"signed in\"\n \n if !@user_projected_ratings.blank?\n @this_projected_rating = ProjectedRating.find_by_id(@customer_projected_rating_id)\n @inventory = Inventory.find_by_id(@this_projected_rating.inventory_id)\n @inventory_id = @inventory.id\n else\n @inventory = Inventory.find_by_id(@customer_projected_rating_id)\n @inventory_id = @inventory.id\n end\n \n # find if customer currently has an order in process\n @current_order = OrderPrep.where(account_id: @user.account_id, status: \"order in process\").first\n \n if @current_order.blank? # create a new Order Prep entry\n @current_order = OrderPrep.create!(account_id: @user.account_id, status: \"order in process\")\n end\n \n # now check if this inventory item already exists in the Order Drink Prep table\n @current_drink_order = OrderDrinkPrep.where(user_id: @user.id,\n order_prep_id: @current_order.id,\n inventory_id: @inventory_id)\n \n if !@current_drink_order.blank? #update entry\n if @customer_drink_quantity != 0\n @current_drink_order.update(quantity: @customer_drink_quantity)\n else\n @current_drink_order[0].destroy!\n end\n else # create a new entry\n OrderDrinkPrep.create!(user_id: @user.id,\n account_id: @user.account_id,\n inventory_id: @inventory.id,\n order_prep_id: @current_order.id,\n quantity: @customer_drink_quantity,\n drink_price: @inventory.drink_price_four_five)\n end\n\n # find total drink number in cart\n @order_prep_info = OrderDrinkPrep.where(order_prep_id: @current_order.id)\n @customer_number_in_cart = @order_prep_info.sum(:quantity)\n # get total amount in cart so far\n @subtotal = @order_prep_info.sum( \"drink_price*quantity\" ) \n @sales_tax = @subtotal * 0.101\n @total_drink_price = @subtotal + @sales_tax\n\n # if all drinks have been removed, delete the order prep\n if @customer_number_in_cart.to_i == 0\n @current_order.destroy!\n else\n if @current_order.delivery_fee.nil?\n @grand_total = @total_drink_price\n else\n @grand_total = @current_order.delivery_fee + @total_drink_price\n end\n # update Order Prep with cost info\n @current_order.update(subtotal: @subtotal, \n sales_tax: @sales_tax, \n total_drink_price: @total_drink_price,\n grand_total: @grand_total)\n end\n \n # update page\n respond_to do |format|\n format.js\n end # end of redirect to jquery\n \n end", "def create_stock_item\n\n added_new_stock_item = false\n # Get stock location for appropriate location\n @product_row[:location].split(',').each do |sub_location|\n sub_location.chomp!\n stock_location = case sub_location.to_s.downcase\n when /george/\n @@loc_attic\n # NFS no matter what - JC10 OR buffalo display case OR back shop\n when /jc\\d{1,2}|buffalo|back\\sshop|attic/\n @@loc_home_nfs\n # NFS if listed as not for sale (don't count in quantity)\n when /w\\d{1,2}/\n (@product_row[:available] && @product_row[:available].downcase == \"n\") ? @@loc_home_nfs : @@loc_home\n when /[[:alpha:]]\\d{2,3}|D\\d{3}\\.\\d|h\\d|file\\scabinet|suite\\s2/\n (@product_row[:available] && @product_row[:available].downcase == \"n\") ? @@loc_suite2_nfs : @@loc_suite2\n # NWC08\n when /nw[[:alpha:]]\\d{1,2}|ste3/\n @@loc_suite3\n # Warehouse\n when /warehouse/\n @@loc_warehouse\n # West trailer OR east racks\n when /east\\sracks|west\\strailer/\n @@loc_east_racks\n else # if unidentifiable location\n @errors << { :part_number => @product_row[:name], :condition => @product_row[:condition], :message => \"Cannot identify location \" + sub_location }\n next # skip to next location\n end\n\n # if no exisiting sub location, add one\n if(@new_product_condition.add_sub_location(sub_location, stock_location))\n added_new_stock_item = true\n end\n\n end # end location loop\n\n added_new_stock_item # return true if at least one new stock item added\n\n end", "def reorganizeCart\n\t\t@new_cart = {}\n\t\t@cart.each do |itemhash|\n\t\t\titemhash.each do |item, details|\n\t\t\t\t@new_cart[item] = details\n\t\t\t\t# adds :count key value to the hash\n\t\t\t\tif @new_cart[item][:count].nil? \n\t\t\t\t\t@new_cart[item][:count] = 1\n\t\t\t\telse\n\t\t\t\t\t@new_cart[item][:count] += 1\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#gets rid of duplicate entries\n\t\trepeat = []\n\t\t@new_cart.each do |item, hash|\n\t\t\tif repeat.include?(item) \n\t\t\t\tdelete(item)\n\t\t \telse\n\t\t \t\trepeat << item\n\t\t \tend\n\t\tend\n\t\t@new_cart\n\tend", "def update_stock_market_places(product_stocks)\n messages = []\n lazada_stock_hash = {}\n zalora_stock_hash = {}\n product_stocks.each do |key, value|\n variant = Spree::Variant.find(key)\n begin\n value.each do |sp_key, stock_count|\n stock_product = Spree::StockProduct.find(sp_key)\n smpp = stock_product.sellers_market_places_product\n market_place = smpp.market_place\n user_market_place = Spree::SellerMarketPlace.where(\"seller_id=? AND market_place_id=?\", smpp.seller_id, market_place.id)\n case market_place.code\n when \"qoo10\"\n res = Spree::StockMovement.stock_update_qoo10(variant.product, market_place.id, stock_count, stock_product, user_market_place.first, smpp, stock_count)\n when \"lazada\"\n if lazada_stock_hash[user_market_place.first.id.to_s].present?\n lazada_stock_hash[user_market_place.first.id.to_s].first.merge!(variant.sku.to_s=>stock_count)\n else\n lazada_stock_hash.merge!(user_market_place.first.id.to_s=>[{variant.sku.to_s=>stock_count}])\n end\n when \"zalora\"\n if zalora_stock_hash[user_market_place.first.id.to_s].present?\n zalora_stock_hash[user_market_place.first.id.to_s].first.merge!(variant.sku.to_s=>stock_count)\n else\n zalora_stock_hash.merge!(user_market_place.first.id.to_s=>[{variant.sku.to_s=>stock_count}])\n end\n end\n messages << (market_place.name+\": \"+ res) if res.present? && res != true\n end\n rescue Exception => e\n messages << e.message\n end\n end # end of stock product loop\n # Update stock for lazada in bulk\n Spree::StockMovement.stock_update_lazada_bulk(lazada_stock_hash) if lazada_stock_hash.present?\n Spree::StockMovement.stock_update_lazada_bulk(zalora_stock_hash) if zalora_stock_hash.present?\n return messages.present? ? \"fail\" : \"success\"\n end", "def validate_push_to_fba\n @order = Spree::Order.find_by_number(params[:id])\n cart_no = @order.cart_no if @order.present?\n @orders = Spree::Order.where(:cart_no => cart_no)\n @errors = []\n if @orders.present?\n @orders.each do |order|\n @line_items = order.line_items if order.line_items.present?\n if @line_items.present?\n @line_items.each do |line_item|\n @errors << line_item.variant.sku.to_s+\" sku is out of stock on FBA\" if line_item.variant.fba_quantity < 0\n end\n else\n flash[:error] = order.market_place_order_no.to_s+\" : No line items found...\" \n end\n end\n end\n if @errors.present? && @errors.count > 0\n flash[:error] = \"Ooop's \"+ @errors.join(', ') \n redirect_to modify_order_admin_order_path(@order)\n else\n cart_numbers = []\n cart_numbers << cart_no\n Spree::Order.push_to_fba(cart_numbers)\n flash[:success] = \"Order Pushed to FBA Successfully !\"\n redirect_to admin_order_path(@order)\n end\n end", "def convert_to_orders\n purchased_at = Time.zone.now\n line_items.includes(:item).each do |li|\n # TODO: Do this in memory\n order = Order.where(buyer_id: user_id, seller_id: li.item.user_id, purchased_at: purchased_at) \\\n .first_or_initialize(buyer_id: user_id, seller_id: li.item.user_id)\n order.line_items << li\n li.item.update_attribute(:sold, true)\n order.purchased_at = purchased_at unless order.persisted?\n orders << order unless orders.include? order\n order.save\n end\n # TODO this is not a great place for this... this entire method is\n # getting out of hand. Need a separate domain concept.\n orders.each do |order|\n OrderMailer.delay.sale_made_email(order.id)\n ReminderDeliveryWorker.perform_in(7.days, order.id) # Schedule review reminder\n end\n update_attribute(:purchased_at, purchased_at)\n save\n end", "def create\n @transaction = Transaction.new(params[:transaction])\n #@item = Item.find(@transaction.item_id)\n #@item.buyer_id = current_user.id\n @transaction.user_id = current_user.id\n @shopping_cart = ShoppingCart.find_by_user_id(current_user.id)\n error_flag = 0\n error_message = \"\"\n available_item = Array.new\n eval(@shopping_cart.item_list).each do |item_id, quantity|\n item = Item.find(Integer(item_id))\n if item.quantity < quantity\n error_message = \"Sorry! Only #{item.quantity} of #{item.title} is available at the moment\"\n error_flag = 1\n else\n available_item += [item]\n item.quantity -= quantity\n end\n end\n\n if error_flag == 1\n redirect_to @shopping_cart, notice: error_message\n else\n item_list = Hash.new\n eval(@shopping_cart.item_list).each do |item_id, item_quantity|\n index = Item.find(Integer(item_id)).attributes.except(\"created_at\", \"updated_at\", \"product_file_name\",\n \"product_content_type\", \"product_file_size\", \"product_updated_at\")\n item_list[index] = item_quantity\n end\n @transaction.item_list = item_list.to_s\n\n respond_to do |format|\n if @transaction.save\n available_item.each do |item|\n item.save\n end\n @shopping_cart.delete\n format.html { redirect_to @transaction, notice: 'Transaction successful.' }\n format.json { render json: @transaction, status: :created, location: @transaction }\n else\n format.html { render action: \"new\" }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def save_order\n @order = Order.new(params[:order]) \n @order.line_items << @cart.items \n if @order.save \n @cart.empty!\n redirect_to_index('Thank you for your order.')\n else\n render(:action => 'checkout') \n end\n end", "def consolidate_cart(cart)\n \n #declare new array\n new_cart = []\n \n #start with a counter so it begins at the first item\n counter = 0 \n \n #then create while loop\n while counter < cart.length \n \n #take each item in the cart and see if it is already in the new cart\n #calling the find_item_by_name_in_collection to check if item is in the new cart. Second argument is the collection we want to search want to see if the item is in our new cart.\n #So this will return either the item found or if not found it will return nil\n \n new_cart_item = find_item_by_name_in_collection(cart[counter][:item], new_cart)\n #if item is already in cart, we just want to increase the count\n if new_cart_item != nil \n \n #if new_cart_item does not equal nil then we want to access new_cart_item and inside we want to access the count and increase by 1\n new_cart_item[:count] += 1\n \n #otherwise, item is nil. We would need to create our item. Inside the hash we need to construct the new item in the new cart\n else\n new_cart_item = {\n :item => cart[counter][:item], \n :price => cart[counter][:price],\n :clearance => cart[counter][:clearance],\n #this is the first time count is being used, the old item did not have count\n :count => 1\n }\n #after the new_cart is built, we are going to shovel new_cart_item variable\n new_cart << new_cart_item\n end\n #to ensure there is not an infinite loop \n counter += 1\n end\n new_cart\nend", "def consolidate_cart(cart)\n new_cart = []\n count = 0\n while count < cart.length\n new_cart_item = find_item_by_name_in_collection(cart[count][:item], new_cart)\n if new_cart_item != nil\n new_cart_item[:count] += 1\n else\n new_cart_item = {\n :item => cart[count][:item], \n :price => cart[count][:price],\n :clearance => cart[count][:clearance],\n :count => 1\n }\n new_cart << new_cart_item\n end\n count += 1\n end\n new_cart\nend", "def checkout_cart\n self.line_items.each do |li|\n li.item.inventory -= li.quantity\n li.item.save\n end\n self.line_items.clear\n self.status = \"submitted\"\n self.user.current_cart_id = nil\n self.user.save\n end", "def transfer_order_items_from_previous_session\n if session[:cart_id].present? && Cart.find_by(id: session[:cart_id]).order_items.present?\n \n @cart = Cart.first_or_create(user_id: current_user.id)\n \n #we iterate through order_items of the cart which was in previous session, \n #and we add order items to our current_user cart (if order_item is present \n #in current_user cart then we update quantity of that order_item)\n #debugger\n Cart.find_by(id: session[:cart_id]).order_items.each do |order_item|\n if @cart.order_items.find_by(product_id: order_item.product_id).present?\n\n @cart.order_items.find_by(product_id: order_item.product_id).update_attributes(quantity: @cart.order_items.find_by(product_id: order_item.product_id).quantity + order_item.quantity)\n \n else\n \n order_item.update_attributes(cart_id: @cart.id)\n end \n end\n session[:cart_id] = @cart.id\n end\n end", "def consolidate_cart(cart)\n updated_cart = []\n i = 0\n while i < cart.length do\n updated_cart_item = find_item_by_name_in_collection(cart[i][:item], updated_cart)\n if updated_cart_item #if it does have a value\n updated_cart_item[:count] += 1\n else\n updated_cart_item = {\n :item => cart[i][:item],\n :price => cart[i][:price],\n :clearance => cart[i][:clearance],\n :count => 1\n }\n updated_cart << updated_cart_item\n end\n i += 1\n end\n updated_cart\nend", "def consolidate_cart(cart)\n cons_cart = []\n item_index = 0 \n while item_index < cart.length do \n item = cart[item_index][:item]\n price = cart[item_index][:price]\n clearance = cart[item_index][:clearance]\n current_item = find_item_by_name_in_collection(item, cons_cart)\n if !current_item\n cons_cart << {:item => item, :price => price, :clearance => clearance, :count => 1}\n else\n current_item[:count] += 1\n end\n item_index += 1\n end\n cons_cart\nend", "def create\n @cart = Cart.find(session[:cart_id])\n @order = Order.new(order_params)\n @order.cart_id = @cart.id\n @order.user_id = current_user.id\n @order.Status = false\n @cartsitems = Cartsitem.all.where(cart_id: @cart.id)\n @user = User.find(current_user.id)\n\n @cartsitems.each do |item|\n if item.fruit_id\n @fruit = Fruit.find(item.fruit_id)\n @fruit.quantity = @fruit.quantity - item.quantity \n @fruit.save\n end\n if item.vegetable_id\n @vegetable = Vegetable.find(item.vegetable_id)\n @vegetable.quantity = @vegetable.quantity - item.quantity \n @vegetable.save\n end\n\n end\n\n if @user.ordernumber\n @user.ordernumber = @user.ordernumber + 1\n \n else\n @user.ordernumber = 1\n end\n @user.save\n @cart = Cart.create\n session[:cart_id] = @cart.id\n\n\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to '/', notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def consolidate_cart(cart)\n new_cart = []\n counter = 0 \n while counter < cart.length do \n new_cart_item = find_item_by_name_in_collection(cart[counter][:item], new_cart) #returns item if it finds it, and if it doesn't find it will return nil\n if new_cart_item != nil #if this variable has a truthy value,\n new_cart_item[:count] += 1 \n else #if that new cart item is nil, create our item. in hash construct item for the new cart\n new_cart_item = {\n :item => cart[counter][:item],\n :price => cart[counter][:price], \n :clearance => cart[counter][:clearance],\n :count => 1 #here we are going over item's name price and clearance value and adding a count key value pair and setting that equal to one.\n }\n new_cart << new_cart_item\nend \ncounter += 1 \nend\nnew_cart \nend", "def consolidate_cart(cart)\n # Consult README for inputs and outputs\n #\n # REMEMBER: This returns a new Array that represents the cart. Don't merely\n # change `cart` (i.e. mutate) it. It's easier to return a new thing.\n new_cart = []\n counter = 0\n\n while counter < cart.length\n new_item = find_item_by_name_in_collection(cart[counter][:item], new_cart)\n if new_item != nil\n new_item[:count] += 1\n else\n new_item = {\n :item => cart[counter][:item],\n :price => cart[counter][:price],\n :clearance => cart[counter][:clearance],\n :count => 1\n }\n new_cart << new_item #shoving the new hash into new array\n end\n counter += 1\n end\n\n new_cart\nend", "def replaces(old_cart)\n transaction do\n product_ids = self.line_items.collect(&:product_id)\n old_cart.line_items.where(product_ids.blank? ? \"true=true\" : \"product_format_id not in (select id from product_formats where product_id in (#{product_ids.join(\",\")}) )\").all.each do |item|\n item.update_attributes(:saved_for_later => true, :line_item_collection_id => self.id)\n end\n self.update_attribute(:user, old_cart.user)\n Cart.destroy(old_cart.id)\n end\n end", "def consolidate_cart(cart)\n consol_cart = []\n i = 0\n while i < cart.length\n new_item = find_item_by_name_in_collection(cart[i][:item], consol_cart)\n if new_item\n new_item[:count] += 1\n else\n new_item = {\n :item => cart[i][:item],\n :price => cart[i][:price],\n :clearance => cart[i][:clearance],\n :count => 1\n }\n consol_cart << new_item\n end\n i += 1\n end\n consol_cart\nend", "def new\n\n #Create new order object associated to the user\n order=current_user.orders.build\n order.save\n\n cart_items=current_user.cart.cart_items.all\n\n cart_items.each do |cart_item|\n item=Item.find(cart_item.item_id)\n\n #Create immutable object \"OrderItem\" that holds everything about the item.\n order_items=OrderItem.new(item.name,item.price,cart_item.quantity,item.keeper_id,item.id,order.id)\n order_items.save\n end\n\n #Clear cart after placing an order\n current_user.cart.clear_cart\n\n end", "def consolidate_cart(cart)\n \n new_cart = []\n index = 0\n\n while index < cart.count do\n new_cart_item = find_item_by_name_in_collection(cart[index][:item], new_cart)\n if new_cart_item\n new_cart_item[:count] += 1\n else\n new_cart_item = {\n :item => cart[index][:item],\n :price => cart[index][:price],\n :clearance => cart[index][:clearance],\n :count => 1\n }\n new_cart << new_cart_item\n end\n\n index += 1\n end\n \n return new_cart\nend", "def apply_clearance(cart) #want to loop through each item in this cart and check if each item is on clearance. if is, want to adjust items price for that item and return cart for all adjusted items.\n counter = 0 \n while counter < cart.length do \n if cart[counter][:clearance] #if this is true, we want to go into that if statement, and if false we don't want to go into that if statement. \n cart[counter][:price] = (cart[counter][:price] - (cart[counter][:price] * 0.20)).round(2) #called 2 in the round method to round our number to 2 decimal places. \n end \n counter += 1 \nend\ncart\nend", "def old_order_lines_from_cart(cart)\n order = self\n cart.cart_lines.each do |cl|\n ol = OldOrderLine.create(cl.attributes)\n ol.cart_id = nil\n order.old_order_lines << ol\n end\n return order\n end", "def consolidate_cart(cart)\n \n nhash ={}\n new_array = []\n row_index =0\n \n while row_index < cart.length\n item_mutch = find_item_by_name_in_collection(cart[row_index][:item],nhash)\n \n if !item_mutch\n \n nhash[row_index] = {}\n nhash[row_index][:item] = cart[row_index][:item]\n nhash[row_index][:count] = 1\n nhash[row_index][:clearance] = false\n nhash[row_index][:price] = cart[row_index][:price]\n new_array << nhash[row_index]\n# binding.pry\nelse\n item_mutch[:count] += 1\n item_mutch[:clearance] =true\n # nhash[:price] += cart[row_index][:price]\nend\n\n\n row_index += 1\n # Consult README for inputs and outputs\n #\n # REMEMBER: This returns a new Array that represents the cart. Don't merely\n # change `cart` (i.e. mutate) it. It's easier to return a new thing.\n\nend\nreturn new_array\n end", "def add_default_entries\n product = self.product\n begin\n # Title entry\n tm = Spree::TitleManagement.where(\"market_place_id=? AND product_id=?\", self.market_place_id, self.product_id)\n if !tm.present?\n Spree::TitleManagement.create(:name=>product.name, :market_place_id=>self.market_place_id, :product_id=>product.id)\n else\n tm.update_all(:name=>product.name)\n end\n\n # Desctription entry\n dm = Spree::DescriptionManagement.where(\"market_place_id=? AND product_id=?\", self.market_place_id, self.product_id)\n if !dm.present?\n Spree::DescriptionManagement.create(:description=>product.description, :market_place_id=>self.market_place_id, :product_id=>product.id, :meta_description=>product.meta_description, :package_content=>product.package_content)\n else\n dm.update_all(:description=>product.description, :meta_description=>product.meta_description, :package_content=>product.package_content)\n end\n\n # Price & Stock entry\n variants = []\n variants << (product.variants.present? ? product.variants : product.master)\n variants = variants.flatten\n variants.each do |variant|\n sp = variant.stock_products.where(:sellers_market_places_product_id=>self.id)\n if !sp.present?\n type = STOCKCONFIG[product.stock_config_type] == \"default\" ? STOCKCONFIG[product.seller.stock_config_type] : STOCKCONFIG[product.stock_config_type]\n count_on_hand = 0\n count_on_hand = variant.fba_quantity if (type == 'flat_quantity')\n Spree::StockProduct.create(:sellers_market_places_product_id=>self.id, :variant_id=>variant.id, :virtual_out_of_stock=>false, :count_on_hand=>count_on_hand)\n else\n sp.update_all(:count_on_hand=>0)\n end\n\n pm = Spree::PriceManagement.where(\"market_place_id=? AND variant_id=?\", self.market_place_id, variant.id)\n if !pm.present?\n Spree::PriceManagement.create(:selling_price=>variant.selling_price.to_f, :special_price=>variant.special_price.to_f, :settlement_price=>0.0, :market_place_id=>self.market_place_id, :variant_id=>variant.id)\n else\n pm.update_all(:selling_price=>variant.selling_price.to_f, :special_price=>variant.special_price.to_f, :settlement_price=>0.0)\n end\n end\n rescue Exception=> e\n end\n end", "def consolidate_cart(cart)\n# [{:item => \"AVOCADO\", :price => 3.00, :clearance => true },\n# {:item => \"AVOCADO\", :price => 3.00, :clearance => true },\n# {:item => \"KALE\", :price => 3.00, :clearance => false}]\n new_cart = []\n i = 0\n while i < cart.length do\n new_cart_item = find_item_by_name_in_collection(cart[i][:item], new_cart)\nif new_cart_item != nil\n new_cart_item[:count] += 1\nelse\n new_cart_item = {\n :item=> cart[i][:item],\n :price => cart[i][:price],\n :clearance => cart[i][:clearance],\n :count => 1\n }\n new_cart << new_cart_item\nend\n i+=1\n end\n new_cart\nend", "def add_items_from_cart(cart)\n cart.line_items.each do |item|\n self.line_items << item if item.sufficient_stock?\n end\n end", "def create\n @customer = CustomerManagement.find(order_params[:customer_id])\n if @customer.cart.address_id\n if @customer.cart_items.length > 0 \n location_same = false\n if @customer.cart.address.city && @customer.cart.address.city.downcase == current_location.downcase\n location_same = true \n end\n \n serve_all = true\n \n if !location_same\n @extra_cart_items = \"\"\n @customer.cart_items.each do |cart_item| \n if !((!cart_item.product_variant.location) || cart_item.product_variant.location == \"\")\n @temp_item = ProductVariant.where(:product_id => cart_item.product_variant.product_id, :location => @customer.cart.address.city, :value => cart_item.product_variant.value).first\n if @temp_item\n cart_item.update_columns(product_id: @temp_item.id, price: (@temp_item.price + (cart_item.include_service ? @temp_item.service_price : 0))) \n else\n @extra_cart_items = @extra_cart_items + \" & \" + cart_item.product.name\n serve_all = false\n end \n end \n end \n end\n \n if location_same || serve_all\n @order = Order.find_or_create_by(:customer_id => order_params[:customer_id],:active => true) \n @customer.cart_items.each do |cart_item| \n @order_to_product = OrderToProduct.where(:product_id => cart_item.product_id, :order_id => @order.id).first_or_create\n @order_to_product.update_price_quantity(cart_item.unit_price, cart_item.quantity,cart_item.include_service)\n cart_item.delete \n end\n @order.save\n @order.update_columns(address_id: @customer.cart.address_id, customer_id: @customer.id, active: true, additional_info: order_params[:additional_info],appointment_time: @customer.cart.appointment_time)\n @customer.cart.delete \n @customer.send_order_confirmation_mail(@order)\n redirect_to action: 'show', id: @order\n else\n redirect_back_or(root_url, notice: @extra_cart_items+\" can not be served at #{@customer.cart.address.city}\")\n end \n else\n redirect_back_or(root_url, notice: 'Empty Cart.')\n end\n else\n redirect_back_or(root_url, notice: 'Kindly select service address')\n end \n end", "def apply_clearance(cart)\n counter = 0\n while counter < cart.length\n if cart[counter][:clearance]\n cart[counter][:price] = (cart[counter][:price] * 0.8).round(2)\n end\n counter += 1\n end\n cart\nend", "def consolidate_cart(cart)\n i = 0\n cons_cart = [] #will be a new array that represents the cart with the item counts\n while i < cart.length do\n in_cart = find_item_by_name_in_collection(cart[i][:item],cons_cart)\n if in_cart != nil\n in_cart[:count] += 1\n else\n in_cart = {\n :item => cart[i][:item],\n :price => cart[i][:price],\n :clearance => cart [i][:clearance],\n :count => 1\n }\n cons_cart << in_cart\n end\n i += 1\n end\n cons_cart\nend", "def ensure_cart\n @cart = Order.find_by(id: session[:order_id])\n\n if @cart.nil?\n @cart = Order.make_cart\n session[:order_id] = @cart.id\n end\n\n if @cart.nil?\n flash[:error] = \"A problem occurred. The shopping cart could not be found.\"\n redirect_to root_path\n end\n\n @cart.status = \"pending\"\n @cart.save\n end", "def consolidate_cart(cart)\nindex = 0\nnew_cart = []\n\nwhile index < cart.length do\n item = find_item_by_name_in_collection(cart[index][:item],new_cart)\n if item\n new_cart_index = 0\n while new_cart_index < new_cart.length do\n if new_cart[new_cart_index][:item]===item[:item]\n new_cart[new_cart_index][:count]+=1\n end\n new_cart_index+=1\n end\n else \n cart[index][:count] = 1\n new_cart << cart[index]\n end\n index+=1\nend\nnew_cart\nend", "def update_snack_queue\n\n order_ids = params[:undelivered_order_ids]\n cart_ids = params[:cart_ids]\n @subscription_id = params[:subscription_id]\n\n orders = []\n @all_carts_full = Cart.is_carts_full?(cart_ids)\n\n if @all_carts_full\n\n order_ids.each do |key, order_id|\n orders.push(order_id)\n order = Spree::Order.where(id: order_id).first\n cart = Cart.where(id: cart_ids[key.to_i]).first\n order_line_items = cart.get_line_items_for_order\n order.pack_line_items(order_line_items, current_user.id, \"USD\", request.remote_ip)\n order.update_total_and_item_total\n #cart.destroy\n end\n\n order = Spree::Order.where(id: order_ids[\"0\"]).first\n result = queue_update_mail_params(order)\n VeganMailer.snack_queue_update_mail(result).deliver\n\n else\n\n end #end of complete if condition.\n end", "def completed\n\n #@order = current_order\n \n posted_xml = params[:ROMANCARTXML]\n\n # Remove XHTML character encoding (hopefully won't need to do this when we receive XML message from RomanCart!)\n xml = posted_xml.sub(\"<?xml version='1.0' encoding='UTF-8'?>\", \"\")\n \n xml_doc = Nokogiri::XML(xml) \n \n total_price = xml_doc.xpath(\"/romancart-transaction-data/sales-record-fields/total-price\").first.content\n orders = Spree::Order.where(\"state = ? AND total = ?\", \"cart\",total_price)\n Rails.logger.info \"#{orders.count} orders in 'cart' state with a price of #{total_price}\"\n \n if orders.count == 0\n # 5/3/14 DH: Testing ROMANCARTXML feedback locally so price is something...\n orders = Spree::Order.where(\"state = ? AND total > ?\", \"cart\",\"0.00\")\n end\n\n @order = orders.last\n \n # 6/3/14 DH: Since CSRF checking is removed for ROMANCARTXML feedback then need to check 'storeid' + items match\n if @order and feedbackValid(xml_doc,@order)\n Rails.logger.info \"Order number selected: #{@order.number}\"\n \n @order.email = xml_doc.xpath(\"/romancart-transaction-data/sales-record-fields/email\").first.content\n \n @order.user_id = xml_doc.xpath(\"/romancart-transaction-data/orderid\").first.content\n \n @order.number = xml_doc.xpath(\"/romancart-transaction-data/orderid\").first.content\n #Rails.logger.info \"Keeping Spree Order number rather than taking RomanCart one\"\n \n #flash[:message] = \"Order number taken from current time!\"\n #@order.number = Time.now.to_i.to_s\n \n # ----------------------- Billing Address -------------------------------\n @order.bill_address = romancartAddress(xml_doc)\n # ----------------------- Delivery Address ------------------------------ \n #<delivery-address1/>\n if xml_doc.xpath(\"/romancart-transaction-data/sales-record-fields/delivery-address1\").first.content.empty?\n @order.use_billing = true\n else\n @order.ship_address = romancartAddress(xml_doc, \"delivery-\")\n end\n \n # Spree StateMachine = 1)cart -> 2)address -> 3)delivery -> 4)payment -> 5)confirm -> 6)complete\n\n # If the order is just for samples then it'll be free so no payment is required\n if @order.item_total == 0\n \n while @order.state != \"complete\"\n @order.next!\n end\n \n else\n \n while @order.state != \"payment\"\n @order.next!\n Rails.logger.info \"Order number '#{@order.number}' is in state:#{@order.state}\" \n end\n \n #if xml_doc.xpath(\"/romancart-transaction-data/paid-flag\").first.content.eql?(\"True\")\n if xml_doc.xpath(\"/romancart-transaction-data/paid-flag\").first.content.eql?(\"False\")\n Rails.logger.info \"Testing ROMANCARTXML feedback using cheque payment so '<paid-flag>False</paid-flag>'\"\n\n unless @order.payments.exists?\n # 5/3/14 DH: Previously this worked for 'spree-2.0.4' but the payments system was changed in 'spree-2.1'\n #@order.payments.create!(:amount => @order.total)\n #@order.payments.last.payment_method = Spree::PaymentMethod.find_by_name(\"RomanCart\")\n #@order.payments.last.complete\n\t \n # 5/3/14 DH: Taken this from 'spree/2-1-stable/api/app/models/spree/order_decorator.rb' \n payment = @order.payments.build\n payment.amount = @order.total\n payment.complete\n payment.payment_method = Spree::PaymentMethod.find_by_name(\"RomanCart\")\n payment.save!\n\t \n if @order.payments.last.payment_method\n Rails.logger.info \"Creating #{@order.payments.last.payment_method.name} payment of #{@order.total}\"\n else\n Rails.logger.info \"RomanCart payment method not found!\"\n end\n end\n \n \n @order.payment_total = @order.total\n\n # To 6 - Complete\n #@order.payment_state = \"paid\"\n updater = Spree::OrderUpdater.new(@order)\n updater.update_payment_state\n \n @order.state = \"complete\"\n @order.completed_at = Time.now\n @order.save!\n Rails.logger.info \"Order number '#{@order.number}' is in state:#{@order.state}\"\n end\n end\n\n else # No current order (prob because of the CSRF error preventing Devise access the current order session)\n Rails.logger.info \"Well that's what Devise does since there's no CSRF authenticy...doh!\"\n end\n\n end", "def create\n # Find associated product and current cart\n chosen_cabinet = CabConfig.find(params[:cab_config_id])\n current_cart = @current_cart\n \n # If cart already has this product then find the relevant line_item and iterate quantity otherwise create a new line_item for this product\n if current_cart.cab_configs.include?(chosen_cabinet)\n # Find the line_item with the chosen_product\n @cart_item = current_cart.cart_items.find_by(cab_config_id: chosen_cabinet)\n # Iterate the line_item's quantity by one\n @cart_item.quantity += 1\n else\n @cart_item = CartItem.new\n \n @cart_item.cart = current_cart\n @cart_item.cab_config = chosen_cabinet\n end\n \n\n # Save and redirect to cart show path\n @cart_item.save\n redirect_to cart_path(current_cart)\n end", "def create\n # Find the item in the user's cart, if the user does not already\n # have the item in their cart, create a new line_item\n current_item = LineItem.find_or_create_by product_size_id: params[:product_size_id], cart_id: @cart.id\n\n # Increment the item's quantity by one\n requested_qty = current_item.quantity + 1\n\n # Invoke method in line_item.rb that checks the\n # requested qty against current stock levels\n update_qty = current_item.get_update_qty requested_qty\n\n # If the user's requested quantity can not be fulfilled, set a flash error\n unless update_qty == requested_qty\n flash[:item_error] = \"Sorry, not enough stock. Your shopping basket has been adjusted accordingly.\"\n end\n\n # Save the line_item update\n current_item.update quantity: update_qty\n\n # Redirect to My Basket page\n redirect_to cart_path\n end", "def sync_all_orders_qoo10(orders)\n @message = []\n @cart_numbers = []\n begin\n orders.each do |ord|\n if !ord.products.present?\n @order = nil\n @shpping_address = nil\n @billing_address = nil\n @is_customer_pickup = nil\n order = ord.market_place_details\n @order = Spree::Order.find_by_market_place_order_no(order[\"orderNo\"]) if order.present?\n if @order.present? && order.present?\n gift = order[\"Gift\"].present? ? false : true\n shipping_country = Spree::Country.find_by_iso(order[\"shippingCountry\"])\n billing_country = Spree::Country.find_by_iso(order[\"senderNation\"])\n name = order[\"receiver\"].present? ? order[\"receiver\"] : (order[\"buyer\"].present? ? order[\"buyer\"] : \"NA\")\n telno = order[\"receiverTel\"].present? ? order[\"receiverTel\"] : (order[\"buyerTel\"].present? ? order[\"buyerTel\"] : \"NA\")\n mobileno = order[\"receiverMobile\"].present? ? order[\"receiverMobile\"] : (order[\"buyerMobile\"].present? ? order[\"buyerMobile\"] : \"NA\")\n if order[\"OrderType\"] == \"Pickup\"\n @is_customer_pickup = true\n # our singapore warehouse address\n address1 = \"151 Pasir Panjang Road\"\n address2 = \"#02-02 Pasir Panjang Distripark\"\n zipcode = \"118480\"\n phone = \"+65 6271 0524\"\n @order.shipping_address.update_attributes(:firstname=> name, :lastname=> name, :address1=> address1, :address2=> address2,\n :city=> shipping_country.name, :zipcode=> zipcode, :phone=> phone, :alternative_phone=> \"\", :country_id=> shipping_country.id,\n :state_name=> shipping_country.name)\n if order[:Addr1].present?\n @order.billing_address.update_attributes(:firstname=> name, :lastname=> name, :address1=> order[\"Addr1\"], :address2=> order[\"Addr2\"],\n :city=> shipping_country.name, :zipcode=> order[\"zipCode\"], :phone=> telno, :alternative_phone=> mobileno, :country_id=> shipping_country.id,\n :state_name=> shipping_country.name)\n end\n else\n @is_customer_pickup = false\n @order.shipping_address.update_attributes(:firstname=> name, :lastname=> name,\n :address1=> order[\"Addr1\"], :address2=> order[\"Addr2\"],\n :city=> shipping_country.name, :zipcode=> order[\"zipCode\"],\n :phone=> telno, :alternative_phone=> mobileno,\n :country_id=> shipping_country.id, :state_name=> shipping_country.name)\n end\n if !order[\"senderName\"].present? && !order[\"senderAddr\"].present? && !order[\"senderNation\"].present? && !order[\"senderZipCode\"].present? && !order[\"senderTel\"].present? && !billing_country.nil?\n @order.billing_address.update_attributes(:first_name=> order[\"senderName\"], :lastname=>\"\",\n :address1=> order[\"senderAddr\"], :address2=>\"\",\n :city=> billing_country.name, :zipcode=> order[\"senderZipCode\"],\n :phone=> order[\"senderTel\"], :alternative_phone=>\"\",\n :country_id=> billing_country.id, :state_name=> billing_country.name)\n end\n billing_address = (!@order.billing_address.nil? && !@order.billing_address.blank?) ? @order.billing_address.id : nil\n @mp_product = nil\n @line_item = nil\n @stock = nil\n @mp_product = Spree::SellersMarketPlacesProduct.find_by_market_place_product_code(order[\"itemCode\"])\n @order.update_attributes(:number=> order[\"orderNo\"], :order_date=> order[\"PaymentDate\"], :item_total=> order[\"orderPrice\"],\n :total=> order[\"total\"], :payment_total=> order[\"total\"],\n :email=> order[\"buyerEmail\"], :currency=> order[\"Currency\"],\n :send_as_gift=> gift, :market_place_id=> @mp_product.present? ? @mp_product.market_place_id : nil,\n :market_place_order_no=> order[\"orderNo\"],\n :bill_address_id=> billing_address, :ship_address_id=> @order.shipping_address.id)\n #@order.adjustments.first.update_attributes(:amount=> -order[\"discount\"].to_f, :label=> \"discount\") if @order && @order.adjustments.present? && order[\"discount\"].to_f != 0.0\n if @mp_product.present? && @order.present?\n if order[\"option\"] == \"\"\n # options not present i.e. for product\n @variant = Spree::Variant.find_by_sku(@mp_product.product.sku)\n if !@mp_product.nil? && !@mp_product.blank? && !@variant.nil? && !@variant.blank?\n @line_item = Spree::LineItem.create!(:variant_id=> @variant.id, :order_id=> @order.id, :quantity=> order[\"orderQty\"].to_i, :price=> order[\"orderPrice\"], :currency=> order[\"Currency\"], :is_pick_at_store => @is_customer_pickup)\n @stock = @mp_product.product.stock_products.first\n end\n else\n # options are present i.e. for variant\n #option_arr = order[\"option\"].split(\"(\")[0].split(\":\")\n option_arr = order[:option].split(\":\")\n if option_arr[1].split(\"(+\").count > 1\n option_arr[1] = option_arr[1].split(\"(+\")[0]\n elsif option_arr[1].split(\"(-\").count > 1\n option_arr[1] = option_arr[1].split(\"(-\")[0]\n end\n @variant = nil\n @mp_product.product.variants.each do |v|\n @variant = v if !v.option_values.blank? && (v.option_values.map(&:presentation).include?option_arr[1].strip)\n end if !@mp_product.nil? && @mp_product.product && @mp_product.product.option_types && !@mp_product.product.option_types.blank? && (@mp_product.product.option_types.map(&:presentation).include?option_arr[0])\n if !@mp_product.nil? && !@mp_product.blank? && !@variant.nil? && !@variant.blank?\n @line_item = Spree::LineItem.create!(:variant_id=> @variant.id, :order_id=> @order.id, :quantity=> order[\"orderQty\"].to_i, :price=> order[\"orderPrice\"], :currency=> order[\"Currency\"], :is_pick_at_store => @is_customer_pickup)\n @stock = @mp_product.product.stock_products.where(\"variant_id=?\", @variant.id).first\n end\n end\n # to reduce the stock after placing the order\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[\"orderQty\"].to_i) >= 0 ? (@stock.count_on_hand - order[\"orderQty\"].to_i) : 0 ) if @stock\n # code to reduce the kit quantity after order placed for kit as product\n @product = @mp_product.product\n if @product.kit.present? && @product.present?\n @product.kit.update_attributes(:quantity => @product.kit.quantity - order[\"orderQty\"].to_i)\n end\n # reload the order object\n @order.reload\n # add cart number into array\n @cart_numbers << order[\"packNo\"]\n end\n end\n @message << (@order && @order.present? ? (@order.market_place_order_no.to_s+\": \"+ \"Success\") : nil)\n end # end of if product does not exist\n end # end of orders loop\n rescue Exception => e\n @message << e.message\n end\n # take only unique cart number from array\n @cart_numbers = @cart_numbers.uniq\n # pass the array to method which can clubbed the orders according to cart number and then push to FBA\n @message << \"FBA: \"+ Spree::Order.push_to_fba(@cart_numbers)\n return @message.join(\"; \")\n end", "def apply_coupons(cart, coupons)\ni = 0\nwhile i<coupons.length\n cart_item = find_item_by_name_in_collection(coupons[i][:item], cart)\n couponed_item_name = \"#{coupons[i][:item]} W/COUPON\"\n cart_item_with_coupon = find_item_by_name_in_collection(couponed_item_name, cart)\n if cart_item && cart_item[:count] >= coupons[i][:num]\n if cart_item_with_coupon\n cart_item_with_coupon[:count] += coupons[i][:num ]\n cart_item -= coupons[i][:num]\n else\n cart_item_with_coupon =\n { :item=>couponed_item_name,\n :price=>coupons[i][:cost] / coupons[i][:num],\n :count => coupons[i][:num],\n :clearance=>cart_item[:clearance]\n }\n cart << cart_item_with_coupon\n cart_item[:count] -= coupons[i][:num]\n\n end\n\n end\n i += 1\nend\ncart\nend", "def increment_units\n contents.each do |key,content|\n id = content[\"_id\"] || content[\"item_id\"]\n begin\n \n product = shop.products.find(id)\n return false if product.nil? || product.dont_track_quantities?\n\n new_pv = []\n\n if product.price_variants.length==1\n\n new_pv = product.price_variants.first\n new_pv['quantity'] = new_pv['quantity'].to_i+content['quantity'].to_i\n product.num_orders = [product.num_orders-content['quantity'].to_i].max\n product.price_variants = [ new_pv ]\n\n else\n\n product.price_variants.each do |pv|\n name = [pv['primary'],pv['secondary']].join(\" \").downcase.trim\n name = \"\" if name==\" \"\n if name==content['variant_name'].trim.downcase && !pv['quantity'].blank?\n new_pv << pv.merge( 'quantity' => (pv['quantity'].to_i+content['quantity'].to_i) )\n else \n new_pv << pv\n end\n end\n product.num_orders = [product.num_orders-content['quantity'].to_i].max\n product.price_variants = new_pv\n\n end\n product.save\n\n rescue Exception => e\n ::Exceptional::Catcher.handle(e)\n # raise(e)\n end\n end\n end", "def apply_clearance(cart)\n cart.each do |item_name, item_info|\n item_info.each do |key, value|\n if key == :clearance\n if value == true\n cart[item_name][:price] = (cart[item_name][:price] * 0.8).round(3)\n end\n end\n end\n end\n return cart\nend", "def apply_coupons(cart, coupons)\n coupons.each do |coupon|#for each coupon...\n coupon_item = coupons[coupon][:item]\n if cart[coupon_item][:count] >= coupons[coupon][:num] #if there are at least enough items for the coupon to be applied...\n new_price = coupons[coupon][:cost] / coupons[coupon][:num] #calculate the discounted price for the item\n remaining_full_price = cart[coupon_item][:count] % coupons[coupon][:num] #calculate the number of items remaining at full price\n coupon_applied = cart[coupon_item][:count] - remaining_full_price #calculate the number of items that will have the discounted price applied\n cart[\"#{coupon_item} W/COUPON\"] = {:price => new_price, :clearance => true, :count => coupon_applied} #create new discounted item\n cart[coupon_item][:count] = remaining_full_price #change the previous cart number to the number remaining\n if cart[coupon_item][:count] == 0 #if there are no full price items left...\n cart.delete(coupon_item) #delete the full price item hash from the cart\n end\n else\n false\n end\n end\n cart #return the new cart with coupons applied\nend", "def apply_clearance(cart)\n index = 0 \n while index < cart.length do\n if cart[index][:clearance] == true\n cart[index][:price] = (cart[index][:price] * 0.8).round(2)\n end\n index += 1\n end\n cart\nend", "def update\n @order.earliest_pickup_date = calculate_earliest_pickup_date(:update)\n # Save off original quantity for order_products\n original_quantities = {}\n @order.order_products.each { |order_product| original_quantities[order_product.id] = order_product.quantity }\n respond_to do |format|\n if @order.update(order_params)\n okay = true\n @order.order_products.each do |order_product|\n new_quantity = order_product.quantity\n original_quantity = original_quantities[order_product.id]\n unless (new_quantity == original_quantity)\n product = order_product.product\n new_quantity_in_stock = (product.quantity_in_stock + original_quantity - new_quantity)\n if new_quantity_in_stock < 0 # Desired quantity no longer available\n okay = false if okay\n # Update the order the best we can and notify user of discrepancy\n new_quantity_in_stock = 0\n # The original quantity was already subtracted from the stock; quantity should never have to decrease below what was previously ordered\n new_quantity = original_quantity + product.quantity_in_stock\n order_product.update_attributes(quantity: new_quantity)\n end\n product.update_attributes(quantity_in_stock: new_quantity_in_stock)\n end\n end\n redirect_to(edit_order_path(@order), notice: t('orders.not_available')) and return if (!okay) # \"One or more of the products you selected is not available in the desired quantity. Please review the updated order.\"\n if session[:showing_user]\n format.html { redirect_to @order.user, notice: t('orders.create') } # \"Order was successfully updated.\"\n format.json { head :no_content }\n else\n format.html { redirect_to orders_path, notice: t('orders.create') } # \"Order was successfully updated.\"\n format.json { head :no_content }\n end\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def perform\n update_null = \" or (stock is null and last_stock_reported_centry is not null)\"\n query = \"stock <> last_stock_reported_centry or ((stock is not null and last_stock_reported_centry is null)#{update_null if ENV[\"UPDATE_NULL_STOCK\"] == \"false\"})\"\n\n ::Product.where(query).each do |local_product|\n resp = centry.put('/conexion/v1/variants/sku.json', {}, {\"sku\": local_product[:sku], \"quantity\": local_product[:stock]})\n if (resp.code == \"200\")\n centry_variant_info = JSON.parse(resp.body)\n local_product[:last_stock_reported_centry] = centry_variant_info[\"quantity\"]\n local_product[:id_product_centry] = centry_variant_info[\"product_id\"]\n local_product.save!\n end\n end\n end", "def create\n @order = Order.new(params[:order])\n @order.user_id = current_user.id\n @order.add_line_items_from_cart(current_cart)\n #logger.debug \"New order: #{@order.attributes.inspect}\"\n #logger.debug \"Order should be valid: #{@order.valid?}\"\n\n respond_to do |format|\n if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.html { redirect_to(store_url, :notice =>\n 'Thank you for your order.') }\n format.xml { render :xml => @order, :status => :created,\n :location => @order }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors,\n :status => :unprocessable_entity }\n end\n end\n end", "def issue_unissue_po_line_items_when_so_and_cart_diffs(issue_cart)\n logger.debug \"==@@@@==SalesOrder: issue unissue(), issuce_cart.id==== #{issue_cart.id}\"\n # so line_items not in cart(will be removed), issueback po\n self.line_items.each do |so_line|\n if not issue_cart.line_items.where(line_number: so_line.line_number).exists?\n logger.debug \"==@@@@==line_items to be removed from so==== #{so_line.id}\"\n self.issue_back_refer_line_item(so_line, so_line.quantity)\n end\n end\n\n # cart line_items not in so(will be added), issue po\n issue_cart.line_items.each do |line_item|\n # cart line_items not in so: to be added to so\n if not self.line_items.where(line_number: line_item.line_number).exists?\n logger.debug \"==@@@@==new line, to be added to so==== #{line_item.id}\" \n self.issue_refer_line_item(line_item, line_item.quantity) \n else # exist, but quantity different\n line = self.line_items.where(line_number: line_item.line_number).take\n logger.debug \"==@@@@==exsit line, update po==== #{line_item.id}\"\n if line.quantity < line_item.quantity\n self.issue_refer_line_item(line_item, line_item.quantity - line.quantity)\n elsif line.quantity > line_item.quantity\n self.issue_back_refer_line_item(line_item, line.quantity - line_item.quantity) \n end\n end\n end\n end", "def consolidate_cart(cart)\n new_cart = []\n counter = 0 \n while counter < cart.length do \n new_cart_item = find_item_by_name_in_collection(cart[counter][:item], new_cart)\n #We want to figureout if item is in our new cart \n #This method checks to see if the item we're looking for is in the new cart. Takes in items name and collection or cart. :item key points to name of the item. \n # This will either return the item or it will retrun nil. RETURNS THE ITEM OR RETURNS NIL\n #This above code produces nil or cart[counter], per the above method. If nil is prodcued then a new hash called new_cart_item is added to the new array with a new hash called :count.\n #If it already exist, the counter is incremented by one. \n #My question is, what is new_cart_item \n\nif new_cart_item \n #If this has a truthy value, do whats below. New_cart_item is the item!!! It will be truthy if it is in the array. If in the array, we will just incremement count by 1. And do this every time this item comes up. \n new_cart_item[:count] += 1 \n else new_cart_item = { \n #Else is all other options. Either truthy of falsey. If new_cart_item returns nil, then we will do below. Which is creating our item. Creating a new hash, which is the same hash with :count added. So you can say, if this is not already in our array, which will produce nil, we will add :count to the array and and put it into the new array. We will give it a count of 1. Once its been built the count will be incremented by one for each time the item is in the old cart.\n:item => cart[counter][:item], \n:price => cart[counter][:price],\n:clearance => cart[counter][:clearance],\n:count => cart[counter][:count] = 1 \n }\nnew_cart<< new_cart_item\nend \ncounter += 1 \nend\nnew_cart \n\nend", "def apply_clearance(cart)\n new_cart = cart\n cart.each do |name, hash|\n if hash[:clearance] #if clearance is true, take 20% off\n new_cart[name][:price] = (cart[name][:price] * 0.8).round(2)\n \n end\n \n end\n new_cart #if not, just return the same cart\nend", "def create\n @cart = current_cart\n if @cart.items_in_cart.empty?\n redirect_to store_url, notice: \"Your cart is empty\"\n return\n end\n\n @order = Order.new(params[:order])\n # which user was involved\n @order.user = current_user.id\n # add every item from the cart to this order\n @order.add_items_from_cart(current_cart)\n # withdraw money from user\n current_user.pay(@order)\n # remember new balance\n new_balance = current_user.balance\n #logout user\n current_user_session.destroy\n #increase cleaning counter\n coffee_count = Settings.coffees_since_last_clean_up.to_i\n Settings.coffees_since_last_clean_up = coffee_count + @order.coffees_in_order\n\n respond_to do |format|\n if @order.save && current_user.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.html { redirect_to invoice_path(id: @order.id, balance: new_balance) }\n format.json { render json: @order, status: :created, location: @order }\n else\n @cart = current_cart\n format.html { redirect_to store_url, notice: 'Could not save order!' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def merge(cart)\n cart.orders.each do |order|\n (1..order.quantity).each { |c| add_product_by_sku(order.sku) }\n cart.remove_product_by_sku(order.sku)\n end\n end", "def place_order\n @order = Order.new(order_params)\n @basket.line_items.map do |line_item|\n @order.line_items << line_item\n item.basket_id = nil\n\n dish = Dish.find(line_item.dish_id)\n dish.inventory -= line_item.quantity\n dish.save\n end\n @order.save\n @basket.destroy\n render Dish.all, status: :ok\n end", "def create\n @order = Order.new(order_params)\n @cart = Cart.find(@order.cart_id)\n\n # @store_products = StoreProduct.all\n # @products = Product.all\n #\n # @store_product = StoreProduct.find(params[:store_product_id])\n # @product = Product.find(params[:product_id])\n #\n # @order.product_id = @product.id\n # @order.store_product_id = @store_product.id\n\n @order.store_product_id = @cart.line_items { |item| item.store_product.store_product_id}\n\n # respond_to do |format|\n if @order.save\n\n session[:cart_id] = nil\n\n # @cart.destroy\n # format.html { redirect_to @order, notice: 'Order was successfully created.' }\n # format.json { render :show, status: :created, location: @order }\n redirect_to '/'\n flash[:notice] = \"Order was successfully created.\"\n\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n # end\n end\n end", "def apply_coupons(cart, coupons)\n # binding.pry\n coupons.each do |coupon|\n item_in_cart = find_item_by_name_in_collection(coupon[:item], cart) \n cart_item_w_coupon = find_item_by_name_in_collection(coupon[:item] + \" W/COUPON\", cart)\n if cart_item_w_coupon && item_in_cart[:count] >= coupon[:num] \n cart_item_w_coupon[:count] += coupon[:num] \n item_in_cart[:count] -= coupon[:num] \n elsif item_in_cart && item_in_cart[:count] >= coupon[:num]\n cart << {\n :item => coupon[:item] + \" W/COUPON\",\n :price => coupon[:cost] / coupon[:num],\n :count => coupon[:num],\n :clearance => item_in_cart[:clearance]\n }\n item_in_cart[:count] -= coupon[:num]\n end \n end\n cart\nend", "def build\n my_order = nil\n if cart = user && user.cart\n Order.transaction do\n my_order = Order.create(user: user)\n my_order.products = cart.products\n cart.destroy\n end\n else\n error = Struct.new(:full_messages).new\n error.full_messages = [\"No cart to create order from\"]\n @errors = error\n end\n my_order\n end", "def update\n if @cart.update(order_params)\n flash[:success] = \"Your order has been placed successfully\"\n # order model method 'update_orderitem_status' changes the orderitems status from \"pending\" to \"paid\"\n @cart.update_orderitem_status\n # order model method 'update_product_stock' updates the inventory of the product ro reflect sale\n @cart.update_product_stock\n # updates the card_number stored in the databas -- only store last 4 digits\n @cart.update(card_number: @cart.card_number.split('').last(4).join)\n redirect_to confirm_path\n return\n else\n flash.now[:failure] = \"A problem occurred: Could not place order\"\n render :edit\n end\n end", "def create\n @order = Order.new(order_params)\n @order.add_line_items_from_cart(@cart)\n\n respond_to do |format|\n if @order.save \n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.html { redirect_to store_index_url, notice: 'Thank you come again!'}\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def populate\n\n\n\n#Cart limit set\n\n# @powerbeat_qty = 0\n# @variant = Spree::Product.find(23).variants\n# if(current_order)\n# current_order.line_items.each do |linevalidate|\n# @variant.each do |linevariants|\n# if (linevariants.id == linevalidate.variant_id)\n# @powerbeat_qty += linevalidate.quantity\n# #raise (\"Powerbeat_Qty: \" << @powerbeat_qty.to_yaml)\n# \t\t if(@powerbeat_qty >=2 )\n# flash.notice = 'You can not add more than 2 Powerbeat product'\n# end\n# \tend\n# \tend \n# end\n# end\n\t\n\npopulator = Spree::OrderPopulator.new(current_order(create_order_if_necessary: true), current_currency)\n\nif populator.populate(params[:variant_id], params[:quantity], params[:options])\n\nrespond_with(@order) do |format|\nformat.html { redirect_to cart_path }\nend\nelse\nflash[:error] = populator.errors.full_messages.join(\" \")\nredirect_back_or_default(spree.root_path)\nend\nend", "def apply_coupons(cart, coupons)\n counter = 0\n # doesn't break if there is no coupon\n while counter < coupons.length\n # check coupons to see if it matches any of our cart items\n cart_item = find_item_by_name_in_collection(coupons[counter][:item], cart)\n # does the coupon item exist in the cart? change name to add \"W/COUPON\"\n couponed_item_name = \"#{coupons[counter][:item]} W/COUPON\"\n cart_item_with_coupon = find_item_by_name_in_collection(couponed_item_name, cart)\n # checks if the item is in the cart and that the count satisfies the coupon reqs\n # doesn't break if the coupon doesn't apply to any items\n if cart_item && cart_item[:count] >= coupons[counter][:num]\n # can apply multiple coupons\n if cart_item_with_coupon\n cart_item_with_coupon[:count] += coupons[counter][:num]\n cart_item[:count] -= coupons[count][:num]\n else\n # adds the coupon price to the property hash of couponed item\n cart_item_with_coupon = {\n :item => couponed_item_name,\n # adds the coupon price to the property hash of couponed item\n :price => coupons[counter][:cost] / coupons[counter][:num],\n # adds the count number to the property hash of couponed item\n :count => coupons[counter][:num],\n # remembers if the item was on clearance\n :clearance => cart_item[:clearance]\n }\n cart << cart_item_with_coupon\n # removes the number of discounted items from the original item's count\n cart_item[:count] -= coupons[counter][:num]\n end\n end\n counter += 1\n end\n cart\nend", "def checkout\n #@carts.each do |c|\n @order = Order.new\n @order.item_ordered = params[:itemid]\n @order.user_id = params[:user_id] \n @order.orderdate = Datetime.now\n @order.save\n #end\n end", "def apply_coupons(cart, coupons)\n i = 0\n while i < coupons.length\n item = find_item_by_name_in_collection(coupons[i][:item],cart)\n coupon_item = \"#{coupons[i][:item]} W/COUPON\"\n cart_item_coupon = find_item_by_name_in_collection(coupon_item, cart)\n #binding.pry\n if item && item[:count] >= coupons[i][:num] #if its elgible for a coupon, apply it!\n if cart_item_coupon\n cart_item_coupon[:count] += coupons[i][:num]\n item[:count] -= coupons[i][:num]\n else\n cart_item_coupon = {\n :item => coupon_item,\n :price => coupons[i][:cost]/coupons[i][:num],\n :count => coupons[i][:num],\n :clearance => item[:clearance]\n }\n cart << cart_item_coupon\n item[:count] -= coupons[i][:num]\n #binding.pry\n end\n end\n i += 1\n end\n cart\nend", "def purchase\n @cart_items = CartItem.where(cart: Cart.last)\n \n @cart_items.each do |cart_item|\n @product = cart_item.product\n if (@product.inventory_count > 0)\n cart_item.product.update(title: @product.title, \n description: @product.description,\n price: @product.price,\n inventory_count: @product.inventory_count - cart_item.quantity)\n cart_item.destroy\n else\n flash[:notice] = \"Item in cart had no inventory left\"\n next\n end\n end\n if @cart = Cart.last\n @cart.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Cart was successfully purchased.'}\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_to products_url, notice: \"A cart must exist for products to be added to\" }\n format.json { head :no_content }\n end\n end\n Cart.create()\n end", "def update\n order_changed = false\n @errors = Array.new #holds error objects\n @line_items = Array.new #holds existing_line items in case of errors\n line_items = params[:line_items]\n #Loop through @line_items first to validate but NOT to persist. If any is invalid, then render the order edit\n #view to display @errors without saving. Otherwise save them and redirect to order show page.\n \n line_items.each do |li|\n line_item = LineItem.new(li)\n if ! li[:id].empty? #has value for id\n existing_line_item = LineItem.find(li[:id]) #line item already exists\n if line_item.quantity == 0 || line_item.quantity.nil? #quantity changed to 0\n #existing_line_item.destroy\n #order_changed = true\n @line_items << existing_line_item\n elsif existing_line_item.quantity == line_item.quantity #quantity not changed\n #do nothing if quantity not changed\n @line_items << existing_line_item\n else #quantity changed to something other than 0\n #existing_line_item.update_attributes(li)\n @errors << line_item.errors if line_item.invalid?\n @line_items << existing_line_item\n #order_changed = true\n end\n elsif line_item.quantity != 0 && line_item.id.nil? && ! line_item.quantity.nil? #line item does not already exist, so need to create a new one\n #@line_item = line_item\n line_item.order_id = params[:order_id]\n #@line_item.save\n #order_changed = true\n @errors << line_item.errors if line_item.invalid?\n @line_items << line_item\n else\n @line_items << line_item\n end\n end #each to validate\n if ! @errors.empty?\n @order = Order.find(params[:order_id])\n render \"orders/edit\"\n else\n line_items.each do |li|\n line_item = LineItem.new(li)\n if ! li[:id].empty? #has value for id\n existing_line_item = LineItem.find(li[:id]) #line item already exists\n if line_item.quantity == 0 || line_item.quantity.nil? #quantity changed to 0\n existing_line_item.destroy\n order_changed = true\n elsif existing_line_item.quantity == line_item.quantity #quantity not changed\n #do nothing if quantity not changed\n else #quantity changed to something other than 0\n existing_line_item.update_attributes(li)\n \n order_changed = true\n end\n elsif line_item.quantity != 0 && line_item.id.nil? && ! line_item.quantity.nil? #line item does not already exist, so need to create a new one\n line_item = line_item\n line_item.order_id = params[:order_id]\n line_item.save\n order_changed = true\n end\n end #each to save\n \n UserMailer.send_invoice(current_user, Order.find(params[:order_id]), true).deliver if order_changed\n notice = order_changed ? 'Order was successfully updated' : 'Order was not changed'\n redirect_to Order.find(params[:order_id]), notice: notice\n end\n end", "def proceed_to_checkout\n \n order = Order.new\n order.cart_id = @cart.id\n order.responseCode = 100\n order.responseDescription = \"Tests added to your account.\"\n order.save!\n \n cart = Cart.find(order.cart_id)\n \n # Add each cartitem to user's account.\n cart.cart_items.each do | cart_item |\n if cart_item.quiz_id != nil\n # Add Quiz\n quiz_user = QuizUser.new\n quiz_user.quiz_id = cart_item.quiz_id\n quiz_user.user_id = current_user.id\n quiz_user.save!\n end\n end\n \n redirect_to homes_index_path, notice: \"Test added to your account.\"\n end", "def apply_coupons(cart, coupons)\n new_cart = []\n cart.each do |grocery_item|\n modified = false\n\n coupons.each do |coupon_item|\n if grocery_item[:item] == coupon_item[:item] && grocery_item[:count] >= coupon_item[:num]\n\n discount_item = {\n :item => \"#{grocery_item[:item].upcase} W/COUPON\",\n :price => coupon_item[:cost] / coupon_item[:num],\n :clearance => grocery_item[:clearance],\n :count => coupon_item[:num]\n }\n grocery_item[:count] -= coupon_item[:num]\n\n new_cart.push(discount_item)\n new_cart.push(grocery_item)\n modified = true\n end\n end\n if !modified\n new_cart.push(grocery_item)\n end\n end\n new_cart\nend", "def add_package_to_customer_cart\n # get params\n @package_id = params[:id]\n @customer_drink_quantity = params[:quantity].to_i\n \n # get drink info\n if user_signed_in?\n @user = current_user\n else\n # first create an account\n @account = Account.create!(account_type: \"consumer\", number_of_users: 1)\n \n # next create fake user profile\n @fake_user_email = Faker::Internet.unique.email\n @generated_password = Devise.friendly_token.first(8)\n \n # create new user\n @user = User.create(account_id: @account.id, \n email: @fake_user_email, \n password: @generated_password,\n password_confirmation: @generated_password,\n role_id: 4,\n getting_started_step: 0,\n unregistered: true)\n \n if @user.save\n # Sign in the new user by passing validation\n bypass_sign_in(@user)\n #Rails.logger.debug(\"Current user: #{current_user.inspect}\")\n end\n end #end of check whether user is already \"signed in\"\n \n @special_package = SpecialPackage.find_by_id(@package_id)\n \n # find if customer currently has an order in process\n @current_order = OrderPrep.where(account_id: @user.account_id, status: \"order in process\").first\n \n if @current_order.blank? # create a new Order Prep entry\n @current_order = OrderPrep.create!(account_id: @user.account_id, status: \"order in process\")\n end\n \n # now check if this inventory item already exists in the Order Drink Prep table\n @current_drink_order = OrderDrinkPrep.where(user_id: @user.id,\n order_prep_id: @current_order.id,\n special_package_id: @package_id)\n \n if !@current_drink_order.blank? #update entry\n if @customer_drink_quantity != 0\n @current_drink_order.update(quantity: @customer_drink_quantity)\n else\n @current_drink_order[0].destroy!\n end\n else # create a new entry\n OrderDrinkPrep.create!(user_id: @user.id,\n account_id: @user.account_id,\n special_package_id: @package_id,\n order_prep_id: @current_order.id,\n quantity: @customer_drink_quantity,\n drink_price: @special_package.actual_cost)\n end\n\n # find total drink number in cart\n @order_prep_info = OrderDrinkPrep.where(order_prep_id: @current_order.id)\n @customer_number_in_cart = @order_prep_info.sum(:quantity)\n # get total amount in cart so far\n @subtotal = @order_prep_info.sum( \"drink_price*quantity\" ) \n @sales_tax = @subtotal * 0.101\n @total_drink_price = @subtotal + @sales_tax\n\n # if all drinks have been removed, delete the order prep\n if @customer_number_in_cart.to_i == 0\n @current_order.destroy!\n else\n if @current_order.delivery_fee.nil?\n @grand_total = @total_drink_price\n else\n @grand_total = @current_order.delivery_fee + @total_drink_price\n end\n # update Order Prep with cost info\n @current_order.update(subtotal: @subtotal, \n sales_tax: @sales_tax, \n total_drink_price: @total_drink_price,\n grand_total: @grand_total)\n end\n \n # update page\n respond_to do |format|\n format.js\n end # end of redirect to jquery\n \n end", "def create\n @cart = current_cart\n @product = Product.find(params[:id])\n @order_item = @cart.order_items.build\n @order_item.product_id = @product.id\n #@order_item = OrderItem.create!(:cart => current_cart, :product => @product, :qty_ordered => params[:qty_ordered], :qty_ordered_price => @product.price)\n #@order_item = OrderItem.find_or_initialize_by_cart_id(:cart_id => current_cart.id, :cart => current_cart, :product => @product, :qty_ordered => params[:qty_ordered], :qty_ordered_price => @product.price)\n # @order_item = OrderItem.new\n # @order_item.cart_id = current_cart.id\n # @order_item.product_id = @product.id\n @order_item.qty_ordered = params[:qty]\n @order_item.qty_ordered_price = @product.price\n @order_item.save\n flash[:notice] = \"Added #{@product.name} to cart.\"\n redirect_to current_cart_url\n\n # @order = current_order\n # product = Product.find(params[:product_id])\n # # @order_item = OrderItem.new(params[:order_item]) Ian's line\n # @order_item = @order.add_product(product.id)\n \n # if Order.last == nil\n # @order_item.order_id = 1\n # else @order_item.order_id = Order.last.id + 1\n # end\n # @order_item.qty_ordered_price = @order_item.product.price\n\n # respond_to do |format|\n # if @order_item.save\n # format.html { redirect_to @order_item.order, notice: 'Order item was successfully created.' }\n # format.json { render json: @order_item, status: :created, location: @order_item }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @order_item.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @stock = Stock.new(stock_params)\n @stock.user_id = current_user.id # set user_id\n @item = Stock.where(\"user_id = ? and item_name = ?\" , current_user.id , @stock.item_name )\n @uom = Stock.where(\"user_id = ? and item_name = ? and unit_of_measure = ?\" , current_user.id , @stock.item_name , @stock.unit_of_measure)\n @stocks = Stock.where(\"user_id = ? and item_name = ? and unit_of_measure = ? and batch_number = ? \" , current_user.id , @stock.item_name , @stock.unit_of_measure , @stock.batch_number)\n time = Time.now.strftime(\"%Y-%m-%d\")\n respond_to do |format|\n if @stock.expiry_date <= Date.parse(time)\n format.html { redirect_to @stock, notice: 'Product is alreday expired, check the expiry date' }\n\n elsif @stock.quantity <= 0\n format.html { redirect_to @stock, notice: 'Quantity should be positive' }\n\n else\n if !@stocks.present?\n\n master = Master.where(\"item_name = ? and uom = ?\" , @stock.item_name , @stock.unit_of_measure)\n\n # if item is not in masters then consider it as personal item\n if master.present?\n # base is master's row with level = 1 , to get base uom\n base = Master.where(\"item_name = ?\" , @stock.item_name )\n base = base.where(\"level = ? \" , \"1\")\n uom = base.pluck(:uom)\n uom = uom[0]\n mrp = base.pluck(:mrp)\n mrp = mrp[0]\n # onlt if given unit_of_measure is base_uom(level=1)\n if uom.to_s == @stock.unit_of_measure.to_s\n price = @stock.quantity*mrp\n purchase=Purchase.create(user_id: current_user.id , wholesaler: \"Stock Correction\",item_name: @stock.item_name ,\n batch_number: @stock.batch_number ,unit_of_measure: uom ,\n expiry_date: @stock.expiry_date , quantity:@stock.quantity , date_of_purchase: time , total_price:price)\n\n # update in report\n report = Report.find_by(item_name: @stock.item_name , user_id: current_user.id)\n if report.present?\n report.value = (price + report.value*report.quantity)/(@stock.quantity + report.quantity)\n report.quantity = report.quantity + @stock.quantity\n report.save\n else\n report=Report.create(user_id:current_user.id , item_name:@stock.item_name,value:(price/(@stock.quantity)),\n quantity:@stock.quantity)\n end\n\n if @stock.save\n format.html { redirect_to @stock, notice: 'New Item has been successfully added.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n\n else\n format.html { redirect_to @stock, notice: 'Item from masters list is only allowed with base unit_of_measure(level=1)' }\n format.json { render :show, status: :created, location: @stock }\n end\n\n else\n # is personal item present in stock\n if @item.present?\n # only 1 uom is allowed for personal item\n if @uom.present?\n # find average value of product\n report = Report.find_by(item_name: @stock.item_name , user_id: current_user.id)\n price = @stock.quantity*report.value\n\n purchase=Purchase.create(user_id: current_user.id , wholesaler: \"Stock Correction\",item_name: @stock.item_name ,\n batch_number: @stock.batch_number ,unit_of_measure: @stock.unit_of_measure ,\n expiry_date: @stock.expiry_date , quantity:@stock.quantity , date_of_purchase: time , total_price:price)\n\n report.value = (price + report.value*report.quantity)/(@stock.quantity + report.quantity)\n report.quantity = report.quantity + @stock.quantity\n report.save\n\n if @stock.save\n format.html { redirect_to @stock, notice: 'New Item has been successfully added.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n\n else\n # as defined Personal item with only one unit_of_measure is allowed\n format.html { redirect_to @stock, notice: 'Personal item with only one unit_of_measure is allowed' }\n format.json { render :show, status: :created, location: @stock }\n end\n\n else\n purchase=Purchase.create(user_id: current_user.id , wholesaler: \"Stock Correction\",item_name: @stock.item_name ,\n batch_number: @stock.batch_number ,unit_of_measure: @stock.unit_of_measure ,\n expiry_date: @stock.expiry_date , quantity:@stock.quantity , date_of_purchase: time , total_price:0)\n\n report=Report.create(user_id:current_user.id , item_name:@stock.item_name,value:0,\n quantity:@stock.quantity)\n\n if @stock.save\n format.html { redirect_to @stock, notice: 'New Item has been successfully added.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n\n end\n end\n else\n format.html { redirect_to @stock, notice: 'Item with corresponding unit_of_measure and batch number already exist.' }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def prepare_cart_items(variant_id)\n self.update_attributes(variant_id: variant_id, quantity: 1)\n end", "def create\n # if user is not logged_in\n if cart_product_params[:user_id].empty?\n session[:temp_cart] = cart_product_params\n redirect_to login_path, :notice => \"Please log in, the product will be placed in your cart once you've logged in.\"\n else\n @cart_product = CartProduct.new(cart_product_params)\n respond_to do |format|\n if cart_product_params[:quantity].to_i > 0\n if @cart_product.save\n format.html { redirect_to request.referrer, notice: \"Added to Cart. Please go to your cart to pay for your items!\" }\n format.json { render :show, status: :created, location: @cart_product }\n \n # Then remove from savedlist\n session[:savedlist] ||= []\n session[:savedlist].delete(cart_product_params[:product_id])\n \n # update admin stats\n saved_products_stats(cart_product_params[:product_id], -1)\n \n # Then update popularity of product\n increase_product_popularity_by_product_id(cart_product_params[:product_id])\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @cart_product.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to request.referrer, notice: \"Quantity cannot be 0 or less!.\" }\n end\n end\n end\n end", "def apply_coupons(cart, coupons)\n coupons.each do |coupon|\n item = coupon[:item] #avocado, cheese,...\n coupon_item=\"#{item} W/COUPON\"\n if cart.has_key?(item) \n if cart[item][:count] >= coupon[:num]\n if !cart[coupon_item] \n cart[coupon_item] ={count: coupon[:num], price: coupon[:cost]/ coupon[:num], clearance: cart[item][:clearance] }\n else\n cart[coupon_item][:count] += coupon[:num]\n end\n cart[item][:count] -= coupon[:num] \n end\n end\n end\n cart\nend", "def apply_clearance(cart)\n counter = 0\n while counter < cart.length\n if cart[counter][:clearance] \n cart[counter][:price] = (cart[counter][:price] - (cart[counter][:price] * 0.20)).round(2)\n end\n counter += 1\n end\n cart\nend", "def test_check_inventory\n # Create a cart and add some products.\n a_cart = Order.new\n a_cart.add_product(items(:red_lightsaber), 2)\n a_cart.add_product(items(:blue_lightsaber), 4)\n assert_equal a_cart.items.length, 2\n \n an_out_of_stock_product = items(:red_lightsaber)\n assert an_out_of_stock_product.update_attributes(:quantity => 1)\n \n # Assert that the product that was out of stock was removed.\n removed_products = a_cart.check_inventory\n assert_equal removed_products, [an_out_of_stock_product.name]\n\n # Should last the right quantity of the rest.\n assert_equal a_cart.items.length, 1\n end", "def receive_quietly backordered_units\n \n return if backordered_units.count < 1\n \n # TODO backordered units are not in stock\n \n self.variant.update_column(:count_on_hand, self.variant.on_hand + backordered_units.count)\n self.variant.save\n backordered_units.each(&:fill_backorder)\n \n end", "def checkout(cart, coupons)\n cons_cart = consolidate_cart(cart)\n coup_cart = apply_coupons(cons_cart, coupons)\n clearance_cart = apply_clearance(coup_cart)\n\n cart_total = 0\n clearance_cart.each do |item, value|\n cart_total += clearance_cart[item][:price] * clearance_cart[item][:count]\n end\n if cart_total > 100\n cart_total = (cart_total * 0.9)\n end\n cart_total\nend", "def checkout(cart, coupons)\n #Consolidate cart...\n consolidated_cart = consolidate_cart(cart)\n # Apply coupons...\n coupons_applied = apply_coupons(consolidated_cart, coupons)\n #Apply clearance...\n final_cart = apply_clearance(coupons_applied)\n #start cart total at zero\n cart_total = 0\n #calculate the cost of the cart...\n final_cart.each do |item, attributes|\n item_total = attributes[:price] * attributes[:count]\n cart_total = cart_total + item_total\n end\n final_total = cart_total.round(2)\n # If the final_tota is > 100...\n if final_total > 100\n final_total *= 0.9\n end\n final_total\nend", "def apply_clearance(cart)\n cart.each do |item, info_hash|\n if info_hash[:clearance] == true\n info_hash[:price] = (info_hash[:price] * 0.80).round(2)\n end\n end\nend", "def update_product_cache_stock\n\t\t\tself.state_check_details.each do |scd|\n scd.update_product_cache_stock\n end\n\t\tend", "def create\n @order = current_order\n # if there already is an order_item with that product_id, then just update the quantity of the order_item\n # if product_in_cart?, redirect to the edit method\n unless product_in_cart?\n @item = @order.order_items.new(item_params)\n @item.save\n @order.save\n session[:order_id] = @order.id\n redirect_to cart_path\n else\n edit\n end\n end", "def update\n # find order item by params id\n\n if order_item_params[:quantity].to_i == 0\n @orders_item.destroy\n flash.now[:danger] = \"Removed item from your cart\"\n redirect_to order_path(@current_order.id)\n else\n if @orders_item && @orders_item.product.can_purchase?(order_item_params[:quantity].to_i) && @orders_item.update(order_item_params)\n flash[:success] = \"The cart item #{@orders_item.product.name} has been updated\"\n redirect_to order_path(@current_order.id)\n elsif @orders_item && !@orders_item.product.can_purchase?(order_item_params[:quantity].to_i) #the order item exists and it was invalid input for quantity\n flash.now[:danger] = \"There is not enought stock to add that quantity to the cart!\"\n redirect_to order_path(@current_order.id)\n else\n flash[:danger] = \"Something went wrong\"\n redirect_to order_path(@current_order.id)\n end\n end\nend", "def consolidate_cart(cart)\n index = 0\n new_cart = []\n \n cart.each do |grocery_item|\n current_item = find_item_by_name_in_collection(grocery_item[:item], new_cart)\n if current_item\n new_cart_index = 0\n new_cart.each do |new_cart_item|\n if new_cart_item[:item] === current_item[:item]\n new_cart_item[:count] += 1\n end\n new_cart_index += 1\n end\n else\n grocery_item[:count] = 1\n new_cart << grocery_item\n end\n index += 1\n end\n new_cart\nend", "def save_quote\n event_id = params[\"event_id\"]\n for each in Specification.where(event_id: event_id).where(exclude_from_quote: nil)\n if params[\"quoted_price-#{each.id}\"] == nil\n each.quoted_price = 0\n else\n each.quoted_price = (params[\"quoted_price-#{each.id}\"].gsub(\",\" , \"\").to_f * 100).round(2)\n end\n items_cost = params[\"per_item_cost-#{each.id}\"].to_f * 100.0\n each.per_item_cost = items_cost.round(2)\n each.per_item_list_price = (params[\"per_item_list_price-#{each.id}\"].to_f * 100).round(2)\n each.extended_list_price = (params[\"extended_list_price-#{each.id}\"].to_f * 100).round(2)\n each.save!\n end\n quote = Quote.where(event_id: event_id).first\n quote.quote_name = params[\"quote_name\"]\n quote.quote_style = params[\"quote_style\"]\n quoted_total_price = 0\n quoted_total_cost = 0\n for each in Specification.where(event_id: event_id).where(exclude_from_quote: nil)\n if each.quoted_price == nil\n each.quoted_price = 0\n else # do nothing\n end\n quoted_total_price = quoted_total_price + each.quoted_price\n quoted_total_cost = quoted_total_cost + (((each.per_item_cost / 100.0) * (each.item_quantity / 100.0)).round(2) * 100.0).round(2)\n end \n quote.total_price = quoted_total_price\n quote.total_cost = quoted_total_cost\n if quoted_total_cost != 0\n quote.markup = (quoted_total_price / quoted_total_cost) * 100\n else # do nothing\n end\n quote.status = params[\"status\"]\n if params[\"status\"] != \"Completed\" && params[\"status\"] != \"Ordered\"\n quote.wholesale_order_date = nil\n else # do nothing\n end\n quote.save!\n event = Event.where(id: event_id).first\n event.event_status = params[\"status\"]\n event.quote_message = params[\"quote_message\"]\n event.save!\n redirect_to \"/generate_quote/#{event_id}\" and return\n end", "def merge_cart_file(old_cart, new_cart)\n need_added_data = {}\n\n new_cart.each do |new_name, new_data|\n if old_cart.key?(new_name)\n old_data = old_cart[new_name]\n\n new_data = CartFileChecker.check_library_by(new_data, old_data)\n\n case new_data.conflict_type\n when ConflictType::ACCEPT\n need_added_data[new_name] = new_data\n when ConflictType::ERROR\n raise \"Halt !!! #{new_data.error_msg}\"\n else\n # ignore state, do nothing.\n end\n\n else # not has key 'new_name'\n new_data.conflict_type = ConflictType::ACCEPT\n need_added_data[new_name] = new_data\n end\n end\n\n old_cart.merge!(need_added_data)\n old_cart\nend", "def consolidate_cart(cart:[])\n add_item_counts(cart:cart)\n remove_duplicates(cart:cart)\n cart.inject({}) { |hash, cart_item| hash.merge(cart_item) }\nend", "def checkout(cart, coupons)\n \n #binding.pry\n \n #use same cart to apply all the different discounts onto otherwise it wont be totaled\n \n \n cart_output = consolidate_cart(cart)\n apply_coupons(cart_output, coupons)\n apply_clearance(cart_output)\n \n grand_total = 0\n\n #binding.pry\n cart_output.each do |item_name, item_details|\n \n #have to get price AND count otherwise items aren't charged repeatedly\n grand_total += item_details[:price] * item_details[:count]\n \n end\n \n #binding.pry\n \n if grand_total > 100.00\n grand_total = ( grand_total * (0.90) ).round(2)\n end \n #binding.pry\n \n grand_total\nend" ]
[ "0.6655813", "0.64634234", "0.62644565", "0.62572646", "0.62338233", "0.6221731", "0.6160598", "0.60869896", "0.60228485", "0.5998863", "0.59857064", "0.59836817", "0.59468913", "0.59129775", "0.58774203", "0.5873198", "0.5858518", "0.58464986", "0.582184", "0.5810873", "0.5800353", "0.57630247", "0.5696381", "0.56722564", "0.5646647", "0.56446993", "0.5644236", "0.5640015", "0.5630154", "0.56150395", "0.56024253", "0.5588545", "0.5587874", "0.55850285", "0.55775845", "0.55694336", "0.5567716", "0.55648077", "0.5562206", "0.5554087", "0.5550995", "0.55467665", "0.5536163", "0.5512177", "0.55073184", "0.55029297", "0.5499613", "0.5497023", "0.54950684", "0.54756564", "0.54733175", "0.54699314", "0.5459932", "0.5453624", "0.54403615", "0.5420676", "0.54163647", "0.54053175", "0.54029405", "0.540201", "0.5401697", "0.539857", "0.53970975", "0.53922087", "0.5373863", "0.5373831", "0.5372956", "0.5355917", "0.5354952", "0.53422594", "0.5341984", "0.5327054", "0.53259057", "0.53144324", "0.53126556", "0.5302231", "0.5295092", "0.5294035", "0.5291037", "0.52871364", "0.5283153", "0.5274661", "0.5267308", "0.52655727", "0.52612704", "0.52569205", "0.5243309", "0.5242854", "0.5242274", "0.5234753", "0.52343917", "0.5231503", "0.5231014", "0.52277774", "0.52191854", "0.5218429", "0.52163506", "0.5204817", "0.52046853", "0.5201051" ]
0.6795797
0
Empty the user's shopping cart
def clear_cart update_cart({}) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_carts\n current_user.carts.each_with_index do |cart, i|\n cart.delete if i != current_user.carts.length - 1\n end\n end", "def empty_cart\n self.each do |item|\n item.cart_id = nil\n item.save!\n end\n end", "def empty_cart\n puts \"========= Emptying Cart\"\n @b.goto 'http://shoppingcart.aliexpress.com/shopcart/shopcartDetail.htm'\n\n if @b.link(class: \"remove-all-product\").exists?\n @b.link(class: \"remove-all-product\").click\n @b.div(class: \"ui-window-btn\").button.click\n end\n end", "def empty_cart\n puts \"========= Emptying Cart\"\n @b.goto 'http://shoppingcart.aliexpress.com/shopcart/shopcartDetail.htm'\n\n if @b.link(class: \"remove-all-product\").exists?\n @b.link(class: \"remove-all-product\").click\n @b.div(class: \"ui-window-btn\").button.click\n end\n end", "def clear_item_from_cart\n\t\tcart_hash = session[:cart]\n\n\t\tredirect_to root_url\n\tend", "def empty_cart\n @cart.empty!\n redirect_to_index('Your cart is now empty')\n end", "def clear_cart\r\n session[:cart] = []\r\n flash[:info] = 'Cart has been emptied!'\r\n redirect_to root_url\r\n end", "def clear\n session[:cart] = nil\n redirect_to :action => :index\n end", "def clear_cart\n items=CartItem.where(:cart_id=>self.id)\n items.each do |item|\n item.destroy\n end\n end", "def clearCart\n \tsession[:cart] = nil\n \tredirect_to :action => :index\n end", "def clear_cart(cart)\n cart(:CartClear, {:CartId => cart.cart_id, :HMAC => cart.hmac})\n end", "def my_cart\n @cart = @current_branch.carts.find(current_cart.id)\n @cart.line_items.where(:quantity => 0).destroy_all\n render layout: 'mobile/application'\n end", "def destroy\n @in_shopping_cart.destroy\n end", "def empty_cart\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n view_cart_button.click\n wait_for_landing_page_load\n shopping_cart_label.should_exist\n\n # note: edit_link does NOT have to to be clicked to remove items, but we will perform steps\n unless (empty_cart_label.exists)\n len = timeout(1000).cart_list.length\n while len > 0\n shopping_cart_edit_link.should_exist\n shopping_cart_edit_link.click\n shopping_cart_edit_done_link.should_exist\n\n cart_list.at(0).remove_button.click\n wait_for_landing_page_load\n len-=1\n end\n end\n end", "def remove_items_from_cart\n line_items.each { |i| i.cart = nil }\n end", "def shopping_cart_cleanup\n\n end", "def destroy\n current_user.selecteditems.destroy_all\n redirect_to display_cart_user_path(current_user.id)\n end", "def clearCart\n #sets session variable to nil and bring back to index\n session[:cart] = nil\n redirect_to :action => :index\n end", "def remove_items\n system 'clear'\n CoffeeMan.stay_logo\n @@cart = @@cart.flatten\n cart_arr = @@cart \n if cart_arr.count == 0 \n puts \"Your cart is empty, please add items\"\n sleep 1\n view_cart\n end\n if cart_arr.count > 0 \n splitted_cart = cart_arr.split(\" \")\n selected_items = prompt.multi_select(\"Which item would you like to remove?\", splitted_cart)\n selected_items.each do |del| \n cart_arr.delete_at(cart_arr.index(del))\n end \n # @@cart = cart_arr\n sleep(0.6)\n view_cart\n end\n end", "def cart_clear\n cc = CartClear.new\n cc.params.merge!( { 'CartId' => @cart_id, 'HMAC' => @hmac } )\n cart = search( cc, @rg ).cart_clear_response.cart\n @cart_items = []\n @saved_for_later_items = []\n end", "def show\n @cart.destroy_cart_items\n\n end", "def destroy\n\t\t@cart_item.destroy\n\n\t\thead :no_content\n\tend", "def delCart\n session.delete(:cart_id)\n end", "def remove_item\n item = Item.find(params[\"format\"])\n #select the cart of the log-in user\n if user_signed_in?\n cart = current_user.cart\n #check if the item is in the cart\n if item.carts.find(cart.id)\n item.carts.delete(cart)\n end\n redirect_to carts_show_path\n else\n redirect_to root_path\n end\n end", "def checkout_cart\n self.line_items.each do |li|\n li.item.inventory -= li.quantity\n li.item.save\n end\n self.line_items.clear\n self.status = \"submitted\"\n self.user.current_cart_id = nil\n self.user.save\n end", "def clear_cart\n sleep(1)\n #element = $driver.find_element(:css,\"#mini-cart-wrap > li > div.minicart-inner-div > a:nth-child(3) > span\") \n \n puts \"moving cursor to minicart\"\n $driver.action.move_to(mini_cart_text).perform\n\n sleep(2) \n begin\n empty_my_cart = $driver.find_element(:css,\"#minicart-bottom > p.pull-left > a\")\n sleep(1)\n empty_my_cart.click\n sleep(1)\n rescue \n puts \"cart is already empty\"\n end \n end", "def log_out_cart\n session.delete(:cart_id)\n @cart = nil\nend", "def reset_basket(order)\n order.empty_basket\n session[:coupons] = nil\n end", "def reset\n\t\t@shop = ShopProfile.find(params[:shop_profile_id])\n\t\tauthorize @shop\n\t\tif @shop.shipping_charges.destroy_all\n\t\t flash[:success] = \"Removed Successfully\"\n\t\t redirect_to shop_profiles_path\n\t\telse\n\t\t\tflash[:danger] = \"Error While Removing\"\n\t\t\tredirect_to request.referrer || root_path\n\t\tend\t \n\tend", "def associated_user\n user = User.find_by(cart_id: self.id) # returns the user_id associated with a cart to delete it.\n if user\n user.update_attribute(:cart_id, nil)\n end\n end", "def empty_new_cart\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n if edit_cart_link.exists\n edit_cart_link.click\n wait_for_landing_page_load\n len = timeout(1000).remove_item_link.length\n while len > 0\n remove_item_link.at(0).click\n wait_for_landing_page_load\n len-=1\n end\n end\n\n shopping_cart_empty_label.should_exist\n end", "def log_out\n session[:cart] = []\n session.delete(:user_id)\n @current_user = nil\n end", "def delete\n\t\t@cart.delete(:item_id)\n end", "def complete_cart\n render json: { status: 'Success', message: 'Checkout Complete! Thank you for shopping with us!', data: products_in_cart(true) }\n Cart.destroy_all\n end", "def call(_obj, args, _ctx)\n cart = ShoppingCart.find_by(user_id: args[:user_id])\n product = Product.find_by(product_id: args[:product_id])\n item = CartItem.find_by(product_id: args[product_id])\n cart.cart_items.delete(item)\n cart.total_cost -= product.price * item.quantity + product.shipping\n cart.save\n cart\n end", "def destroy\n\t\t@cart.destroy\n\t\tsession.delete(:cart)\n\tend", "def add_shop_items_from_user_cart(shop_cart)\n shop_cart.shop_items.each do |si|\n si.shop_cart_id = nil\n shop_items << si\n end\n end", "def destroy\n @cart = current_cart\n #need to first destroy each of the line items\n @cart.line_items.each do |i|\n i.destroy\n end\n #now destroy the cart and set the cookie to nil so that it will request a new cookie.\n @cart.destroy if @cart.id == session[:cart_id]\n session[:cart_id] = nil\n respond_to do |format|\n format.html { redirect_to '/', notice: 'Cart was successfully emptied.' }\n format.json { head :no_content }\n end\n end", "def remove_from_cart\n\t\tcart_hash = session[:cart]\n\n\t\tcart_hash[params[:id]][\"quantity\"] -= 1\n\t\tif cart_hash[params[:id]][\"quantity\"] === 0\n\t\t\tcart_hash.delete(params[:id])\n\t\tend\n\n\t\tredirect_to root_url\n\tend", "def clear_cart\n sleep(1)\n element = $driver.find_element(:css,\"#mini-cart-wrap > li > div.minicart-inner-div > a:nth-child(3) > span\") \n puts \"moving cursor to minicart\"\n $driver.action.move_to(element).perform\n\n sleep(2) \n begin\n empty_my_cart = $driver.find_element(:css,\"#minicart-bottom > p.pull-left > a\")\n sleep(1)\n empty_my_cart.click\n sleep(1)\n rescue \n\n puts \"cart is already empty\"\n end \n end", "def delete_cart(id)\n db = database()\n db.execute(\"DELETE FROM carts WHERE UserId = ?\", id)\n end", "def destroy\n if @cart.id == session[:cart_id]\n session[:cart_id] = nil\n end\n\n respond_to do |format|\n format.html { redirect_to store_index_url, notice: \"Your cart is currently empty\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @cart.destroy if @cart.id == session[:cart_id]\n flash[:success] = \"Cart was successfully empty\"\n #Use of logger class to log messages into the log file\n Logger.instance.log(Time.now.to_s + \": Cart destroyed by user \\n\")\n redirect_to products_path\n end", "def destroy\n @cart = current_cart\n @cart.destroy\n session[:cart_id] = nil\n\n respond_to do |format|\n format.html { redirect_to(root_url,\n :notice => 'Your cart is currently empty' ) }\n format.json { head :no_content }\n end\n end", "def destroy\n @cart_item.destroy\n\n head :no_content\n end", "def remove_cart\n\t\tcart = current_user.saved.carts.find(params[:cart])\n #saved.carts.delete(cart)\n cart.destroy\n redirect_to :back\n\tend", "def cancel_order\n system 'clear'\n CoffeeMan.stay_logo\n @@cart.clear\n puts \"Your cart has been emptied\"\n sleep(0.09)\n main_menu\n sleep(2)\n end", "def perform_empty_cart(session_id, owner_id, client_channel, locale, version)\n $tracer.trace(\"GameStopCartServiceDSL: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n remove_products_from_cart_rsp = perform_empty_cart_and_return_message(session_id, owner_id, client_channel, locale, version)\n unless remove_products_from_cart_rsp.nil? == true\n remove_products_from_cart_rsp.code.should == 200\n end\n return true\n end", "def destroy\r\n @cart_item = CartItem.find(params[:id])\r\n if @cart_item.destroy\r\n \t@cart_item.unbuy # returns unbought items in the cart to products table\r\n \tflash[:notice] = \"Item has been removed from cart!\"\r\n end\r\n redirect_to edit_cart_item_path(@cart_item)\r\n end", "def clear\n @products.clear\n end", "def destroy_all\n @order = current_order\n @basket_items = @order.basket_items\n @basket_items.clear\n redirect_to(:back)\n end", "def destroy\n session[:user_id] = nil\n session[:basket_id] = nil\n redirect_to root_path, notice: \"Logged out\"\n end", "def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n session[:cart_id] = nil\n\n respond_to do |format|\n format.html { redirect_to(root_path,\n\t:notice => 'Your cart is currently empty') }\n format.json { head :no_content }\n end\n end", "def remove_from_cart\n id = params[:id]\n session[:cart].delete(id)\n redirect_to root_path\n end", "def checkout\n self.update_item_inventory_for_checkout\n self.update(status: \"submitted\")\n self.user.current_cart = nil\n # self.user.save\n # binding.pry\n end", "def destroy\n if @cart.cart?\n @cart.destroy\n end\n session[:cart_id] = nil\n redirect_to cart_url\n end", "def delete_item\n if current_user\n @item = Item.find(params[:id].to_i)\n current_cart.items.delete(@item)\n redirect_to cart_path\n else\n delete_item_in_guest_cart(params[:id].to_i)\n redirect_to cart_path\n end\n end", "def checkout\n if session[:cart] then\n session[:cart] = nil\n redirect_to ('/shopper/new')\n flash[:notice] = \"Your order has been placed!\"\n else\n redirect_to ('/cart')\n flash[:notice] = \"Your cart is empty!\"\n end\n end", "def print_cart\n\t\tputs \"----- #{@user}'s Shopping Cart -----\"\n\t\tif @cart.length > 0\n\t\t\t@cart.each do |item|\n\t\t\t\tputs \"> #{item}\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"Your shopping list is empty.\"\n\t\tend\n\t\tputs \"--------------------------------\"\n\tend", "def destroy\n @cart.destroy\n @cart = nil\n session[:cart_id] = nil\n\n respond_to do |format|\n format.html { redirect_to store_index_url, notice: 'Your cart is currently empty' }\n format.json { head :no_content }\n format.js\n end\n end", "def delete_from_cart\n cart_op {|cart| cart.delete(params[:id].to_i); cart }\n render_cart_size\n end", "def destroy\n if current_user.cart.present? && current_user.cart.carts_products.where(id: params[:id]).present?\n current_user.cart.carts_products.delete(params[:id])\n render json: { message: \"Item removed from cart\" }\n else\n render json: { message: \"Can't find item in cart\" }, status: :not_found\n end\n end", "def destroy\n @product_id = params[:product_id].to_s\n\n # remove the item from the session\n session[:shopping_cart].delete(@product_id)\n\n calculate_order_total\n end", "def remove_from_cart\n Cart.remove_from_cart(session[:cart], params[:id])\n redirect_to show_cart_products_path\n end", "def ensure_cart_isnt_empty\n if @cart.line_items.empty?\n redirect_to store_index_url, notice: 'Cart is empty'\n end\n end", "def destroy\n\t\t@user_basket = UserBasket.find(params[:id])\n\t\t@shop = ShopProfile.find(@user_basket.shop_profile_id);\n\t\t@price = ShopProduct.find(@user_basket.shop_product_id).selling_price\n\t\t@price *= @user_basket.quantity\n\t\t@user_basket.destroy\n\t\tif current_user.user_baskets.empty?\n\t\t\trespond_to do |format|\n \tformat.html { redirect_to root_path }\n \tformat.js {}\n\t end\n\t\telse\n\t\t\trespond_to do |format|\n \tformat.html { redirect_to request.referer || root_path }\n \tformat.js {}\n\t end\n\t\tend\n\tend", "def remove\n\t\tremove_from_cart(Item.find(params[:id]))\n\t\tredirect_to :controller => \"cart\", :action => \"index\"\n\tend", "def remove_from_cart\n if @cart.candle_carts.count == 1\n destroy\n else\n item = CandleCart.find(cart_params[:id])\n item.destroy\n flash[:alert] = \"Succesfully Removed\"\n redirect_back fallback_location: root_path\n end\n end", "def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n\n session[:cart_id] = nil\n\n respond_to do |format|\n format.html { redirect_to(store_url, notice => 'Your cart is currently empty') }\n format.xml { head :ok }\n\n end\n end", "def sign_out\n session[:shop_id] = nil\n end", "def set_cart\n if @current_user.nil?\n redirect_to login_path\n elsif @current_user.carts.nil?\n @cart = Cart.create( user_id: @current_user.id )\n elsif @current_user.carts.where( purchase_completed: false ).empty?\n @cart = Cart.create( user_id: @current_user.id )\n else\n @cart = @current_user.carts.find_by( purchase_completed: false )\n end\n # redirect_to cart_path( @cart )\n end", "def destroy\n current_cart.line_items.destroy_all\n current_cart.destroy\n session[:cart_id] = nil\n session[:referer] = nil\n respond_to do |format|\n format.html { redirect_to(root_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n # get the item with id and get the quantity of this item\n @item = ShoppingCart.find(params[:id]).item\n\n @item.save\n current_user.remove_item_from_cart!(@item)\n # remove the item from shopping cart\n respond_to do |format|\n format.html { redirect_to @item }\n format.js\n end\n end", "def destroy_from_cart\n unless cookies[:cart].nil?\n @cart = Cart.find_by_unique_identifier(cookies[:cart])\n @cart.delete_product(params[:catalog_id],params[:product_id])\n if @cart.save\n if @cart.products.size == 1\n products = @cart.products[0]\n if products[:products_count] == 0\n @cart.destroy\n cookies.delete(:cart)\n redirect_to root_url, :alert => t('cart.msg_cart_destroyed_no_products')\n else\n redirect_to show_mycart_path, :notice => t('cart.msg_del_prod')\n end\n else\n redirect_to show_mycart_path, :notice => t('cart.msg_del_prod')\n end\n else\n redirect_to show_mycart_path, :alert => t('cart.msg_no_del_prod')\n end\n else\n redirect_to root_url, :alert => t('cart.msg_nothing')\n end\n end", "def destroy\n if @cart_item.destroy\n # if @cart_item.cart.items.present?\n build do\n message 'Удаление товара из корзины'\n view 'cart_items/delete'\n end\n # else\n # @cart = @cart_item.cart\n # @cart.destroy\n # build do\n # message 'Удаление корзины'\n # view 'carts/delete'\n # end\n # end\n end\n end", "def cart_action(current_user_id)\n if $redis.sismember \"cart#{current_user_id}\", id\n \"Remove from\"\n else\n \"Add to\"\n end\n end", "def remove_product(name)\n @products_in_cart.delete(Product)\nend", "def remove_from_cart\n #see if you can change number of items in cart\n item_id = params[:remove_from_cart][:item_id]\n remove_item_from_cart(item_id)\n\n redirect_to cart_path\n end", "def confirm\n # resets sessions to clear the current cart once the order has been confirmed\n session[:order_id] = nil\n end", "def destroy\n @cart = @current_cart\n @cart.destroy\n session[:cart_id] = nil\n redirect_to cart_path(@cart.id)\n end", "def empty!\n @items = []\n @total_price = 0.0\n end", "def no_cart?(user_id)\n Order.where(:checked_out => false, :user_id => user_id).empty?\nend", "def require_cart_to_have_items\n if shopping_cart.empty?\n redirect_to(cart_items_path, alert: 'Tu carrito está vacio, deberías agregar items a tu carrito antes.')\n end\n end", "def checkout\n @current_cart.adjust_inventory\n @current_cart.mark_submited\n current_user.remove_current_cart\n redirect_to cart_path(@current_cart)\n end", "def clean\n # Call method clean! on model\n current_cart.clean!\n flash[:warning] = \"Shopping cart is empty!\"\n redirect_to carts_path \n end", "def logging_in\n guest = guest_user\n current_cart = current_user.cart\n\n # if guest exists and the current_user does not already have a pending cart from previous session\n # then save all items in current cart into its own cart\n\n unless guest.nil? || !current_cart.items.empty?\n guest_cart = guest.cart\n current_cart.items.destroy_all unless current_user.cart.items.empty?\n current_cart.items = guest_cart.items\n current_cart.save!\n end\n end", "def destroy\n if @shop.user_id == current_user.id\n @shop.destroy\n end\n respond_to do |format|\n format.html { redirect_to shops_url, notice: 'お手続きした商品を削除致しました。今後とも『オトクーナ』をどうぞ宜しくお願い致します。' }\n format.json { head :no_content }\n end\n end", "def remove_item\n prod_id = params[:product_id].to_s\n item = cart[prod_id] || {\"Num\" => 0}\n item[\"Num\"] -=1\n cart[prod_id] = item\n cart.delete(prod_id) if item[\"Num\"] < 1\n update_cart cart\n flash[:success] = t('itm_removed')\n redirect_back fallback_location: :root\n end", "def clear_all\n # Walk around the read-only profiles\n User.find(session[:user_id]).profiles.each do |p|\n # Restore the profile status if imported\n newp = Profile.find(p.id)\n newp.status = 'Waiting'\n newp.quote_type = ''\n newp.save\n \n # Delete all quotes\n Quote.delete_all([\"profile_id = #{p.id}\"])\n end\n\n # Clear the user portfolio\n User.find(session[:user_id]).portfolios.each {|p| p.destroy}\n \n # Reset status and delete all Pm/investors since quotes are clear.\n\t\treset_without_agent_reserved\n\t\t\n flash[:notice] = 'Your portfolio is empty now and PM/investor have been deleted.'\n redirect_to :action => 'index'\n end", "def clear!\n @items.clear\n end", "def destroy\n \tsession[:user_id] = nil\n \tredirect_to products_url, :notice => \"Logged out\"\n end", "def destroy\n if @cart.class == Hash\n session[:cart] = nil\n else @cart.class == Cart\n @cart.destroy\n end\n respond_to do |format|\n format.html { redirect_to store_url }\n format.json { head :no_content }\n end\n end", "def clear!\n @items.clear\n save\n end", "def remove\n id = params[:id]\n cart = session[:cart]\n cart.delete id\n \n redirect_to :action => :index\n end", "def removeProduct\n id = params[:id]\n cart = session[:cart]\n cart.delete id\n redirect_to :action => :index\n \n end", "def clear!\n @items.clear\n end", "def clear_current_user; end", "def index \n \n @page_title = \"Register for NAETI Courses\"\n @padding = true\n retrieve_shopping_cart\n \n if current_user\n @user = current_user\n else\n @user = User.new\n end\n \n #update cart for removals\n if params[:remove]\n for id in params[:shopping_cart_item][:ids]\n @shopping_cart_item = ShoppingCartItem.where(:id=>id).first\n @shopping_cart_item.destroy\n end\n end\n \n retrieve_shopping_cart\n\n if params[:user]\n \n if current_user\n @user.update_attributes(params[:user])\n @user = set_credit_card_info(@user)\n \n if @user.valid?\n process_checkout\n else\n flash.now[:notice] = \"Please correct the indicated fields.\"\n end\n else\n \n @user = User.new(params[:user])\n @user = set_credit_card_info(@user)\n \n if @user.valid?\n @user.save\n process_checkout\n else\n flash.now[:notice] = \"Please correct the indicated fields.\"\n end\n # end\n end\n\n end\n \n end", "def reset_current_useritem\n session[:useritem_id] = nil\n session[:useritem_type] = nil\n end", "def check_cart_full?\n current_cart.destroy if current_cart.present? && !current_cart.is_full?\n end" ]
[ "0.8031044", "0.77986765", "0.7593933", "0.7593933", "0.739813", "0.7364413", "0.7336975", "0.7253655", "0.72161233", "0.71335286", "0.70281833", "0.6977616", "0.69772935", "0.69201314", "0.68642545", "0.6854456", "0.6851387", "0.68240815", "0.6815093", "0.67398065", "0.670847", "0.6700029", "0.6691251", "0.6690963", "0.66581154", "0.66400254", "0.6619992", "0.6612203", "0.6607981", "0.6596691", "0.659244", "0.65830755", "0.65703297", "0.65256286", "0.6507996", "0.64994925", "0.64621454", "0.644632", "0.6442276", "0.64372903", "0.64363384", "0.6434557", "0.63990045", "0.6395255", "0.6364324", "0.6334078", "0.632411", "0.6306264", "0.6302006", "0.6294411", "0.6293709", "0.62830895", "0.62614053", "0.6223671", "0.61991334", "0.61896026", "0.6170041", "0.6166276", "0.61508906", "0.6149543", "0.61433125", "0.61383754", "0.6132662", "0.61239946", "0.61198115", "0.6114022", "0.61106265", "0.6098068", "0.6091368", "0.60899216", "0.6075181", "0.606831", "0.60606664", "0.60565424", "0.60559714", "0.6055435", "0.60448337", "0.602676", "0.60254514", "0.6023502", "0.60216266", "0.60136604", "0.59991777", "0.5994499", "0.5977193", "0.59720504", "0.5966045", "0.59645957", "0.59538406", "0.594485", "0.5918581", "0.5918425", "0.5916919", "0.5910654", "0.5908184", "0.5903118", "0.5896159", "0.588487", "0.5876556", "0.5862742" ]
0.78453743
1
Get total cost of all products in the cart
def cart_total total = 0 cart.each do |pId, info| if (prod = Product.find_by(id: pId)) total += prod.price * info["Num"].to_i end end total end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_price\n total = 0\n self.carts.each do |item|\n total += item.quantity * item.product.price\n end\n return total\n end", "def cart_total\n total = 0\n cart.each do |product_id, details|\n if p = Product.find_by(id: product_id)\n total += p.price_cents * details['quantity'].to_i\n end\n end\n total\n end", "def cart_total\n total = 0\n cart.each do |product_id, details|\n if p = Product.find_by(id: product_id)\n total += p.price_cents * details['quantity'].to_i\n end\n end\n total\n end", "def total_price\n total = 0\n cart_items.collect do |item|\n total += item.total_price\n end\n\n total\n end", "def cart_total_price\n total = 0\n self.cart_items.each do |cart_item|\n total += cart_item.sub_total\n end\n total\n end", "def products_total\n @cart.cart_products.inject(0) do |total, cart_product|\n total += (cart_product.qty * cart_product.price)\n end\n end", "def total_price\n cart_items.to_a.sum { |item| item.total_price }\n end", "def cart_total\r\n\t\ttotal = 0\r\n\t\tfor item in @cart_items\r\n\t\t\ttotal = total + @products[item].to_f\r\n\t\tend\r\n\t\ttotal\r\n\tend", "def total\n total_cost = 0\n \n # Summing up the product cost\n @products.each do |item, cost|\n total_cost += cost\n end\n \n # Calculate a 7.5% tax\n total_order_cost = total_cost * 1.075\n \n # Rounding the result to two decimal places\n return total_order_cost.round(2)\n end", "def total_products\n self.carts.sum(:quantity)\n end", "def total_price(cart)\n cart.sum {|item| item.price} \n end", "def total\n\t\tif @products == {}\n\t\t\treturn 0\n\t\telse\n\t\t\treturn (@products.sum {|product, cost| cost} * 1.075).round(2)\n\t\tend\n\tend", "def total_cost\n product.cost * quantity\n end", "def cart_price_total\n price = 0\n CartProduct.all.each do |cart_product|\n if cart_product.user_id == logged_in\n if product = get_product_by_id(cart_product.product_id)\n price += (product.price * cart_product.quantity) \n end\n end\n end\n return price\n end", "def total_price \n \tcart_items.to_a.sum { |item| item.total_price }\n end", "def total\n total_price = 0.0\n cart.line_items.each do |line_item|\n if !line_item.unit_price.blank?\n total_price += line_item.unit_price.to_f\n if line_item.line_item_options\n line_item.line_item_options.each do |line_item_option|\n total_price += line_item_option.price.to_f\n end\n end\n elsif line_item.menu_section_item\n total_price += line_item.menu_section_item.price.to_f\n if line_item.menu_item_options\n line_item.menu_item_options.each do |menu_item_option|\n total_price += menu_item_option.price.to_f\n end\n end\n else\n total_price += 0\n end\n end\n tax = total_price.to_f * 0.0825\n total_price = total_price + tax\n if tip\n total_price = total_price.to_f + tip.to_f\n end\n return total_price\n end", "def total_product_price\n total_price = @products.map{|product| product.price}\n total_price.reduce(:+) \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 total_cost\r\n self.qty * self.price\r\n end", "def total_cost\n quantity * product.price\n end", "def total_cost\n quantity * product.price\n end", "def get_total(store)\n\t\tcost = 0 # Initial cost\n\t\tif @cart.length > 0\n\t\t\t@cart.each do |item|\n\t\t\t\tif store.prices.include?(item.to_sym) # error handling if an item is removed from inventory\n\t\t\t\t\tcost += store.get_price(item) # Add all items in the list to the cost variable\n\t\t\t\telse\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn cost\n\t\telse\n\t\t\treturn 0\n\t\tend\n\tend", "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 total\n @items_total = []\n self.line_items.each do |item|\n @item = Item.find_by_id(item.item_id)\n @items_total << @item.price.to_f\n end\n cart_total = @items_total.inject(0){|sum, x| sum + x }\n @cart_total = cart_total.round(2)\n @cart_total\n end", "def total_cost\n self.delivery_cost_price +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.total_cost }\n end", "def total\n product_total = 0\n tax = 1.075\n @products.each do |product, price|\n product_total += price\n end\n order_total = (product_total * tax).round(2)\n return order_total\n end", "def total_price\n res = product.price * count\n if product_options.any?\n res = res + product_options.map { |po| po.price }.sum * count\n end\n res\n end", "def total\n # extracts all of the values from the hash and sums them up\n cost = @products.values.sum\n # add 7.5% tax and round to two decimal places\n return (cost * 1.075).round(2)\n end", "def total\n self.inject(0) { |t, calculator| t + (calculator.active? ? calculator.price(@cart) : 0) }\n end", "def total_cost\n order.delivery_cost_price +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.total_cost }\n end", "def total\n total = @products.map do |product, price|\n price\n end\n\n return (total.sum * 1.074).round(2)\n end", "def total\n product_total = 0\n subtotal = 0\n @products.each_value do |prices|\n subtotal += prices\n end\n product_total = (subtotal * 0.075).round(2)+ subtotal\n return product_total\n\n end", "def calc_cart_total\n @cart_total = 0\n #This will determine the cart total\n @user_cart.each do |product|\n @cart_total = @cart_total + product[:price]\n end\n puts \"Your cart will cost you $#{@cart_total.round(2)} currently.\"\nend", "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 total_price\n\t\tproduct.price * quantity\n\tend", "def total_cost\n order_items.map { |order_item| order_item.subtotal }.sum.round(2)\n end", "def total_price\n \t\tsale_items.sum { |item| (item.product.price * item.quantity) }\n\tend", "def total_cost\n @quantity * @price\n end", "def total_cost\n line_items.to_a.sum {|item| item.total_cost}\n end", "def total_price\r\n\t\t@items.inject(0.0) { |sum, i| sum + i.total_unit_price * i.quantity }\r\n\tend", "def total_purchases_cost\n purchases.to_a.sum(&:cost)\n end", "def total_purchases_cost\n purchases.to_a.sum(&:cost)\n end", "def cumulative_total_before_tax\n amount = 0.0\n @products_in_cart.each do |product|\n amount += product.price\n end#each\n return amount\nend", "def total_price\n total = 0\n if self.nil? || self.order_items.empty?\n else\n items = Order.find(self.id).order_items\n if items.length > 0\n items.each do |item|\n total += Product.find(item.product_id).price * item.quantity\n end\n end\n end\n\n\n return total\n end", "def total_price\n \tresult = 0;\n \titems = self.order_items\n\n \titems.each do |item|\n \t\tresult += item.price\n \tend\n \treturn result\n end", "def total_cost\n # quantity * unit_cost_price\n unit_cost_price\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_cost_items\n line_items.sum(&:total_cost_line_item)\n end", "def total_price\n # convert to array so it doesn't try to do sum on database directly\n @total = 0\n line_items.each do |item|\n @total = item.price\n end\n line_items.to_a.sum {|item| (item.quantity * item.price) }\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 cost \n\n \ttotal=@costItems.reduce(0) do |sum,hm|\n \t\tsum+=hm \n end\n puts total\n end", "def cumulative_total_after_tax\n amount = 0.0\n @products_in_cart.each do |product|\n amount += product.total\n end#each\n return amount\nend", "def total_items\n @cart_items.sum{|k,v| v}\n end", "def calculate_totals\n subtotal = 0\n\n carted_products.each do |carted_product|\n subtotal += carted_product.subtotal\n end\n\n tax = subtotal * 0.09\n total = subtotal + tax\n update(subtotal: subtotal, tax: tax, total: total)\n end", "def get_cost_without_tax\n total_costs = 0.0\n @products.each_value { |cost| total_costs += cost if is_valid_cost?(cost) }\n return total_costs\n end", "def total\n\t\tProduct.find(self.product_id).price * quantity.to_i\n\tend", "def total_cost_of_sales\n costs = self.purchases.map(&:cost)\n self.total_costs = costs.inject{|sum, cost| sum + cost}.to_f\n end", "def total_cost\n order_details.inject(0) { |sum, od| sum += od.total }\n end", "def total_price\n \tresult = 0;\n \titems = self.temp_order_items\n\n \titems.each do |item|\n \t\tresult += item.price\n \tend\n \treturn result\n end", "def total_price\n line_items.map { |line_item| line_item.item.price * line_item.quantity }.sum\n end", "def total_with_tax\n total = 0\n @cart_items.each do |item|\n total += item.total_price\n end\n return total\n end", "def order_item_total_cost(order_item_id)\n order_item = OrderItem.find_by(id: order_item_id)\n return (order_item.product.price * order_item.quantity)\n end", "def total_cost\n self.ingredients.map{ | ing | ing.cost_per_unit * ing.quantity } .reduce(&:+).round(2)\n end", "def cart_price_total_wtax\n price = 0\n tax = 2.99\n CartProduct.all.each do |cart_product|\n if cart_product.user_id == logged_in\n if product = get_product_by_id(cart_product.product_id)\n price += (product.price * cart_product.quantity) \n end\n end\n end\n return price + tax\n end", "def product_cost\n product_with_unit_cost + product_without_unit_cost\n end", "def total_price\n self.ice_cream_orders.map { |ico| ico.ice_cream.price }.inject(:+)\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 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 price\n\t\tvalue = 0\n\t\tself.items.each do |item|\n\t\t\tvalue += item.product.price * item.amount\n\t\tend\n\t\tvalue\n\tend", "def cart_total_price\n total = 0\n params[:items].each do |item|\n if variant = Variant.find_by(id: item[:variant_id])\n total += variant.price * item[:quantity].to_i\n end\n end\n total\n end", "def total_cost\n self.qty * self.unit_cost\n end", "def test_return_total_price\n # Create a cart and add some products.\n a_cart = Order.new\n a_cart.add_product(items(:red_lightsaber), 2)\n a_cart.add_product(items(:blue_lightsaber), 4)\n assert_equal a_cart.items.length, 2\n\n total = 0.0\n for item in a_cart.items\n total += (item.quantity * item.unit_price)\n end\n\n assert_equal total, a_cart.total\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 total\n @sum = @products.values.inject(0, :+)\n @total = @sum + (@sum * 0.075).round(2)\n return @total\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price}\n end", "def total_price\n product.price * quantity\n end", "def total_price\n product.price * quantity\n end", "def total_price\n product.price * quantity\n end", "def total_price\n product.price * quantity\n end", "def total_price\n product.price * quantity\n end", "def total_price\n items.map(&:price).sum\n end", "def total\n total_amount = 0\n @order.each do |product, quantity|\n prod_price = PRODUCTS[product]\n if @pricing_rules.key?(product)\n rule = @pricing_rules[product]\n n = rule[1]\n type = rule[0]\n case type\n when \"Nx1\"\n total_amount += prod_price*( quantity/n + quantity%n )\n when \"BULK\"\n disccount_price = rule[2]\n total_amount += quantity * (quantity < n ? prod_price : disccount_price) #disccount price\n end\n else\n total_amount += prod_price * quantity\n end\n end\n total_amount\n end", "def total\r\n\t\tthe_cost = product[:wholesale_base_price] + option_value[:wholesale_extra_cost]\r\n\t\tthe_discount = product[:discount]\r\n\t\tabs_discount = product[:discount_is_abs]\r\n\r\n\t\tmultiplier = draft.priced ? 1.0 : 1.1\r\n\r\n\t\tProduct.discount_price(the_cost, the_discount, abs_discount) * quantity * multiplier\r\n\tend", "def total\n self.quantity * self.product.price\n end", "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 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 total_before_tax\n total = 0\n @cart_items.each do |item|\n total += item.price\n end\n return total\n end", "def total_price\n\t\tline_items.to_a.sum { |item| item.total_price }\n\tend", "def total_cost\n ingredients_cost + components_cost\n end", "def total_price\n\t\tline_items.to_a.sum{|item| item.total_price}\n\tend", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_order\n total = 0.00 #initializing total\n @selected_prices.each do |cost| #for each selected item add the total cost\n total += cost\n end\n total\n end", "def total\n (@products.values.sum * 1.075).round(2)\n end", "def component_total_price(product)\n entries = product.component_entries\n return Price.zero if entries.empty?\n entries.map { |entry|\n final_price(entry.component) * entry.quantity\n }.sum\n end", "def cart_total_quantity\n order = current_order ? current_order : new_order_from_cookies\n order.order_items.collect { |item| item.quantity }.sum\n end", "def total\n self.line_items_total + self.shipping_cost\n end", "def total\n charges.map { |x| x.total_cost.to_f }.inject(:+)\n end" ]
[ "0.8293662", "0.8215741", "0.8215741", "0.80555874", "0.7956167", "0.7939108", "0.7927913", "0.791726", "0.77824396", "0.7778452", "0.77516174", "0.7708805", "0.7658332", "0.7639621", "0.76211673", "0.7582056", "0.7579942", "0.75787103", "0.7560054", "0.7533393", "0.7533393", "0.7529847", "0.75063056", "0.7504214", "0.7494701", "0.7477397", "0.745762", "0.74573725", "0.74522936", "0.7446368", "0.7437835", "0.7427397", "0.7406199", "0.7349856", "0.7347158", "0.73424417", "0.73288083", "0.73151857", "0.7307847", "0.72966516", "0.7295448", "0.7295448", "0.7291058", "0.7283533", "0.72535706", "0.7252101", "0.72429746", "0.72414833", "0.72298557", "0.7228587", "0.7226761", "0.7220034", "0.72197104", "0.7214349", "0.7209746", "0.7207086", "0.72010976", "0.7188197", "0.71816146", "0.71446574", "0.7140199", "0.712113", "0.71142995", "0.71087307", "0.71064824", "0.7103952", "0.7097285", "0.70934325", "0.70858836", "0.7068437", "0.7058332", "0.7057815", "0.7054496", "0.7039261", "0.7027037", "0.7024328", "0.7024328", "0.7024328", "0.7024328", "0.7024328", "0.7009962", "0.6999359", "0.69865376", "0.6985036", "0.6973092", "0.6973078", "0.69661933", "0.6961983", "0.6947933", "0.6935907", "0.691738", "0.691738", "0.691738", "0.691738", "0.6907428", "0.690451", "0.69007635", "0.68966705", "0.68948305", "0.6891004" ]
0.8125215
3
returns first of the given paths that exists, or the last one if none exists
def first_existing(*paths) last_path = nil paths.each do |path| last_path = path break if @io.exist?(path) end last_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_first(*paths)\n xpath(*paths).first\n end", "def common_path(paths)\n return nil if paths.empty?\n strs = paths.map do |path|\n unless path.absolute?\n raise ArgumentError, \"Paths must be absolute #{path}\"\n end\n path.dirname.to_s\n end\n min, max = strs.minmax\n min = min.split('/')\n max = max.split('/')\n idx = min.size.times { |i| break i if min[i] != max[i] }\n result = Pathname.new(min[0...idx].join('/'))\n # Don't consider \"/\" a common path\n return result unless result.to_s == '' || result.to_s == '/'\n end", "def find_common_directory_path(paths)\n case paths.length\n when 0\n return '/'\n when 1\n return paths.first.split('/').slice(0...-1).join('/')\n else\n arr = paths.sort\n first = arr.first.split('/')\n last = arr.last.split('/')\n i = 0\n i += 1 while first[i] == last[i] && i <= first.length\n first.slice(0, i).join('/')\n end\nend", "def find_path(paths = [[@position]])\n if not @path and finished?(paths)\n return @path\n else\n new_paths = []\n change = false\n paths.each do |path|\n possible_positions?(path).each do |position|\n new_paths << path.dup.push(position)\n change = true\n end\n end\n find_path(new_paths) if change\n end\n end", "def get_first_match(path)\n\n store.transaction(true) do\n\n store.roots.each do |k|\n\n if path.match(k)\n return k\n end\n\n end\n end\n false\n end", "def at_xpath(*paths)\n result = nil\n\n paths.each {|path|\n if result = xpath(path).first\n break\n end\n }\n\n result\n end", "def fetch_path(start_path)\n ['', 'config'].each do |directory|\n ['', '.'].each do |prefix|\n path = File.join(start_path, directory, \"#{prefix}#{@file_name}\")\n return path if File.exist?(path)\n end\n end\n nil\n end", "def find_exist_first_file\n if !(local_webs = ENV[\"APP_LOCAL_WEBS\"].split.find_all { |dir| File.basename(dir) == params[:level1] }).empty?\n File.join(local_webs.first, \"index.html\")\n else\n params_path = params.map(&:first).grep(/level/).sort.map(&params.method(:fetch)).join(\"/\")\n ENV[\"APP_LOCAL_WEBS\"].split.concat([ENV[\"APP_ROOT_PATH\"]])\n .map { |dir| File.join(dir, params_path) }\n .find_all(&File.method(:file?)).first\n end\n end", "def figure_path(file, paths)\n if Pathname.new(file).absolute?\n return File.exist?(file) ? file : nil\n end\n\n paths.each do |possible_path|\n full_path = File.join(possible_path, file)\n return full_path if File.exist?(full_path)\n end\n nil\n end", "def find_existing_path(typed_name)\n is_global = global?\n smart_paths.effective_paths(typed_name.type).each do |sp|\n next unless sp.valid_name?(typed_name)\n origin = sp.effective_path(typed_name, is_global ? 0 : 1)\n unless origin.nil?\n if sp.fuzzy_matching?\n # If there are multiple *specific* paths for the file, find\n # whichever ones exist. Otherwise, find all paths that *might* be\n # related to origin\n if origin.is_a?(Array)\n origins = origin.map { |ori| existing_path(ori) }.compact\n return [origins, sp] unless origins.empty?\n else\n origins = candidate_paths(origin)\n return [origins, sp] unless origins.empty?\n end\n else\n existing = existing_path(origin)\n return [origin, sp] unless existing.nil?\n end\n end\n end\n nil\n end", "def xpath_first(outer_set, path_name)\n outer_set.xpath(path_name).first\n end", "def find_by_path(path, flags={})\n if parseit = path.match(/^.*?(([^\\/]+)\\/)?([^\\/]+?)(\\.git)?$/)\n if proj = Project.find_by_identifier(parseit[3]) || !GitHosting.multi_repos?\n # return default or first repo with blank identifier (or first Git repo--very rare?)\n proj && (proj.repository || proj.repo_blank_ident || proj.gitolite_repos.first)\n elsif repo_ident_unique? || flags[:loose] && parseit[2].nil?\n find_by_identifier(parseit[3])\n elsif parseit[2] && proj = Project.find_by_identifier(parseit[2])\n find_by_identifier_and_project_id(parseit[3],proj.id) ||\n flags[:loose] && find_by_identifier(parseit[3]) || nil\n else\n nil\n end\n else\n nil\n end\n end", "def longest_common_subpath(paths)\n return if paths.empty?\n\n lcsp = Pathname.new(paths[0])\n\n paths[1..-1].each do |path|\n until ascendant_of?(lcsp, path)\n if lcsp.root?\n # If we get here a root directory is not an ascendant of path.\n # This may happen if there are paths in different drives on\n # Windows.\n return\n else\n lcsp = lcsp.parent\n end\n end\n end\n\n lcsp\n end", "def path(*a)\n return @path if a.empty?\n ret = File.join(@path, *(a.map { |arg| arg.to_s }))\n ret = File.expand_path(ret) # Try to fix some heroku issues (?)\n File.exists?(ret) ? ret : nil\n end", "def pick_candidate(paths, new_path, element)\n # NOTE: order here is important due to early matching\n candidates = [element + \"/\", element + \"[1]\",\n element.sub(/\\[\\d+\\]/, \"\"), element]\n paths.each do |p|\n candidates.each do |c|\n return c if p.start_with?(new_path + c)\n end\n end\n end", "def first(path_stack, node); end", "def full_path\n look_in.each do |dir|\n extensions.each do |ext| \n path = File.join(dir, [@path, ext].join)\n if File.exists?(path) && File.file?(path)\n return path\n end\n end\n end\n return\n end", "def find_min_path(i, j)\n return 1 if i == 0 || j == 0\n return find_min_path(i-1, j) + find_min_path(i, j-1)\nend", "def last_for_path(repo, ref, path = nil)\n where(\n repo: repo,\n ref: ref,\n path: path,\n limit: 1\n ).first\n end", "def find_path(x, y, path = [])\n if x.zero? && y.zero?\n @results << path\n return 1\n elsif x < 0 || y < 0\n return 0\n elsif @grid[x][y] == 1\n return 0\n end\n\n new_path = path.dup\n new_path.insert(0, [y, x])\n\n @cache[[x - 1 , y]] ||= find_path(x - 1, y, new_path)\n @cache[[x, y - 1]] ||= find_path(x, y - 1, new_path)\n end", "def find_nearest_route(path)\n\t\t\tpath_parts = path.parts.dup\n\t\t\tloop do\n\t\t\t\troute = routes.navigate(*path_parts)&.first_route\n\t\t\t\tbreak route if route || path_parts.pop.nil?\n\t\t\tend\n\t\tend", "def select_file(*files)\n files.each do |file|\n if File.exists?(file) then return file end\n end\n return nil\n end", "def find_file(file_name, path_array)\n result = nil\n lookup = []\n\n unless path_array.empty?\n search_paths = path_array\n\n if path_array.first.kind_of? String\n search_paths = [path_array]\n end\n\n search_paths.each do |elem|\n full_path = (elem.kind_of?(String)) ? elem : File.join(elem)\n\n files = Dir.glob(File.join(full_path, file_name))\n\n unless files.empty?\n result = files.sort.last\n break\n else\n lookup << full_path\n end\n end\n end\n\n if result.nil?\n fail \"Could not find file #{file_name} at #{lookup.join(', ')}\"\n end\n\n result\nend", "def find_data_path(path)\n each_data_path(path).first\n end", "def any?(*paths)\n catch(:done){ traverse(*paths){|f| throw(:done, true) if yield f }}\n end", "def select_possible_path(possible_paths)\n vertex, data = possible_paths.min_by do |vertex, data|\n data[:cost]\n end\n vertex\nend", "def path_to glob\n paths_to(glob).first\n end", "def paths_split(paths, filename)\n paths.each do |path|\n base = \"#{path}#{File::SEPARATOR}\"\n if filename.start_with?(base)\n return path, filename[base.length..-1]\n end\n end\n nil\n end", "def concat(*paths) = add(paths, position: :last)", "def find_on_path( s )\n # for now, Windows-only; parameter s with or without path\n if ARCH != 'w32'\n return nil\n end\n ENV['PATH'].gsub( \"\\\\\", \"/\" ).split( /;/ ).each do |d|\n d = File.expand_path( d ) # this seems a syntactic operation\n s_full = d.sub( /\\/$/, '' ) + '/' + s\n if test( ?d, d ) and test( ?f, s_full )\n return s_full\n end\n ENV['PATHEXT'].split( /;/ ).each do |e|\n # components of PATHEXT should include leading dot\n s_full = d.sub( /\\/$/, '' ) + '/' + s + e\n if test( ?f, s_full )\n return s_full\n end\n end # do |e|\n end # do |d|\n return nil\nend", "def find_shortest_path(exclude_path_with_tile = nil)\n node = find_end_tile(exclude_path_with_tile)\n return [@start_tile, @end_tile] if node.nil?\n expand_path(node)\n end", "def require_path\n val = require_paths and val.first\n end", "def xpath_first(doc, path, pnamespace = '')\n elements = xpath_all(doc, path, pnamespace)\n (elements != nil) ? elements.first : nil\n end", "def _find_(type, filename, extnames=nil)\n if type.nil? || filename.nil?\n return nil\n end\n\n if absolute?(filename)\n return File.exists?(filename) ? filename : nil\n end\n\n path(type).each do |dir|\n each_full_path(dir, filename, extnames) do |full_path|\n if File.exists?(full_path) && subpath?(dir, full_path)\n return full_path\n end\n end\n end\n\n nil\n end", "def relative(paths, reference_path = Dir.pwd)\n paths = [paths].flatten.collect do |path|\n path = Pathname.new(File.expand_path(path))\n reference_path = Pathname.new(File.expand_path(reference_path))\n path.relative_path_from(reference_path).to_s\n end\n\n paths.length == 1 ? paths.first : paths\n end", "def common_dir(*paths)\n fail ArgumentError, 'At least one path is required' if paths.empty?\n\n paths.map do |path|\n new(path).dirname.ascendants\n end.inject(:&).first\n end", "def get_path(fullpath = \"\")\n (fullpath || \"\").scan(/^[\\w+|\\/]+/)[0]\n end", "def call\n return nil unless on_the_graph? # Prevents a stack overflow in the gem\n return shortest_path[1..-1] if shortest_path.length > 1\n end", "def lookup_file_path\n file_path_list.each do |candidate_file_path|\n next unless File.file?(File.expand_path(candidate_file_path))\n return candidate_file_path\n end\n nil\n end", "def entrance(*path_or_paths)\n return if @skip_set_entrance\n @paths += path_or_paths\n end", "def xpath_first(doc, path, pnamespace = '')\n elements = xpath_all(doc, path, pnamespace)\n (elements != nil) ? elements[0] : nil\n end", "def unshift(*paths) = add(paths, position: :first)", "def existent(path)\n expanded(path).select { |f| File.exist?(f) }\n end", "def path_for(filename)\n return nil unless filename\n for dir in @dirs\n result = path_from_dir_for(dir,filename)\n return result if result\n end\n @logger.fatal(\"Failed to locate '#{filename}'\")\n return nil\n end", "def pathTo(name)\r\n\t\tif @paths.nil?\r\n\t\t\treturn nil\r\n\t\tend\r\n\t\t@paths.each do |path|\r\n\t\t\tif path.getDestination().getName() == name\r\n\t\t\t\treturn path\r\n\t\t\tend\r\n\t\tend\r\n\t\treturn nil\r\n\tend", "def find_path(path)\n @data.each_pair do |name, dir|\n if dir[:directory] == path\n return Directory::new(name, dir)\n end\n end\n \n return nil\n end", "def min_path\n if @layers.count == 2\n return [ top ] + [ @layers[1].min ]\n end\n\n left_min_path = left_child.min_path\n left_min_path_sum = left_min_path.inject(0, :+)\n right_min_path = right_child.min_path\n right_min_path_sum = right_min_path.inject(0, :+)\n\n if left_min_path_sum < right_min_path_sum\n [ top ] + left_child.min_path \n else\n [ top ] + right_child.min_path\n end\n end", "def preferred_sources(paths)\n paths.collect do |source_path|\n PREFERRED_EXTENSIONS.inject(nil) do |source_file, extension|\n source_file || begin\n path = File.join(@folder, \"#{source_path}.#{extension}\")\n File.exists?(path) ? path : nil\n end\n end\n end.compact\n end", "def contains_path(one_or_all, *paths)\n fn = json_op(:contains_path, self, one_or_all.to_s, *paths)\n Sequel::SQL::BooleanExpression.new(:NOOP, fn)\n end", "def first(*args)\n find_first_or_last(:first, *args)\n end", "def first( path_stack, node )\n return nil if path.size == 0\n\n case path[0]\n when :document\n # do nothing\n return first( path[1..-1], node )\n when :child\n for c in node.children\n r = first( path[1..-1], c )\n return r if r\n end\n when :qname\n name = path[2]\n if node.name == name\n return node if path.size == 3\n return first( path[3..-1], node )\n else\n return nil\n end\n when :descendant_or_self\n r = first( path[1..-1], node )\n return r if r\n for c in node.children\n r = first( path, c )\n return r if r\n end\n when :node\n return first( path[1..-1], node )\n when :any\n return first( path[1..-1], node )\n end\n return nil\n end", "def get_path( source_node, *path )\n h = source_node.to_hash\n path.inject(h) { |obj, item| obj[item.to_s] || break }\nend", "def get(path, default=nil)\n path = path.split('.') if path.is_a?(String)\n return default if path.nil? or (path.respond_to?(:empty?) and path.empty?)\n\n # flatten/arrayify all path components\n path = [*path]\n\n # stringify keys and set root to self\n root = self.stringify_keys()\n key = path.first.to_s\n rest = path[1..-1]\n\n # if current path component is in this hash...\n if root.has_key?(key)\n # if the value is a hash\n if root[key].is_a?(Hash)\n # return default or value if no more path components are left\n return (root[key].nil? ? default : root[key]) if rest.empty?\n\n # otherwise recurse into sub-hash\n return root[key].get(rest, default)\n\n # if the value is an array of hashes\n elsif root[key].is_a?(Array) and root[key].first.is_a?(Hash)\n # return default or value if no more path components are left\n return (root[key].nil? ? default : root[key]) if rest.empty?\n\n # otherwise, for each array item, recurse and return array of sub-hashes\n return root[key].collect{|v|\n v.get(rest, default)\n }.flatten()\n else\n # value is a scalar, return value or default\n return (root[key].nil? ? default : root[key])\n end\n else\n # short circuit to default\n return default\n end\n end", "def find_existing(path)\n until File.directory?(path)\n path = File.dirname(path)\n end\n path\n end", "def find_alternative_paths\n reset\n \n @pairs.reverse!\n find_paths\n @pairs.reverse!\n\n @pairs.map{|pair| pair.path}\n end", "def get_path_by_names(start, stop)\n s1 = get_node(start)\n s2 = get_node(stop)\n if s1 != nil && s2 != nil\n return get_path(s1, s2)\n end\n Array.new \n end", "def fetch_path(*args)\n args = args.first if args.length == 1 && args.first.kind_of?(Array)\n raise ArgumentError, \"must pass at least one key\" if args.empty?\n\n result = self\n args.each_with_index do |key, i|\n raise ArgumentError, \"must be a number\" if result.kind_of?(Array) && !key.kind_of?(Numeric)\n\n result = result[key]\n if !result.respond_to?(:fetch_path) && (i + 1) != args.size\n result = nil\n break\n end\n end\n result\n end", "def find(path); end", "def find(path); end", "def find_path_with_base(f)\n Dir.glob(f + \"*\").first || \"\" # don't return nil; makes for bad spec error messages\nend", "def select(files, context, path)\n files = get_paths(files, context)\n files.each_with_index do |f, i|\n file = path ? File.join(path, f) : f\n if exists(file, context)\n return f\n # If \"file.html || none\" is passed, fail gracefully\n elsif i == files.size - 1\n return f.downcase == 'none' ? false : f\n end\n end\n end", "def relative_path_from(other_path)\n out = [ ]\n\n matching_prefix = true\n 0.upto(@parts.length - 1) do |index|\n matching_prefix = false unless @parts[index] == other_path.part(index)\n out << @parts[index] unless matching_prefix\n end\n\n FilePath.new(*out)\n end", "def join_paths(*args)\n paths = []\n full_path = []\n temp_paths = []\n args.each {|x| temp_paths << x }\n temp_paths.flatten!\n temp_paths.each do |x|\n unless x.nil?\n paths << x.to_s.dup\n end\n end\n if paths[0].start_with?('/')\n absolute_path = true\n else\n absolute_path = false\n end\n paths.each do |path|\n unless path.nil?\n path.strip!\n path.slice!(0) while path.start_with?('/')\n path.chop! while path.end_with?('/')\n full_path << path\n end\n end\n full_path_string = full_path.join('/')\n full_path_string.slice!(0) while full_path_string.start_with?('/')\n full_path_string.chop! while full_path_string.end_with?('/')\n full_path_string.insert(0, '/') if absolute_path == true\n full_path_string\n end", "def check_file(filenames)\n filenames.select{ |f| File.exists?(f) }.first\n end", "def find_path(start, finish, *avoid_sectors)\n shortest_path(start, finish, avoid_sectors.flatten)\n end", "def path_comps path\n path.nil? || path.empty? ? [] : path[1..(path[-1] == \"/\" ? -2 : -1)].split('/')\n end", "def blocking_path(path)\n current_path = self.path\n relative_path = '.'\n File.dirname(path).split(File::SEPARATOR).each do |segment|\n relative_path = File.join(relative_path, segment)\n current_path = File.join(current_path, segment)\n return relative_path if File.file?(current_path)\n end\n nil\n end", "def find_first(xpath, nslist = nil)\n find(xpath, nslist).first\n end", "def prepend(*paths) = add(paths, position: :first)", "def mungle_paths(paths)\n return paths if terraform.pre_0_12?\n\n paths.map do |path|\n File.directory?(path) ? path : File.dirname(path)\n end.uniq\n end", "def get_relative_paths(paths)\n paths.collect do |p|\n get_relative_path(p)\n end\n end", "def match_paths(path)\n # Turn multiple slashes into one\n # nodes//x -> nodes/x\n path = path.gsub(%r{[/]+}, \"/\")\n # If it's absolute, start the matching with /. If it's relative, start with '' (relative root).\n if path[0] == \"/\"\n matches = [ \"/\" ]\n else\n matches = [ \"\" ]\n end\n\n # Split the path, and get rid of the empty path at the beginning and end\n # (/a/b/c/ -> [ 'a', 'b', 'c' ])\n parts = path.split(\"/\").select { |x| x != \"\" }.to_a\n\n # Descend until we find the matches:\n # path = 'a/b/c'\n # parts = [ 'a', 'b', 'c' ]\n # Starting matches = [ '' ]\n parts.each_with_index do |part, index|\n # For each match, list <match>/<part> and set matches to that.\n #\n # Example: /*/foo\n # 1. To start,\n # matches = [ '/' ], part = '*'.\n # list('/', '*') = [ '/organizations, '/users' ]\n # 2. matches = [ '/organizations', '/users' ], part = 'foo'\n # list('/organizations', 'foo') = [ '/organizations/foo' ]\n # list('/users', 'foo') = [ '/users/foo' ]\n #\n # Result: /*/foo = [ '/organizations/foo', '/users/foo' ]\n #\n matches = matches.parallel_map do |pth|\n found, error = list(pth, part)\n if error\n if parts[0..index - 1].all? { |p| p != \"*\" }\n raise error\n end\n\n []\n else\n found\n end\n end.flatten.to_a\n end\n\n matches\n end", "def common_directory paths\n dirs = paths.map{|path| path.split('/')}\n min_size = dirs.map{|splits| splits.size}.min\n dirs = dirs.map{|splits| splits[0...min_size]}\n uncommon_idx = dirs.transpose.each_with_index.find{|dirnames, idx| dirnames.uniq.length > 1}.last\n dirs[0][0...uncommon_idx].join('/')\n end", "def path_finder(value, structure, path = [])\n #i tracks the index of the current array\n if value == structure\n path << true\n end\n if !path.include?(true)\n # binding.pry\n if structure.respond_to?(:each)\n #test each element of the hash\n structure.each do |element_key, element_value|\n if !path.include?(true)\n #once we've captured \"true\", we don't need to add to the path anymore\n path << element_key\n end\n if element_value == value\n path << true\n else\n path = path_finder(value, element_value, path)\n if !path.include?(true)\n #if path comes back from a false branch, remove the last part\n path.pop\n end\n end\n end\n else\n return path\n end\n end\n path\nend", "def get_path(f, t)\n if(f > t)\n from = t\n to = f\n else\n from = f\n to = t\n end\n @paths.each { |path| return path if(path.from==from && path.to==to) }\n return 0\n end", "def resolve(logical_path, options = {})\n # If a block is given, preform an iterable search\n if block_given?\n args = attributes_for(logical_path).search_paths + [options]\n trail.find(*args) do |path|\n yield Pathname.new(path)\n end\n else\n resolve(logical_path, options) do |pathname|\n return pathname\n end\n raise FileNotFound, \"couldn't find file '#{logical_path}'\"\n end\n end", "def lookup_path(path, dir)\n dir = ::File.expand_path(dir)\n top = ::File.expand_path(wiki.path)\n home = ::File.expand_path('~')\n\n loop do\n found = Dir[::File.join(dir, path)].first\n return found if found\n return nil if dir == top\n return nil if dir == home # just in case\n return nil if dir == '/' # doubly so\n dir = ::File.dirname(dir)\n end\n end", "def path_from_start_elements(start, elements = [])\n (start.empty? ? '/' : '') + elements.join('/')\nend", "def resolve_path(path)\n path = File.absolute_path(path) if path.start_with?('./') || path.start_with?('../')\n\n if Pathname.new(path).absolute?\n return path if File.exists?(path)\n return nil\n end\n\n @load_path.each do |load_path|\n possible_path = File.absolute_path(path, load_path)\n return possible_path if File.exists?(possible_path)\n end\n\n nil\n end", "def css_search_first(path)\n\t\tself.cs(path).first\n\tend", "def finished?(paths)\n paths.each do |path|\n if path.last == @final_position\n @path = path[1..-1]\n end\n end\n @path\n end", "def by_path(path); end", "def next_step_from(paths)\n paths.map do |path|\n possible_neighbours(path.most_recent_step.coordinate, @max_x, @max_y) \n .map { |c| coord_to_step_on_path(c, path) }\n .reject { |p| p == nil }\n end\n .flatten\n end", "def join(*args)\n args.unshift self\n result = Path.new(args.pop)\n return result if result.absolute?\n args.reverse_each { |arg|\n arg = Path.new(arg)\n result = arg / result\n return result if result.absolute?\n }\n result\n end", "def FilePath\n if(FilePaths.length == 0)\n return nil\n end\n return FilePaths[0]\n end", "def just_find_it(here=Pathname.pwd)\n mainfile = here + MAINFILE\n return mainfile if mainfile.exist?\n return nil if here == here.parent\n return just_find_it(here.parent)\nend", "def get_path_recursively(previouses, vert1, vert2)\n return vert1 if vert1 == vert2\n raise ArgumentError, \"No path from #{vert1} to #{vert2}\" if previouses[vert2].nil?\n [vert2, get_path_recursively(previouses, vert1, previouses[vert2])].flatten\n end", "def find(file, paths)\n if(Pathname.new(file).absolute?)\n return unless (timestamp = mtime(file))\n @logger.debug(\"Found #{file}\")\n [ file, timestamp ]\n else\n paths.each do |path|\n fullpath = File.expand_path((File.join(path, file)))\n next unless (timestamp = mtime(fullpath))\n @logger.debug(\"Found #{file} in #{fullpath}\")\n return([ fullpath, timestamp ])\n end\n return(nil)\n end\n end", "def paths?\n !paths.empty?\n end", "def pull_to_path(*names)\n names.each { |name| pull_to_start name }\n end", "def group_directories_first\n return if @group_directories == :none\n\n files = @files\n dirs = files.select { |f| File.directory?(f) }\n # earlier I had File? which removed links, esp dead ones\n fi = files.reject { |f| File.directory?(f) }\n @files = if @group_directories == :first\n dirs + fi\n else\n fi + dirs\n end\nend", "def get_path_recursively(previouses, src, dest)\n return src if src == dest\n raise ArgumentError, \"No path from #{src} to #{dest}\" if previouses[dest].nil?\n [dest, get_path_recursively(previouses, src, previouses[dest])].flatten\n end", "def resolve path\n return nil if path.nil?\n lefts = [path]\n rights = ['']\n lefts.push(\"#{path}s\") if might_be_plural?\n rights.push(might_have_extension) if might_have_extension\n try_these = lefts.map{|x| rights.map{|y| \"#{x}#{y}\"}}.flatten\n try_these.each do |try|\n if File.exist?(try)\n return try\n end\n end\n return false\n end", "def find_files( path )\n file_paths.each_with_object([]) do |search_path,obj|\n found = File.join( search_path, path )\n obj << found if File.exist? found\n end.reverse.uniq\n end", "def match_root_folder(path)\n SETTINGS.each_key do |key|\n return SETTINGS[key] if path.index(SETTINGS[key]['path'])\n end\n return nil\nend", "def find_file( path )\n find_files( path ).first\n end", "def get(path, zeroIdx, idx)\n idx < zeroIdx ? 0 : path[idx]\nend", "def find_next\n status = `git status -s`.lines.reject(&:nil?).grep(/.. (PCL|tsion|steveklabnik)\\//)\n return nil if status.empty?\n\n first = status.map{|x| x.gsub(/^.. /, '') }.first.strip\n \n if File.directory?(first) \n return [first, [first]]\n else\n name = first.split('/')[-1].split('_', 2)[1]\n end\n\n pcl = find_file('PCL', name)\n tsion = find_file('tsion', name)\n steve = find_file('steveklabnik', name)\n\n [name, [pcl, tsion, steve]]\n end", "def entity_for_path(path)\n local_entities_list.find do |e|\n path[0, e.path.length] == e.path\n end\n end", "def processNextStart()\n while true\n path = starts.next\n if building_path\n if compare.call path.first, building_path.first\n add_path path\n else\n return next_path(path)\n end\n else\n next_path(path)\n end\n end\n rescue Pacer::EmptyPipe, java.util.NoSuchElementException\n if building_path\n r = building_path\n self.building_path = nil\n r\n else\n raise EmptyPipe.instance\n end\n end" ]
[ "0.72064084", "0.6627912", "0.65136635", "0.6481619", "0.638956", "0.6097864", "0.6002848", "0.5953102", "0.5939572", "0.5894156", "0.58747023", "0.58626807", "0.57939816", "0.57574594", "0.57429886", "0.57225275", "0.5713313", "0.5698395", "0.56867754", "0.5674942", "0.564055", "0.5635744", "0.55962884", "0.55835533", "0.5581424", "0.5580066", "0.5566785", "0.5564914", "0.5534266", "0.5515057", "0.55125636", "0.54893947", "0.5483339", "0.5479914", "0.5479491", "0.54747665", "0.5474444", "0.54716766", "0.54700464", "0.54682004", "0.5454255", "0.5453664", "0.5446481", "0.5439567", "0.5411333", "0.53761995", "0.5370521", "0.53673357", "0.5366307", "0.536344", "0.53599024", "0.5338218", "0.53359497", "0.5332669", "0.53092813", "0.53024536", "0.529785", "0.5287447", "0.5287447", "0.5282464", "0.52744186", "0.5268848", "0.5263644", "0.52635837", "0.52569884", "0.52519155", "0.52485806", "0.52448624", "0.5240673", "0.5238838", "0.52378714", "0.523538", "0.52264315", "0.52251774", "0.5222949", "0.5220271", "0.5218252", "0.52151537", "0.5209908", "0.5190218", "0.51882917", "0.5186156", "0.51834786", "0.5183386", "0.51819694", "0.5181119", "0.51725113", "0.51601654", "0.5157363", "0.5155484", "0.5149294", "0.5135141", "0.51316404", "0.5128971", "0.5127232", "0.51241815", "0.51232046", "0.51221365", "0.5107568", "0.51068187" ]
0.8213236
0
does some basic form validation, uses the most recent Veritable analysis completed to make a prediction for the time the task will actually take, and adds the new task and estimates to the database
def register_estimate(params) # half-hour increments params.update(:user_estimate => [1, (params[:user_estimate].to_f * 2).round].max) if params[:user_estimate] > 0 # check to make sure that the user's estimate is meaningful a = most_recent_analysis_succeeded veritable_estimate = a.predict(stringify_hash_keys(params).update( 'true_time' => nil, # this is what we're predicting 'user_class' => params[:user_class] ))['true_time'] Task.create(params.update(:veritable_estimate => veritable_estimate)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def estimate\n if self.submitted? && (Time.now - self.updated_at) > 5 * 60\n # re-initialize the estimates\n self.estimated_cost = nil\n self.estimated_duration = nil\n # only estimate projects with a budget of $200K! because why bother!\n budget = self.budget_allocated\n if budget > 200_000\n # give them a 50/50\n if rand > 0.5\n # estimate the number of college grads needed during the time frame + 30%\n # to consume the budget * 2\n days = ((self.end_date - self.start_date) * 1.3).ceil\n budget_per_day = budget * 2 / days\n student_per_day = 200 * 8 # $200/hour * 8 hours\n students = (budget_per_day / student_per_day).ceil\n self.estimated_cost = students * student_per_day * days\n self.estimate_breakdown = number_with_delimiter(students) + ' resources needed at $200/hour for ' +\n number_with_delimiter(days) + ' days.'\n self.estimated_duration = (self.start_date + days * 7 / 5).strftime(\"%B %-m %Y\")\n else\n self.estimate_breakdown = 'Jay has reviewed your request, and does not believe the requirements are ' +\n 'feasible within the budget and time frames. Please try submitting another request.'\n end\n else\n self.estimate_breakdown = 'Jay has reviewed your request, and the allocated budget is not sufficient to meet ' +\n 'the requirements. Please try submitting another request.'\n end\n self.status = :complete\n self.save\n end\n end", "def doValidation\r\n\t\tprepare if ! @machine\r\n\t\ti = 0 \r\n\t\twhile i < @trainTestStruct.testSetCount\r\n\t\t\ttrainTestDataSplit = getTargets @trainTestStruct.testSets(i)\r\n\t\t\t@trainTestStruct.pushResult @machine.validateSet(trainTestDataSplit.first, trainTestDataSplit.last, @predictionType)\r\n\t\t\ti += 1\r\n\t\tend\r\n\tend", "def validate\n \n \n end", "def validate\r\n\r\n end", "def submits; end", "def check\n @trainer = Trainer.find(params[:id])\n temp = session[@trainer.id.to_s + \"_trainer\"]\n temp[:user_ans] = params[:user_ans].to_f.round(1)\n @generated_task = temp\n end", "def validate_time_to_market\n # lead time based on priority!\n today = Date.today\n days = (self.start_date - today).to_i\n if days < LEAD_TIME[self.priority]\n add_validation 'Start date must be at least ' + LEAD_TIME[self.priority].to_s + ' days in advance for ' +\n EngagementRequest::PRIORITIES[self.priority] + ' priority'\n end\n\n # 30 day minimum!\n length = (self.end_date - self.start_date).to_i\n if length < 30\n add_validation 'Projects with a length of less than 30 days will not be considered'\n end\n\n # must start on a Monday and end on a Friday\n if self.start_date.wday != 1\n add_validation 'Start Date must be a Monday'\n end\n if self.end_date.wday != 5\n add_validation 'End Date must be a Friday'\n end\n\n # cost reduction projects!\n cost_reduction = ['Operations Streamlining', 'Manufacturing Efficiency'].include? self.program.name\n if cost_reduction && self.projected_revenue != 0\n add_validation self.program.name + ' is not expected to generate revenue'\n end\n if cost_reduction && ! self.low_risk?\n add_validation self.program.name + ' projects must be low risk'\n end\n\n # potential profit!\n profit = self.projected_revenue - self.budget_allocated\n if ! cost_reduction && profit < RISK_REWARD[self.risk_rating]\n add_validation EngagementRequest::RISK_RATINGS[self.risk_rating] +\n ' risk projects should be expected to produce at least ' +\n number_to_currency(RISK_REWARD[self.risk_rating]) + ' profit'\n end\n\n # risks should be defined! 5 sentences!\n validate_sentences_length 'Risks', self.risks, 100, 500, 5\n end", "def assess\n @latest_assessment = @task.assessments.find_or_initialize_by_assessed_on(Time.now.to_date)\n @latest_assessment.attributes = params[:latest_assessment]\n if @latest_assessment.save\n respond_to do |format|\n format.html do\n flash[:notice] = 'Task progress was recorded.'\n flash[:highlight_dom_id] = dom_id(@latest_assessment)\n redirect_to task_path(@task)\n end\n end\n else\n respond_to do |format|\n format.html { render :action => 'show' }\n end\n end\n end", "def custom_validations\n self.validate_baseline && validate_baseline_date && \n self.validate_trial_days && self.validates_goal_name && self.validation_due_date\n end", "def create\n student_answers_hash = assessment_info_params[:student_answers]\n student_answers = student_answers_hash.collect { |s| StudentAnswer.new( s)}\n\n assessment_info_map = assessment_info_params.except(:student_answers)\n\n\n\n assessment_info_map[:student_answers] = student_answers\n\n @assessment_info = AssessmentInfo.new( assessment_info_map )\n @assessment_info.student_user_id = current_user.id\n\n\n\n\n\n respond_to do |format|\n correct_count = 0\n if @assessment_info.save\n\n @assessment_info.student_answers.each do |student_answer|\n\n sa = StudentAnswer.find(student_answer.id)\n\n if sa.question.question_type == 0\n if sa.answer_choice_id == sa.question.question_answers.first.choice_id\n sa.correct = true\n correct_count = correct_count + 1\n else\n sa.correct = false\n end\n sa.save!\n elsif student_answer.question.question_type == 1\n if student_answer.answer_text == student_answer.question.answer\n sa.correct = true\n correct_count = correct_count + 1\n else\n sa.correct = false\n end\n sa.save!\n end\n\n end\n\n @assessment_info.result = correct_count.to_d/@assessment_info.student_answers.count*100\n #if result less than passing grade set the concept as incomplete\n @learned_concept = LearnedConcept.find_by(concept_id: @assessment_info.assessment.concept_id)\n if !@learned_concept\n\n @learned_concept = LearnedConcept.new\n @learned_concept.concept_id = @assessment_info.assessment.concept.id\n @learned_concept.learned_course_id = @assessment_info.assessment.concept.course_id\n end\n if @assessment_info.result < @assessment_info.assessment.min_passing_grade\n @learned_concept.completed = false\n else\n @learned_concept.completed = true\n end\n @learned_concept.save\n @assessment_info.save\n format.html { redirect_to @assessment_info, notice: 'assessment was submitted.' }\n format.json { render :show, status: :created, location: @assessment_info }\n else\n format.html { render :new }\n format.json { render json: @assessment_info.errors, status: :unprocessable_entity }\n end\n end\nend", "def check_submit_valid\n begin\n if params[:status][:source].length > \n JS_CONFIG[\"limits\"][\"max_source_code_len\"]\n raise t(\"status.prompts.source_code_too_long\") \n end\n begin\n @problem = Problem.find(params[:status][:pid])\n rescue\n raise t(\"problem.prompts.nonexist\")\n end\n if params[:status][:contest_belong].to_i == 0 &&\n @problem.hide && !current_user.is_admin?\n raise t(\"problem.prompts.nonexist\")\n else\n begin\n @contest = Contest.find(params[:status][:contest_belong].to_i)\n rescue\n raise t(\"contest.prompts.nonexist\")\n end\n unless @contest.has_user(current_user.username)\n raise t(\"global.prompts.access_denied\");\n end\n if ContestProblem.where(\n cid: params[:status][:contest_belong].to_i,\n pid: params[:status][:pid].to_i).empty?\n raise t(\"problem.prompts.nonexist\")\n end\n end\n raise t(\"status.prompts.language_unspecified\") if \n params[:status][:language].to_i == 0\n last_status = Status.where(username: current_user.username)\n .order(time_submit: :desc).first\n raise t(\"global.prompts.too_frequent\") if\n Time.now - last_status.time_submit < 5\n rescue Exception => e\n render status: :not_acceptable, json: { msg: e.message }\n return\n end\n end", "def validation; end", "def validation; end", "def create\n\nif params[:commit] == \"survey\" then\n @value = params[:opinion]\n @opinion = current_user.opinions.new\n @opinion.question_id = @value[:question].to_i\n @opinion.save\n redirect_to(home_path(:question => @opinion.question_id))\nelse\n did_save = false\n @bp = current_user.bps.new(params[:bp])\n @measurement = current_user.measurements.new(params[:measurement])\n @food = current_user.foods.new(params[:foods])\n @sleep = current_user.sleeps.new(params[:sleep])\n \n # flash[:notice] = \"\"\n if !@bp.systolic.blank? && !@bp.diastolic.blank? then \n did_save = @bp.save \n flash[:notice] =\"Records updated.\"\n end\n\n if @sleep.started_at != @sleep.woke_up_at then \n did_save = @sleep.save \n flash[:notice] =\"Records updated.\"\n end\n\n if !( @measurement.water_percent.blank? && @measurement.muscle_percent.blank? && @measurement.chest.blank? && @measurement.weight.blank? && @measurement.visceral_fat.blank? && @measurement.bicep.blank? && @measurement.belly.blank? && @measurement.hip.blank? && @measurement.thigh.blank? && @measurement.resting_metabolism.blank? && @measurement.fat_percent.blank? && @measurement.comment.blank? ) then\n did_save = @measurement.save\n flash[:notice] = \"Records updated.\"\n end\n\n if !(@food.name.blank? &&\n # @food.complex_carbs.blank? &&\n # @food.monounsaturated_fats.blank? &&\n # @food.category.blank? &&\n # @food.subcategory.blank? &&\n # @food.fiber.blank? &&\n # @food.simple_carbs.blank? &&\n @food.meal.blank? &&\n # @food.protein.blank? &&\n #@food.saturated_fats.blank? &&\n #@food.comment.blank? &&\n #@food.polyunsaturated_fats.blank? &&\n @food.calories_per_serving.blank? ) then \n did_save = @food.save\n flash[:notice] = \"Records updated\"\n end\n\n\n\n unless did_save then\n flash[:notice] = \"There were no updates, please fill out the required data and submit again.\"\n end \n \n redirect_to(home_path) \n\nend \n\nend", "def new\n @evaluation_result = EvaluationResult.new\n\n #Carregar a apointment dinamicamente\n @appoint_id = 0\n if !params[:appID].blank?\n @appoint_id = params[:appID].to_i\n end\n\n @wais = nil\n @wms = nil\n @tmt = nil\n @ftt = nil\n @clock = nil\n\n app = Appointment.find(@appoint_id)\n s = AppointmentStatus.find_by_name(\"Realizada\")\n app.appointment_status = s\n app.save\n\n #atual (a que acabou de se realizada)\n appoint_plan = AppointmentPlan.where(:appointment_id => @appoint_id)\n @patient = appoint_plan.first.appointment.patient\n appoint_plan.each do |a|\n if(a.evaluation_test.name == \"wais\")\n @wais = WaisResult.where(:appointment_plan_id => a.id)\n end\n if(a.evaluation_test.name == \"wms\")\n @wms = WmsResult.where(:appointment_plan_id => a.id)\n end\n if(a.evaluation_test.name == \"ftt\")\n @ftt = FttResult.where(:appointment_plan_id => a.id)\n end\n if(a.evaluation_test.name == \"tmt\")\n @tmt = TmtResult.where(:appointment_plan_id => a.id)\n end\n if(a.evaluation_test.name == \"clock\")\n @clock = ClockResult.where(:appointment_plan_id => a.id)\n end\n end\n\n #a antiga\n @waisOld = nil\n @wmsOld = nil\n @tmtOld = nil\n @fttOld = nil\n @clockOld = nil\n\n old_appoint = Appointment.joins(:appointment_status).where(\"appointments.patient_id = #{@patient.id} AND appointments.id != #{@appoint_id} AND appointments.appointment_day < '#{app.appointment_day.strftime(\"%Y-%m-%d\")}' AND appointment_statuses.name = 'Realizada'\").order(\"appointments.appointment_day DESC\")\n\n if old_appoint.count > 0\n appoint_old_plan = AppointmentPlan.where(:appointment_id => old_appoint.first.id)\n\n appoint_old_plan.each do |a|\n if(a.evaluation_test.name == \"wais\")\n @waisOld = WaisResult.where(:appointment_plan_id => a.id)\n end\n if(a.evaluation_test.name == \"wms\")\n @wmsOld = WmsResult.where(:appointment_plan_id => a.id)\n end\n if(a.evaluation_test.name == \"ftt\")\n @fttOld = FttResult.where(:appointment_plan_id => a.id)\n end\n if(a.evaluation_test.name == \"tmt\")\n @tmtOld = TmtResult.where(:appointment_plan_id => a.id)\n end\n if(a.evaluation_test.name == \"clock\")\n @clockOld = ClockResult.where(:appointment_plan_id => a.id)\n end\n end\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluation_result }\n end\n end", "def create\n p = params[:prediction]\n q = filter_params(p)\n p = Prediction.where(nt: q[:nt], cutoff: q[:cutoff]).where(\"res_seq like ?\", \"%#{q[:res_seq]}%\").first\n @prediction = Prediction.new q\n unless p.nil?\n i = p.res_seq.index q[:res_seq]\n @prediction.res_status = p.res_status[i, q[:res_seq].length]\n @prediction.res_ri = p.res_ri[i, q[:res_seq].length]\n @prediction.pdb_flag = p.pdb_flag\n @prediction.pdb_id = p.pdb_id\n end\n\n respond_to do |format|\n if @prediction.save\n @notice = \"Your task were accepted, the result will be sent to you by email\"\n Resque.enqueue(ProgressPrediction, @prediction.id, q[:email])\n format.html { render action: \"new\" }\n format.json { render json: @prediction, status: :created, location: @prediction }\n else\n format.html { render action: \"new\" }\n format.json { render json: @prediction.errors, status: :unprocessable_entity }\n end\n end\n end", "def validate_workflow\n e = 0\n status_usage = Array.new( flow_list.count, 0 )\n obsolete_use = Array.new( flow_list.count, 0 )\n @flow_list.each_with_index do |f,i|\n # count usage\n if f.status_id < 0 or f.status_id >= status_usage.count then\n puts \" status_id outside range: (0,#{flow_list.count})\"\n e += 1\n else\n status_usage[ f.status_id ] += 1\n obsolete_use[ f.status_id ] += 1 if f.obsolete\n end\n # there must be no gaps = undefined flows in the flow_list\n if f.nil? then\n puts \" Missing Flow definition with id = #{ i }\"\n e += 1\n else\n # flow id must match index in flow_list\n if i != f.id then\n puts \" Mismatch of flow_list index #{ i } and flow.id #{ f.id } - they must be identical.\"\n e += 1\n end\n end\n end\n # check number of status labels\n status_usage_sum = status_usage.reduce(0,:+)\n if status_usage_sum != flow_list.count then\n puts \" Number of status labels (#{ status_usage_sum }) does not correspond to number of flows (#{ flow_list.count })\"\n e += 1\n end\n if permit_duplicate_status then\n if status_list.count > flow_list.count then\n puts \" Number of status labels (#{ status_list.count }) must be <= number of flows (#{ flow_list.count })\"\n e += 1\n end\n else\n if status_list.count != flow_list.count then\n puts \" Number of status labels (#{ status_list.count }) must be == number of flows (#{ flow_list.count })\"\n e += 1\n end\n end\n status_usage.each_with_index do |u,i| \n if obsolete_use[ i ] > 0 and obsolete_use[ i ] != u then\n puts \" Status '#{ status_list[ i ]}' must be obsolete for ALL flows or NONE:\\n\" + \\\n \" Remove single obsolete flows manually instead of marking them as obsolete\"\n e += 1\n end\n end\n # check tasks\n @task_list.each_with_index do |t,i|\n # there must be no gaps = undefined tasks in the task_list\n if t.nil? then\n puts \" Missing Task definition with id = #{ i }\"\n e += 1\n else\n # task id must match index in task_list\n if i != t.id then\n puts \" Mismatch of task_list index #{ i } and task.id #{ t.id } - they must be identical.\"\n e += 1\n end\n # all tasks but the initial task must have incoming flows\n if t == @task_list.first then\n if !t.inflows.empty? then\n puts \" Initial Task must not have any incoming flows.\"\n e += 1\n end\n else\n if t.inflows.empty? then\n puts \" Task #{ t.id } '#{ t.label }' cannot be reached: no incoming flows.\"\n e += 1\n end\n end\n # all tasks but the terminal task must have outgoing flows\n if t == @task_list.last then\n if !t.outflows.empty? then\n puts \" Terminal Task must not have any outgoing flows.\"\n e += 1\n end\n else\n if t.outflows.empty? then\n puts \" Task #{ t.id } '#{ t.label }' has no outgoing flows but is not the Terminal Task.\"\n e += 1\n end\n end\n # task label must be unique\n @task_list[ i+1 .. -1 ].each do |s|\n next if s.nil?\n if s.label == t.label then\n puts \" Identical label for tasks #{ t.id } and { s.id }: '#{ t.label }'\"\n e += 1\n end\n end\n t.outflows.each do |fo|\n # flow must be in flow_list\n if fo != @flow_list[ fo.id ] then\n puts \" Outgoing flow from #{ t.id } with status '#{ fo.status }' not found in worklist's flow_list.\"\n e += 1\n end\n # outgoing flow must have a corresponding incoming flow - this should always pass\n if !@task_list[ fo.target_task_id ].inflows.include?( fo ) then\n puts \" Outgoing flow from #{ t.id } with status '#{ status_list[ fo.status_id ]}' is not incoming flow to #{ fo.target_task_id }\"\n e += 1\n end\n # check if obsolete task has non-obsolete outgoing flow\n if t.obsolete and !fo.obsolete then\n puts \" Obsolete task #{ t.id } has non-obsolete outgoing flow\\n\"\\\n \" with status '#{ fo.status }' to task ##{ fo.target_task_id}\"\n e += 1\n end\n end\n t.inflows.each do |fi|\n # flow must be in flow_list\n if fi != @flow_list[ fi.id ] then\n puts \" Incoming flow to #{ t.id } with status '#{ status_list[ fi.status ]}' not found in worklist's flow_list.\"\n e += 1\n end\n # incoming flow must have a corresponding outgoing flow - this should always pass\n if !@task_list[ fi.source_task_id ].outflows.include?( fi ) then\n puts \" Incoming flow to #{ t.id } with status '#{ fi.status }' is not outgoing flow from #{ fi.source_task_id}\"\n e += 1\n end\n # check if obsolete task has non-obsolete incoming flow\n if t.obsolete and !fi.obsolete then\n puts \" Obsolete task #{ t.id } has non-obsolete incoming flow\\n\"\\\n \" with status '#{ fi.status }' from task ##{ fi.source_task_id}\"\n e += 1\n end\n end\n end\n end\n # test initial task\n if @task_list.first.outflows.length > 1 then\n puts\n puts \">>> Warning: Initial Task has more than one outgoing flow:\"\n @task_list.first.outflows.each do |f|\n puts \">>> #{f.to_s}\"\n end\n puts\n end\n # summarize\n puts \" Validation of Tasks: #{ e > 0 ? 'failed' : 'OK' }\"\n @validation_errors += e\n end", "def update_table_rows\n\t \t@outcome_id = params[:outcome_id]\n\t \t@outcome = Outcome.find(@outcome_id)\n\t \t@project_id = params[:project_id]\n\t \t@is_diagnostic = ExtractionForm.is_diagnostic?(@outcome.extraction_form_id)\n\t \t@checkbox_timepoints = @outcome.outcome_timepoints\n\t \tunless params[:subgroup_id].nil?\n\t\t\t@subgroup = OutcomeSubgroup.find(params[:subgroup_id])\n\t\telse\n\t\t\t@subgroup = nil\n\t\tend\n\n\t \t# IF THIS IS A DIAGNOSTIC TEST RESULT TABLE\n\t \tif @is_diagnostic\n\t \t\t@selected_timepoints = Comparison.get_selected_timepoints_for_diagnostic_tests(@outcome,@subgroup)\n\t \t\tparams[:tps_to_add].keys.each do |sectionNum|\n\t \t\t\ttpString = params[:tps_to_add][sectionNum].join(\"_\")\n\t \t\t\t#puts \"The original TP string is #{@selected_timepoints[sectionNum.to_i]} and the string we're adding is #{tpString}\"\n\t \t\t\tif @selected_timepoints[sectionNum.to_i].empty?\n\t\t\t\t\t@selected_timepoints[sectionNum.to_i] = tpString\n\t\t\t\telse\n\t\t\t\t\t@selected_timepoints[sectionNum.to_i] += \"_#{tpString}\"\n\t\t\t\tend\n\t\t\t\t#puts \"THE RESULT IS: #{@selected_timepoints[sectionNum.to_i]}\\n\\n\"\n\t \t\tend\n\t \t\n\t \t\t\n\t\t\t@outcome_id, @study_id, @extraction_form_id, @selected_tp_array, @timepoints, @comparisons, \n\t\t\t@comparators, @all_comparators, @comparison_measures, @comparison_datapoints, @index_tests, \n\t\t\t@reference_tests, @thresholds, @footnotes = OutcomeDataEntry.get_diagnostic_test_results(@outcome,@subgroup,@selected_timepoints)\n\n\t\t\t@outcomes = Outcome.find(:all, :conditions=>[\"study_id=?\",@outcome.study_id],:select=>[\"id\",\"title\",\"extraction_form_id\"])\n\t\t\t@outcome_subgroups = Outcome.get_subgroups_by_outcome(@outcomes)\n\n\t\t\t@index_test_options, @reference_test_options = DiagnosticTest.get_select_options(@index_tests,@reference_tests,@thresholds)\n\t \t\n\t \t# OTHERWISE, IF IT'S AN RCT RESULT TABLE\n\t \telse\n\t \t\t@selected_tp_array = params[:selected_timepoints].split(\"_\")\n\t \t\ttps_to_add = params[:tps_to_add]\n\t\t\tunless tps_to_add.nil?\n\t\t\t\t@selected_tp_array = @selected_tp_array + tps_to_add\n\t\t\tend\n\t\t\t@selected_timepoints = @selected_tp_array.join(\"_\")\n\n\t\t\t#-----------------------------------------\n\t\t \t# Data for the entry table\n\t\t \t#-----------------------------------------\n\t\t \t@outcome_id, @study_id,@extraction_form_id, @selected_tp_array, @timepoints, @OCDEs, \n\t\t\t@measures, @datapoints, @arms, @comparisons, @comparison_measures, @comparators, \n\t\t\t@all_comparators, @num_comparators, @comparison_datapoints, @wa_comparisons, @wa_measures, \n\t\t\t@wa_comparators, @wa_all_comparators, @wa_datapoints, @footnotes = OutcomeDataEntry.get_information_for_entry_table(@outcome,@subgroup,@selected_timepoints)\t\n\t\t\t\t\n\t\t @hide_wait_icon = true # indicate that we need to hide a loading icon\n\n\t \tend\n\n\t render '/outcome_data_entries/show_timepoints'\n\tend", "def validate\n validate_amount\n validate_game\n validate_period\n end", "def check_data_validation\r\n if @tx_interest.text.to_f > 0 and \r\n @tx_interest.text.to_f < 0.1 and\r\n @tx_amount.text.to_i >= 1000 and\r\n @tx_years.text.to_i >= 1 then\r\n tf = true\r\n else\r\n tf = false\r\n end\r\n return tf\r\n end", "def create\n # receive datas\n word_id = params[:word_id]\n answer = params[:answer]\n @exam = Exam.find(params[:exam_id])\n\n #create a result_paper\n @rpaper = ResultPaper.new(:exam_id => @exam.id, :paper_id => @exam.paper_id, :user_id => current_user.id)\n @rpaper.save\n\n # index is for array index\n # each student only can answer once,never more(if only recreate the task)\n index = 0\n word_id.each do |f|\n is_right = 2\n Word.find(word_id[index]).meanings.each do |f|\n if f.content.to_s.strip == answer[index].to_s.strip\n is_right = 1\n break\n elsif f.content.to_s.strip.empty?\n is_right = 0\n end\n end\n\n @answer = ResultWord.new(:is_right => is_right,:word_id => word_id[index], :answer => answer[index],:result_paper_id => @rpaper.id)\n @answer.save\n \n index = index + 1\n end\n #generate the score\n all = ResultWord.where(:result_paper_id => @rpaper.id).count*1.00\n score = ResultWord.where(:is_right => 1,:result_paper_id => @rpaper.id).count\n\n @result_paper = ResultPaper.find(@rpaper.id)\n @result_paper.update_attributes(:score => score, :rate => (score/all)*100)\n @exam.update_attributes(:status => 2)\n\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'submit successfully created.' }\n end\n \n end", "def extra_validations\n success\n end", "def create\n @contest = Contest.new(params[:contest])\n @problem_count = 4\n\n @contest.begin_date_str = params[:begin_date]\n @contest.end_date_str = params[:end_date]\n\n problems = []\n for i,p in params[:problems]\n number = p[:number]\n score = p[:score]\n\n next if number.blank? && score.blank?\n @contest.errors[:problem] << \"#{i}'s number is invalid.\" and next if number.blank?\n @contest.errors[:problem] << \"#{i}'s score is invalid.\" and next if score.blank?\n\n aoj_problem = AOJ::Problem.new(number)\n @contest.errors[:problem] << \"#{i} is invalid.\" and next unless aoj_problem.valid?\n problem = Problem.new({\n number: number.to_i,\n name: aoj_problem.name,\n score: score.to_i,\n contest: @contest,\n })\n problems << problem\n end\n @contest.problems = problems\n\n @contest.errors[:problems] << 'are required more than 0.' if problems.size==0\n\n\n unless @contest.errors.empty?\n render action: 'new' and return\n end\n\n respond_to do |format|\n if @contest.save\n format.html { redirect_to @contest, notice: 'Contest was successfully created.' }\n format.json { render json: @contest, status: :created, location: @contest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end", "def results_for_competition\n return if disqualified?\n return if competition.nil?\n\n if competition.imports_times?\n unless time_is_present?\n errors.add(:base, \"Must enter full time\")\n end\n else\n unless points?\n errors.add(:base, \"Must select either time or points\")\n end\n end\n end", "def submit_factor_changes\n params[:factor_depends].each do |factor|\n f = Factor.find_by(id: factor[0][0..-1])\n f.dependency = factor[1]\n f.save\n end\n\n params[:factor_amount].each do |factor|\n f = Factor.find_by(id: factor[0][0..-1])\n f.amount = factor[1][0..-1]\n f.save\n end\n\n params[:factor_unit].each do |factor|\n f = Factor.find_by(id: factor[0])\n f.unit = factor[1..-1].join\n f.save\n end\n\n params[:factor_question].each do |factor|\n f = Factor.find_by(id: factor[0])\n f.variableName = factor[1..-1].join\n f.save\n end\n\n redirect_to statistics_path\n end", "def perform\n validate_data_from_requests\n end", "def create\n @real_cost = RealCost.new(params[:real_cost])\n @bootcamp = Bootcamp.find(@real_cost.bootcamp_id)\n\n # @real_cost = RealCostsCalculator.new(@bootcamp, salary, length).calc\n # Loan Summary (Total_Tuition, Down_Payment, Interest_Rate, Total_Payment_Due)\n down_payment = @bootcamp.tuition_cost * 0.25 #save it\n interest_rate = 0.05 \n total_payment_due = (@bootcamp.tuition_cost * interest_rate) + @bootcamp.tuition_cost #save it\n\n # Real_Cost = tuition_cost + total_oppty_cost\n total_oppty_cost = (@real_cost.salary / 52) * @bootcamp.length\n true_cost = @bootcamp.tuition_cost + total_oppty_cost #save it\n\n # Expected_increase_yearly_salary\n new_salary = (67000 / 52)\n\n new_salary_number = 67000.0\n difference = new_salary_number - @real_cost.salary\n dec_difference = (difference / @real_cost.salary)\n yearly_increase = (dec_difference * 100).to_i #save it\n\n # Breakeven time\n \n breakeven_time = total_oppty_cost / new_salary #save it\n\n @real_cost.down_payment = down_payment\n @real_cost.total_payment_due = total_payment_due\n @real_cost.true_cost = true_cost\n @real_cost.yearly_increase = yearly_increase\n @real_cost.breakeven_time = breakeven_time\n\n @real_cost.save # make if else\n\n redirect_to @real_cost\n end", "def evaluate_params(params)\n unless params[:savetime].blank?\n save_advance_safety(params[:savetime][:actual],params[:savetime][:clicked])\n end\n \n unless params[:savedate].blank?\n save_advance_rank_safety(params[:savedate][:actual],params[:savedate][:clicked],params[:savedate][:date])\n end\n\n unless params[:impact].blank?\n superficie_t = params[:impact][:superficie_t] \n mobiliario_t = params[:impact][:mobiliario_t] \n impacto_t = Towns.get_value_from_impact(params[:impact][:type],params[:impact][:impacto_t])\n superficie_s = params[:impact][:superficie_s] \n mobiliario_s = params[:impact][:mobiliario_s]\n\n sumaS = (superficie_s.to_f - mobiliario_s.to_f) / 0.5\n sumaA = (superficie_t.to_f - mobiliario_t.to_f) / impacto_t.to_f\n\n total = sumaS + sumaA\n save_aforo(total)\n respond_to do |format|\n format.js { render :js => \"set_value_aforo(#{total.to_i});\"}\n end\n end\n \n unless params[:pagetime].blank? \n next_value = getNext(params[:pagetime][:next],params[:pagetime][:restriction],params[:pagetime][:next_restrictions])\n progreso_de_seguridad = get_progress(params[:pagetime][:totals],next_value)\n respond_to do |format| \n if next_value == \"0\"\n format.js { render :partial => 'shared/outputs/finish_safety', :locals => {:type => t('outputs.safety.type_last'), :text =>t('outputs.safety.comment_last'),:next_text=>t('outputs.safety.next_text_last'), :path=> \"#{diagnostic_index_path}\",new_window: false}}\n else\n format.js { render :js => \"hidden_div(#{next_value},100,100,#{progreso_de_seguridad});\"}\n end\n end\n end\n end", "def validate_tasks\n validated = false\n if tasks_completed?\n validated = tasks_completed!\n end\n\n validated\n end", "def update_funding_and_estimates\n self.save_without_validating\n end", "def validation_submission(params)\n\n possible_errors = Array.new\n\n aa_seq_array = is_sequence_empty(params[:aa_sequence], params[:aa_fasta])\n puts \"aa_seq_array => #{aa_seq_array}\"\n # if user submit more than 20 sequence at time, return error immediately\n if !aa_seq_array.nil? and aa_seq_array.length > 20\n possible_errors << \"You submitted more than 20 amino acid sequences. While, we only accept 20 amino acid sequences or less per submission.\"\n return possible_errors\n end\n\n nt_seq_array = is_sequence_empty(params[:nt_sequence], params[:nt_fasta])\n puts \"nt_seq_array => #{nt_seq_array}\"\n if !nt_seq_array.nil? and nt_seq_array.length > 20\n possible_errors << \"You submitted more than 20 nucleotide sequences. While, we only accept 20 nucleotide sequences or less per submission.\"\n return possible_errors\n end\n\n\n if aa_seq_array.nil? or nt_seq_array.nil?\n possible_errors << \"Either your amino acid sequence or nucleotide sequence are empty\"\n return possible_errors\n end\n\n # Check aa sequence \n aa_sequence_hash = Hash.new\n header_array = Array.new\n accession_no_array = Array.new\n invalid_definition = \"\"\n invalid_sequence = \"\"\n aa_seq_array.each do |fasta_sequence|\n query = Bio::FastaFormat.new( fasta_sequence )\n aa_sequence_definition = parse_definition(query.definition)\n\n aa_sequence = validate_seq(query.to_seq.seq,\"aa\") # fail return nil; success return 0\n # puts \"validation aa_sequence => #{aa_sequence}\"\n if aa_sequence_definition.nil?\n invalid_definition += \"#{query.definition}\\n\"\n end\n\n if aa_sequence.nil?\n invalid_sequence += \"#{query.definition}\\n\"\n end\n\n if !aa_sequence_definition.nil? and !aa_sequence.nil?\n aa_sequence_hash[aa_sequence_definition[0]] = query.to_seq.seq\n\n header_array << aa_sequence_definition[0].strip\n accession_no_array << aa_sequence_definition[1].strip\n end\n \n end\n \n if invalid_definition.length > 0 or invalid_sequence.length > 0\n # something wrong with aa sequence field\n invalid_submission_msg = \"Your following amino acid sequences are not following our submission rules\\n\"\n if invalid_definition.length > 0\n invalid_submission_msg += \"Failed fasta format:\\n #{invalid_definition}\"\n end\n if invalid_sequence.length > 0\n invalid_submission_msg += \"Failed amino acid sequence:\\n #{invalid_sequence}\"\n end\n\n possible_errors << invalid_submission_msg\n\n return possible_errors\n\n end\n\n # check uniqueness of header\n duplicate_header = check_uniqueness_of_header(header_array)\n if duplicate_header.length != 0\n invalid_submission_msg = \"Your following amino acid sequences have duplicate header:\\n\"\n duplicate_header.each do |d_header|\n invalid_submission_msg += \"#{d_header}\\n\"\n end\n\n possible_errors << invalid_submission_msg\n \n return possible_errors\n end\n\n # check if the accession number is validate or not\n # we only check the correctness of aa accession number; not gene; since we only care one accession number\n invalid_accession_num = validate_accession_numbers(accession_no_array, \"aa\")\n if invalid_accession_num.length != 0\n invalid_submission_msg = \"Your following amino acid sequences have invalid accession number from NCBI. Please check NCBI protein database:<br>\"\n invalid_accession_num.each do |accession_no|\n invalid_submission_msg += \"#{accession_no}<br>\"\n end\n\n possible_errors << invalid_submission_msg\n \n return possible_errors\n end\n\n ########################################################################################\n # Check nt sequence\n nt_sequence_hash = Hash.new\n header_array = Array.new\n accession_no_array = Array.new\n invalid_definition = \"\"\n invalid_sequence = \"\"\n nt_seq_array.each do |fasta_sequence|\n query = Bio::FastaFormat.new( fasta_sequence )\n nt_sequence_definition = parse_definition(query.definition)\n nt_sequence = validate_seq(query.to_seq.seq,\"nt\")\n \n # puts \"validation nt_sequence => #{nt_sequence}\"\n if nt_sequence_definition.nil?\n invalid_definition += \"#{query.definition}\\n\"\n end\n\n if nt_sequence.nil?\n invalid_sequence += \"#{query.definition}\\n\"\n end\n\n if !nt_sequence_definition.nil? and !nt_sequence.nil?\n nt_sequence_hash[nt_sequence_definition[0]] = query.to_seq.seq\n\n header_array << nt_sequence_definition[0].strip\n accession_no_array << nt_sequence_definition[1].strip\n end\n end\n\n if invalid_definition.length > 0 or invalid_sequence.length > 0\n # something wrong with aa sequence field\n invalid_submission_msg = \"Your following nucleotide sequences are not following our submission rules\"\n if invalid_definition.length > 0\n invalid_submission_msg += \"Failed fasta format:\\n #{invalid_definition}\"\n end\n if invalid_sequence.length > 0\n invalid_submission_msg += \"Failed nucleotide sequence:\\n #{invalid_sequence}\"\n end\n\n possible_errors << invalid_submission_msg\n return possible_errors\n end\n \n duplicate_header = check_uniqueness_of_header(header_array)\n if duplicate_header.length != 0\n invalid_submission_msg = \"Your following nucleotide sequences have duplicate header:\\n\"\n duplicate_header.each do |d_header|\n invalid_submission_msg += \"#{d_header}\\n\"\n end\n \n possible_errors << invalid_submission_msg\n \n return possible_errors\n end\n\n invalid_accession_num = validate_accession_numbers(accession_no_array, \"nt\")\n if invalid_accession_num.length != 0\n invalid_submission_msg = \"Your following nucleotide sequences have invalid accession number from NCBI. Please check NCBI protein database:<br>\"\n invalid_accession_num.each do |accession_no|\n invalid_submission_msg += \"#{accession_no}<br>\"\n end\n\n possible_errors << invalid_submission_msg\n \n return possible_errors\n end\n\n\n\n # check missing sequence\n missing_aa_sequence, missing_nt_sequence = check_matchness(aa_sequence_hash,nt_sequence_hash)\n # puts \"missing_aa_sequence => #{missing_aa_sequence}\"\n # puts \"missing_nt_sequence => #{missing_nt_sequence}\"\n missing_seq_string = \"\"\n if missing_aa_sequence.length > 0\n missing_seq_string += \"You are missing following amino acid sequence based on your nucleotide sequence:\\n\"\n missing_aa_sequence.each do |aa_seq_name|\n missing_seq_string += \"#{aa_seq_name}\\n\"\n end\n end\n\n if missing_nt_sequence.length > 0\n missing_seq_string += \"You are missing following nucleotide sequence based on your amino acid sequence:\\n\"\n missing_nt_sequence.each do |nt_seq_name|\n missing_seq_string += \"#{nt_seq_name}\\n\"\n end\n end\n\n if missing_seq_string.length > 0\n possible_errors << missing_seq_string\n end\n\n\n\n # if error, return error\n # else, return aa_array and nt_array \n if possible_errors.length > 0\n return possible_errors\n else\n aa_nt_array = Hash.new\n aa_nt_array[\"aa\"] = aa_seq_array\n aa_nt_array[\"nt\"] = nt_seq_array\n return aa_nt_array\n end\n\n end", "def submit_result\n process_submit_response(submit_request) if @score > 1363\n end", "def create\n @goal = Goal.new(params[:goal])\n @mentors = @goal.accountability.split(',');\n\t@users = User.find(:all,:order=>\"name\")\n\t@mentors.each do |onementor|\n\t\tif onementor != '' and @goal.goal != ''\n\t\t\tif @users\n\t\t\t\t@users.each do |user| \n\t\t\t\t\tif user.name == onementor.strip and user.id.to_i != @goal.user_id.to_i\n\t\t\t\t\t\t@mu = MentorUser.where('mentor_user_id = ? and student_user_id = ? ',user.id.to_i,@goal.user_id.to_i)\n\t\t\t\t\t\tif @mu.length == 0\n\t\t\t\t\t\t\t@mentorUser = MentorUser.new(:mentor_user_id=>user.id.to_i ,:student_user_id=>@goal.user_id.to_i)\n\t\t\t\t\t\t\t@mentorUser.save\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n respond_to do |format|\n\t if @goal.goal == ''\n\t\tformat.html { redirect_to goals_url+'?filter='+@goal.category, notice: 'Your goal cannot be empty.' }\n format.json { render json: @goal, status: :created, location: @goal }\n\t elsif \n\t\t @validated = true\n\t\t @goal.tasks.each do |ot|\n\t\t\tif ot.startdue > ot.due\n\t\t\t @validated = false\n\t\t\t\tformat.html { redirect_to goals_url+'?filter='+@goal.category, notice: 'Start date cannot be less than end date.' }\n\t\t\t\tformat.json { render json: @goal, status: :created, location: @goal }\n\t\t\tend\n\t\t end\n\t\t if @validated == true\n\t\t\t @goal.save\n\t\t\t \n\t\t\t # destroy blank tasks\n\t\t\t blanktasks = Task.where('task = \\'\\' and goal_id = ?',@goal.id)\n\t\t\t blanktasks.each do |bt|\n\t\t\t\t bt.destroy\n\t\t\t end\n\t\t\t \n\t\t\t format.html { redirect_to goals_url+'?filter='+@goal.category, notice: 'Your goal was successfully created.' }\n \t\t\t format.json { render json: @goal, status: :created, location: @goal }\n\t\t end\n else\n format.html { redirect_to goals_url }\n format.json { render json: @goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def validated; 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 \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 \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 update\n if @submission.Scores == \"Not submitted\"\n\t\t\t# end time\n\t\t\tdate=DateTime.now\n\t\t\t@assessment = Assessment.find(@submission.assessment_id)\n\t\t\t# if within time limit\n\t\t\tif date.to_time < @submission.SubmittedAt.to_time + @assessment.Duration.minutes + 5.seconds\n\t\t\t\tparms = {\"Duration\"=>((date.to_time-@submission.SubmittedAt.to_time)).to_i}\n\t\t\t\tscores = []\n\t\t\t\tanswers = []\n\t\t\t\t@questions = Question.where(assessment_id: @submission.assessment_id).order(:id)\n\t\t\t\t@assessment = Assessment.find(@submission.assessment_id)\n\t\t\t\t# if assessment exists\n\t\t\t\tif @assessment\n\t\t\t\t\tuser = User.find(@assessment.user_id)\n\t\t\t\t\t@creator = user.Fname + \" \" + user.Lname\n\t\t\t\tend\n\t\t\t\t# for every question of the assessment\n\t\t\t\tfor question in @questions\n\t\t\t\t\tcase question.Type\n\t\t\t\t\t# if multiple choice\n\t\t\t\t\twhen \"MCQ\"\n\t\t\t\t\t\tanswer = params[(\"MCQRadios-\"+@questions.index(question).to_s).to_sym]\n\t\t\t\t\t\tqScore=0\n\t\t\t\t\t\t# if there was an answer\n\t\t\t\t\t\tif answer != nil\n\t\t\t\t\t\t\t# get the percentage value of that answer\n\t\t\t\t\t\t\tvalue = question.Answer[question.Answer.index(answer)+answer.length+1..question.Answer.index(answer)+question.Answer[question.Answer.index(answer)..].index(\"%\")-1].to_i\n\t\t\t\t\t\t\t# set the quesiton score\n\t\t\t\t\t\t\tqScore=question.Points*value/100\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# if negatime marking was active apply it\n\t\t\t\t\t\tif qScore == 0 && question.Options.include?(\"NEG1\") && answer != nil\n\t\t\t\t\t\t\tqScore -= question.Options[5..].to_i\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# add score and answer to their respective array\n\t\t\t\t\t\tscores << qScore\n\t\t\t\t\t\tanswers << answer\n\t\t\t\t\t# if multiple answer\n\t\t\t\t\twhen \"MA\"\n\t\t\t\t\t\tanswer = params[(\"MACheckboxes-\"+@questions.index(question).to_s).to_sym]\n\t\t\t\t\t\tqScore=0\n\t\t\t\t\t\twrong = false\n\t\t\t\t\t\t# if there was an answer\n\t\t\t\t\t\tif answer != nil\n\t\t\t\t\t\t\t# for each selected answer\n\t\t\t\t\t\t\tfor check in answer\n\t\t\t\t\t\t\t\t# check if wrong answer was chosen\n\t\t\t\t\t\t\t\tif wrong == false\n\t\t\t\t\t\t\t\t\tvalue = question.Answer[question.Answer.index(check)+check.length+1..question.Answer.index(check)+question.Answer[question.Answer.index(check)..].index(\"%\")-1].to_i\n\t\t\t\t\t\t\t\t\t# if answer was wrong\n\t\t\t\t\t\t\t\t\tif value == 0\n\t\t\t\t\t\t\t\t\t\twrong = true\n\t\t\t\t\t\t\t\t\t\tqScore = 0\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t# update question score\n\t\t\t\t\t\t\t\t\tqScore+=question.Points*value/100\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t# fix the score for questions with no partial marking\n\t\t\t\t\t\t\tif question.Answer.scan(/(?=100)/).count != 0\n\t\t\t\t\t\t\t\tqScore /= question.Answer.scan(/(?=100)/).count\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# if partial marking was not active and the answer is not complete\n\t\t\t\t\t\tif question.Options.include?(\"PAR0\") && qScore != question.Points\n\t\t\t\t\t\t\tqScore = 0\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# if negatime marking was active apply it\n\t\t\t\t\t\tif qScore == 0 && question.Options.include?(\"NEG1\") && answer != nil\n\t\t\t\t\t\t\tqScore -= question.Options[5..question.Options.index(\"P\")-1].to_i\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# add score and answer to their respective array\n\t\t\t\t\t\tanswers << answer\n\t\t\t\t\t\tscores << qScore\n\t\t\t\t\t# if fill the blank\n\t\t\t\t\twhen \"FTB\"\n\t\t\t\t\t\tanswer = params[(\"FTBAnswer-\"+@questions.index(question).to_s).to_sym]\n\t\t\t\t\t\tanswerCopy = answer\n\t\t\t\t\t\ttargetAnswer = question.Answer[question.Answer.index(\"〔\")+1..question.Answer.index(\"〕\")-1]\n\t\t\t\t\t\tqScore=0\n\t\t\t\t\t\t# if there was an answer\n\t\t\t\t\t\tif answer != nil\n\t\t\t\t\t\t\t#if the answer is not case sensitive act accordingly\n\t\t\t\t\t\t\tif question.Options.include?(\"CAS0\")\n\t\t\t\t\t\t\t\ttargetAnswer = targetAnswer.upcase\n\t\t\t\t\t\t\t\tanswerCopy = answerCopy.upcase\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t#if multiple spaces are allowed act accordingly\n\t\t\t\t\t\t\tif question.Options.include?(\"MUL1\")\n\t\t\t\t\t\t\t\tanswerCopy = answer.squeeze().strip\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t#if answers that contain the correct answer are allowed act accordingly\n\t\t\t\t\t\t\tif question.Options.include?(\"CON1\")\n\t\t\t\t\t\t\t\tif answerCopy.include?(targetAnswer)\n\t\t\t\t\t\t\t\t\tqScore = question.Points\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tif answerCopy == targetAnswer\n\t\t\t\t\t\t\t\t\tqScore = question.Points\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# if negatime marking was active apply it\n\t\t\t\t\t\tif qScore == 0 && question.Options.include?(\"NEG1\") && answerCopy != nil\n\t\t\t\t\t\t\tqScore -= question.Options[5..].to_i\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# add score and answer to their respective array\n\t\t\t\t\t\tscores << qScore\n\t\t\t\t\t\tanswers << answer\n\t\t\t\t\t# if true false\n\t\t\t\t\twhen \"TF\"\n\t\t\t\t\t\tanswer = params[(\"TFRadio-\"+@questions.index(question).to_s).to_sym]\n\t\t\t\t\t\tqScore=0\n\t\t\t\t\t\t# if there was an answer\n\t\t\t\t\t\tif answer != nil\n\t\t\t\t\t\t\t# if the answer was correct\n\t\t\t\t\t\t\tif question.Answer.include?(answer)\n\t\t\t\t\t\t\t\tqScore = question.Points\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# if negatime marking was active apply it\n\t\t\t\t\t\tif qScore == 0 && question.Options.include?(\"NEG1\") && answer != nil\n\t\t\t\t\t\t\tqScore -= question.Options[5..].to_i\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# add score and answer to their respective array\n\t\t\t\t\t\tscores << qScore\n\t\t\t\t\t\tanswers << answer\n\t\t\t\t\t# if regular expression\n\t\t\t\t\twhen \"REG\"\n\t\t\t\t\t\tanswer = params[(\"REGAnswer-\"+@questions.index(question).to_s).to_sym]\n\t\t\t\t\t\tregex = Regexp.new question.Answer[question.Answer.index(\"〔\")+1..question.Answer.index(\"〕\")-1]\n\t\t\t\t\t\tqScore=0\n\t\t\t\t\t\t# if there was an answer\n\t\t\t\t\t\tif answer != nil\n\t\t\t\t\t\t\t# if the answer was correct\n\t\t\t\t\t\t\tif !(answer =~ regex).nil?\n\t\t\t\t\t\t\t\tqScore = question.Points\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# if negatime marking was active apply it\n\t\t\t\t\t\tif qScore == 0 && question.Options.include?(\"NEG1\") && answer != nil\n\t\t\t\t\t\t\tqScore -= question.Options[5..].to_i\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# add score and answer to their respective array\n\t\t\t\t\t\tscores << qScore\n\t\t\t\t\t\tanswers << answer\n\t\t\t\t\t# if formula\n\t\t\t\t\twhen \"FRM\"\n\t\t\t\t\t\tvalues = eval(params[(\"FRMvalues-\"+@questions.index(question).to_s).to_sym])\n\t\t\t\t\t\tformula = question.Answer[question.Answer.index(\"〔\")+1..question.Answer.index(\"〕\")-1]\n\t\t\t\t\t\t# calculate the correct answer with the student variable values\n\t\t\t\t\t\tfor val in values\n\t\t\t\t\t\t\tkey, value = val\n\t\t\t\t\t\t\tformula = formula.gsub(\"[\" + key.upcase + \"]\",value.to_s)\n\t\t\t\t\t\t\tformula = formula.gsub(\"[\" + key.downcase + \"]\",value.to_s)\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# round it\n\t\t\t\t\t\ttargetAnswer = eval(formula+\".to_f\").round(2)\n\t\t\t\t\t\tanswer = params[(\"FRMAnswer-\"+@questions.index(question).to_s).to_sym]\n\t\t\t\t\t\tqScore=0\n\t\t\t\t\t\t# if there was an answer\n\t\t\t\t\t\tif answer != nil\n\t\t\t\t\t\t\t# if answer error was allowed act accordingly\n\t\t\t\t\t\t\tif question.Options.include?(\"RAN1\")\n\t\t\t\t\t\t\t\trange = question.Options[question.Options.index(\"RAN1\")+5..].to_f\n\t\t\t\t\t\t\t\t# if within range\n\t\t\t\t\t\t\t\tif answer.to_f >= targetAnswer-range && answer.to_f <= targetAnswer+range\n\t\t\t\t\t\t\t\t\tqScore = question.Points\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t# if answer mathces\n\t\t\t\t\t\t\t\tif answer.to_f == targetAnswer\n\t\t\t\t\t\t\t\t\tqScore = question.Points\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# if negatime marking was active apply it\n\t\t\t\t\t\tif qScore == 0 && question.Options.include?(\"NEG1\") && answer != nil\n\t\t\t\t\t\t\tqScore -= question.Options[5..].to_i\n\t\t\t\t\t\tend\n\t\t\t\t\t\t# add score and answer to their respective array\n\t\t\t\t\t\tscores << qScore\n\t\t\t\t\t\tanswers << answer\n\t\t\t\t\tend\n\t\t\t\t\t# set the scores and answers parameters\n\t\t\t\t\tparms[\"Scores\"] = scores\n\t\t\t\t\tparms[\"Answers\"] = answers\n\t\t\t\tend\n\t\t\t\trespond_to do |format|\n\t\t\t\t\tif @submission.update(parms)\n\t\t\t\t\t\t@submission.send_submission_results(@assessment, @questions, @creator)\n\t\t\t\t\t\tformat.html { redirect_to \"/submissions/received\" }\n\t\t\t\t\t\tformat.json { redirect_to \"/submissions/received\" }\n\t\t\t\t\telse\n\t\t\t\t\t\tformat.html { render :edit, status: :unprocessable_entity }\n\t\t\t\t\t\tformat.json { render json: @submission.errors, status: :unprocessable_entity }\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tredirect_to root_url\n\t\t\tend\n\t\telse\n\t\t\tredirect_to \"/submissions/duplicate\", :error => 'Failed to record the submission.'\n\t\tend\n end", "def date_validation\n #get a new session_id that is valid\n pastValidHold = PrecisionInput.count(:all, :group => 'session_id')\n if pastValidHold\n if pastValidHold.count()>0\n sessionID = pastValidHold.max[0] + 1\n else\n sessionID = 1\n end\n else\n sessionID = 1\n end\n statID = Statistic.all.pluck(:id).max\n\n #send a random sample of events and associated precision_inputs\n\n\n\n @validateEvents = Event.all.sample(10)\n\n @precInputs = []\n @validateEvents.each do |event|\n precinput = PrecisionInput.new\n precinput.event_id = event.id\n precinput.field_name = \"pdate\"\n precinput.session_id = sessionID\n precinput.statistic_id = statID\n precinput.save\n @precInputs << precinput\n end\n end", "def create\n scores = []\n # ?essays=true we use essays to predict scores.\n if params['essays']\n psu_date = DateTime.new(2017,11,27) # PSU DAY\n user_essays = current_user.essays.order(\"date_full ASC\")\n objectives = current_user.objectives\n [2,1,4,3].each do |s|\n completed = false\n subject_objective = objectives.select {|x| x.subject_id == s}.first # We get objective\n objective_score = subject_objective.nil? ? nil : subject_objective.score # We get objective score.\n essays = user_essays.select { |x| x.subject_id == s}\n if essays.length >= 4 # If there is enough essays we use a prediction.\n result = predict(essays,psu_date,s,objective_score)\n if result['r_score'] > 0.2 # Valid prediction.\n scores.append result['prediction']\n completed = true\n end\n elsif essays.length == 0 # If no essays we assume is not relevant to user.\n scores.append 0\n completed = true\n end\n unless completed\n if objective_score.nil? # If score doesnt have objective we assume is not relevant to user.\n scores.append 0\n else\n scores.append objective_score\n end\n end\n end\n # We add NEM to score array.\n scores += [current_user.nem]\n\n # ?essays=false we use objectives as scores.\n else\n scores = []\n objs = current_user.objectives\n [2,1,4,3].each do |i|\n obj = objs.select {|x| x.subject_id == i}\n if obj.first\n scores.append(obj.first.score)\n else\n scores.append(0)\n end\n end\n # We add NEM to score array.\n scores += [current_user.nem]\n end\n\n # Calculating area.\n\n #?area=compute\n if params['area'] == 'compute'\n areas = current_user.carreers.map {|x| x.area_id}\n # We get the ids of the two most frequent areas in user goals.\n areas = areas.map {|x| [x, areas.count(x)]}.uniq.sort_by {|x| x[1]}.reverse[0..1].map {|x| x[0]}\n else\n areas = [params['area'].to_i]\n end\n\n # Request for recommendations\n url = 'newton.tuniversidad.cl/get_recommendations' # Newton URL\n areas.each do |area|\n payload = {area_id:area,scores:[scores]}\n response = RestClient.post(url,payload.to_json, {content_type: :json, accept: :json})\n result_req = JSON.parse(response)\n # We create a recommendation object for each result.\n result_req['result'][\"0\"].each do |id|\n Recommendation.create do |rec|\n rec.user_id = current_user.id\n rec.carreer_id = id.to_i\n rec.liked = false\n rec.seen = false\n rec.area_id = area.to_i\n # We store params to use them on GET requests.\n rec.essay = params['essays']\n rec.computed_area = params['area'] == 'compute'\n end\n end\n end\n # Select a random subset of the created recs.\n result = random_select(current_user,RECS_NUMBER,params['essays'],params['area'])\n if result\n updater(result) # We set send recommendations to seen.\n render json:result, status:200\n else\n # IF random sampling fails we try with similar to he ones that have already been computed.\n sampled_area = areas.sample(1).first\n recs = Recommendation.where(user_id:current_user.id,liked:true,area_id: sampled_area.to_i)\n if recs.empty?\n recs = Recommendation.where(user_id:current_user.id,liked:false,area_id:sampled_area.to_i)\n end\n k = 5\n result = []\n while result.length < RECS_NUMBER\n recs.each do |rec|\n similars = request_similar([rec.carreer_id],k)\n similars[1...similars.length].each do |similar|\n new_rec = Recommendation.new do |new_rec|\n new_rec.user_id = current_user.id\n new_rec.carreer_id = similar\n new_rec.liked = false\n new_rec.seen = false\n new_rec.area_id = sampled_area.to_i\n new_rec.essay = params['essays']\n new_rec.computed_area = params['area'] == 'compute'\n end\n if new_rec.save\n result.append(new_rec)\n end\n end\n end\n k += 1\n end\n updater(result[0...RECS_NUMBER])\n render json:result[0...RECS_NUMBER], status:200\n end\n end", "def at_least_one_indicator_target_exist \n #when not even 1 set exist(indicator_desc+target+achievement+progress )\n if half==2 && (indicator_desc_quality.blank? && target_quality.blank? && achievement_quality.blank? && progress_quality.blank?) && (indicator_desc_time.blank? && target_time.blank? && achievement_time.blank? && progress_time.blank?) && (indicator_desc_quantity.blank? && target_quantity.blank? && achievement_quantity.blank? && progress_quantity.blank?) && (indicator_desc_cost.blank? && target_cost.blank? && achievement_cost.blank? && progress_cost.blank?)\n return false \n errors.add(\"aa\",\"error la\")\n# elsif id.nil? && half==2 \n# \n# #when user selected 'Sent to PPP for Report' - with INCOMPLETE NEWly inserted xtvt(not yet saved) - (render fields although record not yet saved due to errors)\n# #RESTRICTIONS : requires 'Target fields' to be completed for repeating fields to be rendered when error occurs\n# if ( !indicator_desc_quality.blank? && !target_quality.blank? && !achievement_quality.blank? && !progress_quality.blank?)\n# return true\n# else\n# return false\n# end\n# if ( !indicator_desc_time.blank? && !target_time.blank? && !achievement_time.blank? && !progress_time.blank?)\n# return true\n# else\n# return false\n# end\n# if ( !indicator_desc_quantity.blank? && !target_quantity.blank? && !achievement_quantity.blank? && progress_quantity.blank?)\n# return true\n# else\n# return false\n# end\n# if ( !indicator_desc_cost.blank? && !target_cost.blank? && !achievement_cost.blank? && !progress_cost.blank?)\n# return true\n# else\n# return false\n# end\n\n elsif half==1 && (indicator_desc_quality.blank? && target_quality.blank?) && (indicator_desc_time.blank? && target_time.blank?) && (indicator_desc_quantity.blank? && target_quantity.blank?) && (indicator_desc_cost.blank? && target_cost.blank?)\n return false\n end\n end", "def create\n @run = current_user.runs.new(params[:run])\n @goal = current_user.goals.first\n @run.duration = @run.hours*3600 + @run.minutes*60 + @run.seconds \n @run.avgspeed = ((@run.distance/@run.duration)*3600).round(1)\n @run.note = 'Click to enter a short note here'\n \n \n @run.distance_comparison = (((@run.distance-@goal.distance)/@goal.distance)*100).round(1)\n #@run.duration_comparison = (((@run.duration-@goal.duration)/@goal.duration)*100).round(1)\n @run.avgspeed_comparison = (((@run.avgspeed-@goal.avgspeed)/@goal.avgspeed)*100).round(1)\n @run.total_comparison = ((@run.distance_comparison+@run.avgspeed_comparison)/2).round(1)\n \n\t@run.save \n\t@runs = current_user.runs.all(:order => 'created_at DESC') \n\n \n #respond_to do |format|\n # if @run.save\n # flash[:notice] = 'Run was successfully created.'\n # format.html { redirect_to(@run) }\n # format.xml { render :xml => @run, :status => :created, :location => @run }\n # else\n # format.html { render :action => \"new\" }\n # format.xml { render :xml => @run.errors, :status => :unprocessable_entity }\n #end\n #end\n \n end", "def create_answer\n current_stat_id = nil\n factorIds = []\n badFactors = []\n if params[:form_fields] != nil\n params[:form_fields].each do |field|\n current_stat_id = field[1][:statistic_id].to_i\n af = AnsweredFactor.where(factor_id: field[1][:factor_id],\n statistic_id: current_stat_id,\n month: params[:month],\n year: params[:year],\n user_id: current_user.id).first_or_create\n\n af[:amount] = field[1][:value]\n af.save\n\n if af.amount == nil\n badFactors.push(af)\n af.delete\n else\n factorIds.push([af.id, current_stat_id])\n end\n end\n if badFactors.count == 0\n userFactors = rearrangeFactors(factorIds)\n updateAnswer(userFactors,{:month=>params[:month],:year=>params[:year]})\n current_user.score += Mission.getScore(current_user)\n current_user.effective_score += Mission.getScore(current_user)\n current_user.save\n end\n end\n if badFactors.count == 0 and factorIds.count != 0\n redirect_to statistics_path\n else\n redirect_to emissions_template_path, alert: \"Factor cannot be left blank.\"\n end\n end", "def submit; end", "def step_validation\n step_index = form_steps[:pages].index(form_step)\n\n if self.form_steps[:pages].index('title') <= step_index\n self.errors['name'] << 'You must enter a name for the dataset' if self.name.blank? || self.name.strip.blank?\n end\n\n if self.form_steps[:pages].index('connector') <= step_index\n self.errors['type'] << 'You must enter a connector type' unless CONNECTOR_TYPES.include? self.type\n self.errors['provider'] << 'You must enter a connector provider' unless CONNECTOR_PROVIDERS.include? self.provider\n self.errors['connector_url'] << 'You must enter a valid url' \\\n unless self.connector_url && !self.connector_url.blank? && valid_url?(self.connector_url)\n end\n\n if self.form_steps[:pages].index('labels') <= step_index\n unless self.legend && self.legend.is_a?(Hash)\n self.errors['legend'] << 'Labels not correctly defined'\n return\n end\n self.errors['legend'] << 'Latitude and Longitude have to be filled together' if\n self.legend[:lat].blank? ^ self.legend[:long].blank?\n self.errors['legend'] << 'Country and Region have to be filled together' if\n self.legend[:country].blank? ^ self.legend[:region].blank?\n end\n end", "def perform\n options.clean_options!\n at(0, 100, t('common.progress_initializing'))\n\n user = User.find(options[:user_id])\n @dataset = user.datasets.active.find(options[:dataset_id])\n task = @dataset.analysis_tasks.find(options[:task_id])\n\n task.name = t('.short_desc')\n task.save\n\n analysis_type = (options[:analysis_type] || :mi).to_sym\n num_pairs = (options[:num_pairs] || 50).to_i\n focal_word = options[:word].mb_chars.downcase.to_s if options[:word]\n\n # Part of speech tagging requires the Stanford NLP\n if analysis_type == :pos && Admin::Setting.nlp_tool_path.blank?\n analysis_type = :mi\n end\n\n case analysis_type\n when :mi\n algorithm = t('.mi')\n column = t('.mi_column')\n klass = RLetters::Analysis::Collocation::MutualInformation\n when :t\n algorithm = t('.t')\n column = t('.t_column')\n klass = RLetters::Analysis::Collocation::TTest\n when :likelihood\n algorithm = t('.likelihood')\n column = t('.likelihood_column')\n klass = RLetters::Analysis::Collocation::LogLikelihood\n when :pos\n # :nocov:\n algorithm = t('.pos')\n column = t('.pos_column')\n klass = RLetters::Analysis::Collocation::PartsOfSpeech\n # :nocov:\n else\n fail ArgumentError, 'Invalid value for analysis_type'\n end\n\n analyzer = klass.new(\n @dataset,\n num_pairs,\n focal_word,\n ->(p) { at(p, 100, t('.progress_computing')) }\n )\n grams = analyzer.call\n\n # Save out all the data\n at(100, 100, t('common.progress_finished'))\n csv_string = CSV.generate do |csv|\n csv << [t('.header', name: @dataset.name)]\n csv << [t('.subheader', test: algorithm)]\n csv << ['']\n\n csv << [t('.pair'), column]\n grams.each do |w, v|\n csv << [w, v]\n end\n\n csv << ['']\n end\n\n # Write it out\n ios = StringIO.new(csv_string)\n file = Paperclip.io_adapters.for(ios)\n file.original_filename = 'collocation.csv'\n file.content_type = 'text/csv'\n\n task.result = file\n\n # We're done here\n task.finish!\n\n completed\n end", "def validate\n unless TrueClass === @obsolete or FalseClass === @obsolete then\n raise RuntimeError.new( 'task validation failed: obsolete must be true or false ')\n end\n unless @id.is_a? Integer then\n raise RuntimeError.new( 'task validation failed: id must be an Integer' )\n end\n unless @role_id.is_a? Integer or @role_id.nil? then\n raise RuntimeError.new( 'task validation failed: role_id must be nil or an Integer' )\n end\n unless @label.is_a? String then\n raise RuntimeError.new( 'task validation failed: label must be a String' )\n end\n unless @inflows.is_a? Array then\n raise RuntimeError.new( 'task validation failed: incoming flows must be an Array' )\n else\n @inflows.each do |f|\n unless f.is_a? WorkFlowFlow\n raise RuntimeError.new( 'task validation failed: an incoming flow is not a WorkFlowFlow' )\n end\n end\n end\n unless @outflows.is_a? Array then\n raise RuntimeError.new( 'task validation failed: outgoing flows must be an Array' )\n else\n @outflows.each do |f|\n unless f.is_a? WorkFlowFlow\n raise RuntimeError.new( 'task validation failed: an outgoing flow is not a WorkFlowFlow' )\n end\n end\n end\n end", "def submit_all_blank_and_validate\n blank_dates\n click_on 'Add'\n validate_fields(@fields)\n end", "def create\n @submission = Submission.new(submission_params)\n\n if @submission.valid?\n Ml.classify(@submission)\n @submission.save\n redirect_to calculate_submission_path(@submission) \n else\n render :new\n end\n end", "def decisions\n \n if params[:decisions].present? # if :decisions parameters are present then set the semester and campus accordingly\n @semesterSelected = params[:decisions]['semester']\n @semesterID = Semester.find_semester_id(@semesterSelected)\n @campusSelected = params[:decisions]['campus']\n @campusID = Campus.find_campus_id(@campusSelected)\n \n elsif params[:continue].present? # if :continueparameters are present then set the semester and campus accordingly\n @semesterSelected = params[:continue]['semester']\n @semesterID = Semester.find_semester_id(@semesterSelected)\n @campusSelected = params[:continue]['campus']\n @campusID = Campus.find_campus_id(@campusSelected)\n \n error_message = \"Please make sure all required fields are filled in.\"\n #Error Checking\n if params[:continue]['method'].nil? or params[:continue]['day'].nil? or params[:continue]['month'].nil? or params[:continue]['year'].nil? or params[:continue]['decision'].nil? or params[:continue]['shared'].nil? or\n params[:continue]['method'] == \"\" or params[:continue]['day'] == \"\" or params[:continue]['month'] == \"\" or params[:continue]['year'] == \"\" or params[:continue]['decision'] == \"\" or params[:continue]['shared'] == \"\"\n # redirect_with_flash\n flash[:notice] = error_message\n redirect_to :action => 'decisions', :decisions =>{'semester' => @semesterSelected, 'campus' => @campusSelected} and return\n end\n # end of error checking\n \n # get all parameters\n method = params[:continue]['method']\n methodID = Prcmethod.find_method_id(method)\n day = params[:continue]['day']\n month = params[:continue]['month']\n year = params[:continue]['year']\n date = Date.parse(\"#{year}-#{month}-#{day}\")\n if params[:continue]['notes'].present?\n notes = params[:continue]['notes']\n else \n notes = nil\n end\n name = params[:continue]['decision']\n witness = params[:continue]['shared']\n believer = params[:continue]['believer']\n \n # submit decision\n Prc.submit_decision(@semesterID, @campusID, methodID, date, notes, name, witness, believer)\n end\n \n # Initialize Variables Used by View \n \n # arrays for date\n @years = [2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011]\n @months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n @days = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]\n \n @methods = Prcmethod.find_methods()\n @decisions = Prc.find_by_semester_and_campus(@semesterID,@campusID)\n end", "def create\n @tracker = Tracker.new()\n @tracker.period = params[:period]\n @tracker.user_id = current_user.id\n @user = User.find(current_user.id)\n\n respond_to do |format|\n if @tracker.save\n \n @fields = [Field.new(), Field.new(), Field.new()]\n\n @lastfields = Field.all.order(\"id desc\").limit(3).reverse\n\n if not @lastfields.any? \n @fields[0].title = \"Progress\" \n @fields[1].title = \"Plan\"\n @fields[2].title = \"Problems\"\n else\n @fields[0].title = @lastfields[0].title \n @fields[1].title = @lastfields[1].title\n @fields[2].title = @lastfields[2].title\n end\n\n @fields.each do |f|\n f.tracker_id = @tracker.id\n f.save\n\n @entries = [Entry.new(), Entry.new(), Entry.new()]\n @entries.each do |e|\n e.field_id = f.id\n e.task = \"Click here to edit goal\"\n e.save\n\n end\n\n \n end\n\n format.html { redirect_to @user, notice: 'Tracker was successfully created.' }\n format.json { render :show, status: :created, location: @tracker }\n else\n format.html { render :new }\n format.json { render json: @tracker.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n unless @submission.evaluated.blank?\n respond_to do |format|\n format.html { redirect_to test_submission_path(@test, @submission), info: \"Evaluated!\" }\n end\n return\n end\n\n unless Time.now > @timeout + 5.seconds\n @submission.answers_of_questions.each do |user_answer|\n user_answer.update(choice: submission_params.fetch(user_answer.answer_id.to_s, \"false\"))\n end\n end\n if Time.now > @timeout || params[:evaluate]\n @test.questions.each do |question|\n crrct = get_result(question)\n @submission.increment!(:point, question.point) if crrct\n @submission.question_evaluations.create({question_id: question.id, value: crrct})\n end\n @submission.update(evaluated: true)\n respond_to do |format|\n format.html { redirect_to test_submission_path(@test, @submission) }\n end\n else\n respond_to do |format|\n format.html { redirect_to submissions_path, success: 'Submission was successfully saved.' }\n end\n end\n\n end", "def log_submit\n @user = User.find_by(email: params[:user])\n @cud = @user ? @course.course_user_data.find_by(user_id: @user.id) : nil\n unless @cud\n err = \"ERROR: invalid username (#{params[:user]}) for class #{@course.id}\"\n render(plain: err, status: :bad_request) && return\n end\n\n @assessment = @course.assessments.find_by(name: params[:name])\n if !@assessment\n err = \"ERROR: Invalid Assessment (#{params[:id]}) for course #{@course.id}\"\n render(plain: err, status: :bad_request) && return\n elsif !@assessment.allow_unofficial\n err = \"ERROR: This assessment does not allow Log Submissions\"\n render(plain: err, status: :bad_request) && return\n end\n\n @result = params[:result]\n render(plain: \"ERROR: No result!\", status: :bad_request) && return unless @result\n\n # Everything looks OK, so append the autoresult to the log.txt file for this lab\n ASSESSMENT_LOGGER.setAssessment(@assessment)\n ASSESSMENT_LOGGER.log(\"#{@user.email},0,#{@result}\")\n\n # Load up the lab.rb file\n mod_name = @assessment.name + (@course.name).gsub(/[^A-Za-z0-9]/, \"\")\n require(Rails.root.join(\"assessmentConfig\", \"#{@course.name}-#{@assessment.name}.rb\"))\n eval(\"extend #{mod_name.camelcase}\")\n\n begin\n # Call the parseAutoresult function defined in the lab.rb file. If\n # the list of scores it returns is empty, then we the lab developer is\n # asking us not to create an unofficial submission in the\n # database. Simply return a successful status string to the client and\n # exit.\n scores = parseAutoresult(@result, false)\n\n render(plain: \"OK\", status: 200) && return if scores.keys.length == 0\n\n # Try to find an existing submission (always version 0).\n submission = @assessment.submissions.find_by(version: 0, course_user_datum_id: @cud.id)\n if !submission\n submission = @assessment.submissions.new(\n version: 0,\n autoresult: @result,\n user_id: @cud.id,\n submitted_by_id: 0,\n )\n submission.save!\n else\n # update this one\n submission.autoresult = @result\n submission.created_at = Time.now\n submission.save!\n end\n\n # Update the scores in the db's unofficial submission using the list\n # returned by the parseAutoresult function\n scores.keys.each do |key|\n problem = @assessment.problems.find_by(name: key)\n score = submission.scores.find_or_initialize_by(problem_id: problem.id)\n score.score = scores[key]\n score.released = true\n score.grader_id = 0\n score.save!\n end\n rescue StandardError => e\n ExceptionNotifier.notify_exception(e, env: request.env,\n data: {\n user: current_user,\n course: @course,\n assessment: @assessment,\n submission: submission,\n })\n COURSE_LOGGER.log(e.to_s)\n end\n\n render(plain: \"OK\", status: 200) && return\n end", "def create\n @account = current_account\n @expense_report = ExpenseReport.new(expense_report_params)\n @expense_report.account_id = @account.id\n @expense_report.estimate2 =(@expense_report.Flight + @expense_report.Hotel + @expense_report.Transportation + @expense_report.Other)\n \n @travel_forms = TravelForm.all\n @expense_reports = ExpenseReport.all\n @expense_reports.each do |expense_report|\n @travel_forms.each do |travel_form|\n @travel_form = @travel_forms.find(@expense_report.travel_forms_id)\n if @expense_report.estimate2 > @travel_form.estimate\n @expense_report.update_attributes(:status => \"Denied\")\n end\n end\n end\n respond_to do |format|\n if @expense_report.save\n format.html { redirect_to employee_path(current_account.accountable_id), notice: 'Expense report was successfully created.' }\n format.json { render :show, status: :created, location: @expense_report }\n else\n format.html { render :new }\n format.json { render json: @expense_report.errors, status: :unprocessable_entity }\n end\n end\n end", "def fees_particulars_create2\n batch=Batch.find(params[:finance_fee_particular][:batch_id])\n @tax_slabs = TaxSlab.all if @tax_enabled\n if params[:particular] and params[:particular][:receiver_id]\n\n all_admission_no = admission_no=params[:particular][:receiver_id].split(',')\n all_students = batch.students.map { |stu| stu.admission_no }.flatten\n rejected_admission_no = admission_no.select { |adm| !all_students.include? adm }\n unless (rejected_admission_no.empty?)\n @error = true\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{rejected_admission_no.join(',')} #{t('does_not_belong_to_batch')} #{batch.full_name}\")\n end\n\n selected_admission_no = all_admission_no.select { |adm| all_students.include? adm }\n selected_admission_no.each do |a|\n s = Student.first(:conditions => [\"admission_no LIKE BINARY(?)\", a])\n if s.nil?\n @error = true\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{a} #{t('does_not_exist')}\")\n end\n end\n unless @error\n unless selected_admission_no.present?\n @finance_fee_particular=batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{t('admission_no_cant_be_blank')}\")\n @error = true\n else\n selected_admission_no.each do |a|\n s = Student.first(:conditions => [\"admission_no LIKE BINARY(?)\", a])\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.receiver_id=s.id\n @error = true unless @finance_fee_particular.save\n end\n end\n end\n elsif params[:finance_fee_particular][:receiver_type]==\"Batch\"\n\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @finance_fee_particular.receiver_id=batch.id\n @error = true unless @finance_fee_particular.save\n else\n @finance_fee_particular = batch.finance_fee_particulars.new(params[:finance_fee_particular])\n @error = true unless @finance_fee_particular.save\n @finance_fee_particular.errors.add_to_base(\"#{t('category_cant_be_blank')}\") if params[:finance_fee_particular][:receiver_id]==\"\"\n end\n @batch=batch\n @finance_fee_category = FinanceFeeCategory.find(params[:finance_fee_particular][:finance_fee_category_id])\n include_associations = @tax_enabled ? [:tax_slabs] : []\n @particulars = FinanceFeeParticular.paginate(:page => params[:page],\n :include => include_associations, :conditions => [\"is_deleted = '#{false}' and\n finance_fee_category_id = '#{@finance_fee_category.id}' and batch_id='#{@batch.id}' \"])\n\n 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 \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 create\n params[:predictions].each do |prediction|\n @prediction = current_user.predictions.new(prediction)\n if @prediction.valid?\n @prediction.save\n end\n end\n redirect_to root_path\n end", "def validate_and_save(new_model)\n # will need to check for partial matches that could indicate a change in the displayed content\n # may also need to delete events that are no longer in the feed if they are determined to have been cancelled\n\n # if model is invalid using built-in validations, attempt to repair it\n Reparator.repair_model(new_model, logger) unless new_model.valid?\n\n # clear errors to retry validations after attempted fixes\n new_model.errors.clear\n # perform save\n if new_model.valid?\n idempotent_save_or_update(new_model)\n else\n # logger.info new_model.start_date.class\n logger.warn \"failed to save model with errors #{new_model.errors.messages}\\ntitle: #{new_model.title}\\nurl: #{new_model.url}\"\n end\n false\n end", "def validate\n end", "def run_validations\n true\n 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 \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 perform_validation\n raise NotImplementedError\n end", "def create\n @solution = Solution.new(solution_params)\n #找出正确答案\n id=@solution.assignment_id\n assignment=Assignment.find_by_id(id)\n \n if assignment\n real_answer = assignment.answer.upcase\n answer=@solution.student_answer.upcase\n #对比得到成绩\n @solution.score=comp_string(real_answer,answer)\n session[:secret_key] = nil\n if @solution.save\n flash[:notice] = \"提交成功,本次课堂成绩得到 #{@solution.score.to_s} 分!!\"\n redirect_to \"/sessions/new\"\n else\n flash[:notice] =\"提交保存出现错误,请联系老师说明原因!!\"\n redirect_to \"/sessions/new\"\n end\n else\n flash[:notice] = \"没有找到课堂任务!!\"\n redirect_to \"/sessions/new\"\n end\n end", "def validate; end", "def validate; end", "def validate; end", "def validate; 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 \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 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 \n \n \n \n \n \n \n \n \n \n \n \n end", "def run\n content_at_file = @file_to_validate\n outcome = no_subtitle_marks_followed_by_space?(content_at_file)\n log_and_report_validation_step(outcome.errors, outcome.warnings)\n end", "def validate_resident_survey model\n \n # What ID do we use to mark ambiguous users?\n err_res_id = P4Resident.find_by_p4_program_id('#999')[:id]\n\n # Get list of all surveys, and look for duplicate survey entries\n # group by p4_resident_id so we don't get false positives on\n # manually mapped users\n if not model.column_names.index('abfm_last_four').nil?\n surveys = model.select('count(*) as xcount, p4_program_id, abfm_last_four, p4_resident_id').group('p4_program_id,abfm_last_four,p4_resident_id')\n else\n puts \"No abfm_last_four in: #{model.class.name}\"\n return\n end\n\n surveys.each do |survey|\n log_msgs = []\n # Manually matched survey\n if survey.p4_resident_id.nil? == false\n next\n end\n\n abfm_last_four = survey.abfm_last_four.to_s.rjust(4,'0')\n\n\n # look for matching resident \n residents = P4Resident.where(\n [\"\n (abfm_last_four = ? OR abfm_last_four_old = ?) \n AND p4_program_id = ?\n \",\n abfm_last_four,abfm_last_four,survey.p4_program_id\n ]\n )\n\n # Multiple surveys have the same identifying information\n if survey.xcount.to_i != 1\n resident = P4Resident.find(err_res_id)\n log_msgs += [[\"Duplicate Surveys found\",survey]]\n end \n\n if residents.count == 0\n # No matching resident\n resident = P4Resident.find(err_res_id)\n log_msgs += [['No matching user', survey]]\n elsif residents.count > 1\n # This survey can me matched to more than one resident\n resident = P4Resident.find(err_res_id)\n log_msgs += [['Matched multiple users', survey]]\n else\n resident = residents[0]\n end\n \n # Update survey records to point to the correct resident\n conditions= ['p4_program_id= ? AND abfm_last_four = ?', \n survey.p4_program_id,abfm_last_four ]\n\n responses = model.where(conditions) \n \n responses.each do |response|\n #if response.p4_resident_id.nil? == false && response.p4_resident_id != err_res_id\n # # This user was manually mapped, skip setting id and override log messages\n # #log_msgs = []\n # #log \"Manually Matched: #{response.p4_resident_id}\", response\n # next\n #end\n response.p4_resident_id = resident[:id]\n response.save!\n end\n\n # Log messages \n log_msgs.each do |arr|\n log arr[0],arr[1]\n end\n\n end\nend", "def run\n # @file_to_validate is an array with the content_at and\n # subtitle/subtitle_tagging_import files\n content_at_file, subtitle_import_file = @file_to_validate\n errors, warnings = [], []\n\n catch(:abandon) do\n outcome = contents_match?(\n content_at_file.read,\n subtitle_import_file.read\n )\n\n if outcome.fail?\n errors += outcome.errors\n warnings += outcome.warnings\n #throw :abandon\n end\n end\n\n log_and_report_validation_step(errors, warnings)\n end", "def new\n if @submission.gradings.count > 0\n redirect_to edit_course_assessment_submission_grading_path(@course, @assessment, @submission, @submission.gradings.first)\n return\n end\n\n @summary = {qn_ans: {}}\n\n @assessment.questions.each_with_index do |q,i|\n if q.is_a?(Assessment::MpqQuestion)\n @summary[:qn_ans][q.id] = { qn: q.specific, i: i + 1 }\n @summary[:qn_ans][q.id][:sub_q] = {}\n q.as_question.sub_questions.each_with_index do |sq, si|\n @summary[:qn_ans][q.id][:sub_q][sq.id] = { qn: sq.specific, i: si + 1 }\n end\n else\n @summary[:qn_ans][q.id] = { qn: q.specific, i: i + 1 }\n end\n end\n\n eval_answer\n\n @submission.answers.each do |ans|\n qn = ans.question\n if qn.parent\n @summary[:qn_ans][qn.parent.question.id][:sub_q][qn.id][:ans] = ans\n else\n @summary[:qn_ans][qn.id][:ans] = ans\n end\n\n\n #suggest grading for auto grading question\n if qn.is_a?(Assessment::CodingQuestion) && qn.auto_graded?\n results = ans.result_hash[\"eval\"]\n evals = results ? results.select {|r| r}.length : 0\n tests = qn.data_hash[\"eval\"].length\n tests = tests == 0 ? 1 : tests\n grade = (qn.max_grade * evals / tests).to_i\n ag = ans.answer_grading.new\n ag.grade = grade\n\n @summary[:qn_ans][qn.question.id][:grade] = ag\n end\n end\n end", "def new\n @disabled = Turkee::TurkeeFormHelper::disable_form_fields?(params)\n\n @survey = Survey.new\n task = Turkee::TurkeeTask.find_by_hit_id(params[:hitId]) rescue nil\n\n unless @disabled\n experiment = nil\n experiment = task.experiment unless task.nil?\n if experiment.nil?\n experiment = Experiment.last\n end\n\n @survey.experiment = experiment\n @survey.turkee_task_id = task.id unless task.nil?\n @survey.ip_address = request.remote_ip\n questions = @survey.experiment.randomize_questions\n @questions = questions.collect {|x| x.randomize_to_json}.to_json\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @survey }\n end\n end", "def addEval\n #puts \"hi student being evaluatied\"\n #puts params[:evaluation][:student_evaluated]\n #@team_member = User.find_by(u_name: params[:evaluation][:student_evaluated])\n @specific_user = User.find_by(u_name: params[:evaluation][:student_evaluating])\n @current_project = Project.find_by(p_name: params[:evaluation][:project])\n\n #puts \"start11\"\n #puts @team_member.inspect\n #puts @specific_user.inspect\n #puts @current_project.inspect\n\n # Klass.create subject: 'Maths', student: bart, tutor: edna\n # object = Student.new(:name => \"a\", :age => 2)\n @evaluation = Evaluation.new(student_evaluated: params[:evaluation][:student_evaluated], content: params[:evaluation][:content], rating: params[:evaluation][:rating], user: @specific_user, project: @current_project)\n puts \"hi2\"\n puts @evaluation.inspect\n #@evaluation = Evaluation.new(student_evaluated: @team_member.u_name, content: params[:content], \n #rating: params[:rating], user: @specific_user, project: @current_project)\n if @evaluation.save\n redirect_to userSpecificProjects_url\n #format.html { redirect_to evalAndSuccess_url(@evaluation), notice: 'Evaluation was successfully created.' }\n #format.json { render :evalAddSuccess, status: :created, location: @evaluation }\n else\n redirect_to userSpecificProjects_url\n #format.html { render :ratingPage_path(:team_member => @team_member.id) }\n end\n end", "def exercise1\n parse_data MinMaxValidator\n validators.count(&:valid?)\n end", "def validate\n raise RuntimeError.new( 'only terminated workflows can be validated' ) unless @terminated\n @validation_errors = 0\n puts\n puts \"Start Validation of WorkFlow '#{ label }\"\n validate_workflow\n validate_reachability\n puts \"Validation of WorkFlow '#{ label }' #{\n @validation_errors > 0 ? 'FAILED' : 'successfully completed' }.\"\n puts\n 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 \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 create\n @task = Task.new(params[:task])\n @task.autor = @staff_login.id\n @task.from_userid = @staff_login.id\n @task.current_staff = @staff_login\n @client = Client.find(params[:task][:cl_id])\n @task.name = @client.address if @task.name.empty?\n @task.status = \"new\" if @task.status.nil?\n @task.time_create = Time.now.getlocal\n @task.point_group = Task.maximum('point_group').to_i+1 if @task.point_group.nil? || @task.point_group.to_s.empty?\n @task.zapros_gid = Task.maximum('zapros_gid').to_i+1 if @task.zapros_gid.nil? || @task.zapros_gid.to_s.empty?\n @task.target = if @task.target.empty? || (@task.target=~/[\\d]+/).nil?\n \"0\"\n else\n /([\\d]+)/.match(@task.target)[1]\n end\n respond_to do |format|\n\t\tTask.transaction do\n\t\t\tbegin\n\t\t\t\t@task.save\n\t\t\t\tif @task.type_t == 'upgrade'\n\t\t\t\t\tif (shema = Task.where(point_group: @task.point_group, type_t: 'shem').first) != nil\n\t\t\t\t\t\tshema.update_attributes({status: 'run',target: @task.target})\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tformat.html { redirect_to \"/tasks/?cl_id=#{@client.id}\", notice: 'Task was successfully created.' }\n\t\t\t\tformat.json { render json: @task, status: :created, location: @task }\n\t\t\trescue\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @task.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend\n end", "def create\n @nota = Nota.new(params[:nota])\n\t\t@plan = Plan.find_by_subject_id(@nota.subject_id)\n\t\tif !@nota.examen_1\n\t\t\t@nota.examen_1 = 0.0\n\t\tend\n\t\tif !@nota.examen_2\n\t\t\t@nota.examen_2 = 0.0\n\t\tend\n\t\tif !@nota.examen_3\n\t\t\t@nota.examen_3 = 0.0\n\t\tend\n\t\tif !@nota.examen_4\n\t\t\t@nota.examen_4 = 0.0\n\t\tend\n\n\t\tif !@nota.acumulado_1\n\t\t\t@nota.acumulado_1 = 0.0\n\t\tend\n\t\tif !@nota.acumulado_2\n\t\t\t@nota.acumulado_2 = 0.0\n\t\tend\n\t\tif !@nota.acumulado_3\n\t\t\t@nota.acumulado_3 = 0.0\n\t\tend\n\t\tif !@nota.acumulado_4\n\t\t\t@nota.acumulado_4 = 0.0\n\t\tend\n\t\t\n\t\tif @nota.examen_1 > @plan.examen_1 || @nota.examen_2 > @plan.examen_2 ||\n\t\t\t @nota.examen_3 > @plan.examen_3 || @nota.examen_4 > @plan.examen_4 ||\n @nota.acumulado_1 > @plan.acumulado_1 || @nota.acumulado_2 > @plan.acumulado_2 ||\n\t\t\t @nota.acumulado_3 > @plan.acumulado_3 || @nota.acumulado_4 > @plan.acumulado_4\n\t\t\tflash[:notice] = 'La calificacion no puede ser mayor que los valores de ponderacion.'\n\t\t\tredirect_to new_student_score_path(:id => @nota.subject_id, :id2 => @nota.student_id)\n\t\telse\n\t\t\tif @nota.save\n current_subject = Subject.find(@nota.subject_id)\n sender = current_user.email\n student = Student.find(@nota.student_id, :conditions => {:is_deleted => false})\n guardians = student.guardians.compact.uniq\n\n to = []\n to.push student.email\n to.concat guardians\n to.compact!\n\n #to << student.email unless student == nil\n #to << guardians.map{ |g| g.email }.select{ |s| !s.empty? }.uniq unless guardians == nil\n #to.reject! { |i| i.empty? or i.nil? }\n\n subject = \"#{t('gradebook_published')} - \" + current_subject.name\n body = \"#{t('grade_text')},\\r\\n\" + \"#{t('assigment')}: \" + current_subject.name\n\n if to.count > 0\n Delayed::Job.enqueue(GradebookMailJob.new(sender,to,subject,body))\n end\n\t\t flash[:notice] = 'Alumno calificado con exito.'\n\t\t\t\tredirect_to (\"/plans/\"+@plan.id.to_s) \n\t\t else\n\t\t flash[:notice] = 'Something went wrong when creating score.'\n\t\t\t\t#render :action => \"new\"\n\t\t end\n\t\tend\n end", "def create\n @report = Report.new(report_params)\n @report.owner_id = current_user.id\n @report.creation_date = Date.today\n @report.diference = (@report.consumedCalories - @report.burnedCalories) \n if @report.diference > 0\n @report.diference_value = 'Caloric Surplus'\n elsif @report.diference <0\n @report.diference_value = 'Caloric Deficit'\n else\n @report.diference_value = 'Balance'\n end\n \n progress = Progress.where('user_id = ?', current_user.id).where('expires_at = ?', @report.creation_date)\n if progress != nil\n \n progress.each do |goal|\n puts \"Informacion de mi goal #{goal.consumedCalories} #{goal.burnedCalories} #{goal.consumedObjetive} #{goal.burnedObjetive} \"\n goal.burnedObjetive = goal.burnedObjetive + @report.burnedCalories\n goal.consumedObjetive = goal.consumedObjetive + @report.consumedCalories\n goal.porcent = (((goal.burnedObjetive+goal.consumedObjetive) * 100)/(goal.consumedCalories+goal.burnedCalories)).to_i\n if goal.porcent > 100\n goal.porcent = 100\n end\n puts \"Informacion de mi goal2 #{goal.consumedCalories} #{goal.burnedCalories} #{goal.consumedObjetive} #{goal.burnedObjetive} \"\n if goal.save\n puts \"guarda\"\n else\n puts \"algo paso\"\n end\n end\n end\n \n \n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: \"Report was successfully created.\" }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \t@study = Study.find(params[:study_id])\n\t@project = Project.find(@study.project_id)\n\t@extraction_form = ExtractionForm.find(params[:extraction_form_id])\n\t@adverse_event = AdverseEvent.new\n\t@adverse_event.study_id = @study.id\n\t@adverse_event.extraction_form_id = @extraction_form.id\n\t@saved = @adverse_event.save\n\n\tif @saved\n\t\t@extraction_form = ExtractionForm.find(@adverse_event.extraction_form_id)\n\t\t@extraction_form_adverse_event_columns = AdverseEventColumn.find(:all, :conditions => [\"extraction_form_id = ?\", @extraction_form.id])\n\t\t@arms = Arm.find(:all, :conditions => [\"study_id = ? AND extraction_form_id = ?\", params[:study_id], @extraction_form.id], :order => \"display_number ASC\")\n\t\t@adverse_events = AdverseEvent.find(:all, :conditions=>['study_id=? AND extraction_form_id = ?', params[:study_id], @extraction_form.id])\n\t\t@adverse_event_result = AdverseEventResult.new\n\t\t@num_rows = 0\n\n\t\t# get titles suggested by the extraction form creator\n\t\t@suggested_ae_titles = ExtractionFormAdverseEvent.where(:extraction_form_id => params[:extraction_form_id])\n\t\tif @extraction_form.adverse_event_display_arms\n\t\t\t@num_rows = @num_rows + @arms.length\n\t\tend\n\t\tif @extraction_form.adverse_event_display_total\n\t\t\t@num_rows = @num_rows + 1\n\t\tend\t\t\n\telse\n\t\tproblem_html = create_error_message_html(@adverse_event.errors)\n\t\tflash[:modal_error] = problem_html\n\tend\t\n end", "def validate_resident_survey model\n\n # What ID do we use to mark ambiguous users?\n err_res_id = P4Resident.find_by_p4_program_id('#999')['id']\n # Get list of all surveys, and look for duplicate survey entries\n if not model.column_names.index('abfm_last_four2').nil?\n # In rails 2.3 the select method is private\n # So either use rails 3.2 or use the find method\n # model.find( :all,\n # :select=>'count(*) as xcount, p4_program_id, contclin, abfm_last_four, abfm_last_four2',\n # :group:=>'p4_program_id,contclin,abfm_last_four,abfm_last_four2,p4_resident_id'\n # )\n surveys = model.select('count(*) as xcount, p4_program_id, contclin, abfm_last_four, abfm_last_four2').group('p4_program_id,contclin,abfm_last_four,abfm_last_four2,p4_resident_id')\n else\n surveys = model.select('count(*) as xcount, p4_program_id, contclin, abfm_last_four').group('p4_program_id,contclin,abfm_last_four,p4_resident_id')\n end\n\n surveys.each do |survey|\n abfm_last_four = survey.abfm_last_four.to_s.rjust(4,'0')\n if survey.attributes.has_key? 'abfm_last_four2'\n abfm_last_four_old = survey.abfm_last_four2.to_s.rjust(4,'0')\n else\n abfm_last_four_old = abfm_last_four\n end\n\n # look for matching resident \n residents = P4Resident.joins(:p4_resident_clinics).\n where([\"(abfm_last_four = ? OR abfm_last_four_old = ?) AND p4_resident_clinics.p4_clinic_id = ?\",abfm_last_four,abfm_last_four_old,survey.contclin])\n\n log_msgs = []\n # Multiple surveys have the same identifying information\n if survey.xcount.to_i != 1\n resident = P4Resident.find(err_res_id)\n log_msgs += [[\"Duplicate Surveys found\",survey]]\n end\n \n if residents.count == 0\n # No matching resident\n resident = P4Resident.find(err_res_id)\n log_msgs += [['No matching user', survey]]\n elsif residents.count > 1\n # This survey can me matched to more than one resident\n resident = P4Resident.find(err_res_id)\n log_msgs += [['Matched multiple users', survey]]\n else\n resident = residents[0]\n end\n \n # Update survey records to point to the correct resident\n if abfm_last_four == abfm_last_four_old\n conditions= ['p4_program_id= ? AND (abfm_last_four = ?) AND contclin=?', \n survey.p4_program_id,abfm_last_four,survey.contclin ]\n else\n conditions= ['p4_program_id= ? AND (abfm_last_four=? OR abfm_last_four2 = ?) AND contclin=?', \n survey.p4_program_id,abfm_last_four,abfm_last_four_old,survey.contclin ]\n end\n\n responses = model.where(conditions) \n \n responses.each do |response|\n if not response.p4_resident_id.nil? and response.p4_resident_id != err_res_id\n log_msgs = []\n log \"Manually Matched: #{response.p4_resident_id}\", response\n next\n end\n response.p4_resident_id = resident[:id]\n response.save!\n end\n \n log_msgs.each do |arr|\n log arr[0],arr[1]\n end\n\n end\nend", "def step1_1_team_analysis\n# DEBUG\n logger.debug( \"\\r\\n\\r\\n!! ------ #{self.class.name} - team_analysis -----\" )\n logger.debug( \"> #{params.inspect}\" )\n # [Steve, 20161001] We need to whitelist all parameters, since we are using this as Admins\n params.permit!()\n # Propagate forward (phase-3) the parameters from Phase-1, if any:\n @force_missing_meeting_creation = (params[:force_meeting_creation] == 'true') ||\n (params[:force_meeting_creation].to_i > 0)\n @force_team_or_swimmer_creation = (params[:force_team_or_swimmer_creation] == 'true') ||\n (params[:force_team_or_swimmer_creation].to_i > 0)\n if ( params[:id].to_i > 0 )\n @data_import_session = DataImportSession.find_by_id( params[:id].to_i )\n @analysis_results = DataImportTeamAnalysisResult.where( data_import_session_id: @data_import_session.id )\n else\n @data_import_session = nil\n @analysis_results = []\n end\n end", "def execute()\n \n # Retrieve a single entry from KS_SRV_Helper form\n base_record = @@remedy_forms['KS_SRV_CustomerSurvey'].find_entries(\n :single,\n :conditions => [%|'CustomerSurveyInstanceId' = \"#{@parameters['Submission ID']}\" OR 'CustomerSurveyID' = \"#{@parameters['Submission ID']}\"|],\n :fields => :all\n )\n \n raise \"Unable to find KS_SRV_CustomerSurvey record with CustomerSurvey ID or instanceId of: #{@parameters['Submission ID']}\" if base_record.nil?\n \n\tif (@taskVersion == \"3\")\n\t#v3\n # Build the template record from the KS_SRV_CustomerSurvey record, which\n # includes the Template fields.\n\t template_record = Records::Template.new(base_record)\n \n # Build the template dataset mappings based on the KS_SRV_DataSet form\n # records for dataset specified on the current KS_SRV_CustomerSurvey\n # record.\n\n\t @dataset_hash = Records::TemplateDataSetMapping.find_all(\n\t\t :data_set => template_record.data_set\n\t\t).inject({}) do |hash, mapping_record|\n\t\t # Define the current KS_SRV_DataSet record's field_id as a Fixnum\n\t\t field_id = mapping_record.field_id.to_i\n\t\t # Retrieve the ArsModels::Field associated with the current\n\t\t # KS_SRV_CustomerSurvey field.\n\t\t mapping_field = Records::RequestBase.form.field_for(field_id)\n\t\t # Unless the field does not exist on the form, or the field is display only\n\t\t unless mapping_field.nil? || mapping_field.entrymode == \"DISPLAY_ONLY\"\n\t\t\t# Retrieve the value of the field on the KS_SRV_CustomerSurvey entry\n\t\t\tvalue = base_record[field_id]\n\t\t\t# Map the KS_SRV_DataSet record's field label value to the field value\n\t\t\thash[mapping_record.field_label] = value.respond_to?(:value) ? value.value : value\n\t\t end\n\t\t # Return the hash to continue injecting\n\t\t hash\n\t\tend\n\t\t puts(format_hash(\"Dataset Found: \", @dataset_hash)) if @debug_logging_enabled\n\t\n\telsif (@taskVersion == \"4\")\n\t \n\t template_record = Records::Template.new(base_record, :context => @@remedy_context)\n\t \n\t @dataset_hash = Records::TemplateDataSetMapping.find_all(\n\t\t :data_set => template_record.data_set, :context => @@remedy_context\n\t\t).inject({}) do |hash, mapping_record|\n\t\t # Define the current KS_SRV_DataSet record's field_id as a Fixnum\n\t\t field_id = mapping_record.field_id.to_i\n\t\t # Retrieve the ArsModels::Field associated with the current\n\t\t # KS_SRV_CustomerSurvey field.\n\t\t mapping_field = Records::RequestBase.form.field_for(field_id)\n\t\t # Unless the field does not exist on the form, or the field is display only\n\t\t unless mapping_field.nil? || mapping_field.entrymode == \"DISPLAY_ONLY\"\n\t\t\t# Retrieve the value of the field on the KS_SRV_CustomerSurvey entry\n\t\t\tvalue = base_record[field_id]\n\t\t\t# Map the KS_SRV_DataSet record's field label value to the field value\n\t\t\thash[mapping_record.field_label] = value.respond_to?(:value) ? value.value : value\n\t\t end\n\t\t # Return the hash to continue injecting\n\t\t hash\n\t\tend\n\t\tputs(format_hash(\"Dataset Found: \", @dataset_hash)) if @debug_logging_enabled\n\t\t\n\tend\n \n dataset_results = \"\" \n @dataset_hash.each_pair {|key, value|\n dataset_results << %|<result name=\"#{key}\">#{escape(value)}</result>|\n }\n \n <<-RESULTS\n <results>\n #{dataset_results}\n </results>\n RESULTS\n \n 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 \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 create\n params[:submission][:verdict] = 'pending'\n create_base(params[:submission]) \n end", "def new\n\n if @submission.submission_gradings.count > 0\n redirect_to edit_course_mission_submission_submission_grading_path(@course, @mission,@submission, @submission.submission_gradings.first)\n return\n end\n\n @qadata = {}\n\n @mission.get_all_questions.each_with_index do |q,i|\n @qadata[q.id.to_s+q.class.to_s] = { q: q, i: i + 1 }\n end\n\n eval_answer\n @submission.get_all_answers.each do |sa|\n qn = sa.qn\n @qadata[qn.id.to_s + qn.class.to_s][:a] = sa\n #suggest grading for auto grading question\n\n if sa.class == StdCodingAnswer and qn.is_auto_grading?\n results = sa.result_hash[\"evalTests\"]\n evals = results ? results.select {|r| r}.length : 0\n tests = qn.data_hash[\"evalTests\"].length\n tests = tests == 0 ? 1 : tests\n grade = (qn.max_grade * evals / tests).to_i\n ag = AnswerGrading.new\n ag.grade = grade\n @qadata[qn.id.to_s + qn.class.to_s][:g] = ag\n end\n end\n\n @do_grading = true\n end", "def create\n @goal = @user.goals.new(params[:goal])\n=begin \n if params[:goal_amount].blank?\n @goal.errors[:base] << \"Select score or duration for setting goal.\"\n elsif params[:goal_amount] == \"score\"\n if @goal.goal_amount_score.blank?\n @goal.errors[:goal_amount_score] << \"should be set.\"\n end\n \n if !@goal.goal_amount_duration.blank?\n @goal.goal_amount_duration = nil\n end\n elsif params[:goal_amount] == \"duration\"\n if @goal.goal_amount_duration.blank?\n @goal.errors[:goal_amount_duration] << \"should be set.\"\n end\n \n if !@goal.goal_amount_score.blank?\n @goal.goal_amount_score = nil\n end\n end\n=end \n if @goal.goal_type == 'recurring'\n case params[:goal_frequency]\n when \"daily\"\n @goal.goal_frequency = 1\n @goal.goal_frequency_unit = \"day\"\n when \"weekly\"\n @goal.goal_frequency = 1\n @goal.goal_frequency_unit = \"week\"\n when \"bi-monthly\"\n @goal.goal_frequency = 2\n @goal.goal_frequency_unit = \"week\"\n when \"monthly\"\n @goal.goal_frequency = 1\n @goal.goal_frequency_unit = \"month\"\n when \"other\"\n @goal.goal_frequency = params[:goal_frequency].to_i\n @goal.goal_frequency_unit = params[:frequency][:other_frequency_unit]\n end\n \n end\n \n if !@goal.errors.empty?\n render action: \"new\"\n else\n respond_to do |format|\n if @goal.save\n format.html { redirect_to [@user,@goal], notice: 'Goal was successfully created.' }\n format.json { render json: @goal, status: :created, location: @goal }\n else\n format.html { render action: \"new\" }\n format.json { render json: @goal.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n=begin\n params[:short_term_goal][:tasks] = Array.new\n tasks_array = Array.new\n if params[:task]\n params[:task].each do |num,task| \n tasks_array[Integer(num)] = task if task != ''\n end\n end\n tasks_array.each do |task|\n params[:short_term_goal][:tasks] << Task.create(:name => task) if task != nil\n end\n=end\n @short_term_goal = ShortTermGoal.new(params[:short_term_goal])\n respond_to do |format|\n if @short_term_goal.save\n format.html { redirect_to(myguide_path(@current_user), :notice => 'Short term goal was successfully created.') }\n format.xml { render :xml => @short_term_goal, :status => :created, :location => @short_term_goal }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @short_term_goal.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n unless at_least_match_degree_times_available?\n flash[:error] = \"Error: you must be available for at least #{@participant.match_degree} times.\"\n redirect_to edit_project_participant_ranking_path(:secret_id => @participant.secret_id) and return\n return\n end\n\n update_rankings_from_params\n\n @participant.update(last_responded: Time.now.getutc)\n redirect_to end_project_participant_ranking_path\n end", "def check_formation(corp)\n return if formed?(corp)\n\n if major?(corp) && corp.floated?\n @formed << corp\n @log << \"#{corp.name} forms\"\n elsif minor?(corp) && corp.cash >= minor_required_train(corp).price\n @formed << corp\n @log << \"Minor #{corp.name} forms\"\n\n # buy required train (no phase-change side-effects)\n r_train = minor_get_train(corp)\n @minor_trains.delete(r_train)\n corp.trains << r_train\n r_train.owner = corp\n corp.spend(r_train.price, @bank)\n @log << \"Minor #{corp.name} spends #{format_currency(r_train.price)} for required train (#{r_train.name})\"\n end\n end", "def unofficial_submit\n \n feedback_str = request.body.read\n\n @course = Course.where(:id => params[:course_id]).first\n @assessment = Assessment.where(:id => params[:id]).first\n @user = User.where(:email => params[:user]).first\n\n if !@course then\n puts \"ERROR: invalid course\"\n exit\n end\n\n if !@user then\n puts \"ERROR: invalid username (#{user}) for class #{course.id}\"\n exit\n end\n\n if !@assessment then\n puts \"ERROR: Invalid Assessment (#{assessment}) for course #{course.id}\"\n exit\n end\n\n if !@assessment.allow_unofficial then\n puts \"ERROR: This assessment does not allow Unofficial Submissions\"\n exit\n end\n\n @result = params[:result]\n\n if !@result then\n puts \"ERROR: No result!\"\n exit\n end\n\n # Everything looks OK, so append the autoresult to the log.txt file for this lab\n @logger = Logger.new(\"#{Rails.root}/courses/#{@course.name}/#{@assessment.name}/log.txt\")\n @logger.add(Logger::INFO) { \"#{@user.email},0,#{@result}\" }\n\n # Load up the lab.rb file\n modName = @assessment.name + (@course.name).gsub(/[^A-Za-z0-9]/,\"\")\n require(\"#{Rails.root}/assessmentConfig/#{@course.name}-#{@assessment.name}.rb\")\n eval(\"extend #{modName.camelcase}\")\n\n begin\n # Call the parseAutoresult function defined in the lab.rb file. If\n # the list of scores it returns is empty, then we the lab developer is\n # asking us not to create an unofficial submission in the\n # database. Simply return a successful status string to the client and\n # exit.\n scores = parseAutoresult(@result,false)\n\n if scores.keys.length == 0 then \n render :nothing => true and return\n end\n\n # Try to find an existing unofficial submission (always version 0). \n submission = @assessment.submissions.where(:version=>0,:user_id=>@user.id).first\n if !submission then\n submission = @assessment.submissions.new(:version=>0,\n :autoresult=>@result,\n :user_id=>@user.id,\n :submitted_by_id=>0)\n submission.save!()\n else\n #update this one\n submission.autoresult= @result\n submission.created_at = Time.now()\n submission.save!()\n end\n\n\n # Update the scores in the db's unofficial submission using the list\n # returned by the parseAutoresult function\n for key in scores.keys do\n problem = @assessment.problems.where(:name => key).first\n score = submission.scores.where(:problem_id => problem.id).first\n if !score then \n score = submission.scores.new(:problem_id=>problem.id)\n end\n score.score = scores[key]\n score.released = true\n score.grader_id= 0\n score.save!()\n end\n rescue Exception => e\n print e\n end\n\n\n render :nothing => true and return\n\n end", "def validate_project\n\n # project name should be 10 to 30 length, and 5 words or fewer\n validate_length_words 'Project Name', self.project_name, 10, 30, 0, 5\n\n # vision should be 1 sentence\n validate_sentences_length 'Vision', self.vision, 30, 100, 1\n\n # goal should be 1 sentence\n validate_sentences_length 'Goal', self.goal, 30, 100, 1\n\n # description, and scope should be 5 sentences!\n validate_sentences_length 'Description', self.description, 100, 500, 5\n validate_sentences_length 'Scope', self.scope, 100, 500, 5\n\n # advice needed\n validate_sentences_length 'Advice Required', self.advice_required, 50, 200, 3\n\n # randomize program and train complaints!\n validate_random_day 'Program', self.program.name\n validate_random_day 'Train', self.train.name\n end", "def validate()\n validation_errors = []\n @expected_results.each_pair do |key,expected_result|\n result_key = expected_result[\"population_ids\"].dup\n\n reported_result, errors = extract_results_by_ids(expected_result['measure_id'], result_key)\n @reported_results[key] = reported_result\n validation_errors.concat match_calculation_results(expected_result,reported_result)\n end\n\n validation_errors\n end", "def check_attributes\n if (@values == nil)\n puts \"Specify necessary informations: \"\n get_input_values\n @additions = Array.new()\n end\n #check_time_string\n end", "def test_scenario15\n data = [['data/iris.csv', {\"weight_field\" => \"000000\", \"missing_numerics\" => false}, {\"petal width\" => 1.5, \"petal length\" => 2, \"sepal width\" => 1}, 'Iris-versicolor', 0.9547, '000004']]\n puts \"\"\n puts \"Scenario: Successfully comparing predictions with text options\"\n\n data.each do |filename, parms, data_input, prediction_result, probability, objective|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n\n source = @api.create_source(File.dirname(__FILE__)+\"/\"+filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create a logistic regression model with objective <%s> and params <%s>\" % [objective, parms]\n logistic_regression = @api.create_logisticregression(dataset, {'objective_field' => objective}.merge(parms))\n \n puts \"And I wait until the logistic regression model is ready\"\n assert_equal(BigML::HTTP_CREATED, logistic_regression[\"code\"])\n assert_equal(@api.ok(logistic_regression), true)\n\n puts \"And I create a local logistic regression model\"\n localLogisticRegression = BigML::Logistic.new(logistic_regression)\n\n puts \"When I create a logistic regression prediction for <%s>\" % JSON.generate(data_input)\n prediction = @api.create_prediction(logistic_regression, data_input)\n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n\n puts \"Then the logistic regression prediction is <%s>\" % prediction_result\n assert_equal(prediction_result, prediction[\"object\"][\"output\"])\n\n puts \"And the logistic regression probability for the prediction is <%s>\" % probability\n\n prediction[\"object\"][\"probabilities\"].each do |prediction_value, remote_probability|\n if prediction_value == prediction[\"object\"][\"output\"]\n assert_equal(remote_probability.to_f.round(3),probability.round(3))\n break\n end\n end\n\n puts \"And I create a local logistic regression prediction for <%s>\" % JSON.generate(data_input)\n local_prediction = localLogisticRegression.predict(data_input, {\"full\" => true})\n\n puts \"Then the local logistic regression prediction is <%s>\" % prediction_result\n assert_equal(prediction_result, local_prediction[\"prediction\"])\n\n puts \"And the local logistic regression probability for the prediction is <%s>\" % probability\n assert_equal(probability.round(4), local_prediction[\"probability\"].round(4))\n\n end\n 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 \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 update\n @goal = Goal.find(params[:id])\n is_complete = params[:is_complete]\n\n if(is_complete != nil) # update just complete\n respond_to do |format|\n if @goal.update_attribute(\"is_complete\",is_complete)\n format.html { render :nothing => true }\n format.js { render :json => 1}\n else\n format.html { render :nothing => true }\n format.js { render :json => 2 }\n end\n end\n else # update all\n respond_to do |format|\n\n @validated = true\n @i = 0\n @num = 5\n while @i < @num do\n @sm = params[:goal]['tasks_attributes'][\"#{@i}\"]['startdue(2i)'].to_i\n @sd = params[:goal]['tasks_attributes'][\"#{@i}\"]['startdue(3i)'].to_i\n @sy = params[:goal]['tasks_attributes'][\"#{@i}\"]['startdue(1i)'].to_i\n @dm = params[:goal]['tasks_attributes'][\"#{@i}\"]['due(2i)'].to_i\n @dd = params[:goal]['tasks_attributes'][\"#{@i}\"]['due(3i)'].to_i\n @dy = params[:goal]['tasks_attributes'][\"#{@i}\"]['due(1i)'].to_i\n @i = @i + 1;\n if (@sy > @dy) or (@sm > @dm and @sy == @dy) or (@sd > @dd and @sm == @dm and @sy == @dy)\n @validated = false\n format.html { redirect_to goals_url+'?filter='+@goal.category, notice: 'Start date cannot be less than end date.' }\n format.json { render json: @goal, status: :created, location: @goal }\n end\n end\n\n if @validated == true\n if @goal.update_attributes(params[:goal])\n\n # destroy blank tasks\n blanktasks = Task.where('task = \\'\\' and goal_id = ?',params[:id])\n blanktasks.each do |bt|\n bt.destroy\n end\n\n @mentors = @goal.accountability.split(',');\n @users = User.find(:all,:order=>\"name\")\n @mentors.each do |onementor|\n if onementor != '' and @goal.goal != ''\n if @users\n @users.each do |user|\n if user.name == onementor.strip and user.id.to_i != @goal.user_id.to_i\n @mu = MentorUser.where('mentor_user_id = ? and student_user_id = ? ',user.id.to_i,@goal.user_id.to_i)\n if @mu.length == 0\n @mentorUser = MentorUser.new(:mentor_user_id=>user.id.to_i ,:student_user_id=>@goal.user_id.to_i)\n @mentorUser.save\n end\n end\n end\n end\n end\n end\n\n format.html { redirect_to goals_url+'?filter='+@goal.category, notice: 'Your goal was successfully updated.' }\n format.json { head :ok }\n else\n format.html { redirect_to goals_url }\n format.json { render json: @goal.errors, status: :unprocessable_entity }\n end\n end\n end\n end\n end", "def perform\n options.clean_options!\n at(0, 100, t('common.progress_initializing'))\n\n user = User.find(options[:user_id])\n dataset = user.datasets.active.find(options[:dataset_id])\n task = dataset.analysis_tasks.find(options[:task_id])\n\n task.name = t('.short_desc')\n task.save\n\n # Do the analysis\n analyzer = compute_word_frequencies(\n dataset,\n ->(p) { at(p, 100, t('.progress_calculating')) },\n options)\n corpus_size = RLetters::Solr::CorpusStats.new.size\n\n # Create some CSV\n at(100, 100, t('common.progress_finished'))\n csv_string = CSV.generate do |csv|\n csv << [t('.csv_header', name: dataset.name)]\n csv << ['']\n\n # Output the block data\n if analyzer.blocks.size > 1\n csv << [t('.each_block')]\n\n name_row = ['']\n header_row = ['']\n word_rows = []\n analyzer.word_list.each do |w|\n word_rows << [w]\n end\n types_row = [t('.types_header')]\n tokens_row = [t('.tokens_header')]\n ttr_row = [t('.ttr_header')]\n\n analyzer.blocks.each_with_index do |b, i|\n s = analyzer.block_stats[i]\n\n name_row << s[:name] << '' << '' << ''\n header_row << t('.freq_header') \\\n << t('.prop_header') \\\n << t('.tfidf_dataset_header') \\\n << t('.tfidf_corpus_header')\n\n word_rows.each do |r|\n word = r[0]\n r << (b[word] || 0).to_s\n r << ((b[word] || 0).to_f / s[:tokens].to_f).to_s\n\n r << Math.tfidf((b[word] || 0).to_f / s[:tokens].to_f,\n analyzer.df_in_dataset[word],\n dataset.entries.size)\n if analyzer.df_in_corpus.present?\n r << Math.tfidf((b[word] || 0).to_f / s[:tokens].to_f,\n analyzer.df_in_corpus[word],\n corpus_size)\n else\n r << ''\n end\n end\n\n # Output the block stats at the end\n types_row << s[:types].to_s << '' << '' << ''\n tokens_row << s[:tokens].to_s << '' << '' << ''\n ttr_row << (s[:types].to_f / s[:tokens].to_f).to_s << '' << '' << ''\n end\n\n csv << name_row\n csv << header_row\n word_rows.each do |r|\n csv << r\n end\n csv << types_row\n csv << tokens_row\n csv << ttr_row\n end\n\n # Output the dataset data\n csv << ['']\n csv << [t('.whole_dataset')]\n csv << ['', t('.freq_header'), t('.prop_header'),\n t('.df_header'), t('.tfidf_corpus_header')]\n analyzer.word_list.each do |w|\n tf_in_dataset = analyzer.tf_in_dataset[w]\n r = [w,\n tf_in_dataset.to_s,\n (tf_in_dataset.to_f / analyzer.num_dataset_tokens).to_s]\n if analyzer.df_in_corpus.present?\n r << analyzer.df_in_corpus[w].to_s\n r << Math.tfidf(tf_in_dataset, analyzer.df_in_corpus[w],\n corpus_size)\n else\n r << ''\n r << ''\n end\n csv << r\n end\n csv << [t('.types_header'), analyzer.num_dataset_types.to_s]\n csv << [t('.tokens_header'), analyzer.num_dataset_tokens.to_s]\n csv << [t('.ttr_header'), (analyzer.num_dataset_types.to_f /\n analyzer.num_dataset_tokens).to_s]\n csv << ['']\n end\n\n # Write it out\n ios = StringIO.new(csv_string)\n file = Paperclip.io_adapters.for(ios)\n file.original_filename = 'word_frequency.csv'\n file.content_type = 'text/csv'\n\n task.result = file\n\n # We're done here\n task.finish!\n\n completed\n end", "def add_new_task_form\n if params[:note_id].blank?\n @note = Communication.new(:assigned_by_employee_user_id=> params[:lawyer_id])\n else\n @note = Communication.find(params[:note_id])\n end\n @from_edit = params[:from_edit]\n @time_zone = @note.receiver.time_zone\n users = []\n if current_user.belongs_to_front_office\n users = User.all_cluster_livian(@note.clusters)\n @common_pool_user = false\n @back_office_user = false\n elsif current_user.belongs_to_common_pool\n users = Cluster.get_common_pool_livian_users\n @common_pool_user = true\n @back_office_user = false\n elsif current_user.belongs_to_back_office\n users = Cluster.get_back_office_cluster_livians\n @common_pool_user = false\n @back_office_user = true\n end\n @work_types = @back_office_user ? WorkType.back_office_work_types : WorkType.livian_work_types\n first_work_subtype = @work_types.first.work_subtypes.first\n @complexities = first_work_subtype.blank? ? [] : first_work_subtype.work_subtype_complexities\n get_work_subtypes_and_diffentiate_users(users,@work_types)\n render :update do |page|\n page.insert_html :bottom, :new_task_form, :partial=>'task_fields',:locals=>{:index=>params[:task_index]}\n end\n end", "def create\n @nota = Nota.new(params[:nota])\n\t\t@plan = Plan.find_by_subject_id(@nota.subject_id)\n\t\tif !@nota.examen_1\n\t\t\t@nota.examen_1 = 0.0\n\t\tend\n\t\tif !@nota.examen_2\n\t\t\t@nota.examen_2 = 0.0\n\t\tend\n\t\tif !@nota.examen_3\n\t\t\t@nota.examen_3 = 0.0\n\t\tend\n\t\tif !@nota.examen_4\n\t\t\t@nota.examen_4 = 0.0\n\t\tend\n\n\t\tif !@nota.acumulado_1\n\t\t\t@nota.acumulado_1 = 0.0\n\t\tend\n\t\tif !@nota.acumulado_2\n\t\t\t@nota.acumulado_2 = 0.0\n\t\tend\n\t\tif !@nota.acumulado_3\n\t\t\t@nota.acumulado_3 = 0.0\n\t\tend\n\t\tif !@nota.acumulado_4\n\t\t\t@nota.acumulado_4 = 0.0\n\t\tend\n\t\t\n\t\tif @nota.examen_1 > @plan.examen_1 || @nota.examen_2 > @plan.examen_2 ||\n\t\t\t @nota.examen_3 > @plan.examen_3 || @nota.examen_4 > @plan.examen_4 ||\n @nota.acumulado_1 > @plan.acumulado_1 || @nota.acumulado_2 > @plan.acumulado_2 ||\n\t\t\t @nota.acumulado_3 > @plan.acumulado_3 || @nota.acumulado_4 > @plan.acumulado_4\n\t\t\tflash[:notice] = 'La calificacion no puede ser mayor que los valores de ponderacion.'\n\t\t\tredirect_to new_student_score_path(:id => @nota.subject_id, :id2 => @nota.student_id)\n\t\telse\n\t\t\tif @nota.save\n\t\t flash[:notice] = 'Alumno calificado con exito.'\n\t\t\t\tredirect_to (\"/plans/\"+@plan.id.to_s) \n\t\t else\n\t\t flash[:notice] = 'Something went wrong when creating score.'\n\t\t\t\trender :action => \"new\"\n\t\t end\n\t\tend\n end" ]
[ "0.59465456", "0.5757286", "0.5691471", "0.5658995", "0.5658576", "0.5628313", "0.56260484", "0.56186736", "0.5590127", "0.5581017", "0.55739576", "0.55511534", "0.55511534", "0.5532458", "0.55226046", "0.5512673", "0.5493022", "0.54827636", "0.5476906", "0.54667455", "0.5448173", "0.5426317", "0.5424401", "0.54095995", "0.5397838", "0.5394269", "0.5393668", "0.53847754", "0.5384275", "0.53804594", "0.53781575", "0.5369414", "0.53661835", "0.53587186", "0.5355449", "0.53465", "0.5341764", "0.53403246", "0.5328448", "0.5327212", "0.53262746", "0.5323239", "0.53199434", "0.5318459", "0.5317227", "0.5315263", "0.5313105", "0.5305609", "0.5296995", "0.52862585", "0.528503", "0.52843606", "0.52813935", "0.52640295", "0.525996", "0.5259954", "0.52577674", "0.52549624", "0.5237972", "0.5236636", "0.5228249", "0.52227175", "0.52227175", "0.52227175", "0.52227175", "0.52215636", "0.52215636", "0.5219678", "0.5212963", "0.5211334", "0.5210089", "0.5201279", "0.5197348", "0.5195561", "0.51930386", "0.5191919", "0.51900387", "0.51856565", "0.51849484", "0.5179114", "0.5174389", "0.51725173", "0.517098", "0.5166101", "0.5161166", "0.515636", "0.5156136", "0.5155952", "0.5153102", "0.51512074", "0.5145603", "0.5144275", "0.51409686", "0.512705", "0.5120407", "0.5119697", "0.5119444", "0.51178855", "0.51158535", "0.5114213" ]
0.57034844
2
every time a new task is completed, we run another analysis, which may not be appropriate for production apps with larger datasets
def register_completion(id, true_time) t = Task.get(id) t.update({ :true_time => (true_time.to_f * 2).round }) schema = most_recent_analysis_created.schema n = most_recent_analysis_created._id.split('_')[1].to_i + 1 if most_recent_analysis_created._id != most_recent_analysis_succeeded._id most_recent_analysis_created.delete end r = stringify_hash_keys(t.attributes) r['_id'] = r['id'].to_s r.delete('id') TABLE.upload_row(r) TABLE.create_analysis(schema, "veritabill_#{n}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform\n options.clean_options!\n at(0, 100, t('common.progress_initializing'))\n\n user = User.find(options[:user_id])\n dataset = user.datasets.active.find(options[:dataset_id])\n task = dataset.analysis_tasks.find(options[:task_id])\n\n task.name = t('.short_desc')\n task.save\n\n # Do the analysis\n analyzer = compute_word_frequencies(\n dataset,\n ->(p) { at(p, 100, t('.progress_calculating')) },\n options)\n corpus_size = RLetters::Solr::CorpusStats.new.size\n\n # Create some CSV\n at(100, 100, t('common.progress_finished'))\n csv_string = CSV.generate do |csv|\n csv << [t('.csv_header', name: dataset.name)]\n csv << ['']\n\n # Output the block data\n if analyzer.blocks.size > 1\n csv << [t('.each_block')]\n\n name_row = ['']\n header_row = ['']\n word_rows = []\n analyzer.word_list.each do |w|\n word_rows << [w]\n end\n types_row = [t('.types_header')]\n tokens_row = [t('.tokens_header')]\n ttr_row = [t('.ttr_header')]\n\n analyzer.blocks.each_with_index do |b, i|\n s = analyzer.block_stats[i]\n\n name_row << s[:name] << '' << '' << ''\n header_row << t('.freq_header') \\\n << t('.prop_header') \\\n << t('.tfidf_dataset_header') \\\n << t('.tfidf_corpus_header')\n\n word_rows.each do |r|\n word = r[0]\n r << (b[word] || 0).to_s\n r << ((b[word] || 0).to_f / s[:tokens].to_f).to_s\n\n r << Math.tfidf((b[word] || 0).to_f / s[:tokens].to_f,\n analyzer.df_in_dataset[word],\n dataset.entries.size)\n if analyzer.df_in_corpus.present?\n r << Math.tfidf((b[word] || 0).to_f / s[:tokens].to_f,\n analyzer.df_in_corpus[word],\n corpus_size)\n else\n r << ''\n end\n end\n\n # Output the block stats at the end\n types_row << s[:types].to_s << '' << '' << ''\n tokens_row << s[:tokens].to_s << '' << '' << ''\n ttr_row << (s[:types].to_f / s[:tokens].to_f).to_s << '' << '' << ''\n end\n\n csv << name_row\n csv << header_row\n word_rows.each do |r|\n csv << r\n end\n csv << types_row\n csv << tokens_row\n csv << ttr_row\n end\n\n # Output the dataset data\n csv << ['']\n csv << [t('.whole_dataset')]\n csv << ['', t('.freq_header'), t('.prop_header'),\n t('.df_header'), t('.tfidf_corpus_header')]\n analyzer.word_list.each do |w|\n tf_in_dataset = analyzer.tf_in_dataset[w]\n r = [w,\n tf_in_dataset.to_s,\n (tf_in_dataset.to_f / analyzer.num_dataset_tokens).to_s]\n if analyzer.df_in_corpus.present?\n r << analyzer.df_in_corpus[w].to_s\n r << Math.tfidf(tf_in_dataset, analyzer.df_in_corpus[w],\n corpus_size)\n else\n r << ''\n r << ''\n end\n csv << r\n end\n csv << [t('.types_header'), analyzer.num_dataset_types.to_s]\n csv << [t('.tokens_header'), analyzer.num_dataset_tokens.to_s]\n csv << [t('.ttr_header'), (analyzer.num_dataset_types.to_f /\n analyzer.num_dataset_tokens).to_s]\n csv << ['']\n end\n\n # Write it out\n ios = StringIO.new(csv_string)\n file = Paperclip.io_adapters.for(ios)\n file.original_filename = 'word_frequency.csv'\n file.content_type = 'text/csv'\n\n task.result = file\n\n # We're done here\n task.finish!\n\n completed\n end", "def perform\n options.clean_options!\n at(0, 100, t('common.progress_initializing'))\n\n user = User.find(options[:user_id])\n @dataset = user.datasets.active.find(options[:dataset_id])\n task = @dataset.analysis_tasks.find(options[:task_id])\n\n task.name = t('.short_desc')\n task.save\n\n analysis_type = (options[:analysis_type] || :mi).to_sym\n num_pairs = (options[:num_pairs] || 50).to_i\n focal_word = options[:word].mb_chars.downcase.to_s if options[:word]\n\n # Part of speech tagging requires the Stanford NLP\n if analysis_type == :pos && Admin::Setting.nlp_tool_path.blank?\n analysis_type = :mi\n end\n\n case analysis_type\n when :mi\n algorithm = t('.mi')\n column = t('.mi_column')\n klass = RLetters::Analysis::Collocation::MutualInformation\n when :t\n algorithm = t('.t')\n column = t('.t_column')\n klass = RLetters::Analysis::Collocation::TTest\n when :likelihood\n algorithm = t('.likelihood')\n column = t('.likelihood_column')\n klass = RLetters::Analysis::Collocation::LogLikelihood\n when :pos\n # :nocov:\n algorithm = t('.pos')\n column = t('.pos_column')\n klass = RLetters::Analysis::Collocation::PartsOfSpeech\n # :nocov:\n else\n fail ArgumentError, 'Invalid value for analysis_type'\n end\n\n analyzer = klass.new(\n @dataset,\n num_pairs,\n focal_word,\n ->(p) { at(p, 100, t('.progress_computing')) }\n )\n grams = analyzer.call\n\n # Save out all the data\n at(100, 100, t('common.progress_finished'))\n csv_string = CSV.generate do |csv|\n csv << [t('.header', name: @dataset.name)]\n csv << [t('.subheader', test: algorithm)]\n csv << ['']\n\n csv << [t('.pair'), column]\n grams.each do |w, v|\n csv << [w, v]\n end\n\n csv << ['']\n end\n\n # Write it out\n ios = StringIO.new(csv_string)\n file = Paperclip.io_adapters.for(ios)\n file.original_filename = 'collocation.csv'\n file.content_type = 'text/csv'\n\n task.result = file\n\n # We're done here\n task.finish!\n\n completed\n end", "def perform_processing_run(faids)\n perform_analysis(faids)\n perform_processing!\n end", "def perform\n options.clean_options!\n at(0, 100, t('common.progress_initializing'))\n\n user = User.find(options[:user_id])\n dataset = user.datasets.active.find(options[:dataset_id])\n task = dataset.analysis_tasks.find(options[:task_id])\n\n task.name = t('.short_desc')\n task.save\n\n analyzer = RLetters::Analysis::NamedEntities.new(\n dataset,\n ->(p) { at(p, 100, t('.progress_finding')) })\n\n # Write it out\n at(100, 100, t('common.progress_finished'))\n ios = StringIO.new(analyzer.entity_references.to_json)\n file = Paperclip.io_adapters.for(ios)\n file.original_filename = 'named_entites.json'\n file.content_type = 'application/json'\n\n task.result = file\n\n # We're done here\n task.finish!\n\n completed\n end", "def master_done!\n @done = true\n specification! true\n summarize_performance!\n \t\tsummarize_results! @results\n \t\tcleanup!\n \t\t#Notify.completed @experiment\n\n \t\t#sleep 1\n #DRb.stop_service\n end", "def perform\n @analysis = Analysis.find(@analysis_id)\n\n # get the analysis and report that it is running\n @analysis_job = AnalysisLibrary::Core.initialize_analysis_job(@analysis, @analysis_job_id, @options)\n\n # reload the object (which is required) because the subdocuments (jobs) may have changed\n @analysis.reload\n\n ids = []\n if @options[:data_points].empty?\n logger.info 'No datapoints were passed into the options, therefore checking which datapoints to run'\n\n # queue up the simulations\n @analysis.data_points.where(status: 'na').each do |dp|\n logger.info \"Adding #{dp.uuid} to simulations queue\"\n\n # TODO: move this method to the datapoint model\n ids << dp.submit_simulation\n end\n end\n\n logger.info \"Delayed Job ids are: #{ids}\"\n\n # Watch the delayed jobs to see when all the datapoints are completed.\n # I would really prefer making a chord or callback for this.\n until ids.empty?\n ids.each do |id|\n ids.delete(id) if Delayed::Job.find(id).nil?\n end\n\n # logger.info ids\n\n sleep 5\n end\n\n # TODO: Finalize the worker nodes\n\n rescue => e\n log_message = \"#{__FILE__} failed with #{e.message}, #{e.backtrace.join(\"\\n\")}\"\n logger.error log_message\n @analysis.status_message = log_message\n @analysis.save!\n ensure\n logger.info 'Finished running batchrun method'\n @analysis_job.end_time = Time.now\n @analysis_job.status = 'completed'\n @analysis_job.save!\n @analysis.reload\n @analysis.save!\n end", "def perform_task\n # actually do the work\n end", "def run_completed\n end", "def perform\n @analysis = Analysis.find(@analysis_id)\n\n # get the analysis and report that it is running\n @analysis_job = AnalysisLibrary::Core.initialize_analysis_job(@analysis, @analysis_job_id, @options)\n\n # reload the object (which is required) because the subdocuments (jobs) may have changed\n @analysis.reload\n\n logger.info \"Initializing analysis for #{@analysis.name} with UUID of #{@analysis.uuid}\"\n\n # make this a core method\n if !@analysis.problem['algorithm']['seed'].nil? && (@analysis.problem['algorithm']['seed'].is_a? Numeric)\n logger.info \"Setting R base random seed to #{@analysis.problem['algorithm']['seed']}\"\n @r.converse(\"set.seed(#{@analysis.problem['algorithm']['seed']})\")\n end\n\n selected_variables = Variable.pivots(@analysis.id) + Variable.variables(@analysis.id)\n logger.info \"Found #{selected_variables.count} variables to perturb\"\n\n # generate the probabilities for all variables as column vectors\n grouped = {}\n samples = {}\n var_types = []\n\n # get the probabilities\n logger.info \"Found #{selected_variables.count} variables\"\n\n i_var = 0\n selected_variables.each do |var|\n logger.info \"sampling variable #{var.name} for measure #{var.measure.name}\"\n variable_samples = nil\n # TODO: would be nice to have a field that said whether or not the variable is to be discrete or continuous.\n if var.uncertainty_type == 'discrete'\n variable_samples = var.static_value\n var_types << 'discrete'\n else\n variable_samples = var.static_value\n var_types << 'continuous'\n end\n\n # always add the data to the grouped hash even if it isn't used\n grouped[var.measure.id.to_s] = {} unless grouped.key?(var.measure.id)\n grouped[var.measure.id.to_s][var.id.to_s] = variable_samples\n\n # save the samples to the\n samples[var.id.to_s] = variable_samples\n\n var.r_index = i_var + 1 # r_index is 1-based\n var.save!\n\n i_var += 1\n end\n\n logger.info \"Samples are #{samples}\"\n number_of_runs = @analysis.problem['algorithm']['number_of_runs']\n logger.info \"Number of Runs is #{number_of_runs}\"\n\n (1..number_of_runs).each do |i|\n dp_name = \"Repeat Run Autogenerated #{i}\"\n dp = @analysis.data_points.new(name: dp_name)\n dp.set_variable_values = samples\n dp.save!\n\n logger.info(\"Generated datapoint #{dp.name} for analysis #{@analysis.name}\")\n end\n\n # Only set this data if the analysis was NOT called from another analysis\n unless @options[:skip_init]\n @analysis_job.end_time = Time.now\n @analysis_job.status = 'completed'\n @analysis_job.save!\n @analysis.reload\n end\n @analysis.save!\n\n logger.info \"Finished running analysis '#{self.class.name}'\"\n end", "def refresh_analysis\n Repository::Config.setup_repo @repo, @log, @process, @type\n Rails.logger.debug \"01 - Done switching up initial path - LOG\"\n report_json = analyze_repo\n Rails.logger.debug \"02 - Done analyzing repository - LOG\"\n store_data report_json\n Rails.logger.debug \"03 - Done storing data - LOG\"\n calculate_results\n Rails.logger.debug \"04 - Done calculating results - LOG\"\n rescue => e\n Rails.logger.debug e.backtrace.to_s + \" ----- \" + e.to_s\n raise\n end", "def full_analysis\n Repository::Config.setup_repo @repo, @log, @process, @type\n Rails.logger.debug \"01 - Done setting up initial path - LOG\"\n init_repo\n Rails.logger.debug \"02 - Done initializing codeclimat config - LOG\"\n exclude_files\n Rails.logger.debug \"03 - Done excluding files - LOG\"\n report_json = analyze_repo\n Rails.logger.debug \"04 - Done analyzing repository - LOG\"\n store_data report_json\n Rails.logger.debug \"05 - Done storing data - LOG\"\n calculate_results\n Rails.logger.debug \"06 - Done calculating result - LOG\"\n rescue => e\n Rails.logger.debug e.backtrace.to_s + \" ----- \" + e.to_s\n ActiveRecord::Base.connection_pool.with_connection do \n @repo.update(clone_path: nil)\n repo_name = @repo.repo_name.gsub(/[.]+/, '-') || @repo.repo_name\n FileUtils.rm_rf(Rails.root.join('storage', 'repos', @repo.username, @repo.supplier_project_id.to_s, repo_name, @repo.current_branch))\n end\n end", "def perform!\n log_start\n check_all\n store_audit_results\n notify_if_failed\n delete_stale_reports\n log_end\n end", "def perform\n @analysis = Analysis.find(@analysis_id)\n\n # get the analysis and report that it is running\n @analysis_job = AnalysisLibrary::Core.initialize_analysis_job(@analysis, @analysis_job_id, @options)\n\n # reload the object (which is required) because the subdocuments (jobs) may have changed\n @analysis.reload\n\n # Make the analysis directory if it doesn't already exist\n FileUtils.mkdir_p analysis_dir(@analysis.id) unless Dir.exist? analysis_dir(@analysis.id)\n\n # create an instance for R\n @r = AnalysisLibrary::Core.initialize_rserve(APP_CONFIG['rserve_hostname'],\n APP_CONFIG['rserve_port'])\n logger.info 'Setting up R for GA Run'\n # Initialize some variables that are in the rescue/ensure blocks\n cluster = nil\n begin\n @r.converse(\"setwd('#{APP_CONFIG['sim_root_path']}')\")\n\n # make this a core method\n if !@analysis.problem['algorithm']['seed'].nil? && (@analysis.problem['algorithm']['seed'].is_a? Numeric)\n logger.info \"Setting R base random seed to #{@analysis.problem['algorithm']['seed']}\"\n @r.converse(\"set.seed(#{@analysis.problem['algorithm']['seed']})\")\n end\n # R libraries needed for this algorithm\n @r.converse 'library(rjson)'\n @r.converse 'library(R.utils)'\n @r.converse 'library(parallel)'\n @r.converse 'library(doParallel)'\n @r.converse 'library(NRELGA)'\n\n # At this point we should really setup the JSON that can be sent to the worker nodes with everything it needs\n # This would allow us to easily replace the queuing system with rabbit or any other json based versions.\n\n master_ip = 'localhost'\n\n logger.info(\"Master ip: #{master_ip}\")\n logger.info('Starting GA Run')\n\n # Quick preflight check that R, MongoDB, and Rails are working as expected. Checks to make sure\n # that the run flag is true.\n\n # TODO: preflight check -- need to catch this in the analysis module\n if @analysis.problem['algorithm']['maxiter'].nil? || (@analysis.problem['algorithm']['maxiter']).zero?\n raise 'Number of max iterations was not set or equal to zero (must be 1 or greater)'\n end\n\n if @analysis.problem['algorithm']['popSize'].nil? || (@analysis.problem['algorithm']['popSize']).zero?\n raise 'Must have number of samples to discretize the parameter space'\n end\n\n if @analysis.problem['algorithm']['elitism'] < 0 || @analysis.problem['algorithm']['elitism'] > 1\n raise 'elitism must be 0 <= elitism <= 1'\n end\n\n if @analysis.problem['algorithm']['pcrossover'] < 0 || @analysis.problem['algorithm']['pcrossover'] > 1\n raise 'pcrossover must be 0 <= pcrossover <= 1'\n end\n\n if @analysis.problem['algorithm']['pmutation'] < 0 || @analysis.problem['algorithm']['pmutation'] > 1\n raise 'pmutation must be 0 <= pmutation <= 1'\n end\n\n # TODO: add test for not \"minkowski\", \"maximum\", \"euclidean\", \"binary\", \"manhattan\"\n # if @analysis.problem['algorithm']['norm_type'] != \"minkowski\", \"maximum\", \"euclidean\", \"binary\", \"manhattan\"\n # raise \"P Norm must be non-negative\"\n # end\n\n if @analysis.problem['algorithm']['p_power'] <= 0\n raise 'P Norm must be non-negative'\n end\n\n # exit on guideline 14 is no longer true/false. its 0,1,2,3\n # @analysis.exit_on_guideline_14 = @analysis.problem['algorithm']['exit_on_guideline_14'] == 1 ? true : false\n if [0, 1, 2, 3].include? @analysis.problem['algorithm']['exit_on_guideline_14']\n @analysis.exit_on_guideline_14 = @analysis.problem['algorithm']['exit_on_guideline_14'].to_i\n logger.info \"exit_on_guideline_14 is #{@analysis.exit_on_guideline_14}\"\n else\n @analysis.exit_on_guideline_14 = 0\n logger.info \"exit_on_guideline_14 is forced to #{@analysis.exit_on_guideline_14}\"\n end\n @analysis.save!\n logger.info(\"exit_on_guideline_14: #{@analysis.exit_on_guideline_14}\")\n\n @analysis.problem['algorithm']['objective_functions'] = [] unless @analysis.problem['algorithm']['objective_functions']\n @analysis.save!\n logger.info(\"exit_on_guideline_14: #{@analysis.exit_on_guideline_14}\")\n\n # check to make sure there are objective functions\n if @analysis.output_variables.count { |v| v['objective_function'] == true }.zero?\n raise 'No objective functions defined'\n end\n\n # find the total number of objective functions\n if @analysis.output_variables.count { |v| v['objective_function'] == true } != @analysis.problem['algorithm']['objective_functions'].size\n raise 'Number of objective functions must equal between the output_variables and the problem definition'\n end\n\n pivot_array = Variable.pivot_array(@analysis.id, @r)\n logger.info \"pivot_array: #{pivot_array}\"\n selected_variables = Variable.variables(@analysis.id)\n logger.info \"Found #{selected_variables.count} variables to perturb\"\n\n # discretize the variables using the LHS sampling method\n @r.converse(\"print('starting lhs to discretize the variables')\")\n logger.info 'starting lhs to discretize the variables'\n\n lhs = AnalysisLibrary::R::Lhs.new(@r)\n samples, var_types, mins_maxes, var_names = lhs.sample_all_variables(selected_variables, 3)\n\n # Result of the parameter space will be column vectors of each variable\n logger.info \"Samples are #{samples}\"\n logger.info \"mins_maxes: #{mins_maxes}\"\n logger.info \"var_names: #{var_names}\"\n logger.info(\"variable types are #{var_types}\")\n\n if samples.empty? || samples.size <= 1\n logger.info 'No variables were passed into the options, therefore exit'\n raise \"Must have more than one variable to run algorithm. Found #{samples.size} variables\"\n end\n\n if var_names.empty? || var_names.empty?\n logger.info 'No variables were passed into the options, therefore exit'\n raise \"Must have at least one variable to run algorithm. Found #{var_names.size} variables\"\n end\n\n unless var_types.all? { |t| t.casecmp('continuous').zero? }\n logger.info 'Must have all continous variables to run algorithm, therefore exit'\n raise \"Must have all continous variables to run algorithm. Found #{var_types}\"\n end\n\n # Start up the cluster and perform the analysis\n # cluster = AnalysisLibrary::R::Cluster.new(@r, @analysis.id)\n # unless cluster.configure\n # raise 'could not configure R cluster'\n # end\n\n @r.converse(\"cat('max_queued_jobs: #{APP_CONFIG['max_queued_jobs']}')\")\n worker_ips = {}\n if @analysis.problem['algorithm']['max_queued_jobs']\n if @analysis.problem['algorithm']['max_queued_jobs'] == 0\n logger.info 'MAX_QUEUED_JOBS is 0'\n raise 'MAX_QUEUED_JOBS is 0'\n elsif @analysis.problem['algorithm']['max_queued_jobs'] > 0\n worker_ips[:worker_ips] = ['localhost'] * @analysis.problem['algorithm']['max_queued_jobs']\n logger.info \"Starting R queue to hold #{@analysis.problem['algorithm']['max_queued_jobs']} jobs\"\n end\n elsif !APP_CONFIG['max_queued_jobs'].nil?\n worker_ips[:worker_ips] = ['localhost'] * APP_CONFIG['max_queued_jobs'].to_i\n logger.info \"Starting R queue to hold #{APP_CONFIG['max_queued_jobs']} jobs\"\n else\n raise 'could not start the cluster (cluster size not set correctly)'\n end\n\n # logger.info \"Cluster Started flag is #{cluster.started}\"\n # maxiter is the max number of iterations to calculate\n # varNo is the number of variables (ncol(vars))\n # popSize is the number of sample points in the variable (nrow(vars))\n # epsilongradient is epsilon in numerical gradient calc\n\n # convert to float because the value is normally an integer and rserve/rserve-simpler only handles maxint\n @analysis.problem['algorithm']['failed_f_value'] = @analysis.problem['algorithm']['failed_f_value'].to_f\n @r.command(master_ips: master_ip,\n ips: worker_ips[:worker_ips],\n vartypes: var_types,\n varnames: var_names,\n varseps: mins_maxes[:eps],\n mins: mins_maxes[:min],\n maxes: mins_maxes[:max],\n normtype: @analysis.problem['algorithm']['norm_type'],\n ppower: @analysis.problem['algorithm']['p_power'],\n objfun: @analysis.problem['algorithm']['objective_functions'],\n popSize: @analysis.problem['algorithm']['popSize'],\n run: @analysis.problem['algorithm']['run'],\n maxFitness: @analysis.problem['algorithm']['maxFitness'],\n maxiter: @analysis.problem['algorithm']['maxiter'],\n pcrossover: @analysis.problem['algorithm']['pcrossover'],\n pmutation: @analysis.problem['algorithm']['pmutation'],\n elitism: @analysis.problem['algorithm']['elitism'],\n epsilongradient: @analysis.problem['algorithm']['epsilon_gradient'],\n debug_messages: @analysis.problem['algorithm']['debug_messages'],\n failed_f: @analysis.problem['algorithm']['failed_f_value']) do\n %{\n rails_analysis_id = \"#{@analysis.id}\"\n rails_sim_root_path = \"#{APP_CONFIG['sim_root_path']}\"\n rails_ruby_bin_dir = \"#{APP_CONFIG['ruby_bin_dir']}\"\n rails_mongodb_name = \"#{AnalysisLibrary::Core.database_name}\"\n rails_mongodb_ip = \"#{master_ip}\"\n rails_run_filename = \"#{@options[:run_data_point_filename]}\"\n rails_create_dp_filename = \"#{@options[:create_data_point_filename]}\"\n rails_root_path = \"#{Rails.root}\"\n rails_host = \"#{APP_CONFIG['os_server_host_url']}\"\n r_scripts_path = \"#{APP_CONFIG['r_scripts_path']}\"\n rails_exit_guideline_14 = \"#{@analysis.exit_on_guideline_14}\"\n\n init <- function(x){\n ruby_command <- \"cd #{APP_CONFIG['sim_root_path']} && #{APP_CONFIG['ruby_bin_dir']}/bundle exec ruby\"\n y <- paste(ruby_command,\" #{APP_CONFIG['sim_root_path']}/worker_init_final.rb -h #{APP_CONFIG['os_server_host_url']} -a #{@analysis_id} -s 'initialize'\",sep=\"\")\n print(paste(\"Run command\",y))\n z <- system(y,intern=TRUE)\n z\n }\n init\n source(paste(r_scripts_path,'/functions.R',sep=''))\n source(paste(r_scripts_path,'/ga.R',sep=''))\n }\n end\n logger.info 'Returned from rserve ga block'\n # TODO: find any results of the algorithm and save to the analysis\n rescue StandardError, ScriptError, NoMemoryError => e\n log_message = \"#{__FILE__} failed with #{e.message}, #{e.backtrace.join(\"\\n\")}\"\n logger.error log_message\n @analysis.status_message = log_message\n @analysis.save!\n @analysis_job.status = 'completed'\n @analysis_job.save!\n @analysis.reload\n @analysis.save!\n ensure\n # ensure that the cluster is stopped\n logger.info 'Executing ga.rb ensure block'\n begin\n # cluster.stop if cluster\n rescue StandardError, ScriptError, NoMemoryError => e\n # logger.error \"Error executing cluster.stop, #{e.message}, #{e.backtrace}\"\n end\n # logger.info 'Successfully executed cluster.stop'\n\n # Post process the results and jam into the database\n best_result_json = \"#{APP_CONFIG['sim_root_path']}/analysis_#{@analysis.id}/best_result.json\"\n if File.exist? best_result_json\n begin\n logger.info('read best result json')\n temp2 = File.read(best_result_json)\n temp = JSON.parse(temp2, symbolize_names: true)\n logger.info(\"temp: #{temp}\")\n @analysis.results[@options[:analysis_type]]['best_result'] = temp\n @analysis.save!\n logger.info(\"analysis: #{@analysis.results}\")\n rescue StandardError => e\n logger.error 'Could not save post processed results for bestresult.json into the database'\n end\n end\n\n # Post process the results and jam into the database\n converge_flag_json = \"#{APP_CONFIG['sim_root_path']}/analysis_#{@analysis.id}/convergence_flag.json\"\n if File.exist? converge_flag_json\n begin\n logger.info('read converge_flag.json')\n temp2 = File.read(converge_flag_json)\n temp = JSON.parse(temp2, symbolize_names: true)\n logger.info(\"temp: #{temp}\")\n @analysis.results[@options[:analysis_type]]['convergence_flag'] = temp\n @analysis.save!\n logger.info(\"analysis: #{@analysis.results}\")\n rescue StandardError => e\n logger.error 'Could not save post processed results for converge_flag.json into the database'\n end\n end\n\n # Only set this data if the analysis was NOT called from another analysis\n unless @options[:skip_init]\n @analysis_job.end_time = Time.now\n @analysis_job.status = 'completed'\n @analysis_job.save!\n @analysis.reload\n end\n @analysis.save!\n\n logger.info \"Finished running analysis '#{self.class.name}'\"\n end\n end", "def optimize_workflow\n end", "def process\n # start with the original as if it was the last destination\n tasks.each do |t|\n process_task(t)\n end\n close_files\n\n result_details\n end", "def process(files, parallel, test, output_path)\n\n summaries = []\n files.each do |file|\n\n mediainfo = mediainfo(file)\n\n results = []\n tx_files = duplicate(file, output_path, parallel - 1)\n tx_files << file\n\n start_time = Time.now\n tx(tx_files, results, test, mediainfo, output_path)\n wait_for_completion\n end_time = Time.now\n\n summary = TestSummary.new(File.basename(file), results, start_time, end_time, mediainfo[:duration])\n summaries << summary\n end\n\n summaries\nend", "def queued_tasks(options, analysis_type)\n # Initialize variables for queue dependent actions\n submit_time = Time.now #change to submit time for analysis\n rdata_flag = options[:rdata]\n csv_flag = options[:csv]\n zip_flag = options[:zip]\n download_flag = false\n stop_flag = options[:stop]\n kill_flag = options[:kill]\n warnings = []\n start_wait = options[:start_wait]\n analysis_wait = options[:analysis_wait]\n analysis_type = 'batch_run' if OpenStudio::Analysis::ServerApi::BATCH_RUN_METHODS.include? analysis_type\n\n # Verify download directories and set flags to true should they exist\n if rdata_flag || csv_flag || zip_flag\n if !File.exist? options[:download_directory]\n puts \"INFO: MKDIR -- Making new directory for download results at #{options[:download_directory]}\"\n Dir.mkdir options[:download_directory]\n download_flag = true\n else\n download_flag = true\n end\n end\n\n # Hash commands for run_queued_tasks and warning messages\n flags = {download: download_flag, rdata: rdata_flag, csv: csv_flag, zip: zip_flag, stop: stop_flag, kill: kill_flag}\n completed = {rdata: nil, csv: nil, zip: nil, stop: nil, kill: nil}\n\n # Execute queued tasks should they exist with a Timeout\n puts 'INFO: ANALYSIS STATUS -- Waiting for analysis to start.'\n while Time.now - submit_time < start_wait\n server_status = @server_api.get_analysis_status(@analysis_id, analysis_type)\n if server_status == 'started'\n puts 'INFO: ANALYSIS STATUS -- Analysis has started. Waiting for analysis to complete.'\n returned = run_queued_tasks(analysis_type, options[:download_directory], flags, analysis_wait)\n returned ||= {}\n completed.merge! returned\n break\n elsif server_status == 'failed'\n puts 'WARN: ANALYSIS STATUS -- The analysis status has transitioned to failed. Attempting to execute queued tasks.'\n returned = run_queued_tasks(analysis_type, options[:download_directory], flags, analysis_wait)\n completed.merge! returned\n break\n else\n sleep 1\n end\n end\n\n # Warn if flags were set to true but code not executed.\n if flags[:rdata]\n warnings << 'WARN: TIMEOUT -- RData results were not downloaded due to timeout' unless completed[:rdata]\n end\n\n if flags[:csv]\n warnings << 'WARN: TIMEOUT -- CSV results were not downloaded due to timeout' unless completed[:csv]\n end\n\n if flags[:zip]\n warnings << 'WARN: TIMEOUT -- Zipped files were not downloaded due to timeout' unless completed[:zip]\n end\n\n if flags[:stop]\n warnings << 'WARN: TIMEOUT -- Instance was not stopped due to timeout' unless completed[:stop]\n end\n\n if flags[:kill]\n warnings << 'WARN: TIMEOUT -- Instance was not killed due to timeout' unless completed[:kill]\n end\n\n warnings.join(\". \") if warnings != []\n\nend", "def flush!\n # Check for finished jobs\n @jobs_running.select! do |job|\n r = (job[:ds].nil? ? project : job[:ds]).add_result(job[:job], false)\n say \"Completed pid:#{job[:pid]} for #{job[:task_name]}.\" unless r.nil?\n r.nil?\n end\n # Avoid single datasets hogging resources\n @jobs_to_run.rotate! rand(jobs_to_run.size)\n # Launch as many +jobs_to_run+ as possible\n while jobs_running.size < maxjobs\n break if jobs_to_run.empty?\n launch_job @jobs_to_run.shift\n end\n end", "def begin_analysis\n Thread.new do\n if @type == 'full'\n full_analysis\n elsif @type == 'refresh'\n refresh_analysis\n end\n end\n msg = { :success => true, :message => \"Please wait while we process the repository!\" }\n end", "def calculate_results\n Repository::Config.new(@repo, @log, @process, @type).status(5) {\n files = files_to_analyze\n puts '-----Files to analyze done (Step 1)'\n files = prepare_files_to_rate files\n puts '-----Prepare files to rate done (Step 2)'\n files = count_total_lines files\n puts '-----Count total lines done (Step 3)'\n files = count_errors files\n puts '-----Count errors done (Step 4)'\n files = grade_categories files\n puts '-----Grade categories done (Step 5)'\n files = grade_files files\n puts '-----Grade files done (Step 6)' + files.to_s\n gpa = grade_repo files\n puts '-----Grade repos done (Step 7)' + gpa.to_s\n gpa_percent = get_overall_grades files\n puts '-----Grade overall percentage done (Step 8)' + gpa_percent.to_s\n cat_issues = get_category_issues files\n puts '-----Get categories issues done (Step 9)' + cat_issues.to_s\n store_cat_issues cat_issues\n puts '-----Store category issues done (Step 10)'\n store_grades gpa, gpa_percent\n puts '-----Store grades done (Step 11)'\n }\n end", "def process\n @type = 'refresh'\n full_analysis\n end", "def perform_analysis(faids)\n @checker = Checker.new(schematron, self)\n faids.each do |faid|\n faid = faid.current if faid.is_a? FindingAid\n ActiveRecord::Base.transaction do\n @checker.check(faid).each_slice(1000) do |batch|\n ConcreteIssue.insert_all(batch)\n end\n self.finding_aid_versions << faid\n self.increment! :eads_processed\n end\n end\n end", "def perform\n @analysis = Analysis.find(@analysis_id)\n\n # get the analysis and report that it is running\n @analysis_job = AnalysisLibrary::Core.initialize_analysis_job(@analysis, @analysis_job_id, @options)\n\n # reload the object (which is required) because the sub-documents (jobs) may have changed\n @analysis.reload\n\n # Create an instance for R\n begin\n logger.info \"Initializing analysis for #{@analysis.name} with UUID of #{@analysis.uuid}\"\n logger.info \"Setting up R for #{self.class.name}\"\n\n selected_variables = Variable.variables(@analysis.id)\n logger.info \"Found #{selected_variables.count} non-default variables in the batch datapoint set.\"\n\n # generate the probabilities for all variables as column vectors\n samples = nil\n\n logger.info 'Starting batch datapoint extraction.'\n\n # Iterate through each variable based on the method and add to the samples array in the form of\n # [{a: 1, b: true, c: 's'}, {a: 2, b: false, c: 'n'}]\n values_length = []\n values_set = {}\n\n selected_variables.each do |var|\n if var.map_discrete_hash_to_array.nil? || var.discrete_values_and_weights.empty?\n raise \"no hash values and weight passed in variable #{var.name}\"\n end\n\n values, weights = var.map_discrete_hash_to_array\n raise \"'nil' value(s) found in variable #{var.id}. nil values not yet supported.\" if values.count(&:nil?).nonzero?\n\n values_length = values_length << values.length\n values_set[var.id.to_s.to_sym] = values\n end\n\n raise 'Length of discrete_values passed in variables was not equal across variables.' if values_length.uniq.length != 1\n\n # Create Datapoint Samples\n logger.info 'Creating datapoint samples'\n samples = []\n for i in 0..(values_length[0] - 1)\n instance = {}\n selected_variables.each do |var|\n instance[var.id.to_s.to_sym] = values_set[var.id.to_s.to_sym][i]\n end\n samples << instance\n end\n\n # Add the datapoints to the database\n logger.info 'Adding the datapoints to the database'\n isample = 0\n da_options = @analysis.problem['design_alternatives'] ? true : false\n samples.each do |sample| # do this in parallel\n name = \"Autogenerated #{isample}\"\n description = \"Autogenerated #{isample}\"\n seed_path, da_descriptions, weather_file = false\n if da_options\n instance_da_opts = @analysis.problem['design_alternatives'][isample]\n name = instance_da_opts['name'] if instance_da_opts['name']\n description = instance_da_opts['description'] if instance_da_opts['description']\n seed_path = File.basename instance_da_opts['seed']['path'] if instance_da_opts['seed']\n weather_file = File.basename instance_da_opts['weather_file']['path'] if instance_da_opts['weather_file']\n if instance_da_opts['options']\n da_descriptions = []\n @analysis.problem['workflow'].each do |step_def|\n wf_da_step = instance_da_opts['options'].select { |h| h['workflow_index'].to_i == step_def['workflow_index'].to_i }\n if wf_da_step.length != 1\n raise \"Invalid OSA; multiple workflow_index of #{step_def['workflow_index']} found in the design_alternative options\"\n else\n wf_da_step = wf_da_step[0]\n end\n\n da_descriptions << { name: wf_da_step['name'], description: wf_da_step['description'] }\n end\n end\n end\n dp = @analysis.data_points.new(name: name, description: description)\n dp.da_descriptions = da_descriptions if da_descriptions\n dp.seed = seed_path if seed_path\n dp.weather_file = weather_file if weather_file\n dp.set_variable_values = sample\n dp.save!\n isample += 1\n logger.info(\"Generated datapoint #{dp.name} for analysis #{@analysis.name}\")\n end\n ensure\n # Only set this data if the analysis was NOT called from another analysis\n unless @options[:skip_init]\n @analysis_job.end_time = Time.now\n @analysis_job.status = 'completed'\n @analysis_job.save!\n @analysis.reload\n end\n @analysis.save!\n\n logger.info \"Finished running analysis '#{self.class.name}'\"\n end\n end", "def exec_sentiment_analysis\n sentiment_al.call text: description\n\n create_tracking! if sentiment_al.successfully?\n end", "def run!(not_used_arg)\n while work = @master.get_work\n puts work.inspect\n Experiment::Config.set work[:options]\n @current_cv = work[:cv]\n @dir = work[:dir]\n @data = work[:input]\n #@data = work[:input]\n execute_experiment!\n \t\t\tresult = analyze_result!(@dir + \"/raw-#{@current_cv}.txt\", @dir + \"/analyzed-#{@current_cv}.txt\")\n \t\t\twrite_performance!\n \t\t\t@master.submit_result @current_cv, result, @abm.first\n end\n\n end", "def test_run_completed(test_run)\n report_results test_run\n end", "def action_perform_rake(analysis_params_file)\n path = BawWorkers::Validation.normalise_file(analysis_params_file)\n analysis_params = YAML.load_file(path)\n BawWorkers::Jobs::Analysis::Job.perform_later!(analysis_params)\n end", "def perform\n tick(I18n.t('jobs.expire_analysis_tasks.progress_expiring'))\n Datasets::AnalysisTask.destroy_all ['created_at < ?', 2.weeks.ago]\n\n completed\n end", "def files_with_tasks_to_run\n\n # load all tasks into self.all_tasks\n get_tasks_from_rakefiles\n\n set_and_log_tasks_already_ran(self.all_tasks)\n set_and_log_duplicate_tasks(self.all_tasks_not_previously_run)\n\n close_log_if_this_created_it(log)\n\n rakefiles_with_tasks_to_run\n\n rescue => error\n log.error(\"Error during #{self.class.name} #{__method__}! #{error}\") unless log.nil?\n raise error\n end", "def perform(task, options = {})\n standard_options(task, options)\n\n # Patch up the two strange arguments that don't come in the right format\n # from the web form\n options[:all] = true if options[:word_method] == 'all'\n options.delete(:stemming) if options[:stemming] == 'no'\n\n # Do the analysis\n analyzer = RLetters::Analysis::Frequency.call(\n options.merge(\n dataset: dataset,\n progress: ->(p) { task.at(p, 100, t('.progress_calculating')) }\n )\n )\n\n corpus_size = RLetters::Solr::CorpusStats.new.size\n dataset_size = dataset.document_count\n\n # Create some CSV\n csv_string = csv_with_header(header: t('.csv_header',\n name: dataset.name)) do |csv|\n # Output the block data\n if analyzer.blocks.size > 1\n csv << [t('.each_block')]\n\n name_row = ['']\n header_row = ['']\n word_rows = []\n analyzer.word_list.each do |w|\n word_rows << [w]\n end\n types_row = [t('.types_header')]\n tokens_row = [t('.tokens_header')]\n ttr_row = [t('.ttr_header')]\n\n analyzer.blocks.each_with_index do |b, i|\n s = analyzer.block_stats[i]\n\n name_row << s[:name] << '' << '' << ''\n header_row << t('.freq_header') << t('.prop_header')\n header_row << t('.tfidf_dataset_header')\n header_row << t('.tfidf_corpus_header')\n\n word_rows.each do |r|\n word = r[0]\n r << (b[word] || 0).to_s\n r << ((b[word] || 0).to_f / s[:tokens].to_f).to_s\n\n r << Math.tfidf((b[word] || 0).to_f / s[:tokens].to_f,\n analyzer.df_in_dataset[word],\n dataset_size)\n r << if analyzer.df_in_corpus.present?\n Math.tfidf((b[word] || 0).to_f / s[:tokens].to_f,\n analyzer.df_in_corpus[word],\n corpus_size)\n else\n ''\n end\n end\n\n # Output the block stats at the end\n types_row << s[:types].to_s << '' << '' << ''\n tokens_row << s[:tokens].to_s << '' << '' << ''\n ttr_row << (s[:types].to_f / s[:tokens].to_f).to_s << '' << '' << ''\n end\n\n csv << name_row\n csv << header_row\n word_rows.each do |r|\n csv << r\n end\n csv << types_row\n csv << tokens_row\n csv << ttr_row\n end\n\n # Output the dataset data\n csv << ['']\n csv << [t('.whole_dataset')]\n csv << ['', t('.freq_header'), t('.prop_header'),\n t('.df_header'), t('.tfidf_corpus_header')]\n analyzer.word_list.each do |w|\n tf_in_dataset = analyzer.tf_in_dataset[w]\n r = [w,\n tf_in_dataset.to_s,\n (tf_in_dataset.to_f / analyzer.num_dataset_tokens).to_s]\n if analyzer.df_in_corpus.present?\n r << analyzer.df_in_corpus[w].to_s\n r << Math.tfidf(tf_in_dataset, analyzer.df_in_corpus[w],\n corpus_size)\n else\n r << ''\n r << ''\n end\n csv << r\n end\n csv << [t('.types_header'), analyzer.num_dataset_types.to_s]\n csv << [t('.tokens_header'), analyzer.num_dataset_tokens.to_s]\n csv << [t('.ttr_header'), (analyzer.num_dataset_types.to_f /\n analyzer.num_dataset_tokens).to_s]\n end\n\n # Write out the CSV to a file\n task.files.create(description: 'Spreadsheet',\n short_description: 'CSV', downloadable: true) do |f|\n f.from_string(csv_string, filename: 'results.csv',\n content_type: 'text/csv')\n end\n\n # Save out JSON to make an interactive word cloud\n word_cloud_data = {\n word_cloud_words: analyzer.word_list.each_with_object({}) do |w, ret|\n ret[w] = analyzer.tf_in_dataset[w]\n end\n }\n\n task.files.create(description: 'JSON Data for Word Cloud',\n short_description: 'JSON') do |f|\n f.from_string(word_cloud_data.to_json, filename: 'word_cloud.json',\n content_type: 'application/json')\n end\n\n task.mark_completed\n end", "def tasks() []; end", "def perform(folder, task_id)\n log = Logger.new(\"#{Rails.root}/log/song_craw.log\")\n #scan folder for mp3 files\n robot = DiskCrawler.new(Mp3Processor.new(log)) #dependency injection \n robot.scan(folder)\n #mark task\n Task.update_all({:status=>'COMPLETED'}, {:id=>task_id})\n end", "def task\n end", "def perform(task, options)\n standard_options(task, options)\n\n # Get the counts\n dates = RLetters::Analysis::CountTermsByField.call(\n term: options[:term],\n field: :year,\n dataset: dataset,\n progress: ->(p) { task.at(p, 100, t('.progress_computing')) }\n )\n\n # Convert the years to integers and sort\n dates = dates.to_a\n dates.each do |d|\n begin\n # If the field is an integer, convert it to an integer, otherwise leave\n # it alone\n converted = Integer(d[0])\n d[0] = converted\n rescue ArgumentError\n end\n end\n\n dates.sort! do |a, b|\n # We don't want to fail out for bad data; rather, put weird non-numeric\n # data at year zero\n a_int = a[0].is_a?(Integer) ? a[0] : 0\n b_int = b[0].is_a?(Integer) ? b[0] : 0\n\n a_int <=> b_int\n end\n\n # Save out the data\n year_header = Document.human_attribute_name(:year)\n value_header = t('.number_column')\n\n csv_string = csv_with_header(header: t('.header', name: dataset.name),\n subheader: t('.subheader',\n term: options[:term])) do |csv|\n write_csv_data(csv: csv,\n data: dates,\n data_spec: {\n year_header => :first,\n value_header => :second\n })\n end\n\n output = {\n data: dates,\n term: options[:term],\n year_header: year_header,\n value_header: value_header\n }\n\n # Serialize out to JSON\n task.files.create(description: 'Raw JSON Data',\n short_description: 'JSON') do |f|\n f.from_string(output.to_json, filename: 'term_dates.json',\n content_type: 'application/json')\n end\n\n task.files.create(description: 'Spreadsheet',\n short_description: 'CSV', downloadable: true) do |f|\n f.from_string(csv_string, filename: 'results.csv',\n content_type: 'text/csv')\n end\n\n task.mark_completed\n end", "def launch_analysis(t, values)\n\t begin\n\t window(title: \"Running #{t.task}\", width: 750, height: 512) do\n\t background \"#B2E5F4\" .. \"#F1E1F4\"\n\t @job = t.launch_job(values)\n\t stack(margin:30, width:1.0) do\n\t\t subtitle t.task\n\t\t para strong(\"Command:\")\n\t\t edit_box @job.cmd, width:1.0, height:40, state:\"readonly\"\n\t\t para \"\"\n\t\t para strong(\"Start time: \"), @job.start_time.ctime\n\t\t para strong(\"Log: \"), @job.log_path\n\t\t @running = edit_box \"\", state:\"readonly\",\n\t\t\t\t\t width:1.0, height: 275\n\t\t animate(4) do |frame|\n\t\t unless @running.nil?\n\t\t\t@running.text = @job.log\n\t\t\tif @job.alive?\n\t\t\t @running.text += \"\\n#{@job.status}\"+(\".\"*(frame%4))\n\t\t\telse\n\t\t\t para \"\"\n\t\t\t para strong(\"Running time: \"),@job.running_time,\"s.\"\n\t\t\t @running = nil\n\t\t\tend\n\t\t end\n\t\t end\n\t end\n\t end\n\t rescue => e\n\t Shoes.alert \"#{e}\\n\\n#{e.backtrace.first}\"\n\t end\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 perform\n alerts = Alert.utilization_efficiency.where(\"enabled=?\",true)\n\n # if it has just alert the user\n alerts.each do |alert|\n begin\n #calculate in hours the frequency\n utilization_efficiency_hours = 0\n amount = alert.utilization_efficiency_number\n\n #convert the aggregation [days or hours] into hours for calculations\n hours_per_day = 24\n if alert.aggregation_frequency == \"month\"\n utilization_efficiency_hours = amount * hours_per_day * 30 \n elsif alert.aggregation_frequency == \"week\"\n utilization_efficiency_hours = amount * hours_per_day * 7 \n elsif alert.aggregation_frequency == \"day\"\n utilization_efficiency_hours = amount * hours_per_day \n else\n utilization_efficiency_hours = amount\n end\n\n hour_difference = (Time.parse(DateTime.now.to_s) - Time.parse(alert.utilization_efficiency_last_checked.to_s))/3600\n if hour_difference > utilization_efficiency_hours\n alert.update_column(\"utilization_efficiency_last_checked\", Time.now)\n alert_history_count=AlertHistory.where('alert_id=?', alert.id).where('created_at >= ?', alert.utilization_efficiency_last_checked).where('for_aggregation_calculation=true').count\n\n # minimum value for the threshold is one\n if alert_history_count <= alert.aggregation_threshold\n alert_history_triggered(alert, alert_history_count)\n else\n #the sample was read x times correctly so the alert does not need to monitor for this sample id, now disable the alert\n # or do we reset the utilization_efficiency_last_checked and recheck??\n alert.update_column(\"enabled\", false)\n alert.delete_percolator\n end\n end\n\n rescue => e\n Rails.logger.error { \"Encountered an error when trying to run background job HourlyUtilizationEfficiencyJob : #{alert.id}, #{e.message} #{e.backtrace.join(\"\\n\")}\" }\n end\n end\n end", "def post_task\n end", "def poll_for_completion(run_at: 1.minute.from_now)\n if done? && !failed?\n Rails.logger.info \"IngestJob poller: #{pipeline_name} is done!\"\n Rails.logger.info \"IngestJob poller: #{pipeline_name} status: #{current_status}\"\n unless special_action?\n study_file.update(parse_status: 'parsed')\n study_file.bundled_files.each { |sf| sf.update(parse_status: 'parsed') }\n end\n study.reload # refresh cached instance of study\n study_file.reload # refresh cached instance of study_file\n set_study_state_after_ingest\n study_file.invalidate_cache_by_file_type # clear visualization caches for file\n log_to_mixpanel\n subject = \"#{study_file.file_type} file: '#{study_file.upload_file_name}' has completed parsing\"\n message = generate_success_email_array\n if special_action?\n # don't email users for 'special actions' like DE or image pipeline, instead notify admins\n qa_config = AdminConfiguration.find_by(config_type: 'QA Dev Email')\n email = qa_config.present? ? qa_config.value : User.find_by(admin: true)&.email\n SingleCellMailer.notify_user_parse_complete(email, subject, message, study).deliver_now unless email.blank?\n elsif action != :ingest_anndata # don't email users on \"extract\" AnnData jobs\n SingleCellMailer.notify_user_parse_complete(user.email, subject, message, study).deliver_now\n end\n elsif done? && failed?\n Rails.logger.error \"IngestJob poller: #{pipeline_name} has failed.\"\n # log errors to application log for inspection\n log_error_messages\n log_to_mixpanel # log before queuing file for deletion to preserve properties\n # don't delete files or notify users if this is a 'special action', like DE or image pipeline jobs\n subject = \"Error: #{study_file.file_type} file: '#{study_file.upload_file_name}' parse has failed\"\n unless special_action?\n create_study_file_copy\n study_file.update(parse_status: 'failed')\n DeleteQueueJob.new(study_file).delay.perform\n unless persist_on_fail\n ApplicationController.firecloud_client.delete_workspace_file(study.bucket_id, study_file.bucket_location)\n study_file.bundled_files.each do |bundled_file|\n ApplicationController.firecloud_client.delete_workspace_file(study.bucket_id, bundled_file.bucket_location)\n end\n end\n user_email_content = generate_error_email_body\n SingleCellMailer.notify_user_parse_fail(user.email, subject, user_email_content, study).deliver_now\n end\n admin_email_content = generate_error_email_body(email_type: :dev)\n SingleCellMailer.notify_admin_parse_fail(user.email, subject, admin_email_content).deliver_now\n else\n Rails.logger.info \"IngestJob poller: #{pipeline_name} is not done; queuing check for #{run_at}\"\n delay(run_at: run_at).poll_for_completion\n end\n end", "def run\n self.report_type = :daily_tasks\n self.failures = []\n\n EmailSubmission.where(\n created_at: Date.yesterday...Date.current\n ).joins(:c100_application).find_each(batch_size: 25) do |record|\n reference_code = record.c100_application.reference_code\n\n find_failures(record, reference_code, COURT_EMAIL_TYPE)\n\n # Only if the applicant chose to receive a confirmation, otherwise\n # these emails are not sent and there is no need to do any check.\n find_failures(record, reference_code, USER_EMAIL_TYPE) if record.c100_application.receipt_email?\n end\n\n send_email_report if failures.any?\n end", "def collect_all_data(test_name, file, result_dir, thread_count_array)\n FileUtils.mkdir_p(result_dir)\n ended_early = false\n puts \"Running #{test_name}\"\n error_occurred = false\n thread_count_array.each do |thread_count|\n jtl_file = File.join(result_dir, \"#{JTL_FILE_PREFIX}#{thread_count}.jtl\")\n\n puts \" #{thread_count} thread#{thread_count > 1 ? 's' : ''}\"\n start_time = Time.now\n run_jmeter(file, jtl_file, thread_count)\n\n jmeter_result_processor = JmeterResultProcessor.new\n scenario_result = jmeter_result_processor.build_scenario_result(thread_count, jtl_file)\n total_average = scenario_result[JmeterResultProcessor::TOTAL_LABEL]\n error_count = scenario_result[JmeterResultProcessor::ERROR_LABEL]\n\n puts \" Test completed in #{duration(Time.now - start_time)}.\"\n puts \" Average total time per thread took #{duration(total_average/1000)} to complete.\"\n puts \" There #{error_count > 1 ? 'are' : 'is'} #{error_count} error#{error_count > 1 ? 's' : ''}\"\n\n error_occurred ||= (error_count > 0)\n if total_average > @max_avg_elapsed_time\n puts \" Ending #{test_name} test because total average time #{total_average}ms exceeds #{@max_avg_elapsed_time}ms\\n\"\n ended_early = true\n break\n end\n if (@stop_when_error_occurs && error_count > 0)\n puts \" Ending #{test_name} test because error exists\\n\"\n ended_early = true\n break\n end\n end\n unless ended_early\n puts \" Test #{test_name} completed successfully.\\n\"\n end\n !error_occurred\n end", "def perform\n\t\tbegin\n\t\t\tnext_run_at = Time.now + 30.minutes\n\t\t\tDataImporterWorker.perform_at(next_run_at)\n\t\t\tqds = QueryDataSource.find_all_by_enabled(true)\n\t\t\tqds.each do |q|\n\t\t\t\tQueryDataSourceWorker.perform_async(q.id)\n\t\t\tend\n\n\t\t\t#spree data source importer\n\t\t \tspree_data_sources = SpreeDataSource.find_all_by_enabled(true)\n\t\t \tspree_data_sources.each do |sds|\n\t\t\t\tSpreeDataSourceWorker.perform_async(sds.id)\n\t\t\tend\n\t\trescue Exception => e\n\t\t \tRails.logger.error e.to_s\n\t\t\tputs e.to_s\n\t\tend\n\tend", "def perform\n Rails.logger.info(\"BranchStatsWorker_PROCESSING_STARTED\")\n Agents::Branch.find_in_batches do |group|\n group.each do |each_branch|\n Rails.logger.info(\"BranchStatsWorker_PROCESSING_STARTED_#{each_branch.id}\")\n each_branch.branch_specific_stats\n Rails.logger.info(\"BranchStatsWorker_PROCESSING_FINISHED_#{each_branch.id}\")\n end\n end\n Rails.logger.info(\"BranchStatsWorker_PROCESSING_FINISHED\")\n end", "def analyse\n call_data_service\n end", "def perform\n \n end", "def run_queued_tasks(analysis_type, download_dir, flags, timeout)\n completed = {}\n submit_time = Time.now\n while Time.now - submit_time < timeout\n server_status = @server_api.get_analysis_status(@analysis_id, analysis_type)\n if server_status == 'completed' || server_status == 'failed'\n begin\n puts 'INFO: ANALYSIS STATUS -- Analysis has completed. Attempting to execute queued tasks.' if server_status == 'completed'\n puts 'WARN: ANALYSIS STATUS -- Attempting to execute queued tasks on failed analysis.' if server_status == 'failed'\n # Download results and metadata rdataframe\n if flags[:download] && flags[:rdata]\n @server_api.download_dataframe(@analysis_id, 'rdata', download_dir) #results\n @server_api.download_variables(@analysis_id, 'rdata', download_dir) # metadata\n completed[:rdata] = true\n puts 'INFO: DOWNLOAD STATUS -- RDataFrames have been downloaded.'\n end\n\n # Download results and metadata csv\n if flags[:download] && flags[:csv]\n @server_api.download_dataframe(@analysis_id, 'csv', download_dir)\n @server_api.download_variables(@analysis_id, 'csv', download_dir)\n completed[:csv] = true\n puts 'INFO: DOWNLOAD STATUS -- CSVs have been downloaded.'\n end\n\n # Download datapoint directories\n if flags[:download] && flags[:zip]\n dps = @server_api.get_datapoint_status(@analysis_id, 'completed')\n dps_error_count = 0\n if dps.nil? || dps.empty?\n puts 'WARN: ZIP DOWNLOAD -- No datapoints found. Analysis completed with no datapoints'.red\n else\n dps.each do |dp|\n ok, f = @server_api.download_datapoint(dp[:_id], download_dir)\n if ok\n dest = File.join(File.dirname(f), File.basename(f, '.zip'))\n unzip_archive(f, dest)\n File.delete(f)\n else\n puts \"ERROR: ZIP DOWNLOAD -- Failed to download data point #{dp[:_id]}\"\n dps_error_count += 1\n end\n end\n puts \"INFO: DOWNLOAD STATUS -- Zip file download complete. #{dps_error_count} of #{dps.count} datapoints failed to download.\"\n end\n completed[:zip] = true\n end\n\n # Stop aws instance\n if flags[:stop]\n aws.stop\n completed[:stop] = true\n end\n\n # Kill aws instance\n if flags[:kill]\n aws.terminate\n completed[:kill] = true\n end\n rescue => e # Print error message\n puts \"ERROR: QUEUED TASKS -- Queued tasks (downloads, stop, or kill) commands erred in #{__method__}\".red\n puts \"with #{e.message}, #{e.backtrace.join(\"\\n\")}\".red\n ensure # Return exit status\n return completed\n end\n end\n sleep 1\n end\nend", "def perform(*args)\n # puts \"STARTING SENTIMENT ANALYSIS\"\n # Mention.where(sentiment_set: false).where('created_at > ?', Time.now.utc - 10.minutes).each do |mention|\n # if mention.comment\n # mention.update(sentiment: Sentimentalizer.analyze(mention.comment).overall_probability, sentiment_set: true)\n # end\n # end\n # puts \"DONE SENTIMENT ANALYSIS\"\n end", "def execute_scheduled_task\n Rails.logger.info \"EOSDISTagger START run of scheduled EOSDIS tagging task: #{Time.now}, catalog_rest_endpoint: #{@catalog_rest_endpoint}, cmr_base_endpoint: #{@cmr_base_endpoint}, ingest_providers_list_endpoint: #{@ingest_providers_list_endpoint}\"\n time = Benchmark.realtime do\n verify_tag_presence\n populate_providers_hash\n EOSDIS_PROVIDERS.each do |provider|\n tag_provider_collections(provider)\n end\n log_tagging_metrics\n end\n Rails.logger.info \"EOSDIS collection tagging with ONE post request per provider took #{(time.to_f * 1000).round(0)} ms\"\n Rails.logger.info \"EOSDISTagger END run of scheduled EOSDIS tagging task: #{Time.now}\"\n end", "def perform_processing!\n raise \"This run is already processed!\" if run_for_processing\n update(run_for_processing: true)\n outdir = File.join(OUTPUT_DIR, \"#{id}\").shellescape\n indir = File.join(INPUT_DIR, \"#{id}\").shellescape\n Dir.mkdir(outdir, 0755) unless File.directory?(outdir)\n Dir.mkdir(indir, 0755) unless File.directory?(indir)\n\n # Stream input files to zip\n zout_in = java.util.zip.ZipOutputStream.new(File.open(File.join(indir, 'input.zip'), 'wb', 0644).to_outputstream)\n zout_out = java.util.zip.ZipOutputStream.new(File.open(File.join(outdir, 'out.zip'), 'wb', 0644).to_outputstream)\n\n finding_aid_versions\n .joins(:finding_aid, :concrete_issues => :issue)\n .select('finding_aid_versions.*,\n finding_aids.eadid,\n ARRAY_AGG(DISTINCT issues.identifier) AS identifiers')\n .group('finding_aids.eadid,finding_aid_versions.id')\n .each do |fa|\n add_to_zip(zout_in, fa.eadid, fa.file)\n\n # Preflight XML\n fa_xml = Fixes.preflights.values.reduce(fa.xml) do |xml, fix|\n apply_fix(xml, fix)\n end\n\n # Apply all relevant fixes to Finding Aid\n repaired = Fixes\n .to_h\n .select {|identifier, _| fa.identifiers.include? identifier}\n .reduce(fa_xml) do|xml, (identifier, fix)|\n pe = processing_events.create(issue_id: schematron.issues.find_by(identifier: identifier).id,\n finding_aid_version_id: fa.id)\n apply_fix(xml, fix, pe)\n\n end # end of .reduce\n\n # Any problems which have fixes that exist now should theoretically\n # be things that were shadowed by the first pass, so take additional passes\n # untill either no known issues or MAX_PASSES\n MAX_PASSES.times do\n remaining_problems = schematron.issues.where(id: @checker.check_str(repaired.serialize(encoding: 'UTF-8')).map {|el| el[:issue_id]}.uniq).pluck(:identifier) & Fixes.to_h.keys\n\n # Run a second round of fixing if there are remaining problems\n break if remaining_problems.blank?\n repaired = Fixes\n .to_h\n .select {|identifier, _| remaining_problems.include? identifier}\n .reduce(repaired) do |xml, (identifier, fix)|\n pe = processing_events.create(issue_id: schematron.issues.find_by(identifier: identifier).id,\n finding_aid_version_id: fa.id)\n apply_fix(xml, fix, pe)\n end\n end\n\n\n # Add notice of processing to revisiondesc\n today = DateTime.now.in_time_zone\n rd = repaired.at_xpath('/ead/eadheader/revisiondesc') || repaired.at_xpath('/ead/eadheader').add_child(Nokogiri::XML::DocumentFragment.new(repaired, '<revisiondesc />')).first\n rd.prepend_child(Nokogiri::XML::DocumentFragment.new(repaired, \"\\n\" + <<-FRAGMENT.strip_heredoc + \"\\n\"))\n <change>\n <date calendar=\"gregorian\" era=\"ce\" normal=\"#{today.strftime('%Y%m%d')}\">#{today.strftime('%m/%d/%Y')}</date>\n <item>This resource was modified by the ArchivesSpace Preprocessor developed by the Harvard Library (https://github.com/harvard-library/archivesspace-preprocessor)</item>\n </change>\n FRAGMENT\n\n File.open(File.join(outdir, \"#{fa.eadid}.xml\"), 'w', 0644) do |f|\n repaired.write_xml_to(f, encoding: 'UTF-8')\n end\n\n add_to_zip(zout_out, fa.eadid, File.open(File.join(outdir, \"#{fa.eadid}.xml\"), 'r'))\n end\n\n update(completed_at: DateTime.now)\n ensure\n close_zipfiles(zout_in, zout_out)\n end", "def processing_running_task\n reset_undefined_retries!\n 'running'\n end", "def perform_ending_tasks(element)\n if @config.include? element\n process_data(@attributes)\n @current_parent_element = []\n @attributes = []\n end\n if element == \"DataValue\"\n @data_value_identifier = false\n end\n if element == \"RemarkCode\"\n @remark_code_identifier = false\n end\n if @remark_code_grid_identifier and element == \"Grid\"\n process_remark_codes\n end\n if element == \"Batch\"\n @job.update_attributes(:ocr_status => \"SUCCESS\", :job_status => \"NEW\")\n end\n if element == \"ClaimRecord\"\n JobActivityLog.create_activity({:job_id => @job.id, :eob_id => @insurance_payment_eob.id, :activity => 'MPI Search Started', :start_time => Time.now, :eob_type_id => 1})\n facility_id = @facility.id if @facility.mpi_search_type.eql?(\"FACILITY\")\n facility_group = @facility.details[:facility_ids]\n client_id = @facility.client.id if @facility.mpi_search_type.eql?(\"CLIENT\")\n account_number = ClaimInformation.replace_patient_account_number_prefix(@facility.sitecode, @insurance_payment_eob.patient_account_number)\n @insurance_payment_eob.update_attribute(:patient_account_number, account_number)\n patient_last_name = @insurance_payment_eob.patient_last_name\n patient_first_name = @insurance_payment_eob.patient_first_name\n #date_of_service_from = @insurance_payment_eob.service_payment_eobs.first.date_of_service_from\n insured_id = @insurance_payment_eob.subscriber_identification_code\n total_charges = @insurance_payment_eob.total_submitted_charge_for_claim\n @mpi_results = ClaimInformation.mpi_search_for_sphinx(facility_id, client_id, account_number, patient_last_name, patient_first_name, nil, insured_id, total_charges, nil ,nil,nil,nil,nil,facility_group,nil)\n associate = false\n unless @mpi_results.empty?\n JobActivityLog.create_activity({:job_id => @job.id, :eob_id => @insurance_payment_eob.id, :activity => 'MPI Match Found', :start_time => Time.now, :eob_type_id => 1})\n associate = ClaimInformation.compare_and_associate_claim_and_eob(@mpi_results.first.id, @insurance_payment_eob.id)\n end\n if associate\n JobActivityLog.create_activity({:job_id => @job.id, :eob_id => @insurance_payment_eob.id, :activity => 'MPI Match Used', :start_time => Time.now, :eob_type_id => 1})\n MpiStatisticsReport.create_mpi_stat_report({:batch_id => @batch.id, :mpi_status => 'Success', :start_time => Time.now, :eob_id => @insurance_payment_eob.id })\n else\n JobActivityLog.create_activity({:job_id => @job.id, :eob_id => @insurance_payment_eob.id, :activity => 'MPI Failed', :start_time => Time.now, :eob_type_id => 1})\n MpiStatisticsReport.create_mpi_stat_report({:batch_id => @batch.id, :mpi_status => 'Failure', :start_time => Time.now, :eob_id => @insurance_payment_eob.id })\n end\n end\n end", "def series\n Thread.new do\n begin\n activity = get_activity\n analyzer = get_analyzer\n activity.process\n analyzer.process\n rescue => e\n Rails.logger.debug e.backtrace.to_s + \" ----- \" + e.to_s\n ensure\n # do something\n end\n end\n msg = { :success => true, :message => \"Please wait while we process the repository!\" }\n end", "def step\n log_iteration_start\n\n\n @current_task = tasks_list.shift\n status.no_tasks! and return unless current_task #empty tasks list\n\n solve_current_task\n\n return unless current_basis_plan # no optimal plan, so we don't change record and continue\n\n if current_target_function <= record # not interested as previsous record is higher\n status.target_less_than_record!\n elsif task.satisfies_integer?(current_basis_plan)\n change_record\n else\n split_current_task\n end\n log_status\n end", "def pre_task\n end", "def run\n\t\t\tsummary\n\t\tend", "def final_metrics\n Rails.logger.info(\"\\n \\n Priority sync finished at #{Time.zone.now} \\n \\n EPs attempted to sync: #{@run_log.size} \\n EPs successfully synced: #{@run_log.size - @error_log.size} \\n EPs errored: #{@error_log.size} \\n\")\n end", "def perform\n ActsAsTenant.without_tenant do\n Course::Video::Submission.includes(:statistic).references(:all).\n select { |submission| submission.statistic&.cached == false }.\n map(&:update_statistic)\n Course::Video.includes(:statistic).references(:all).\n select { |video| video.statistic.nil? || !video.statistic.cached }.each do |video|\n video.build_statistic(watch_freq: video.watch_frequency,\n percent_watched: video.calculate_percent_watched,\n cached: true).upsert\n end\n end\n end", "def perform(option)\n ##add migration to sport to store an array of league\n\n\n puts \"------------------------------------------\"\n puts \"Starting Job for #{option[:sport]}\"\n puts \"---Starting scrape---\"\n results = SportScraper.scrape_day(option)\n\n puts \"--- Scrape done ---\"\n aa = 0\n b = 0\n c = 0\n results.all.each do |a|\n event = Event.find_by(unique_event_id: a[:unique_id])\n #create an event when it's not there\n if(event.nil?)\n b += 1\n puts \"+ Created: #{a[:unique_id]}\"\n team1 = Team.find_or_create_by(name: a[:team1])\n team2 = Team.find_or_create_by(name: a[:team2])\n hash_ = {team_a: team1, team_b: team2, league: a[:league], status: a[:status],unique_event_id: a[:unique_id],starts_at: a[:date]}\n hash_[:event_date] = EventDate.find_or_create_by(sport: Sport.find_by(name: a[:sport]), date: hash_[:starts_at].strftime(\"%Y-%m-%e\"))\n if(!a[:score].nil?)\n hash_[:scraped_score] = a[:score]\n end\n if(!a[:winner].nil?)\n hash_[:winner] = Team.find_by(name: a[:winner])\n end\n if(!a[:time].nil?)\n hash_[:time] = a[:time]\n end\n Event.create(hash_)\n #already there: just update: score? winner? time? status?\n else\n c += 1\n puts \"/ Updated: #{a[:unique_id]}\"\n prev_state = event.status\n event.update(scraped_score: a[:score], winner: Team.find_by(name: a[:winner]), time: a[:time], status: a[:status])\n if(prev_state == \"Finished\")\n event.update(status: \"Finished\")\n end\n end\n aa += 1\n end\n puts \"OVER #{aa} Events: #{b} Created and #{c} Updated\"\n puts \"\"\n puts \"Job done for #{option[:sport]} PEACE\"\n end", "def update_project_stats\n self.critical_count = tasks.select { |t| t.critical? }.length\n self.normal_count = tasks.select { |t| t.normal? }.length\n self.low_count = tasks.select { |t| t.low? }.length\n self.open_tasks = nil\n self.total_tasks = nil\n end", "def create_scan_tasks\n if self.status == 'started'\n raise 'Report generation already started'\n end\n self.status = 'started'\n self.save!\n\n uri = URI('http://reports.savilo.com/TownCenter/leads.php')\n Net::HTTP.delay.post_form(uri, {:phone => self.phone, :zip => self.zip, :business_name => self.business,\n :email => self.email, :referrer_code => self.referrer_code})\n\n Delayed::Worker.logger.info \"Starting performance: #{Time.now.iso8601}\"\n\n Site.where(enabled_for_scan: true).each do |site|\n scan = Scan.create_for_site(self.id, site)\n end\n\n Delayed::Worker.logger.info \"Ending performance: #{Time.now.iso8601}\"\n\n self\n end", "def complete\n # # step 0: 对Solutions的结果做voting,并将最终结果存入Problem的result中\n # PhotoRecognitionJob.perform_later(self.id.to_s)\n # step 1: 修改Problem的状态为solved,未完成的Solutions的状态为failed\n self.set(status: :solved)\n self.solutions.each { |solution|\n if solution.status.waiting?\n solution.set(status: :failed)\n end\n }\n # # step 2: 修改Seeker与Solvers的credit\n # self.creator.crowdsourcing_profile.decrease_credit(self.credit_expend)\n # self.creator.crowdsourcing_profile.decrease_prepared_credit(self.credit_prepared)\n # self.creator.crowdsourcing_profile.touch(:updated_at)\n # self.creator.crowdsourcing_profile.save\n # self.solutions.each { |solution|\n # if solution.status.solved?\n # solution.creator.crowdsourcing_profile.increase_credit(solution.problem.credit)\n # solution.creator.crowdsourcing_profile.touch(:updated_at)\n # solution.creator.crowdsourcing_profile.save\n # end\n # }\n # step 3: 修改Seeker_Profile中的 finished + 1 以及积分变化\n # 修改Solver_Profile:如果完成,finished + 1,积分变化;如果失败,failed + 1,积分不变\n self.creator.seeker_profile.increase_finished\n # self.creator.seeker_profile.increase_credit(self.credit_expend)\n self.creator.seeker_profile.touch(:updated_at)\n self.creator.seeker_profile.save\n self.solutions.each { |solution|\n if solution.status.solved?\n solution.creator.solver_profile.increase_finished\n # solution.creator.solver_profile.increase_credit(solution.problem.credit)\n solution.creator.solver_profile.touch(:updated_at)\n solution.creator.solver_profile.save\n else\n solution.creator.solver_profile.increase_failed\n solution.creator.solver_profile.touch(:updated_at)\n solution.creator.solver_profile.save\n end\n }\n end", "def perform(analysis_params)\n analysis_params_sym = BawWorkers::Jobs::Analysis::Payload.normalize_opts(analysis_params)\n\n BawWorkers::Config.logger_worker.info do\n { message: 'Started analysis', parameters: Job.format_params_for_log(analysis_params_sym) }\n end\n\n runner = action_runner\n status_updater = action_status_updater\n result = nil\n all_opts = nil\n final_status = nil\n\n begin\n # check if should cancel, if we should raises Resque::Plugins::Status::Killed\n status_updater.begin(analysis_params_sym)\n\n prepared_opts = runner.prepare(analysis_params_sym)\n all_opts = analysis_params_sym.merge(prepared_opts)\n result = runner.execute(prepared_opts, analysis_params_sym)\n\n final_status = status_from_result(result)\n rescue BawWorkers::Exceptions::ActionCancelledError => e\n final_status = :cancelled\n\n # if killed legitimately don't email\n BawWorkers::Config.logger_worker.warn do\n \"Analysis cancelled: '#{e}'\"\n end\n raise\n rescue StandardError => e\n final_status = :failed\n raise\n ensure\n # run no matter what\n # update our action tracker\n status_updater.end(analysis_params_sym, final_status) unless final_status.blank?\n end\n\n # if result contains error, raise it here, since we need everything in execute\n # to succeed first (so logs/configs are moved, any available results are retained)\n # raising here to not send email when executable fails, logs are in output dir\n if !result.blank? && result.include?(:error) && !result[:error].blank?\n BawWorkers::Config.logger_worker.error { result[:error] }\n raise result[:error]\n end\n\n BawWorkers::Config.logger_worker.info do\n log_opts = all_opts.blank? ? analysis_params_sym : all_opts\n \"Completed analysis with parameters #{Job.format_params_for_log(log_opts)} and result '#{Job.format_params_for_log(result)}'.\"\n end\n\n result\n end", "def perform(task, options = {})\n standard_options(task, options)\n\n # Get the counts\n result = RLetters::Analysis::CountArticlesByField.call(\n options.merge(\n field: :year,\n dataset: dataset,\n progress: lambda do |p|\n task.at((p.to_f / 100.0 * 90.0).to_i, 100, t('.progress_counting'))\n end\n )\n )\n\n # Convert the years to integers and sort\n dates = result.counts.to_a\n dates.each do |d|\n begin\n # If the field is an integer, convert it to an integer, otherwise leave\n # it alone\n converted = Integer(d[0])\n d[0] = converted\n rescue ArgumentError\n end\n end\n\n dates.sort! do |a, b|\n # We don't want to fail out for bad data; rather, put weird non-numeric\n # data at year zero\n a_int = a[0].is_a?(Integer) ? a[0] : 0\n b_int = b[0].is_a?(Integer) ? b[0] : 0\n\n a_int <=> b_int\n end\n\n # Save out the data, including getting the name of the normalization\n # set for pretty display\n norm_set_name = ''\n if result.normalize\n norm_set_name = if result.normalization_dataset\n result.normalization_dataset.name\n else\n t('.entire_corpus')\n end\n value_header = t('.fraction_column')\n else\n value_header = t('.number_column')\n end\n year_header = Document.human_attribute_name(:year)\n\n output = { data: dates,\n percent: result.normalize,\n normalization_set: norm_set_name,\n year_header: year_header,\n value_header: value_header }\n\n # Serialize out to JSON and CSV\n task.files.create(description: 'Raw JSON Data',\n short_description: 'JSON') do |f|\n f.from_string(output.to_json, filename: 'article_dates.json',\n content_type: 'application/json')\n end\n\n csv_string = csv_with_header(header: t('.header',\n name: dataset.name)) do |csv|\n write_csv_data(csv: csv,\n data: dates,\n data_spec: { year_header => :first,\n value_header => :second })\n end\n task.files.create(description: 'Spreadsheet',\n short_description: 'CSV', downloadable: true) do |f|\n f.from_string(csv_string, filename: 'results.csv',\n content_type: 'text/csv')\n end\n\n task.mark_completed\n end", "def process_results\n # Clean up some of the files that are not needed\n %w(runmanager.db).each do |f|\n logger.debug \"Removing file: #{@simulation.run_path}/#{f}\"\n File.delete File.join(@simulation.run_path, f) if File.exist? File.join(@simulation.run_path, f)\n end\n\n json = {}\n Dir[\"#{@simulation.run_path}/*\"].each do |f|\n if f =~ /AnalysisResults-BEES.pdf/\n logger.info 'saving the compliance report path to model'\n @simulation.compliance_report_pdf_path = f\n elsif f =~ /.*\\s-\\sAnalysisResults-BEES.xml/\n logger.info \"BEES XML #{f}\"\n @simulation.compliance_report_xml = f\n elsif f =~ /.*\\s-\\sAnalysisResults.xml/\n logger.info \"XML #{f}\"\n @simulation.analysis_results_xml = f\n elsif f =~ /CbeccComWrapper.json/\n # Save the state based on the CbeccComWrapper.json file that is persisted\n json = MultiJson.load(File.read(f), symbolize_keys: true) if File.exist?(f)\n logger.info \"pyCBECC responded with: #{json}\"\n\n @simulation.cbecc_code = json.keys.first.to_s.to_i\n @simulation.cbecc_code_description = json.values.first\n elsif f =~ /.*\\s-\\sab.*/\n logger.info \"Annual baseline results #{f}\"\n @simulation.openstudio_model_baseline = f if File.extname(f) == '.osm'\n\n elsif f =~ /.*\\s-\\szb.*/\n logger.info \"Sizing simulation results #{f}\"\n elsif f =~ /.*\\s-\\sap.*/\n logger.info \"Annual proposed results #{f}\"\n @simulation.openstudio_model_proposed = f if File.extname(f) == '.osm'\n end\n end\n\n # TODO: remove other files\n\n # parse the log file for any errors\n errors = []\n log_file = find_log_file\n if log_file && File.exist?(log_file)\n s = File.read log_file\n s.scan(/Error:\\s{2}.*$/).each do |error|\n errors << error[/Error:\\s{2}(.*)/, 1].chomp\n end\n\n # This appeared once, but haven't seen it since.\n s.scan(/error\\(s\\) encountered simulating.*/i).each do |error|\n errors << error.chomp\n end\n\n # and this error: Compliance report(s) called for but bypassed due to report generator website not accessible.\n if s =~ /compliance report.*called for but bypassed due to report generator website not accessible/i\n @simulation.warning_messages << \"Could not generate Compliance Reports because report generate website was not accessible\"\n end\n\n @simulation.error_messages = errors\n end\n\n # TODO: zip up everything and remove what we don't care about\n\n # success is defined as no error messages\n if !json.keys.empty? && json.keys.first != :'0'\n return false\n end\n\n if !@simulation.error_messages.empty?\n return false\n end\n\n true\n end", "def exec!\n listener = Collector.listen!\n Thread.new do\n loop do\n sleep(15)\n planner.next_histogram(Collector.next_workload_histogram!)\n end\n end\n end", "def execute_task_tests\n # Run all tasks tests (ensuring we capture any changes in the sites we are monitoring)\n test_results = @tasks_by_job_ids.values.map {|task|\n puts \"- Running test for task: #{task.class.name}\" \n if task.respond_to?(:test)\n begin\n result = task.test()\n if result.kind_of?(Array) && result.length > 0\n # Log the error for the result\n @task_test_results_logger.error(\"FAILURE:#{result.inspect}\")\n # Send an email with the failure information\n Notifier.deliver_crawler_error(\"christkv@gmail.com\", task.class.name, result)\n end\n rescue Exception => e\n # Log the error for the result\n @task_test_results_logger.error(\"ERROR:#{e.backtrace}\")\n # Send an email with the failure information\n Notifier.deliver_crawler_error(\"christkv@gmail.com\", task.class.name, [e.backtrace.inspect])\n end\n end\n }\n # return the test results\n return test_results\n end", "def perform(task, options)\n standard_options(task, options)\n options.delete(:stemming) if options[:stemming] == 'no'\n\n result = RLetters::Analysis::Cooccurrence.call(\n options.merge(\n dataset: dataset,\n progress: ->(p) { task.at(p, 100, t('.progress_computing')) }\n )\n )\n\n case result.scoring\n when :mutual_information\n algorithm = t('common.scoring.mutual_information')\n column = t('common.scoring.mutual_information_header')\n when :t_test\n algorithm = t('common.scoring.t_test')\n column = t('common.scoring.t_test_header')\n when :log_likelihood\n algorithm = t('common.scoring.log_likelihood')\n column = t('common.scoring.log_likelihood_header')\n end\n\n # Save out all the data\n csv_string = csv_with_header(header: t('.header', name: dataset.name),\n subheader: t('.subheader',\n test: algorithm)) do |csv|\n write_csv_data(csv: csv,\n data: result.cooccurrences,\n data_spec: { t('.pair') => :first,\n column => :second })\n end\n\n # Write out the CSV to a file\n task.files.create(description: 'Spreadsheet',\n short_description: 'CSV', downloadable: true) do |f|\n f.from_string(csv_string, filename: 'results.csv',\n content_type: 'text/csv')\n end\n task.mark_completed\n end", "def run_successful_task(broker, targets, task, files, input: {}, metadata: nil, **kwargs, &block)\n run_task(broker, targets, task, files, input: input, metadata: metadata) do |response_dataset|\n ensure_successful(broker, targets, response_dataset, **kwargs, &block)\n end\nend", "def process_report_results(result_array_of_hashes)\n Delayed::Worker.logger.debug \"Processing #{@asq.name}\"\n @asq.store_results(result_array_of_hashes.to_json)\n # if asq was previously in operational error, now's the time to clear it:\n @asq.clear\n @asq.finish_refresh\n end", "def run_task\n sweep_stairs\n end", "def run_task\n sweep_stairs\n end", "def run_all\n fail \"no scanner opts (start not called?)!\" if @scanner_opts.nil?\n tracker.run_checks\n ::Brakeman.filter_warnings tracker, @scanner_opts\n print_failed\n throw :task_has_failed if tracker.filtered_warnings.any?\n end", "def analyze\n \t@job_id = params[:id]\n\t@job = DialJob.find(@job_id)\n\n\tif(@job.processed)\n\t\tredirect_to :controller => 'analyze', :action => 'view', :id => @job_id\n\t\treturn\n\tend\n\t\n\t@dial_data_total = DialResult.count(\n\t\t:conditions => [ 'dial_job_id = ? and completed = ?', @job_id, true ]\n\t)\n\t\n\t@dial_data_done = DialResult.count(\n\t\t:conditions => [ 'dial_job_id = ? and processed = ?', @job_id, true ]\n\t)\n\n\t@g1 = Ezgraphix::Graphic.new(:c_type => 'col3d', :div_name => 'calls_pie1')\n\t@g1.render_options(:caption => 'Detected Lines by Type', :y_name => 'Lines', :w => 700, :h => 300)\n\t\n\tltypes = DialResult.find( :all, :select => 'DISTINCT line_type', :conditions => [\"dial_job_id = ?\", @job_id] ).map{|r| r.line_type}\n\tres_types = {}\n\n\tltypes.each do |k|\n\t\tnext if not k\n\t\tres_types[k.capitalize.to_sym] = DialResult.count(\n\t\t\t:conditions => ['dial_job_id = ? and line_type = ?', @job_id, k]\n\t\t)\n\tend\n\t\n\t@g1.data = res_types\n\n\t@dial_data_todo = DialResult.where(:dial_job_id => @job_id).paginate(\n\t\t:page => params[:page], \n\t\t:order => 'number ASC',\n\t\t:per_page => 50,\n\t\t:conditions => [ 'completed = ? and processed = ? and busy = ?', true, false, false ]\n\t)\n\t\n\tif(@dial_data_todo.length > 0)\n WarVOX::JobManager.schedule(::WarVOX::Jobs::Analysis, @job_id)\n\tend\n end", "def reserve_and_run_one_job; end", "def run_task\n begin\n run \n rescue Exception => e\n @task_run.add_error_text(e.class.name + \": \" + e.message)\n @task_run.add_error_text(e.backtrace.inspect)\n @task_run.success = false\n end \n\n finally\n\n @task_run.end_time = Time.now\n @task_run.save\n end", "def create_analysis_views\n puts \"====================\"\n puts \"creating analysis views for #{self.name}\"\n puts \"====================\"\n\n run_analysis_views\n\n puts \"> done\"\n puts \"====================\"\n end", "def load_all_tasks_in_order\n load_dir = ENV[\"load_dir\"]\n tasks_and_files= [{\"ansi_code\"=>\"ansicode.csv\"},\n {\"client_profile_group\"=>\"clients.csv\"},\n {\"facilities\"=>\"facilities.csv\"},\n {\"rcc_payer\"=>\"rcc_payer.csv\"},\n {\"temp_reason_codes\"=>\"rcc_reason_codes.csv\"},\n {\"temp_reason_code_mappings\"=>\"rcc_mappings.csv\"},\n {\"temp_lockbox\"=>\"client_profile_lockbox.csv\"},\n {\"temp_payers\"=>\"ABAInfo.csv\"},\n {\"process_relationships_from_temp_tables\"=>\"\"},\n {\"change_partner_to_bac\"=>\"\"},\n {\"remove_temp_tables\" =>\"\"}]\n errors = []\n \n errors << \"Please provide a valid directory\" if (load_dir.blank? || !FileTest.exists?(load_dir))\n if errors.empty?\n tasks_and_files.each do |hash|\n csv_file = hash[hash.keys[0]]\n if !csv_file.blank?\n abs_path = load_dir + \"/\" + csv_file\n errors << \"File #{csv_file} not found in #{load_dir}\" if ! FileTest.exists?(abs_path)\n end\n end\n end\n\n if errors.empty?\n tasks_and_files.each do |hash|\n task = hash.keys[0]\n csv_file = hash[task]\n if !csv_file.blank?\n abs_path = load_dir + \"/\" + csv_file\n ENV[\"path\"] = abs_path\n puts \"processing file \" + ENV[\"path\"]\n end\n puts \"invoking task dataimport:#{task} ......\"\n Rake::Task[\"dataimport:#{task}\"].invoke \n end\n else\n errors.each do |err|\n puts err + \"\\n\"\n end\n end \nend", "def do_work\n end", "def run(name, task_class, mapping)\n log \" #{name} between #{mapping.database_model.name} and #{mapping.salesforce_model}\"\n runtime = Benchmark.realtime { task task_class, mapping }\n log format(\" COMPLETE after %.4f\", runtime)\n\n true\n rescue => e\n error(e)\n\n false\n end", "def executeSimpleTest(iSimpleTestData)\n lMaxDays = 10\n lFirstDay = Date.new(2000, 1, 1)\n # Create a standard calendar (lMaxDays days, 1 hour per day) for each resource\n # It will be populated lated\n # map< Date, Integer >\n lCalendar = {}\n # Create the index of resources\n # map< String, Resource >\n lResourcesMap = {}\n # Create the index of tasks\n # map< String, Task >\n lTasksMap = {}\n # Create the final assignment\n # map< Task, map< Date, map< Resource, Integer > > >\n lFinalAssignment = {}\n iSimpleTestData.each do |iSimpleTaskInfo|\n lTaskName, lResourceName, lPriority, lSizing, lSuccessorNamesList, lStrFinalAssignment = iSimpleTaskInfo\n if (lStrFinalAssignment.size > lMaxDays)\n lMaxDays = lStrFinalAssignment.size\n end\n # Do we already know this resource ?\n if (!lResourcesMap.has_key?(lResourceName))\n # Create the resource\n lResource = Resource.new(lResourceName, lCalendar)\n lResourcesMap[lResourceName] = lResource\n else\n lResource = lResourcesMap[lResourceName]\n end\n lTask = Task.new(lTaskName, lPriority, lSizing, {lResource => lSizing}, [])\n lTasksMap[lTaskName] = lTask\n # Set its final assignment info\n lFinalTaskAssignment = {}\n lIdxDay = 0\n lStrFinalAssignment.each_byte do |iChar|\n if (iChar == 61) # 61 == '='\n lFinalTaskAssignment[lFirstDay + lIdxDay] = {lResource => 1}\n end\n lIdxDay += 1\n end\n lFinalAssignment[lTask] = lFinalTaskAssignment\n end\n # Create the list of tasks\n # list< Task >\n lTasksList = []\n # Now populate the successors\n iSimpleTestData.each do |iSimpleTaskInfo|\n lTaskName, lResourceName, lPriority, lSizing, lSuccessorNamesList, lStrFinalAssignment = iSimpleTaskInfo\n # Retrieve the task\n lTask = lTasksMap[lTaskName]\n # Parse each successor\n lSuccessorsList = []\n lSuccessorNamesList.each do |iSuccessorName|\n # Retrieve the successor, and add it\n lSuccessorsList << lTasksMap[iSuccessorName]\n end\n # Set the successors in the real task\n lTask.Successors = lSuccessorsList\n # Add the task to the list\n lTasksList << lTask\n end\n # Create a standard project (lMaxDays days, starting from january 1st 2000)\n lProject = Project.new(lFirstDay, lFirstDay + lMaxDays)\n # Populate the calendar of each resource\n lMaxDays.times do |iIdx|\n lCalendar[lFirstDay + iIdx] = 1\n end\n # Execute the test\n executeTest(lTasksList, lProject, lFinalAssignment)\n end", "def after_run\n check_output_files\n show_results\n end", "def done?\n get_ingest_run.done?\n end", "def run_these_cases(current_task_files)\n\n \n $RunResults = Hash.new \n $choicefiles = Array.new\n $PIDS = Array.new\n $FinishedTheseFiles = Hash.new \n $RunNumbers = Array.new\n \n $CompletedRunCount = 0 \n $FailedRunCount = 0 \n \n ## Create working directories \n \n $headerline = \"\" \n $outputHeaderPrinted = false \n \n \n current_task_files.each do |choicefile|\n $FinishedTheseFiles[choicefile] = false \n end \n \n $choicefileIndex = 0 \n numberOfFiles = $FinishedTheseFiles.count {|k| k.include?(false)}\n\n \n stream_out (\" - HTAP-prm: begin runs ----------------------------\\n\\n\")\n \n $choicefileIndex = 0 \n $RunsDone = false \n \n $csvColumns = Array.new \n \n # Loop until all files have been processed. \n $GiveUp = false \n \n while ! $RunsDone \n\n $batchCount = $batchCount + 1 \n\n \n stream_out (\" + Batch #{$batchCount} ( #{$choicefileIndex}/#{numberOfFiles} files processed so far...) \\n\" )\n if ( $batchCount == 1 && $snailStart ) then \n \n stream_out (\" |\\n\") \n stream_out (\" +-> NOTE: \\\"SnailStart\\\" is active. Waiting for #{$snailStartWait} seconds between threads (on first batch ONLY!) \\n\\n\")\n \n end \n\n # Empty arrays for current batch. \n $choicefiles.clear\n $PIDS.clear \n $SaveDirs.clear\n \n \n # Compute the number of threads we will start: lesser of a) files remaining, or b) threads allowed.\n $ThreadsNeeded = [$FinishedTheseFiles.count {|k| k.include?(false)}, $gNumberOfThreads].min \n \n #=====================================================================================\n # Multi-threaded runs - Step 1: Spawn threads. \n for thread in 0..$ThreadsNeeded-1 \n \n # For this thread: Get the next choice file in the batch. \n $choicefiles[thread] = current_task_files[$choicefileIndex] \n \n # Get the name of the .h2k file for this thread. \n $H2kFile = $gArchetypeHash[$choicefiles[thread]]\n $Ruleset = $gRulesetHash[$choicefiles[thread]]\n $Location = $gLocationHash[$choicefiles[thread]]\n \n count = thread + 1 \n #stream_out (\" - Starting thread : #{count}/#{$ThreadsNeeded} for file #{$choicefiles[thread]} \")\n stream_out (\" - Starting thread #{count}/#{$ThreadsNeeded} for sim ##{$choicefileIndex+1} \")\n \n \n # For this thread: Get the next choice file in the batch. \n #$choicefiles[thread] = $RunTheseFiles[$choicefileIndex] \n \n \n # Make sure that's a real choice file ( this just duplicates a test above )\n if ( $choicefiles[thread] =~ /.*choices$/ )\n \n # Increment run number and create name for unique simulation directory\n $RunNumber = $RunNumber + 1 \n $RunDirectory = $RunDirs[thread]\n \n \n $SaveDirectory = \"#{$SaveDirectoryRoot}-#{$RunNumber}\"\n \n # Store run number and directory for this thread \n $RunNumbers[thread] = $RunNumber\n $SaveDirs[thread] = $SaveDirectory \n\n # create empty run directory\n if ( ! Dir.exist?($RunDirectory) )\n if ( ! Dir.mkdir($RunDirectory) )\n fatalerror( \" Fatal Error! Could not create #{$RunDirectory} below #{$gMasterPath}!\\n MKDir Return code: #{$?}\\n\" )\n end \n \n else \n # Delete contents, but not H2K folder\n FileUtils.rm_r Dir.glob(\"#{$RunDirectory}/*.*\") \n end \n \n \n \n \n # Copy choice and options file into intended run directory...\n if $choicesInMemory\n choicefile = File.open(\"#{$RunDirectory}/#{$choicefiles[thread]}\", 'w')\n choicefile.write ($ChoiceFileContents[$choicefiles[thread]])\n choicefile.close\n else \n FileUtils.cp($choicefiles[thread],$RunDirectory)\n end \n \n \n FileUtils.cp($gOptionFile,$RunDirectory) \n FileUtils.cp(\"#{$gArchetypeDir}\\\\#{$H2kFile}\",$RunDirectory)\n \n if ( $gComputeCosts ) then \n # Think about error handling. \n FileUtils.cp($gCostingFile,$RunDirectory)\n end \n # ... And get base file names for insertion into the substitute-h2k.rb command.\n $LocalChoiceFile = File.basename $choicefiles[thread] \n $LocalOptionsFile = File.basename $gOptionFile\n \n\n \n # CD to run directory, spawn substitute-h2k thread and save PID \n Dir.chdir($RunDirectory)\n\n if ( $gDebug ) \n FileUtils.cp(\"#{$H2kFile}\",\"#{$H2kFile}-p0\")\n end \n \n \n\n # Possibly call another script to modify the .h2k and .choice files \n \n case $Ruleset\n when /936_2015_AW_HRV/\n subcall = \"perl C:\\\\HTAP\\\\NRC-scripts\\\\apply936-AW.pl #{$H2kFile} #{$LocalChoiceFile} #{$LocalOptionsFile} #{$Location} 1 \"\n system (subcall) \n when /936_2015_AW_noHRV/\n subcall = \"perl C:\\\\HTAP\\\\NRC-scripts\\\\apply936-AW.pl #{$H2kFile} #{$LocalChoiceFile} #{$LocalOptionsFile} #{$Location} 0 \"\n system (subcall) \n end \n\n if ( $gDebug ) \n FileUtils.cp(\"#{$H2kFile}\",\"#{$H2kFile}-p1\")\n end \n \n $SubCostFlag = \"\"\n if ($gComputeCosts ) then \n $SubCostFlag = \"--auto_cost_options\"\n end \n cmdscript = \"ruby #{$gSubstitutePath} -o #{$LocalOptionsFile} -c #{$LocalChoiceFile} -b #{$H2kFile} --report-choices --prm #{$gExtendedOutputFlag} #{$SubCostFlag}\"\n \n # Save command for invoking substitute [ useful in debugging ] \n $cmdtxt = File.open(\"cmd.txt\", 'w') \n $cmdtxt.write cmdscript\n $cmdtxt.close\n \n #debug_out(\" ( cmd: #{cmdscript} | \\n\") \n \n \n pid = Process.spawn( cmdscript, :out => File::NULL, :err => \"substitute-h2k-errors.txt\" ) \n \n\n \n\n $PIDS[thread] = pid \n \n stream_out(\"(PID #{$PIDS[thread]})...\")\n \n \n \n \n # Cd to root, move to next choice file. \n Dir.chdir($gMasterPath)\n \n end \n\n # Snail-Start: \n # This patch is a workaround for instability observed with highly-thread (20+) runs on machines with slow I/O. \n # On the first batch, the substitute script copies the contents of the h2k folder into the working directories (HTAP-work-X),\n # and these folders are subsequently re-used on the following batches. I suspect that windows struggles when 40+ threads are all \n # trying to copy 80+ MB simultaneously to a slow disk; some folders are not created correctly, some files are missing. The \n # result is a bunch of failed runs. \n #\n # Specifying command line option '--snailStart X' causes prm to pause for X seconds after spawning a thread - * on the first batch only *\n # It seems to give a magnetic disk a fighting chance of keeping up with the copy requests. It doesn't appear to slow the simulation \n # down too much, because it only affects the first batch, the H2K folder copy operation appears to be the most expensive part of that first run.\n\n # In tests with 40 threads writing to a magnetic disk, `-- snailStart 6` produces stable runs. \n # A future improvement might modify substitute-h2k.rb to take a hash of the h2k directory content, and verify its integrity before proceeding. \n \n if ( $batchCount == 1 && $snailStart ) then \n \n stream_out (\" *SS-Wait\")\n for wait in 1..5\n \n stream_out (\".\")\n \n sleep($snailStartWait/5)\n \n end \n \n stream_out( \"*\")\n \n end \n \n \n stream_out (\" done. \\n\")\n $choicefileIndex = $choicefileIndex + 1\n \n # Create hash to hold results \n $RunResults[\"run-#{thread}\"] = Hash.new \n \n end \n \n \n # Multi-threaded runs - Step 2: Monitor thread progress\n \n #=====================================================================================\n # Wait for threads to complete \n \n for thread2 in 0..$ThreadsNeeded-1 \n \n count = thread2 + 1 \n \n stream_out (\" - Waiting on PID: #{$PIDS[thread2]} (#{count}/#{$ThreadsNeeded})...\")\n \n Process.wait($PIDS[thread2], 0)\n \n status = $?.exitstatus \n \n if ( status == 0 ) \n \n stream_out (\" done.\\n\")\n \n else \n \n stream_out (\" FAILED! (Exit status: #{status})\\n\")\n \n $RunResults[\"run-#{thread2}\"][\"s.success\"] = \"false\"\n $RunResults[\"run-#{thread2}\"][\"s.errors@99\"] = \" Run failed - substitute-h2k.rb returned status #{status}\"\n \n end \n \n end \n \n #=====================================================================================\n # Multi-threaded runs - Step 3: Post-process and clean up. \n \n \n \n for thread3 in 0..$ThreadsNeeded-1 \n count = thread3 + 1 \n stream_out (\" - Reading results files from PID: #{$PIDS[thread3]} (#{count}/#{$ThreadsNeeded})...\")\n \n Dir.chdir($RunDirs[thread3])\n \n\n $RunResults[\"run-#{thread3}\"][\"c.RunNumber\"] = \"#{$RunNumbers[thread3].to_s}\"\n $RunResults[\"run-#{thread3}\"][\"c.RunDirectory\"] = \"#{$RunDirs[thread3].to_s}\"\n $RunResults[\"run-#{thread3}\"][\"c.SaveDirectory\"] = \"#{$SaveDirs[thread3].to_s}\"\n $RunResults[\"run-#{thread3}\"][\"c.ChoiceFile\"] = \"#{$choicefiles[thread3].to_s}\"\n \n $runFailed = false\n \n # Parse contents of substitute-h2k-errors.txt, which may contain ruby errors if substitute-h2k.rb did \n # not execute correctly. \n $RunResults[\"run-#{thread3}\"][\"s.substitute-h2k-err-msgs\"] = \"nil\"\n \n if ( File.exist?(\"substitute-h2k-errors.txt\") )\n $errmsgs= File.read(\"substitute-h2k-errors.txt\")\n $errmsgs_chk = $errmsgs\n if ( ! $errmsgs_chk.gsub(/\\n*/,\"\").gsub( / */, \"\").empty? ) \n $RunResults[\"run-#{thread3}\"][\"s.substitute-h2k-err-msgs\"] = $errmsgs \n end \n \n end \n \n \n if ( File.exist?($RunResultFilename) ) \n \n contents = File.open($RunResultFilename, 'r') \n \n \n ec=0\n wc=0 \n \n \n \n lineCount = 0\n contents.each do |line|\n lineCount = lineCount + 1\n line_clean = line.gsub(/ /, '')\n line_clean = line.gsub(/\\n/, '')\n if ( ! line_clean.to_s.empty? ) \n $contents = Array.new \n $contents = line_clean.split('=')\n token = $contents[0].gsub(/\\s*/,'') \n value = $contents[1].gsub(/^\\s*/,'') \n value = $contents[1].gsub(/^ /,'')\n value = $contents[1].gsub(/ +$/,'')\n \n \n # add prefix to \n case token \n when /s.error/ \n token.concat(\"@#{ec}\")\n ec = ec + 1\n when /s.warning/\n token.concat(\"@#{wc}\")\n wc=wc+1 \n end \n $RunResults[\"run-#{thread3}\"][token] = value\n end \n \n end \n contents.close\n\n if $RunResults[\"run-#{thread3}\"][\"s.success\"] =~ /false/ then \n $runFailed = true\n stream_out (\" done (with errors).\\n\")\n else\n stream_out (\" done.\\n\")\n end \n \n \n \n \n\n \n else \n \n stream_out (\" Output couldn't be found! \\n\")\n $runFailed = true \n \n #stream_out (\" RUN FAILED! (see dir: #{$SaveDirs[thread3]}) \\n\")\n $failures.write \"#{$choicefiles[thread3]} (dir: #{$SaveDirs[thread3]}) - no output from substitute-h2k.rb\\n\"\n $FailedRuns.push \"#{$choicefiles[thread3]} (dir: #{$SaveDirs[thread3]}) - no output from substitute-h2k.rb\"\n $FailedRunCount = $FailedRunCount + 1\n \n $RunResults[\"run-#{thread3}\"][\"s.success\"] = \"false\"\n $RunResults[\"run-#{thread3}\"][\"s.errors@99\"] = \" Run failed - no output generated\"\n \n $LocalChoiceFile = File.basename $gOptionFile\n if ( ! FileUtils.rm_rf(\"#{$RunDirs[thread3]}/#{$LocalChoiceFile}\") )\n warn_out(\" Warning! Could delete #{$RunDirs[thread3]} rm_fr Return code: #{$?}\\n\" )\n end \n \n \n end \n \n Dir.chdir($gMasterPath) \n \n # Save files from runs that failed, or possibly all runs. \n if ( $gSaveAllRuns || $runFailed ) \n \n if ( ! Dir.exist?($SaveDirs[thread3]) ) \n \n Dir.mkdir($SaveDirs[thread3]) \n \n else \n \n FileUtils.rm_rf Dir.glob(\"#{$SaveDirs[thread3]}/*.*\") \n \n end \n \n FileUtils.mv( Dir.glob(\"#{$RunDirs[thread3]}/*.*\") , \"#{$SaveDirs[thread3]}\" ) \n FileUtils.rm_rf (\"#{$RunDirs[thread3]}/sim-output\")\n end \n \n #Update status of this thread. \n $FinishedTheseFiles[$choicefiles[thread3]] = true \n \n \n end \n \n errs = \"\" \n stream_out (\" - Post-processing results... \") \n\n $outputlines = \"\"\n \n row = 0 \n \n \n # Alternative output in JSON format. Can be memory-intensive\n if ( $gJSONize ) \n \n \n $RunResults.each do |run,data|\n \n $gJSONAllData[$gHashLoc] = Hash.new\n $gJSONAllData[$gHashLoc] = { \"result-number\" => $gHashLoc+1, \n \"status\" => Hash.new,\n \"archetype\" => Hash.new, \n \"input\" => Hash.new, \n \"output\" => Hash.new, \n \"configuration\" => Hash.new,\n \"miscellaneous_info\" => Hash.new } \n \n # Storage for arrays. \n $gJSONAllData[$gHashLoc][\"status\"] = { \"warnings\" => Array.new, \"errors\" => Array.new } \n \n # Storage for binned data\n if ( $gExtendedOutputFlag =~ /-e/ ) \n $gJSONAllData[$gHashLoc][\"output\"] = { \"BinnedData\" => Hash.new } \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"] = Array.new \n for counter in 0..31\n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][counter] = Hash.new \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][counter][\"bin\"] = counter+1\n end\n else \n $gJSONAllData[$gHashLoc][\"output\"] = { \"BinnedData\" => \"No binned data to report for run ##{$gHashLoc}. Run htap-prm with '-e' to enable\" } \n end \n\n data.each do |token,value|\n \n \n #Detect the type of this token from prefix\n $col_tmp = token.to_s.gsub(/\\s*/, '') \n \n case $col_tmp\n when /^input\\./ , /^i\\./ \n $col_type = \"input\"\n when /^output\\./ , /^o\\./ \n $col_type = \"output\"\n when /^arch\\./ , /^a\\./ \n $col_type = \"archetype\" \n when /^config\\./ , /^c\\./ \n $col_type = \"configuration\" \n when /^status\\./ , /^s\\./ \n $col_type = \"status\" \n else \n $col_type = \"miscellaneous_info\"\n end \n \n # And get remaining text after the '.'\n $col_txt = $col_tmp.to_s.gsub(/^[^\\.]+\\./,'')\n \n # Then store data in the appropriate location \n case $col_txt \n when /error/ \n \n $gJSONAllData[$gHashLoc][\"status\"][\"errors\"].push( value.to_s.gsub(/\"/,'') )\n \n when /warning/ \n \n $gJSONAllData[$gHashLoc][\"status\"][\"warnings\"].push( value.to_s.gsub(/\"/,'') ) \n \n when /BIN-data/\n # format is 'BIN-data-TYPE-##'; Split out TYPE and ##\n $bin_type = Array.new\n $bin_type = $col_txt.gsub(/BIN-data-/, '').split(\"-\") \n $bin_row = $bin_type[1].to_i - 1 \n # Store data in array, based on type.\n \n case $bin_type[0].to_s\n when /HRS/ \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][$bin_row][\"CumulativeHrs\"] = value.to_f\n \n when /TMP/ \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][$bin_row][\"Temperature_oC\"] = value.to_f\n \n when /HLR/ \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][$bin_row][\"HeatLossRateW\"] = value.to_f\n \n when /T2cap/ \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][$bin_row][\"Type2Capacity\"] = value.to_f\n \n when /T2PLR/ \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][$bin_row][\"Type2PartLoadRatio\"] = value.to_f \n \n when /T1PLR/ \n $gJSONAllData[$gHashLoc][\"output\"][\"BinnedData\"][$bin_row][\"Type1PartLoadRatio\"] = value.to_f \n end \n \n else \n \n \n # format according to data type \n case value.to_s.gsub(/\\s*/, '') \n when /^[0-9\\-]+$/ \n $gJSONAllData[$gHashLoc][\"#{$col_type}\"][\"#{$col_txt}\"] = value.to_i\n \n when /^[0-9\\.\\-E]+$/ \n $gJSONAllData[$gHashLoc][\"#{$col_type}\"][\"#{$col_txt}\"] = value.to_f\n \n else \n $gJSONAllData[$gHashLoc][\"#{$col_type}\"][\"#{$col_txt}\"] = value.to_s.gsub(/^\\s*/, '').gsub( /\\s*$/,'')\n\n end\n \n \n \n end \n \n \n end # ends data.each do \n \n # Arr err/warn empty? if so, put 'nil'\n if ( $gJSONAllData[$gHashLoc][\"status\"][\"errors\"].empty? ) \n \n $gJSONAllData[$gHashLoc][\"status\"][\"errors\"].push \"nil\"\n \n end \n \n if ( $gJSONAllData[$gHashLoc][\"status\"][\"warnings\"].empty? ) \n \n $gJSONAllData[$gHashLoc][\"status\"][\"warnings\"].push \"nil\"\n \n end \n \n \n \n # Test to see if the run was successful. Flag if not, otherwise increment completed counter. \n \n if ( $gJSONAllData[$gHashLoc][\"status\"][\"success\"] == \"false\" ) then \n \n $runFailed = true \n errs=\" *** simulation errors found ***\"\n $msg = \"#{$gJSONAllData[$gHashLoc][\"configuration\"][\"ChoiceFile\"]} (dir: #{$gJSONAllData[$gHashLoc][\"configuration\"][\"SaveDirectory\"]}) - substitute-h2k.rb reports errors\"\n $failures.write \"$msg\\n\"\n $FailedRuns.push $msg \n $FailedRunCount = $FailedRunCount + 1\n\n else \n \n $CompletedRunCount = $CompletedRunCount + 1 \n \n end \n\n \n # Increment hash increment too. \n $gHashLoc = $gHashLoc + 1 \n\n if ( $runFailed && $StopOnError ) then \n $RunsDone = true \n $GiveUp = true \n end \n\n\n \n \n end # ends $RunResults.each do\n \n \n end # Ends if JSON.\n \n \n $RunResults.each do |run,data|\n \n # Only write out data from successful runs - this helps prevent corrupted databae \n \n \n if ( data['s.success'] =~ /true/ ) then\n \n if ( ! $outputHeaderPrinted ) then \n # Deal with header first \n data.sort.to_h \n data.each do |column,value|\n \n case column \n when /s\\.error/, /s\\.warning/, /BIN-data/\n # Do nothing \n else \n \n $csvColumns.push column\n $headerline.concat(\"#{column.to_s},\")\n end \n end \n $outputHeaderPrinted = true \n $headerline.concat(\"\\n\")\n $outputCSV.write($headerline) \n end \n \n $csvColumns.each do |key|\n \n $outputlines.concat(\"#{data[key]},\")\n \n end\n \n $outputlines.concat(\"\\n\")\n \n end \n \n end \n \n $outputCSV.write($outputlines) \n $outputCSV.flush\n $failures.flush \n \n $RunResults.clear\n \n stream_out (\"done.#{errs}\\n\\n\")\n\n if ( ! $FinishedTheseFiles.has_value?(false) ) \n \n $RunsDone = true \n \n end \n \n\n end \n \n \n if ( $GiveUp ) then \n stream_out(\" - HTAP-prm: runs terminated due to error ----------\\n\\n\")\n else \n stream_out(\" - HTAP-prm: runs finished -------------------------\\n\\n\")\n end \n \n if ($gJSONize )\n stream_out(\" - Writing JSON output to HTAP-prm-output.json... \")\n $JSONoutput = File.open($gOutputJSON, 'w') \n $JSONoutput.write(JSON.pretty_generate($gJSONAllData))\n $JSONoutput.close \n stream_out(\"done.\\n\\n\")\n end \n \n \n if ( ! $gDebug ) then \n stream_out (\" - Deleting working directories... \") \n FileUtils.rm_rf Dir.glob(\"HTAP-work-*\") \n stream_out(\"done.\\n\\n\")\n end\n \nend", "def run_tasks()\n self.task_queue.each do |task|\n\n self.task_list << task\n trigger_event(:start,:task)\n\n result = self.send(task[:name],*(task[:args]))\n if result[:status] == :failed\n break\n end\n\n\n self.task_list.last[:result]=result\n trigger_event(:end,:task)\n end\n end", "def analyze_data\n @input_dataset.each do |name, email|\n domain_name = find_domain(email)\n current_domain = get_current_domain(domain_name) \n current_domain.learn(name, email)\n end\n\n # Generate predictions for available domains\n @all_domains.each{ |key, domain| domain.generate_predictions }\n\n # Utility method to display Email statistics per domain name\n # display_info\n end", "def buildwise_run_sequential_build_target(build_id, task_name) \r\n begin\r\n FileUtils.rm_rf(\"spec/reports\") if File.exist?(\"spec/reports\")\r\n Rake::Task[task_name].invoke\r\n ensure\r\n puts \"Finished: Notify build status\"\r\n sleep 2 # wait a couple of seconds to finish writing last test results xml file out\r\n puts \"[Rake] finish the build\"\r\n buildwise_finish_build(build_id)\r\n end\r\nend", "def build_summary_data(start_time, end_time, response)\n build_enphase_summary(response.body) \n build_data_harvest(start_time, end_time, response)\n \n total_end_time = Time.now.to_f\n build_job(start_time, total_end_time)\n end", "def run!\n process_classic\n\n length.times do\n activity = ACTIVITIES.sample\n\n unless respond_to?(activity, true)\n LLL.error \"activity #{activity} not implemented\"\n next\n end\n\n LLL.info \"trying #{activity}\"\n before_time = Time.now.to_f\n Timeout.timeout(@timeout) do\n send activity\n end\n after_time = Time.now.to_f\n\n @report[activity].add(after_time - before_time)\n end\n end", "def perform(*args)\n user_id, task_id, task_type, empirical_value, obi, from = args[0][0][0], args[0][0][1], args[0][0][2], args[0][0][3], args[0][0][4], args[0][0][5]\n empirical_value = empirical_value.to_i\n obi = obi.to_i\n user = Core::User.find_by(id: user_id)\n return p \"#{Time.now}————————>error---------------->用户不对!\" unless user.present?\n size = Core::TaskAward.where(user_id: user_id, task_type: task_type).where(\"created_at > ? \", Time.now.beginning_of_day.to_s(:db)).size\n case task_type\n when 'Shop::DynamicComment'\n if size <= 50\n Core::TaskAward.create(user_id: user_id, task_id: task_id, task_type: task_type, empirical_value: empirical_value, obi: obi, from: from )\n user.update(empirical_value: user.empirical_value+empirical_value, obi: user.obi+obi)\n end\n comment = Shop::DynamicComment.find_by(id: task_id)\n comment.dynamic.topic.shop_task.get_obi user\n comment.dynamic.topic.shop_task.increment!(:participants)\n when 'Shop::VoteResult'\n if size <= 50\n Core::TaskAward.create(user_id: user_id, task_id: task_id, task_type: task_type, empirical_value: empirical_value, obi: obi, from: from )\n user.update(empirical_value: user.empirical_value+empirical_value, obi: user.obi+obi)\n end\n vote_result = Shop::VoteResult.find_by(id: task_id)\n vote_result.resource.topic.shop_task.get_obi user\n vote_result.resource.topic.shop_task.increment!(:participants)\n when 'Shop::TopicDynamic'\n topic = Shop::TopicDynamic.find_by(id: task_id).topic\n if from.match(/._share/)\n topic.shop_task.share_state[\"#{Shop::Topic}:#{user.id}\"] += 1\n share_size = Core::TaskAward.where(user_id: user_id, task_type: task_type).where(\"`from` like '%_share' AND created_at > ? \", Time.now.beginning_of_day.to_s(:db)).size #分享次数\n\n if share_size < 20\n Core::TaskAward.create(user_id: user_id, task_id: task_id, task_type: task_type, empirical_value: empirical_value, obi: obi, from: from)\n user.update(empirical_value: user.empirical_value+empirical_value, obi: user.obi+obi)\n end\n end\n #创建动态\n create_size = Core::TaskAward.where(user_id: user_id, task_type: task_type, from: \"create_topic_dynamic\").where(\"created_at > ? \", Time.now.beginning_of_day.to_s(:db)).size\n #点赞\n like_size = Core::TaskAward.where(user_id: user_id, task_type: task_type, from: \"self\").where(\"created_at > ? \", Time.now.beginning_of_day.to_s(:db)).size\n #被别人点赞次数\n liked_size = Core::TaskAward.where(user_id: user_id, task_type: task_type, from: \"other\").where(\"created_at > ? \", Time.now.beginning_of_day.to_s(:db)).size\n\n if (from == 'self' && like_size <= 5) || (from == 'other' && liked_size <= 50) || from == 'create_topic_dynamic' && create_size <= 5\n Core::TaskAward.create(user_id: user_id, task_id: task_id, task_type: task_type, empirical_value: empirical_value, obi: obi, from: from )\n user.update(empirical_value: user.empirical_value+empirical_value, obi: user.obi+obi)\n end\n if from == 'self' || from == \"create_topic_dynamic\"\n topic.shop_task.get_obi user\n topic.shop_task.increment!(:participants)\n end\n when 'Shop::Comment'\n if size <= 50\n Core::TaskAward.create(user_id: user_id, task_id: task_id, task_type: task_type, empirical_value: empirical_value, obi: obi, from: from )\n user.update(empirical_value: user.empirical_value+empirical_value, obi: user.obi+obi)\n end\n comment = Shop::Comment.find_by(id: task_id)\n comment.task.shop_task.get_obi user\n comment.task.shop_task.increment!(:participants)\n when 'Shop::FundingOrder'\n if size <= 50\n Core::TaskAward.create(user_id: user_id, task_id: task_id, task_type: task_type, empirical_value: empirical_value, obi: obi, from: from )\n user.update(empirical_value: user.empirical_value+empirical_value, obi: user.obi+obi)\n end\n order = Shop::FundingOrder.find_by(id: task_id)\n task = order.owhat_product.shop_task\n #task.increment!(:participants)\n task.get_obi(user)\n when 'Shop::Order'\n if size <= 50\n Core::TaskAward.create(user_id: user_id, task_id: task_id, task_type: task_type, empirical_value: empirical_value, obi: obi, from: from)\n user.update(empirical_value: user.empirical_value+empirical_value, obi: user.obi+obi)\n end\n order = Shop::Order.find_by(id: task_id)\n order.order_items.each do |item|\n #item.owhat_product.shop_task.increment!(:participants)\n item.owhat_product.shop_task.get_obi(user)\n end\n when 'Core::User', 'Core::Star', 'Qa::Poster', \"Shop::Event\", \"Shop::Product\", \"Shop::Topic\", \"Shop::Media\", \"Shop::Subject\", \"Shop::Funding\"\n if from.match(/._share/)\n if task_type != 'Core::User' && task_type != 'Core::Star'\n task = eval(task_type).find_by(id: task_id).shop_task\n task.share_state[\"#{task.shop_type}:#{user.id}\"] += 1\n task.get_obi(user, type: 'share')\n end\n share_size = Core::TaskAward.where(user_id: user_id, task_type: task_type).where(\"`from` like '%_share' AND created_at > ? \", Time.now.beginning_of_day.to_s(:db)).size\n if share_size < 20\n Core::TaskAward.create(user_id: user_id, task_id: task_id, task_type: task_type, empirical_value: empirical_value, obi: obi, from: from)\n user.update(empirical_value: user.empirical_value+empirical_value, obi: user.obi+obi)\n end\n else\n #发任务暂时不送O元 包含媒体任务参与 打卡任务\n if task_type != 'Core::User' && task_type != 'Core::Star'\n task = eval(task_type).find_by(id: task_id).shop_task\n task.get_obi user\n task.increment!(:participants)\n end\n Core::TaskAward.create(user_id: user_id, task_id: task_id, task_type: task_type, empirical_value: empirical_value, obi: obi, from: from)\n user.update(empirical_value: user.empirical_value+empirical_value, obi: user.obi+obi)\n end\n end\n\n level, obi = user.update_obi_and_empirical_value(user.empirical_value, user)\n unless user.level == level\n Core::TaskAward.create(user_id: user_id, task_id: user.id, task_type: user.class, empirical_value: 0, obi: (obi - user.obi), from: 'level_up')\n user.update(level: level, obi: obi)\n end\n end", "def work( payload, metadata )\n\t\tself.job_counter.mark\n\t\tself.job_timer.time do\n\t\t\tsuper\n\t\tend\n\tend", "def analyze_experiment\n \n #begin\n data = params['data'].split(\",\")\n logger.debug \"=============================\" + data.inspect + \"==============================\"\n \n if data.size > 1\n data.each do |id|\n @experiment = Experiment.find(id)\n path = get_paths(id)\n @probeNames, @sorted_tsi, @sorted_snr = readGpr(path)\n\n\t\t@gpr_code = Microarraygpr.find(@experiment.microarraygpr_id).verbose_me\n\n @micro_array_analysis_file = MicroArrayAnalysisFile.create(experiment_id: @experiment.id, probe: @probeNames, tsi: @sorted_tsi, snr: @sorted_snr, gprcode: @gpr_code, ecode: @experiment.ecode)\n\n\n end \n else\n\t@experiment = Experiment.find(data[0]) \n\tpath = get_paths(data[0])\n #logger.debug \"&&&&&&&&&&&&&&&&&&&&&\" + path.to_s + \"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\"\n\t@probeNames, @sorted_tsi, @sorted_snr = readGpr(path) \n #logger.debug \"&&&&&&&&&&&&&&&&&&&&&&&&&&&\" + @probeNames.inspect + \"@@@@@@@@@@@@@@@@@@@@@@@@\"\n #logger.debug \"&&&&&&&&&&&&&&&&&&&&&&&&&&&\" + @sorted_tsi.inspect + \"@@@@@@@@@@@@@@@@@@@@@@@@\"\n\t #logger.debug \"&&&&&&&&&&&&&&&&&&&&&&&&&&&\" + @sorted_snr.inspect + \"@@@@@@@@@@@@@@@@@@@@@@@@\"\n\n\n\t@gpr_code = Microarraygpr.find(@experiment.microarraygpr_id).verbose_me\n\n\t \n @micro_array_analysis_file = MicroArrayAnalysisFile.create(experiment_id: @experiment.id, probe: @probeNames, tsi: @sorted_tsi, snr: @sorted_snr, gprcode: @gpr_code, ecode: @experiment.ecode)\n\n\n end \n\n respond_to do |format| \n format.html { redirect_to micro_array_analysis_files_path }\n end \n\n #rescue Exception => e\n\n # e.message\n # e.backtrace\n #raise NoGprError, \"File does not seem to be GPR formatted. Check the file!!\"\n\n #end \n\n end", "def query_long_running_tasks\n Kernel.sleep(0.01)\n target_tasks = []\n 100.times.each do\n target_tasks = @tasks.get[\"nodes\"]\n .map { |k, v| v[\"tasks\"] }\n .flatten.map { |ts| ts.select { |k, v| /bulk/ =~ v[\"action\"] } }\n .flatten.reject { |t| t.empty? }\n break if target_tasks.size > 0\n end\n\n target_tasks\nend", "def perform\n # Fetch the user based on ID\n user = User.find(user_id)\n raise ArgumentError, 'User ID is not valid' unless user\n \n # Create a dataset and save it, to fix its ID\n dataset = user.datasets.build(:name => name)\n raise StandardError, 'Cannot create dataset for user' unless dataset\n raise StandardError, 'Cannot save dataset' unless dataset.save\n \n # Build a Solr query to fetch the results, 1000 at a time\n solr_query = {}\n solr_query[:start] = 0\n solr_query[:rows] = 1000\n solr_query[:q] = q\n solr_query[:fq] = fq\n solr_query[:qt] = qt\n\n # Only get shasum, no facets\n solr_query[:fl] = 'shasum'\n solr_query[:facet] = false\n \n # We trap all of this so that if we get exceptions we can clean them\n # up and delete any and all fledgling dataset parts\n begin\n # Get the first Solr response\n solr_response = Solr::Connection.find solr_query\n\n raise StandardError, 'Unknown error in Solr response' unless solr_response.ok?\n raise StandardError, 'Attempted to save empty query' unless solr_response[\"response\"][\"numFound\"] > 0\n \n # Get our parameters\n docs_to_fetch = solr_response[\"response\"][\"numFound\"]\n dataset_id = dataset.to_param\n \n while docs_to_fetch > 0\n # What did we get this time?\n docs_fetched = solr_response[\"response\"][\"docs\"].count\n\n # Send them all in with activerecord-import\n DatasetEntry.import([ :shasum, :dataset_id ],\n solr_response[\"response\"][\"docs\"].map { |d|\n [ d[\"shasum\"], dataset_id ]\n },\n :validate => false)\n \n # Update counters and execute another query if required\n docs_to_fetch = docs_to_fetch - docs_fetched\n if docs_to_fetch > 0\n solr_query[:start] = solr_query[:start] + docs_fetched\n solr_response = Solr::Connection.find solr_query\n\n raise StandardError, 'Unknown error in Solr response' unless solr_response.ok?\n raise StandardError, 'Attempted to save empty query' unless solr_response[\"response\"][\"numFound\"] > 0\n end\n end\n rescue StandardError => e\n # Destroy the dataset to clean up\n dataset.destroy\n raise\n end\n end", "def execute_scheduled_task_single_post\n Rails.logger.info \"EOSDISTagger START run of scheduled EOSDIS tagging task single POST request: #{Time.now}, catalog_rest_endpoint: #{@catalog_rest_endpoint}, cmr_base_endpoint: #{@cmr_base_endpoint}, ingest_providers_list_endpoint: #{@ingest_providers_list_endpoint}\"\n time = Benchmark.realtime do\n verify_tag_presence\n populate_providers_hash\n tag_provider_collections_single_post\n log_tagging_metrics\n end\n Rails.logger.info \"EOSDIS collection tagging scheduled task with ONE post request took #{(time.to_f * 1000).round(0)} ms\"\n Rails.logger.info \"EOSDISTagger END run of scheduled EOSDIS tagging task single POST request: #{Time.now}\"\n end", "def manage_process(endpoint = nil)\n\n\t endpoint = @endpoint if endpoint.nil?\n\n\t @uri_path = \"/insights/engagement/#{@endpoint}\"\n\n\t if @endpoint == 'historical'\n\n\t\t @start_date = @utils.set_ISO_date_string(@start_date) if @start_date != nil\n\t\t @end_date = @utils.set_ISO_date_string(@end_date) if @end_date != nil\n\n\t\t if not (@start_date == nil and @end_date == nil) #Only set dates if one or both are specified. If both are nil, API handles defaults.\n\n\t\t\t@start_date = @utils.crop_date(@start_date, 'hour', 'before') if @start_date != nil\n\t\t\t@end_date = @utils.crop_date(@end_date, 'hour', 'after') if @end_date != nil\n\n\t\t\tset_dates(@start_date, @end_date)\n\n\t\t end\n\t end\n\n\t continue = true\n\n\t load_ids if @tweet_ids.length == 0\n\n\t AppLogger.log_info \"Generating sets of Tweet IDs for API requests to #{endpoint} endpoint...\"\n\n\t @tweets_of_interest = generate_tweets_of_interest_for_requests(endpoint)\n\n\t AppLogger.log_info \"Will make #{@tweets_of_interest.count} API requests...\"\n\n\t results = {}\n\t results['continue'] = true\n\n\t rate_limit_pause = @rate_limit_seconds/@rate_limit_requests\n\n\t AppLogger.log_info \"Max Top Tweets #{@max_top_tweets} Rate Limit Pause #{rate_limit_pause}\"\n\t\t\n\t start_process = Time.now\n\t \n\t @tweets_of_interest.each do |toi| #These tweets_of_interest items each map to a single request.\n\n\t\t begin\n\n\t\t\tresults['request'] = assemble_request(toi)\n\t\t\tstart_request = Time.now\n\t\t\t@num_requests += 1\n\t\t\tAppLogger.log_info \"Making #{@num_requests} of #{@tweets_of_interest.count} requests...\"\n\t\t\tresults['response'] = JSON.parse(make_post_request(@uri_path, results['request']))\n\t\t\tduration = Time.now - start_request\n\t\t\tresults['retry'] = nil\n\n\t\t\t#--------------------------------------\n\n\t\t\tresults = check_results(results)\n\n\t\t\t#----------------------------------------\n\n\t\t\tif results['continue'] # if success, sleep and continue.\n\n\t\t\t if results['retry'].nil?\n\t\t\t\t AppLogger.log_info \"Managing Top Tweets, handling metadata in API response.\"\n\n\t\t\t\t if @save_api_responses\n\t\t\t\t\t save_api_response(results['response'])\n\t\t\t\t end\n\n\t\t\t\t manage_top_tweets(results['response']) unless (@max_top_tweets == 0 or !results['errors'].nil?)\n\t\t\t\t duration = Time.now - start_request\n\n\t\t\t\t if @tweets_of_interest.count > 1\n\t\t\t \t AppLogger.log_info \"Sleeping #{format('%.02f', rate_limit_pause - duration)} seconds before next API request... \" if duration < rate_limit_pause\n\t\t\t\t\t sleep (rate_limit_pause - duration) if duration < rate_limit_pause\n\t\t\t\t end\n\t\t\t else #some error that has a try-again reaction...\n\t\t\t\t #Like hitting a rate limit\n\t\t\t\t if results['retry'] == 'rate-limit'\n\t\t\t\t\t AppLogger.log_warn \"Rate-limit hit, sleeping #{rate_limit_pause} seconds before next API request...\"\n\t\t\t\t\t sleep (rate_limit_pause)\n\t\t\t\t\t results['response'] = JSON.parse(make_post_request(@uri_path, results['request']))\n\t\t\t\t elsif results['retry'] == 'forbidden-tweets'\n\t\t\t\t\t AppLogger.log_warn \"Retrying after forbidden Tweets removed from request... Sleeping #{rate_limit_pause} seconds before next API request...\"\n\t\t\t\t\t sleep (rate_limit_pause)\n\t\t\t\t\t results['response'] = JSON.parse(make_post_request(@uri_path, results['request']))\n\t\t\t\t else\n\t\t\t\t\t AppLogger.log_warn \"Error not handled?\"\n\n\t\t\t\t end\n\t\t\t end\n\t\t\telse\n\t\t\t AppLogger.log_info \"An 'no retry' type error occurred. Quitting... \"\n\t\t\t continue = false\n\t\t\t return continue\n\n\t\t\tend\n\t\t\t\n\t\t rescue\n\t\t\tAppLogger.log_error \"ERROR occurred, skipping request.\"\n\t\t end\n\t end\n\t \n\t @process_duration = Time.now - start_process\n\n\t AppLogger.log_info \"Sorting Top Tweets...\"\n\t sort_top_tweets(@top_tweets) unless (@max_top_tweets == 0 or @top_tweets.nil?)\n\t continue\n\n end", "def run\n # Process Starting Time\n starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n\n # Get records from national service. They'll be fetched from a certain time onwards.\n new_nat_assertions = national_consents_get\n\n # Get new consent records from HEL service.\n new_hel_consents = hel_records_get\n\n # Identify and add new records\n mapping_all_new_consents(new_nat_assertions[:assertions], new_hel_consents)\n\n # Process Ending Time and calculate total time taken for processing.\n ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n Logging.logger.info \"Time taken to run the job: #{format('%<time>0000.3f', time: (ending - starting))}sec\"\n end", "def runs; end", "def run\n schedule_data_reports\n end", "def runner\n\n add_breadcrumb \"SOGR Capital Project Analyzer\", builder_capital_projects_path\n add_breadcrumb \"Running...\"\n\n @builder_proxy = BuilderProxy.new(params[:builder_proxy])\n if @builder_proxy.valid?\n\n if @builder_proxy.organization_id.blank?\n org_id = @organization_list.first\n else\n org_id = @builder_proxy.organization_id\n end\n org = Organization.get_typed_organization(Organization.find(org_id))\n\n # set class names whether primary or components are selected\n class_names = FtaAssetClass.where(id: @builder_proxy.fta_asset_classes).distinct.pluck(:class_name)\n\n\n\n\n ['Facility', 'Infrastructure'].each do |klass|\n if params[\"#{klass.downcase}_primary\"].to_i == 1\n if params[\"#{klass.downcase}_component\"].to_i == 1\n class_names << \"#{klass}Component\"\n else\n # do nothing Facility class already added from FTA asset class\n end\n else\n if params[\"#{klass.downcase}_component\"].to_i == 1\n class_names << \"#{klass}Component\"\n class_names.delete(klass)\n else\n # this case can't happen but if it does\n class_names.delete(klass)\n end\n end\n end\n\n # save range of FYs for the org\n org.update(capital_projects_range_fys: @builder_proxy.range_fys.to_i)\n\n Delayed::Job.enqueue CapitalProjectBuilderJob.new(org, class_names, @builder_proxy.fta_asset_classes, @builder_proxy.start_fy, @builder_proxy.start_fy.to_i + @builder_proxy.range_fys.to_i, @builder_proxy.scenario_id, current_user), :priority => 0\n\n # Let the user know the results\n msg = \"SOGR Capital Project Analyzer is running. You will be notified when the process is complete.\"\n notify_user(:notice, msg)\n\n if Rails.application.config.try(:use_new_scenarios_tool)\n redirect_to scenarios_url\n else\n redirect_to capital_projects_url\n end\n\n return\n else\n respond_to do |format|\n format.html { render :action => \"builder\" }\n end\n end\n\n end", "def work_received(results)\n\n # write results to disk\n results.each do |name,fasta,qual,comments|\n @@results.write_seq(name,fasta,qual,comments)\n end\n \n end", "def calc_next_run\n nil\n end" ]
[ "0.6940027", "0.6936757", "0.66777074", "0.66599137", "0.6420923", "0.6376106", "0.6270561", "0.6252552", "0.62487745", "0.62278503", "0.6192954", "0.61288834", "0.6111016", "0.61012614", "0.60936373", "0.60735357", "0.6056618", "0.60443026", "0.60374844", "0.60131305", "0.6012526", "0.59829384", "0.5946615", "0.5927145", "0.5925948", "0.5915141", "0.59106344", "0.5894264", "0.5875104", "0.5871971", "0.585622", "0.58230203", "0.5817091", "0.5803867", "0.57667476", "0.5765123", "0.5754674", "0.5738959", "0.5695467", "0.5692627", "0.56871027", "0.5685825", "0.56847554", "0.5684441", "0.56816906", "0.5669854", "0.5655114", "0.5655027", "0.56516564", "0.5650017", "0.5648724", "0.5642105", "0.5638479", "0.562596", "0.5616843", "0.5615531", "0.560291", "0.56004083", "0.55972075", "0.5592227", "0.55671054", "0.55643976", "0.55601346", "0.55599993", "0.55573446", "0.55564976", "0.5554737", "0.55499154", "0.55416995", "0.55361587", "0.55361587", "0.55345756", "0.55307716", "0.5525627", "0.55203503", "0.5516786", "0.5514426", "0.5513448", "0.5509793", "0.55091274", "0.5505434", "0.5503147", "0.548306", "0.5472359", "0.54711044", "0.5467951", "0.54654837", "0.54626393", "0.5462069", "0.54615486", "0.5458728", "0.54576653", "0.5457515", "0.5450425", "0.5449277", "0.54478157", "0.5441157", "0.5437306", "0.5435986", "0.5435156", "0.54314184" ]
0.0
-1
matt's sweet code def clamp_to_edgeeee(node, x, y base=BASE) originX = node % base originY = node / base if originX + x > base node = originX + x base end if originY + y > base node = base (originY + y base) end return node end
def clamp_to_edge(node, x, y, base=BASE) while base - (node % base) < x node -= 1 end while (node + (base*(y-1))) >= (base*base) node -= base end return node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clamp; end", "def clamp(x, low, hi)\n x = low if x < low\n x = hi if x > hi\n return x\n end", "def h(node)\n (node.x - @end.x).abs + (node.y - @end.y).abs\n end", "def limit\n @nodes.each do |node|\n norm = normal(node.disposition.x, node.disposition.y)\n if 0 < norm\n node.position.x += (node.disposition.x / norm) * [norm, @temperature].min\n node.position.y += (node.disposition.y / norm) * [norm, @temperature].min\n end\n end\n end", "def relative index, x, y\n target = index + x + (y * @size)\n if ((target % @size) - (index % @size)).abs > 1\n target = nil\n elsif target < 0 || target > (@size**2) - 1\n target = nil\n end\n target\n end", "def get_edge_value(x, y)\n raise\n end", "def entities_bordering_entity_at(x, y)\n r = x + Entity::WIDTH - 1\n b = y + Entity::HEIGHT - 1\n entities_at_points([\n [x - 1, y], [x, y - 1], # upper-left corner\n [r + 1, y], [r, y - 1], # upper-right corner\n [x - 1, b], [x, b + 1], # lower-left corner\n [r + 1, b], [r, b + 1], # lower-right corner\n ])\n end", "def axis_range_adj axis, radius = 1\n left = axis - radius\n left = 1 if left < 1\n right = axis + radius\n right = @max_cell_idx if right > @max_cell_idx\n (left..right)\n end", "def remove_edge(x, y)\n raise\n end", "def neigbour_helper(current_node, x, y)\n new_x = current_node.value[0] + x\n new_y = current_node.value[1] + y\n new_node = Node.new(new_x, new_y)\n current_node.neighbour_nodes << new_node if valid?(new_node)\n end", "def left_edge?\n x == 0\n end", "def clamp!(rect)\n nself = self.normalize\n rect = Rect.new_from_object(rect)\n #If self is inside given, there is no need to move self\n unless rect.contain?(nself)\n\n #If self is too wide:\n if nself[2] >= rect[2]\n self[0] = rect.centerx - nself[2].div(2)\n #Else self is not too wide\n else\n #If self is to the left of arg\n if nself[0] < rect[0]\n self[0] = rect[0]\n #If self is to the right of arg\n elsif nself.right > rect.right\n self[0] = rect.right - nself[2]\n #Otherwise, leave x alone\n end\n end\n\n #If self is too tall:\n if nself[3] >= rect[3]\n self[1] = rect.centery - nself[3].div(2)\n #Else self is not too tall\n else\n #If self is above arg\n if nself[1] < rect[1]\n self[1] = rect[1]\n #If self below arg\n elsif nself.bottom > rect.bottom\n self[1] = rect.bottom - nself[3]\n #Otherwise, leave y alone\n end\n end\n end\n return self\n end", "def clamp_vector(min_vector, max_vector)\n self.class.new(Vector2.clamp(@x, min_vector.x, max_vector.x),\n Vector2.clamp(@y, min_vector.y, max_vector.y))\n end", "def test_min_edgecases\n point = nil\n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n bbox.add [0,0,0]\n bbox.add [100,100,100]\n point = bbox.min\n end\n expected_point = Geom::Point3d.new 0,0,0\n assert_equal(expected_point, point,\n 'Failed in test_min_edgecases: positive point' )\n\n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n bbox.add [-10,-10,-10]\n bbox.add [-100,-100,-100]\n point = bbox.min\n end\n expected_point = Geom::Point3d.new -100,-100,-100\n assert_equal(expected_point, point,\n 'Failed in test_min_edgecases: negative point' )\n \n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n point = bbox.min\n end\n # Empty boxes should return very large positive numbers\n x_very_small = point.x > 1000000000000000000000000\n y_very_small = point.y > 1000000000000000000000000\n z_very_small = point.z > 1000000000000000000000000\n assert_equal(true, x_very_small,\n 'Failed in test_min_edgecases: empty bb x' )\n assert_equal(true, y_very_small,\n 'Failed in test_min_edgecases: empty bb y' )\n assert_equal(true, z_very_small,\n 'Failed in test_min_edgecases: empty bb z' )\n end", "def min_under_node node\n current = node.right\n while current.left\n current = current.left\n end\n current\n end", "def clamp(val, min, max)\n\treturn min if val < min\n\treturn max if val > max\n\treturn val\nend", "def between_inclusive(node, left, right)\n if left == right\n true\n else\n node_position = Integer(\"0x#{node}\")\n left_position = Integer(\"0x#{left}\")\n right_position = Integer(\"0x#{right}\")\n\n if left_position < right_position\n (left_position <= node_position && right_position >= node_position)\n else\n (left_position <= node_position || right_position >= node_position)\n end\n end\n end", "def test_max_edgecases\n point = nil\n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n bbox.add [0,0,0]\n bbox.add [100,100,100]\n point = bbox.max\n end\n expected_point = Geom::Point3d.new 100,100,100\n assert_equal(expected_point, point,\n 'Failed in test_max_edgecases: positive point' )\n\n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n bbox.add [-10,-10,-10]\n bbox.add [-100,-100,-100]\n point = bbox.max\n end\n expected_point = Geom::Point3d.new -10,-10,-10\n assert_equal(expected_point, point,\n 'Failed in test_max_edgecases: negative point' )\n \n assert_nothing_raised do\n bbox = Geom::BoundingBox.new\n point = bbox.max\n end\n # Empty boxes should return very large negative numbers\n x_very_small = point.x < -1000000000000000000000000\n y_very_small = point.y < -1000000000000000000000000\n z_very_small = point.z < -1000000000000000000000000\n assert_equal(true, x_very_small,\n 'Failed in test_max_edgecases: empty bb x' )\n assert_equal(true, y_very_small,\n 'Failed in test_max_edgecases: empty bb y' )\n assert_equal(true, z_very_small,\n 'Failed in test_max_edgecases: empty bb z' )\n end", "def lower_right\n @lower_right ||= world.point(x_max, y_min)\n end", "def halfDiffering(node_id)\n half_id = node_id.dup # Need to hard copy\n m = 0\n while @guid[m] == node_id[m] && m < @m_max\n m += 1\n end\n if m > 30\n return -1\n end\n m += 1\n half_id[m] = \"8\"\n m += 1\n while m < @m_max\n half_id[m] = \"0\"\n m += 1\n end\n t = half_id.hex - node_id.hex\n return t.abs\n end", "def get_edge_corner_dis\n top_left = [self.x - self.ox, self.y - self.oy]\n bot_right = [top_left[0] + self.width, top_left[1] + self.height]\n return [top_left, bot_right]\n end", "def edges_of(node)\n edges_from(node) | edges_to(node)\n end", "def clamp(start_range, end_range)\n Proc.new { |target|\n next start_range if target < start_range\n next end_range if target > end_range\n\n target\n }\n end", "def cut(x, y)\n x.left.right = x.right\n x.right.left = x.left\n y.degree -= 1\n if (y.degree == 0)\n y.child = nil\n elsif (y.child == x)\n y.child = x.right\n end\n x.right = @next\n x.left = @next.left\n @next.left = x\n x.left.right = x\n x.parent = nil\n x.marked = false\n end", "def edges_to(node)\n edges.select { |edge| edge.last == node }\n end", "def cut(x, y)\n x.left.right = x.right\n x.right.left = x.left\n y.degree -= 1\n if (y.degree == 0)\n y.child = nil\n elsif (y.child == x)\n y.child = x.right\n end\n x.right = @next\n x.left = @next.left\n @next.left = x\n x.left.right = x\n x.parent = nil\n x.marked = false\n end", "def set_boundaries(node, start, stop)\n node.start = start if node.start.nil? or node.start < start\n node.stop = node.start + node.min_size if node.stop.nil? or node.stop < node.start\n node.stop = stop if node.stop > stop\n end", "def clamp(num, a, b)\r\n\treturn a if num < a\r\n\treturn b if num > b\r\n\treturn num\r\nend", "def east_west_edges(node)\n pos = node.position.chars\n letter = pos[0].ord - 1\n w_node = @board.nodes[letter.chr + pos[1]]\n @board.create_edge(node, w_node)\n end", "def calculate_aoe( range_max, range_min, x = @x, y = @y, v_range_aoe = 0) # mod MGC\n return [] if range_max == nil \n return [[x, y]] if range_max == 0\n\n #prevents items from being pushed if height change between core and outer is less than range/2\n positions = []\n #save position for later processing \n \n #prevents items from being pushed if height change between core and outer is less than range/1.5\n for i in 0..range_max\n it = range_max - i \n #test all couples (it, oy) like: 0 <= it+oy <= range_max\n for oy in 0..i\n next if it+oy < range_min \n for ux, uy in[ [x - it, y - oy], [x - it, y + oy], [x + it, y + oy], [x + it, y - oy] ]\n positions.push([ux, uy]) if valid_new_aoe_pos(ux, uy, x , y, v_range_aoe) and not positions.include?([ux, uy]) # mod MGC\n end\n end\n end\n return positions\n end", "def set_edge_value(x, y, v)\n raise\n end", "def chech_first_corner_edge()\n\t\tposition = 4\n\t\treturn position\n\tend", "def chech_first_corner_edge()\n\t\tposition = 4\n\t\treturn position\n\tend", "def calc_edge_collision\n\n #Ensures that the player doesn't fall below the map.\n if state.y < 0\n state.y = 0\n state.dy = 0\n\n #Ensures that the player doesn't go too high.\n # Position of player is denoted by bottom left hand corner, which is why we have to subtract the\n # size of the player's box (so it remains visible on the screen)\n elsif state.y > 720 - state.tile_size # if the player's y position exceeds the height of screen\n state.y = 720 - state.tile_size # the player will remain as high as possible while staying on screen\n state.dy = 0\n end\n\n # Ensures that the player remains in the horizontal range that it is supposed to.\n if state.x >= 1280 - state.tile_size && state.dx > 0 # if player moves too far right\n state.x = 1280 - state.tile_size # player will remain as right as possible while staying on screen\n state.dx = 0\n elsif state.x <= 0 && state.dx < 0 # if player moves too far left\n state.x = 0 # player will remain as left as possible while remaining on screen\n state.dx = 0\n end\n end", "def recurse_bottom_right_to_top_left(x1, y1, x2, y2)\n bottom_right_to_top_left x1, y1, x2, y2\n recurse_top_left_to_bottom_right x1 + 1, y1, x2, y2 - 1 if x2 - x1 > 0\n end", "def clamp(rect)\n self.dup.clamp!(rect)\n end", "def source_edge\n return unless edge\n return unless local_position.on_line?(edge.line)\n\n edge\n end", "def placeNodeNearClosestNode( base, value )\n result = 0\n if( value <= base.payload )\n if( base.leftNode )\n # Check if we're still less than the node to the left\n if( value > base.leftNode.payload)\n # Time to insert a node between leftNode and base:\n # Add a new node with leftNode as its left and base as its right\n # Set the old leftNode's rightNode to be the new node\n # Set the base's left node to be the new node\n node = Node.new(value, base.leftNode, base, nodeArray.count) \n nodeArray.push(node)\n base.leftNode.rightNode = node\n base.leftNode = node\n else\n result = -1 # Continue searching to the left\n end\n else\n # The base is the current minimum\n # Add a new far left node with the base to its right\n node = Node.new(value, nil, base, nodeArray.count) \n nodeArray.push(node)\n base.leftNode = node\n self.lowestValue = node # Update the lowest value counter with this new low\n end\n elsif( value > base.payload )\n if( base.rightNode)\n # Check if we're still more than the node to the right\n if( value <= base.rightNode.payload)\n # Time to insert a node between base and rightNode:\n # Add a new node with current as its left and rightNode as its right\n # Set the old rightNode's leftNode to be the new node\n # Set the base's right node to be the new node\n node = Node.new(value, base, base.rightNode, nodeArray.count)\n nodeArray.push(node)\n base.rightNode.leftNode = node\n base.rightNode = node\n else\n result = 1 # Continue searching to the right\n end\n else\n # The base is the current maximum\n # Add a new far right node with the base to its left\n node = Node.new(value, base, nil, nodeArray.count)\n nodeArray.push(node)\n base.rightNode = node\n self.highestValue = node # Update the highest value counter with this new max\n end\n end\n return result\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 max_under_node node\n current = node.left\n while current.right\n current = current.right\n end\n current\n end", "def mid x,y\n x + (y-x)/2\nend", "def clamped\n FloatRect.new(x, y, [[0.0, w].max, 1.0].min, [[0.0, h].max, 1.0].min)\n end", "def clamp(x , min_or_max={})\n [[x, min_or_max[:max]].compact.min, min_or_max[:min]].compact.max\n end", "def else_range(node); end", "def upper_left\n @upper_left ||= world.point(x_min, y_max)\n end", "def lowerQuartile(node)\n\t\t# Min humidity value from the node in the past day\n\t\tmin_hum = Reading.select(:humidity, :recorded_at).where(node_id: node, recorded_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).minimum(:humidity)\n\t\t# Min temperature value from the node in the past day\n\t\tmin_temp = Reading.select(:temperature, :recorded_at).where(node_id: node, recorded_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).minimum(:temperature)\n\t\t# Determine the parameter with the lowest value\n\t\tmin_val = [min_hum, min_temp].min\n\n\t\t# Check if node has returned any values for the current day\n\t\t# Set the min bound into quartiles\n\t\tunless min_val.nil?\n\t\t\toffset = (min_val % 25)\n\t\t\t# Visibility adjustment\n\t\t\tif offset == 1 \n\t\t\t\toffset = 5\n\t\t\tend\t\t\t\n\t\t\treturn min_val - (offset)\n\t\tend\n\t\t# Graph will be empty, set default min\n\t\treturn 0\n\tend", "def bound_x (x)\n if x == @world.width\n return 0\n elsif x == -1\n return (@world.width - 1)\n else\n return x\n end\n end", "def expand(current_node)\n x = current_node.x\n y = current_node.y\n\n return [ [x, (y - 1)], # north\n [x, (y + 1)], # south\n [(x + 1), y], # east\n [(x - 1), y] ] # west\n end", "def border\n '+' + ('-' * @max_y) + '+'\n end", "def edge\n :first if first?\n :last if last?\n nil\n end", "def halfDiff( node_id )\n half_id = node_id.dup # Need to hard copy\n m = 0\n while @guid[m] == node_id[m] && m < @m_max\n m += 1\n end\n if m > 30\n return -1\n end\n m += 1\n half_id[m] = \"8\"\n m += 1\n while m < @m_max\n half_id[m] = \"0\"\n m += 1\n end\n t = half_id.hex - node_id.hex\n return t.abs\n end", "def affinity_edge(from, to)\n return [ from == @current_post || to == @current_post ? 0 : 1,\n -affinity(from, to),\n from, to ]\n end", "def else_range(node)\n if node.ternary?\n node.else_branch\n else\n range_between(node.loc.else.end_pos, node.loc.end.begin_pos)\n end\n end", "def check_edges(max_y:)\n if location.y > max_y - radius\n @velocity.y *= -0.9 # A little dampening when hitting the bottom\n @location.y = max_y - radius\n end\n end", "def right\n @x_min + @y_min\n end", "def __rl_fix_point(x)\r\n if (x > @rl_end)\r\n @rl_end\r\n elsif (x < 0)\r\n 0\r\n else\r\n x\r\n end\r\n end", "def calc_edge_collision\n # Ensures that player doesn't fall below the map\n if next_y < 0 && state.dy < 0 # if player is moving down and is about to fall (next_y) below the map's scope\n state.y = 0 # 0 is the lowest the player can be while staying on the screen\n state.dy = 0\n # Ensures player doesn't go insanely high\n elsif next_y > 720 - state.tile_size && state.dy > 0 # if player is moving up, about to exceed map's scope\n state.y = 720 - state.tile_size # if we don't subtract tile_size, we won't be able to see the player on the screen\n state.dy = 0\n end\n\n # Ensures that player remains in the horizontal range its supposed to\n if state.x >= 1280 - state.tile_size && state.dx > 0 # if the player is moving too far right\n state.x = 1280 - state.tile_size # farthest right the player can be while remaining in the screen's scope\n state.dx = 0\n elsif state.x <= 0 && state.dx < 0 # if the player is moving too far left\n state.x = 0 # farthest left the player can be while remaining in the screen's scope\n state.dx = 0\n end\n end", "def normalize_coords(x, y)\n x = x * -1 - 1 if x < 0\n y = y * -1 - 1 if y > -1\n [x, y]\n end", "def bounce wall\n self.x = - self.x if self.x < 0\n self.x = wall.x - (self.x - wall.x) if self.x > wall.x\n self.y = -self.y if self.y < 0\n self.y = wall.y - (self.y - wall.y) if self.y > wall.y\n end", "def clamp_of(a, b, c)\r\n return max(min(a, c), b)\r\n end", "def test_top_edge_enumerated_left_to_right\n assert_equal [0, 1, 0, 1, 0], @p.edge(:top)\n end", "def other_offense_in_same_range?(node); end", "def negative_to_positive\n nTwenty = Node.new(-20)\n nSeventeen = Node.new(-17)\n nNineteen = Node.new(-19, nTwenty, nSeventeen)\n one = Node.new(1)\n zero = Node.new(0, nil, one)\n ten = Node.new(10)\n two = Node.new(2, zero, ten)\n \n Node.new(-15, nNineteen, two)\nend", "def right_down( x)\n MembershipValue.new( ( max_point - x) * gradient)\n end", "def extend!(envelope)\r\n lower_corner.x = [lower_corner.x,envelope.lower_corner.x].min\r\n lower_corner.y = [lower_corner.y,envelope.lower_corner.y].min\r\n upper_corner.x = [upper_corner.x,envelope.upper_corner.x].max\r\n upper_corner.y = [upper_corner.y,envelope.upper_corner.y].max\r\n self\r\n end", "def bound(min, max)\n self < min ? min : (self > max ? max : self)\n end", "def right_up( x)\n MembershipValue.new( ( x - min_point) * gradient)\n end", "def xRange(max)\n (@x > 0 ? @x - 1 : @x)..(@x < max - 1 ? @x + 1 : @x) \n end", "def find_overflow_angle(node)\n\t\tx = node.x\n\t\ty = node.y\n\t\tcount = 0\n\t\topen_tiles = Array.new\n\t\tangle = -1\n\t\tfor i in (x-1..x+1)\n\t\t\tfor j in (y-1..y+1)\n\t\t\t\t#if its not the original node\n\t\t\t\tif (i != x or j != y)\n\t\t\t\t\t#tally up how many lake tiles are nearby us\n\t\t\t\t\tif @map[i][j].type == \"Lake\"\n\t\t\t\t\t\tcount+=1\n\t\t\t\t\telsif @map[i][j].elevation <= @map[node.x][node.y].elevation and @map[i][j].type == \"Land\"\n\t\t\t\t\t\topen_tiles.push(@lake_struct.new true, i, j)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#as long as we aren't surrounded by more than 5 river tiles\n\t\tif open_tiles.count > 0 #and count <= 4\n\t\t\tangle = find_angle(node, open_tiles[0].x, open_tiles[0].y)\n\t\tend\n\t\t#search surrounding nodes find out on what sides the river is\n\t\t#if its on all sides then angle = -1\n\t\t#if its on 7 sides then angle = -1\n\t\t#if its 5 sides or greater then angle = -1\n\t\t#if its on 4 sides or less then angle is dependent on what sides\n\t\t#the lake is on\n\t\t\n\t\t#find a direction that will not lead us next to the lake and is lower\n\t\t#elevation if such a direction cannot be found return -1\n\t\t\n\t\treturn angle\n\tend", "def normalize_bbox(min_x, min_y, max_x, max_y)\n min_x = (min_x + 360) if min_x < -180\n min_y = -90.0 if min_y < -90\n max_x = (max_x - 360) if max_x > 180\n max_y = 90.0 if max_y > 90\n [min_x, min_y, max_x, max_y]\n end", "def adjust(node)\n sib = sibling node\n if sib && sib.color == RED\n # case 3 - 1\n sib == node.p.r ? left_rotate(node.p) : right_rotate(node.p)\n sib.color, node.p.color = node.p.color, sib.color\n adjust(node)\n elsif sib && sib.color == BLACK\n return if sib.key == nil\n if sib.l.color == BLACK && sib.r.color == BLACK\n # case 3 - 2, sib.p is black, change color\n if sib.p.color == RED\n sib.color, sib.p.color = RED, BLACK\n else\n sib.color = RED\n adjust(node.p)\n end \n elsif sib.l.color == RED && sib.r.color == BLACK && node == node.p.l\n # case 3 - 4 - 3\n right_rotate(sib)\n sib.color, sib.p.color = sib.p.color, sib.color\n adjust(node) \n elsif sib.r.color == RED && sib.l.color == BLACK && node == node.p.r\n # case 3 - 4 - 4\n left_rotate(sib)\n sib.color, sib.p.color = sib.p.color, sib.color\n adjsut(node)\n elsif sib.r.color == RED && node == node.p.l\n # case 3 - 4 - 2\n left_rotate(node.p)\n # sib's color must be black\n sib.color, node.p.color = node.p.color, sib.color\n sib.r.color = BLACK\n elsif sib.l.color == RED && node == node.p.r\n # case 3 - 4 - 1\n right_rotate(node.p)\n sib.color, node.p.color = node.p.color, sib.color\n sib.l.color = BLACK\n end\n end\n end", "def left_edge\n @image.get(0,0,1,height).pixels\n end", "def normalizeX x, maxX\n step = 8.to_f / maxX\n nx = -4 + x * step\n #puts nx\n nx\n end", "def min_node(node)\n current = node\n return current if current.left.nil?\n\n current = current.left until current.left.nil?\n current\n end", "def rel_x\n return x - Graphics.width/2\n end", "def rel_x\n return x - Graphics.width/2\n end", "def neighbours_off_end(node)\n # Find all arcs that include this node in the right place\n passable_nodes = []\n @arcs.get_arcs_by_node_id(node.node_id).each do |arc|\n if arc.begin_node_id == node.node_id and arc.begin_node_direction\n # The most intuitive case\n passable_nodes.push nodes[arc.end_node_id]\n elsif arc.end_node_id == node.node_id and !arc.end_node_direction\n passable_nodes.push nodes[arc.begin_node_id]\n end\n end\n return passable_nodes.uniq\n end", "def moveto(x, y)\n @x = x \n @y = y \n @real_x = @x * 128\n @real_y = @y * 128\n @prelock_direction = 0\n end", "def remove_edge(eid)\n p1, p2 = @points_of_edge[eid]\n @points_of_edge[eid] = nil\n @length_of_edge[eid] = nil\n\n @edges_of_point[p1] -= [eid]\n @edges_of_point[p2] -= [eid]\n end", "def erode mask\n morph mask, :erode\n end", "def set_default_left_and_right\n maxright = dataset.nested.max(self.class.qualified_right_column).to_i || 0\n # adds the new node to the right of all existing nodes\n self.left = maxright + 1\n self.right = maxright + 2\n end", "def flip_range_neg_xy(points); points.collect{ |v| Vertex.new(v.y,v.x)}; end", "def sel_left\n [sel_x, pos_x].min\n end", "def mid\n (min + max) / 2\n end", "def part_of_right_x?(x, y)\n x == (size - y - 1)\n end", "def promote_node_two_children(parent_node,target_node, max_left_sub_tree, max_left_sub_tree_parent_node)\n\n if parent_node.value <= max_left_sub_tree.value\n parent_node.right = max_left_sub_tree\n promote_node(max_left_sub_tree_parent_node, max_left_sub_tree.left)\n\n\n max_left_sub_tree.left = target_node.left if !target_node.left.nil?\n\n max_left_sub_tree.right = target_node.right if !target_node.right.nil?\n\n\n\n\n\n\n else\n parent_node.left = max_left_sub_tree\n promote_node(max_left_sub_tree_parent_node, max_left_sub_tree.left)\n\n\n max_left_sub_tree.left = target_node.left if !target_node.left.nil?\n\n max_left_sub_tree.right = target_node.right if !target_node.right.nil?\n\n\n end\n\n end", "def find_edge(node_1, node_2)\n @edges[node_1][node_2] if @edges[node_1]\n end", "def leaky_rectified_liniar_unit(x)\n\t\tx > 0 ? x : (x / 5.0)\n\tend", "def common_face(edge2)\n end", "def common_face(edge2)\n end", "def expand(current_node)\r\n x = current_node.x\r\n y = current_node.y\r\n return [ Astar_Node.new(x, y-1, @closed_nodes.size-1, -1, -1, -1), # north\r\n Astar_Node.new(x, y+1, @closed_nodes.size-1, -1, -1, -1), # south\r\n Astar_Node.new(x+1, y, @closed_nodes.size-1, -1, -1, -1), # east\r\n Astar_Node.new(x-1, y, @closed_nodes.size-1, -1, -1, -1) ] # west\r\n end", "def create_edge origin, destiny\n return GraphElements::EdgeDefault.new origin, destiny\n end", "def right_edge\n x = width-1\n @image.get(x,0,x,height).pixels\n end", "def resize_to_local_point_locked_aspect!(grab_handle, point, minimum_dimension=1,limit_by:nil)\n\t\ttype, target_indicies = VEC_TO_TRANSFORM_DATA[grab_handle.to_a]\n\t\t\n\t\tnew_verts = self.verts\n\t\t\n\t\t\n\t\t# store original dimensions before any transforms\n\t\toriginal_width = self.width\n\t\toriginal_height = self.height\n\t\t\n\t\t\n\t\t# compute minimum dimensions\n\t\tlimit_by ||= :smaller\n\t\tlimits = [:smaller, :larger, :width, :height]\n\t\tunless limits.include? limit_by\n\t\t\traise \"Must declare kwarg 'limit by' with one of these values: #{limits.inspect}\"\n\t\tend\n\t\t\n\t\t\n\t\tminimum_x, minimum_y =\n\t\t\tminimum_dimensions(width, height, minimum_dimension, limit_by)\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\tcase type\n\t\t\twhen :edge\n\t\t\t\t# these two lines stolen from CP::Shape::Rect#resize_by_delta!\n\t\t\t\ta,b = target_indicies.collect{|i| new_verts[i] }\n\t\t\t\taxis = ( a.x == b.x ? :x : :y )\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# TODO: consider possible problems of dividing delta by two. Should you use integer division? The underlying measurements are pixels, so what happens when you divide in half? Will you ever lose precision?\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# -----\n\t\t\t\t# Compare these two ratios:\n\t\t\t\t# > minimum dimension calculation\n\t\t\t\t# > scale the secondary axis\n\t\t\t\t# \n\t\t\t\t# The two ratios are similarly calculated, but you can't reuse the same variable.\n\t\t\t\t# The top ratio is based on the which side is longer, \n\t\t\t\t# but the bottom ratio is based on which side is being directly manipulated.\n\t\t\t\t# -----\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# Scale the edge along the axis shared by it's verts\n\t\t\t\t# Then, scale along the other axis\n\t\t\t\tif axis == :x\n\t\t\t\t\t# primary x\n\t\t\t\t\tself.resize_to_local_point!(grab_handle, point, minimum_x)\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t# secondary y\n\t\t\t\t\tratio = original_height / original_width\n\t\t\t\t\t\n\t\t\t\t\tnew_width = self.width\n\t\t\t\t\tnew_height = new_width * ratio\n\t\t\t\t\t\n\t\t\t\t\tdelta = new_height - original_height\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\ta = CP::Vec2.new(0, 1)\n\t\t\t\t\tb = CP::Vec2.new(0, -1)\n\t\t\t\t\tself.resize_by_delta!(a, a*delta/2, minimum_y)\n\t\t\t\t\tself.resize_by_delta!(b, b*delta/2, minimum_y)\n\t\t\t\telse # axis == :y\n\t\t\t\t\t# primary y\n\t\t\t\t\tself.resize_to_local_point!(grab_handle, point, minimum_y)\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t# secondary x\n\t\t\t\t\tratio = original_width / original_height\n\t\t\t\t\t\n\t\t\t\t\tnew_height = self.height\n\t\t\t\t\tnew_width = new_height * ratio\n\t\t\t\t\t\n\t\t\t\t\tdelta = new_width - original_width\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\ta = CP::Vec2.new( 1, 0)\n\t\t\t\t\tb = CP::Vec2.new(-1, 0)\n\t\t\t\t\tself.resize_by_delta!(a, a*delta/2, minimum_x)\n\t\t\t\t\tself.resize_by_delta!(b, b*delta/2, minimum_x)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\twhen :vert\n\t\t\t\t# should perform calculations completely within local space\n\t\t\t\t# (this allows for advanced coordinate space manipulations, ex: body rotation)\n\t\t\t\t\n\t\t\t\tcenter = self.center\n\t\t\t\tvert = new_verts[target_indicies.first]\n\t\t\t\tdiagonal = (vert - center).normalize\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tpoint -= center\n\t\t\t\t\t# perform projection relative to center\n\t\t\t\t\t# ( this coordinate space can not be rotated or skewed\n\t\t\t\t\t# so you can get in / out via translation only )\n\t\t\t\t\tpoint = point.project(diagonal)\n\t\t\t\tpoint += center\n\t\t\t\t\n\t\t\t\t# all calculations in local space\n\t\t\t\t# some calculations local to center, rather than local origin\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# scale each axis separately, so each can be clamped independently\n\t\t\t\tself.resize_to_local_point!(CP::Vec2.new(grab_handle.x,0), point, minimum_x)\n\t\t\t\tself.resize_to_local_point!(CP::Vec2.new(0,grab_handle.y), point, minimum_y)\n\t\t\t\t\n\t\t\t\t\n\t\t\twhen :center\n\t\t\t\t# nothing\n\t\tend\n\tend", "def find_min(target_node)\n while (target_node.left_child)\n target_node = target_node.left_child \n end\n return target_node\n end", "def set_right_start_point\n @leading_x = 0\n @leading_y = find_right_entry\n end", "def rectified_liniar_unit(x)\n\t\tx > 0 ? x : 0.0\n\tend", "def clamp_dimensions!(verts, original_verts, minimum_dimension)\n\t\tvec = (verts[1] - verts[3])\n\t\twidth = vec.x\n\t\theight = vec.y\n\t\t\n\t\t\n\t\tverts.zip(original_verts).each do |vert, original|\n\t\t\t[\n\t\t\t\t[:x, width],\n\t\t\t\t[:y, height]\n\t\t\t].each do |axis, length|\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tif vert.send(axis) != original.send(axis)\n\t\t\t\t\t# vert has been transformed on the given axis\n\t\t\t\t\t\n\t\t\t\t\t# if the dimension on this axis is too short...\n\t\t\t\t\tif length < minimum_dimension\n\t\t\t\t\t\t# counter-steer in the direction of the original vert\n\t\t\t\t\t\tdirection = ( vert.send(axis) > original.send(axis) ? 1 : -1 )\n\t\t\t\t\t\t# by an amount that would make the dimension equal the minimum\n\t\t\t\t\t\tdelta = minimum_dimension - length\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\teval \"vert.#{axis} += #{delta} * #{direction} * -1\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t\n\t\t\tend\n\t\tend\n\t\t\n\tend", "def clamp(value, minimum_inclusive, maximum_inclusive)\n\n if minimum_inclusive > maximum_inclusive\n\n swap = minimum_inclusive\n\n minimum_inclusive = maximum_inclusive\n maximum_inclusive = swap\n end\n\n value < minimum_inclusive ? minimum_inclusive : value < maximum_inclusive ? value : maximum_inclusive\n end", "def add_edge(x, y) # from x to y\n if @nodes.key?(x) and @nodes.key?(y)\n if @edges.key?(x)\n unless @edges[x].include?(y)\n @edges[x] << y\n end\n end\n if @back_edges.key?(y)\n unless @back_edges[y].include?(x)\n @back_edges[y] << x\n end\n end\n else\n raise RuntimeError.new \"#{x} and #{y} not both present\"\n end\n end" ]
[ "0.60007447", "0.59062517", "0.5570146", "0.5416254", "0.53874373", "0.5354287", "0.53438634", "0.5325704", "0.53165317", "0.529577", "0.5265072", "0.52428883", "0.51784825", "0.51435274", "0.50972915", "0.50513065", "0.5031904", "0.50245386", "0.50062066", "0.5004022", "0.50039935", "0.49984443", "0.49975085", "0.49932307", "0.49887523", "0.49837697", "0.4980372", "0.49734402", "0.4942277", "0.49399745", "0.49372068", "0.49153697", "0.49153697", "0.49122745", "0.491219", "0.49083984", "0.490708", "0.4898079", "0.48971385", "0.48803023", "0.48695153", "0.48511454", "0.4845872", "0.48407584", "0.48341212", "0.48279428", "0.48249304", "0.48219138", "0.48000753", "0.479815", "0.47784388", "0.4776403", "0.47670877", "0.47538468", "0.47517115", "0.47346106", "0.47345668", "0.47314173", "0.47281557", "0.47131866", "0.47100025", "0.46998778", "0.46934906", "0.4680159", "0.4678534", "0.4678206", "0.46719187", "0.4667507", "0.46669677", "0.46611375", "0.46609855", "0.4660123", "0.46547166", "0.46499652", "0.46375248", "0.46375248", "0.4636935", "0.46347672", "0.46264073", "0.46247947", "0.46211267", "0.46199358", "0.46171156", "0.46142262", "0.46112254", "0.4609126", "0.46058327", "0.459933", "0.45982897", "0.45982897", "0.4595534", "0.45933712", "0.45850208", "0.4583941", "0.45827582", "0.45772767", "0.45741397", "0.45687354", "0.45681447", "0.456616" ]
0.9105717
0
don't think this is needed? would assume a user is trying to sign up via extension
def install end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attemp_signup\n\n end", "def signup\n end", "def signup\n end", "def sign_up(resource_name, resource)\n true\n end", "def allow_sign_up?\n @allow_sign_up\n end", "def client_sign_up\n\n end", "def sign_up(resource_name, resource)\n true\n end", "def sign_up(resource_name, resource)\n true\n end", "def candidate_sign_up\n\n end", "def sign_up_candidate\n\n end", "def signup_info\n end", "def sign_up(resource_name, resource)\n end", "def registration_approval_required?; false; end", "def create\n if Feedbunch::Application.config.signups_enabled\n super\n else\n Rails.logger.warn \"Creation of new user attempted, but signups are disabled\"\n redirect_to root_path\n end\n end", "def allow_registration?\n true\n end", "def signup\n\n\t\temail = params[:email] # Extract the email from the params of the signup form\n\t\ttimezone = params[:timezone] # Extract the timezone from the params of the signup form\n\n\t\t@url = uniqueUrlKeyGenerator # Generate a unique url key\n\t\told_user = User.find_by_email(email)\n\n\t\t# If user exists\n\t\tif !old_user.nil?\n\t\t # If user is not registered\n\t\t if !old_user.registered?\n\t\t # Send welcome email again and save him\n\t\t old_user.sendWelcomeEmail\n\t\t old_user.save\n\t\t end\n\t\tend\n\n\t\t# Find the user in the user db with the same email as extracted in the params\n\t\tcheck_users = User.find_by_email(email)\n\n\t\t#create a new PotentialUser object with the extarcted email, timezone and url key\n\t\tuser = User.new(email: email, url: @url, timezone: timezone, day: 1, registered: false)\n\n\t\t# If no such user exists\n\t\tif check_users.nil?\n\n\t\t#If the new user is valid and can be saved\n\t\t if user.save\n\t\t user.sendWelcomeEmail\n\t\t @title = \"Thank you for signing up\"\n\t\t @result = \"A confirmation email with instructions has been sent to you\"\n\t\t @result2 = \"Your unique access key is: \" + @url\n\n\t\t#If not valid\n\t\t else\n\t\t #Set @result as the error message\n\t\t @title = \"Looks like something went wrong ...\"\n\t\t @result = \"Email #{user.errors[:email][0]}.\".html_safe\n\t\t end\n\n\t\t#User by this email already exists\n\t\telse\n\n\t\t if !check_users.registered?\n\t\t\t # Result instance variable for the view\n\t\t\t @title = \"Looks like something went wrong ...\"\n\t\t\t @result = \"User by this email already exists, but we sent another confirmation email just in case\"\n\t\t\t else\n\t\t\t @title = \"Looks like something went wrong ...\"\n\t\t\t @result = \"User by this email already exists\"\n\t\t end\n\n\tend\n\n\t\t# Respond to only javascript, set for AJAX\n\t\trespond_to do |format|\n\t\t\tformat.js\n\t\tend\n\tend", "def allow_user_signup?\n Rails.configuration.allow_user_signup\n end", "def allow_user_signup?\n Rails.configuration.allow_user_signup\n end", "def sign_up(resource_name, resource)\n # DO NOT sign_in(resource_name, resource)\n end", "def check_user_signup_allowed\n redirect_to root_path unless Rails.configuration.allow_user_signup\n end", "def do_signup\n hobo_do_signup do\n if this.errors.blank?\n #flash[:notice] << \"You must activate your account before you can log in. Please check your email.\"\n flash[:notice] << \" Your account has been created.\"\n\n # FIXME: remove these two lines after you get email working reliably\n # and before your application leaves its sandbox...\n #secret_path = user_activate_path :id=>this.id, :key => this.lifecycle.key\n #flash[:notice] << \"The 'secret' link that was just emailed was: <a id='activation-link' href='#{secret_path}'>#{secret_path}</a>.\"\n else\n flash[:notice] = @this.errors.full_messages.join(\"<br/>\")\n logger.info \"error is \" + flash[:notice]\n end\n\n end\n end", "def test_cant_signup_user_with_taken_email\n begin\n user = $dav_dev_auth.signup($testuser_user[\"email\"], \"password\", \"testtest\")\n assert false\n rescue StandardError => e\n assert e.message.include? \"2702\"\n end\n end", "def sign_up\n self.sign_up_link\n CreateNewAccount.new @browser\n end", "def signup_with_email\n @status, @msg, @data = UserValidator.signup_with_email(params)\n @status, @msg, @data = UserManager.signup_with_email(params) if @status\n end", "def requires_user_existence!\n if not e.user_exists?\n error \"You have to setup your user before you can perform this action.\"\n exit\n end\n end", "def signup!(params)\n self.login = params[:user][:login]\n self.email = params[:user][:email]\n generate_temporary_password!\n save_without_session_maintenance\n end", "def signup!(params)\n self.username = params[:user][:username]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def signup!(params)\n self.username = params[:user][:username]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def signup\n return set_session_user_id!(nil, 'Введите данные.') { render :signup_new } if params_valid?(:signup)\n LdapService.mutex.synchronize do\n ldap_result = LdapService.new.add(\n email: params[:email],\n password: params[:password],\n name: params[:name],\n surname: params[:surname],\n role: 'painter'\n )\n return set_session_user_id!(nil, 'Невозможно зарегистрироваться.') { render :signup_new } if ldap_result.blank?\n user = User.find_by(ldap_id: ldap_result[:ldap_id])\n return set_session_user_id!(user.id, 'Вы вошли!') { redirect_to root_url } if user.present?\n user = User.new(ldap_result)\n return set_session_user_id!(user.id, 'Вы вошли!') { redirect_to root_url } if user.save\n set_session_user_id!(nil, 'Возникли проблемы. Попробуйте еще раз.') { render :signup_new }\n end\n end", "def after_create_account(user, auth)\n # not required\n end", "def user_signup_finished?\n unless is_guest?\n if current_user == User.friendly.find(params[:id])\n @user = current_user\n if @user.valid? == false # If user's attributes are missing, sends them to 'Finish Profile Page'\n flash[:alert] = \"Please finish signing up for Ossemble by entering your First Name, Last Name, Birth Date, Address, and ensuring your location is correct.\"\n redirect_to edit_user_registration_path # Finish Profile Page Setup with form\n end\n end\n end\n end", "def meetup_auto_create_account?\n self.meetup_auto_create_account\n end", "def user_verification?; end", "def signup_greeting(user, mode = :normal_signup)\n @user = user\n @need_password = (mode == :free_money_signup)\n swapidy_sendmail :to => @user.email, :subject => \"Welcome to Swapidy\"\n end", "def on_users_account\n true\n end", "def signup!(user, prompt, &block)\n return save(true, &block) if openid_complete?\n return signup_as_invitee!(user, prompt, &block) if user and user[:invitation_id]\n signup_without_credentials!(user, &block)\n end", "def signup!(user, prompt, &block)\n return save(true, &block) if openid_complete?\n return signup_as_invitee!(user, prompt, &block) if user and user[:invitation_id]\n signup_without_credentials!(user, &block)\n end", "def signup!(params)\n self.login = params[:user][:login]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def sign_up(resource_name, resource)\n # sign_in(resource_name, resource)\n end", "def signup(user_that_just_signed_up)\n mail to: user_that_just_signed_up.email,\n subject: \"You signed up for YardSale\"\n end", "def register\n if @user.blank? || (!@user.is_registered && @user.tips.count == 0 && @user.votes.count == 0)\n redirect_to :profile, alert: \"Registration Impossible. There is nothing to register\"\n elsif @user.is_registered\n redirect_to :profile, alert: \"Registration Impossible. Account already registered\"\n else\n if @user.register(user_registration_params.to_h)\n #cookies.delete(\"user_id\") #don't delete the cookie, just in case I'm logging in on someone else's device.\n sign_in @user\n redirect_to :profile, notice: \"Account successfully registered. You can now login from anywhere !\"\n else\n redirect_to :profile, alert: \"Registration failed. #{@user.errors.full_messages.to_sentence}\"\n end\n end\n end", "def signup!(params)\n self.email = params[:user][:email]\n self.name = params[:user][:name]\n self.password = params[:user][:password]\n #save_without_session_maintenance\n end", "def sign_up(resource_name, resource)\n sign_in(resource_name, resource) unless current_user_is_admin?\n end", "def signup \n @page_title = 'Sign Up'\n return if generate_blank\n params[:user][:email].downcase!\n @user = User.new(params[:user]) \n if params[:account_type].nil?\n flash[:warning] = \"Please select a user type (student/renter/instructor).\"\n return\n end\n User.transaction(@user) do\n @user.new_password = true\n\n unless LoginEngine.config(:use_email_notification) and LoginEngine.config(:confirm_account)\n @user.email_verified = true\n end\n \n if @user.save\t\n @group = Group.find_by_group_name(params[:account_type]) \n @user.add_group @group\n key = @user.generate_security_token\n url = url_for(:action => 'home', :user_id => @user.id, :key => key)\n UserNotify.deliver_signup(@user, params[:user][:password], url)\n\n flash[:notice] = 'Signup successful! Please check your email at '\n flash[:notice] << @user.email + ' and confirm your membership before using the system.'\n @session[:user] = nil\n redirect_to '/'\n end\n end\n end", "def create\n if resource.active_invitation? && !resource.new_record?\n # The user record already existed\n if resource.update(sign_up_params)\n resource.accept_invitation\n\n # Follow the standard Devise logic to sign in\n set_flash_message! :notice, :signed_up\n sign_up(resource_name, resource)\n respond_with resource, location: after_sign_up_path_for(resource)\n else\n # Follow the standard Devise failed registration logic\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n elsif !Rails.configuration.x.recaptcha.enabled || verify_recaptcha(action: 'register')\n\n # Devise doesn't set a flash message for some reason if its going to fail\n # so do it here\n super do |user|\n flash[:alert] = _('Unable to create your account!') unless user.valid?\n\n # Attach the Shib eppn if this is part of an SSO account creation\n hash = session.fetch('devise.shibboleth_data', {})\n if hash.present? && user.valid?\n user.attach_omniauth_credentials(scheme_name: 'shibboleth',\n omniauth_hash: hash)\n end\n end\n else\n flash[:alert] = _('Invalid security check! Please make sure your browser is up to date and then try again')\n end\n end", "def not_account_owner\n not_account_owner_in_signup && !is_account_owner? \n end", "def user_verification; end", "def register\n # running successfully\n # class_name = params[:user_type].camelize\n # registration_stuff = params[\"#{params[:user_type].to_sym}\"]\n # template = \"#{params[:user_type].pluralize}/new\"\n # save_credentials(class_name, registration_stuff, template)\n\n if(params[:user_type] == 'job_seeker')\n class_name = \"JobSeeker\"\n registration_stuff = params[:job_seeker]\n template = \"job_seekers/new\"\n save_credentials(class_name, registration_stuff, template)\n else\n class_name = \"Employer\"\n registration_stuff = params[:employer]\n template = \"employers/new\"\n save_credentials(class_name, registration_stuff, template)\n end\n end", "def ensure_signed_up!\n # current_user\n end", "def social_sign_up\n user = nil\n external_uid = nil\n success_message = nil\n ActiveRecord::Base.transaction do\n user = User.where(email: params[:user_email]).first_or_initialize\n success_message = \"User retrieved.\"\n if user.new_record?\n success_message = \"User saved.\"\n user.do_password_validation = false\n UserMailer.signupsuccess(user).deliver\n return unless user.save\n end\n external_uid = ExternalUID.where(uid: params[:uid], user_id: user.id).first_or_initialize\n if external_uid.new_record?\n raise ActiveRecord::Rollback unless external_uid.save\n end\n end\n if user.persisted? && external_uid.persisted?\n render :json => {:error => false, :description => success_message, :auth_token => user.authentication_token}\n else\n errors = {}\n errors[:user] = user.errors.messages if user.errors.any?\n errors[:uid] = external_uid.errors.messages if external_uid.errors.any?\n render :json => {:error => true, :description => \"Error saving user\", :errors => errors}, status: 500\n end\n rescue Exception => e\n render :json => {:error => true, :description => \"Internal Server Error.\"}, status: 503 and return\n end", "def sign_up_client\n\n end", "def submit_signup_details_without_password\n user = Users.signup_user_without_password\n enter_signup_details(user)\n # @pages.page_home.signup_register_button\n end", "def finish_signed_up_but_email_not_confirmed?\n @identity.update(identity_params) && !@identity.confirmed?\n end", "def signup_with_facebook\n @status, @msg, @data = UserValidator.signup_with_facebook(params)\n @status, @msg, @data = UserManager.signup_with_facebook(params) if @status\n end", "def sign_up(resource_name, resource)\n redirect_to users_url\n end", "def not_account_owner_in_signup\n enterprise.blank? || !enterprise.id.nil?\n end", "def signup\n client.signup(\n params[:user],\n params[:password]\n )\n end", "def sign_up_helper\n username = prompt.ask(\"Enter Username\")\n while User.find_by(name: username.downcase)\n puts \"This username is already taken, please create a different username\"\n username = prompt.ask(\"Enter Username\")\n end\n password = prompt.ask(\"Enter Password\")\n self.user = User.create(name: username, password: password)\n puts \"Sign up complete.\"\n sleep(0.8)\n puts \"Let's Get Cookin #{self.user.name.upcase}!!!\"\n sleep(1.5)\n main_menu\n end", "def create \n\t\t@user=User.new\n\t\t@user.provider=\"native\"\n\t\t@user.assign_attributes(signup_params)\n\t\t@user.save!\n\t\tflash[:success]=\"Thanks for joining SPACEF!T, #{@user.name ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t@user.email.split(\"@\").first }. \"\n\t\tsign_in!(@user, true)\n\t\tredirect_to root_path\n\trescue ActiveRecord::RecordInvalid,\n\t\t\t\t\tActiveRecord::RecordNotUnique => e\n\t\tflash.now[:error]=\"We were not able to sign you up, please correct the following fields\"\n\t\t@user.wipe\n\t\trender 'new'\n\tend", "def create\n @user = User.find_by_email_and_activated(params[:user][:email], false) # We can only register a user that hasn't been activated yet.\n \n if @user\n # Cases 2 and 3.\n params[:user].delete(:email) # They can't arbitrarily change their email address.\n @user.update_attributes(params[:user])\n else\n # Case 1.\n @user = User.new(params[:user].merge({:perishable_token => \"\"}))\n @user.reset_perishable_token!\n end\n \n # This is true when a user finishes their registration from a link in their email (Case 3),\n # which means we don't need to send an activation link.\n if params[:token] && User.find_using_perishable_token(params[:token], 0) == @user\n activate\n else\n # Cases 1 and 2. \n # Saving without session maintenance to skip\n # auto-login which can't happen here because\n # the user has not yet been activated\n if @user.save_without_session_maintenance\n @user.deliver_activation_instructions\n flash[:notice] = 'Registration successful. Please check your email to activate your account.'\n redirect_to shares_path\n else\n flash[:error] = 'Registration failed. Please try again.'\n redirect_to root_path\n end\n end\n end", "def signup\n if params[:user]\n if User.exists?(id: params[:user_id])\n #check if the user already exists in database\n flash[:notice] = \"User already exists. Please log in\"\n redirect_to root_path()\n else\n auth_user\n end\n else\n auth_user\n end\n \n end", "def marketing_sign_up\n if params[:profile][:email].empty_or_nil?\n flash[:newsletter_error] = \"Email can't be blank.\"\n show_failure(nil) and return\n end\n\n if logged_in? && current_profile.email != params[:profile][:email]\n flash[:newsletter_error] = \"Email entered does not match the email in your account.\"\n show_failure(nil) and return\n end\n profile = Profile.find_by_email(params[:profile][:email])\n\n if profile && profile.has_account? && !logged_in?\n flash[:newsletter_error] = \"Email found. Login to manage your marketing preferences.\"\n show_failure(nil) and return\n end\n\n profile ||= Profile.new(params[:profile])\n profile = update_profile_for_marketing_sign_up(profile)\n if save_objeck(profile)\n Notifier.trigger_marketing_sign_up_thank_you(profile.id)\n show_success(profile.class.to_s)\n set_session_profile(profile) unless logged_in?\n else\n show_failure(profile)\n end\n end", "def signup_admin_if_not_users \r\n redirect_to :signup if User.count==0\r\n end", "def signup\n return if generate_blank\n params[:user].delete('form')\n params[:user].delete('verified') # you CANNOT pass this as part of the request\n @user = User.new(params[:user])\n begin\n User.transaction(@user) do\n @user.new_password = true\n unless LoginEngine.config(:use_email_notification) and LoginEngine.config(:confirm_account)\n @user.verified = 1\n end\n if @user.save\n key = @user.generate_security_token\n url = url_for(:action => 'home', :user_id => @user.id, :key => key)\n flash[:notice] = 'Signup successful!'\n if LoginEngine.config(:use_email_notification) and LoginEngine.config(:confirm_account)\n UserNotify.deliver_signup(@user, params[:user][:password], url)\n flash[:notice] << ' Please check your registered email account to verify your account registration and continue with the login.'\n else\n flash[:notice] << ' Please log in.'\n end\n redirect_to :action => 'login'\n end\n end\n rescue Exception => e\n flash.now[:notice] = nil\n flash.now[:warning] = 'Error creating account: confirmation email not sent'\n logger.error \"Unable to send confirmation E-Mail:\"\n logger.error e\n end\n end", "def test_non_ttc_user_signup\n u = new_non_ttc_user\n assert_rc u.res\n u.login\n assert_equal 3, u.res[\"user\"][\"settings\"][\"current_status\"]\n end", "def sign_up(resource_name, resource)\r\n # Create an account for this user.\r\n account = Account.create(name: \"#{resource.email}'s account\")\r\n \r\n # Sign in the user (from the original Devise::RegistrationsController).\r\n sign_in(resource_name, resource)\r\n end", "def register_with_password\n pu = params[:user]\n if user = User.find_by_email(pu[:email]) \n # Go ahead and sign the user in if he mistakenly used the signup form to login. But dont bother updating any attributes\n # that area different from the last time he used the sign up screen. \n if pu[:password] == user.password\n set_and_cookie_current_user user\n render :json => {:success => {:user => user}}\n else\n render :json => {:fail => {:email => user.email}}\n end\n else user = User.create!( pu.merge(:status => :active,:app_version => params[:v]) )\n set_and_cookie_current_user user\n render :json => {:success => {:user => user}}\n end \n end", "def sign_up\n NexaasID::Resources::SignUp.new(api_token, config)\n end", "def sign_up(useremail, password)\n if new_user_available(useremail)\n query = \"INSERT INTO Users (useremail, password) VALUES('#{useremail}', '#{password}')\"\n @connection.exec(query)\n end\n end", "def sign_up\n user = User.new(user_params); user.id = SecureRandom.uuid # genrating secure uuid token\n if user.save\n image_url = \"\"\n image_url = url_for(user.profile_photo) if user.profile_photo.attached?\n render json: { email: user.email, first_name: user.first_name, last_name: user.last_name, profile_photo: image_url, \"UUID\" => user.id, \"Authentication\" => user.authentication_token }, status: 200\n else\n render json: user.errors.messages, status: 400\n end\n rescue StandardError => e # rescue if any exception occurr\n render json: { message: \"Error: Something went wrong... #{e}\" }, status: 400\n end", "def signup_allowed?(dd)\n dd.deadline_type_id == DeadlineHelper::DEADLINE_TYPE_SIGN_UP\n end", "def registration_required?\n not hosted?\nend", "def registration_required?\n not hosted?\nend", "def signup(params)\n if self.is_client?\n user = self.employees.create!(name: params[:name],last_name: params[:last_name],\n email: params[:email],password: params[:password],password_confirmation: params[:password_confirmation])\n GroupsUser.create!(user_id: user.id,group_id: params[:group_id])\n user\n else\n user = self.clients.create!(name: params[:name],email: params[:email],password: params[:password],\n password_confirmation: params[:password_confirmation])\n end\n end", "def sign_up\n @user = User.new(user_params)\n if @user.save\n sign_in(@user)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def self_signup?\n user_id == author_id\n end", "def signup_facebook_user\n @user = Spree::User.new(user_params_list)\n @user.facebook_token = session[:fb_token]\n\n @user.addresses.first.country_id = 503\n\n if @user.save\n session\n signin_vegan_user(@user.id)\n else\n render 'complete_signup'\n end\n end", "def wechat\n if wechat_user_solver.success?\n # is it a new user ?\n handle_after_sign_up! wechat_user_solver.data[:customer]\n sign_in_user wechat_user_solver.data[:customer]\n else\n failure\n end\n end", "def create\n\n if User.exists? email: params[:user][:email]\n user = User.find_by_email params[:user][:email]\n if user.invited_to_sign_up?\n Rails.logger.warn \"User #{user.email} was invited but instead of accepting the invitation is signing up normally. Destroying old user record before signup.\"\n user.destroy\n end\n end\n\n super\n end", "def sso_user_upn\n request.env[\"HTTP_EPPN\"] || (current_user && current_user.upn) || (current_user && current_user.email) \n end", "def success_signup\n redirect_to root_path if flash[:notice].nil? || flash[:notice] != t('devise.registrations.signed_up_but_inactive')\n end", "def authenticate_user_with_sign_up!\n unless user_signed_in?\n store_location_for(:user, request.fullpath)\n redirect_to new_user_registration_path, alert: t(\"create_an_account_first\")\n end\n end", "def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n flash[:notice] = \"Sign up successfully.\"\n end", "def onthefly_creation_failed(user, auth_source_options = { })\n @user = user\n session[:auth_source_registration] = auth_source_options unless auth_source_options.empty?\n render :action => 'register'\n end", "def create_account\n\n end", "def create_authy_id\n authy = Authy::API.register_user(\n email: current_user.email,\n cellphone: current_user.phone_number,\n country_code: current_user.country_code\n )\n\n current_user.update(\n authy_id: authy.id\n )\n end", "def have_account?\n false\n end", "def trust_registration_number; end", "def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end", "def signup\n @user = User.new\n end", "def signup\n @user = User.new\n end", "def signup_user(options = {})\n options[:email] = options[:email] || $settings.customer_service_email\n options[:password] = options[:password] || 'foobar'\n\n # signup\n json = post_api '/api/session/signup', {\n 'email' => options[:email],\n 'password' => options[:password],\n 'name' => options[:email].split('@')[0]\n }\n assert_equal 200, json['status'], json['message']\n\n login_user(options) unless options[:skip_login]\n end", "def can_create_personal_login?\n teacher_managed_account? # once parent e-mail is added, we should check for it here\n end", "def new_user_setup\n \t@person = Person.find(:first, :conditions => {:email_address => params[:email_address]})\n \tif @person.nil?\n \t\tflash[:error] = \"Invalid Email Address.\"\n \t\tredirect_to :action => 'register'\n\t\telsif !@person.password_hash.blank?\n \t\tflash[:error] = \"Your account has already been set up. See the system administrator for help logging in.\"\n \t\tredirect_to :action => 'index'\n \telsif params[:password] != params[:password_confirm]\n \t\tflash[:error] = \"Passwords don't match. Please try again.\"\n \t\tredirect_to :action => 'register'\n \telse\n \t\t@person.password = params[:password]\n \t\t@person.save!\n \t\tredirect_to home_url(@person)\n \tend\n end", "def sign_up\n @user = User.new\n end", "def createUser(nickname) \n usr = User.new(nickname)\n backend_addUser(usr) \n end", "def signup_as_invitee!(user, prompt, &block)\n self.attributes = user if user\n logged = prompt and validate_password_with_openid?\n save_with_block(logged, &block)\n end", "def sign_up_new_user\n user = User.make\n visit \"/\"\n find('#join_now_link').click\n click_link 'Sign up with Email'\n fill_in 'Full name', with: user.full_name\n fill_in 'Email', with: user.email\n find('#user_password').set user.password\n find('#user_password_confirmation').set user.password\n click_button 'Sign up'\n user\nend", "def sign_up(resource_name, resource)\r\n sign_in(resource_name, resource)\r\n end", "def make_user\n end", "def user_have\n unless current_user\n redirect_to root_path, :alert => \"Зарегистрируйтесь или войдите\"\n end\n end" ]
[ "0.7856785", "0.7408825", "0.7408825", "0.7070852", "0.7024728", "0.70140195", "0.70129937", "0.70129937", "0.6928799", "0.6921636", "0.6823892", "0.67243785", "0.67159003", "0.6688691", "0.6627532", "0.6609308", "0.66084903", "0.66084903", "0.65946454", "0.65833044", "0.65738666", "0.6541816", "0.6510773", "0.64782387", "0.6457208", "0.64562386", "0.64269805", "0.64269805", "0.642109", "0.6418381", "0.63927746", "0.63882726", "0.6383959", "0.6326715", "0.6324077", "0.6323279", "0.6323279", "0.6319888", "0.6317111", "0.6314225", "0.63139945", "0.63127226", "0.63109845", "0.62956184", "0.6287054", "0.6274796", "0.6265389", "0.6265331", "0.6264505", "0.62584704", "0.6257825", "0.6254524", "0.62529093", "0.62526494", "0.62487745", "0.6243332", "0.62380975", "0.6220049", "0.6209227", "0.61946535", "0.6189091", "0.61742276", "0.61691034", "0.61618215", "0.61616975", "0.6154464", "0.6152839", "0.6147779", "0.6138685", "0.61378336", "0.6136306", "0.6133879", "0.6133879", "0.6133111", "0.61266685", "0.6124357", "0.61091405", "0.61063105", "0.60978985", "0.6096266", "0.609392", "0.6081673", "0.60807127", "0.60794", "0.6072903", "0.607221", "0.60716707", "0.60688275", "0.60651684", "0.6057021", "0.6057021", "0.60542804", "0.60527104", "0.60453975", "0.6043113", "0.60425127", "0.60294896", "0.60248303", "0.60225755", "0.602032", "0.6018368" ]
0.0
-1
For the purposes of this kata, some tests may have multiple answers; any valid solutions will be accepted. The input will always be valid (numbers will be an array of length 2 or greater, and all of the items will be numbers; target will always be the sum of two different items from that array). Based on: => twoSum [1, 2, 3] 4 === (0, 2)
def two_sum(numbers, target) arr = numbers num = target index_array = [] return_array = [] current_index = 0 loop do idx_counter = current_index current_element = arr[current_index] loop do break if idx_counter >= arr.length - 1 next_index = idx_counter + 1 next_element = arr[next_index] if current_element + next_element == num index_array << current_index << next_index end idx_counter += 1 end if return_array == [] current_index += 1 end break if return_array.reduce(:+) == num end p index_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def two_sum(array, target)\n\n !!array.uniq.combination(2).detect { |a, b| a + b == target }\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 is_sum_of_any_two(target, numbers)\n for index1 in 0...numbers.length - 1\n for index2 in index1 + 1...numbers.length\n if (numbers[index1] + numbers[index2]) == target\n return true\n end\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n \n\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 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 okay_two_sum?(arr, target)\n arr.sort!\n pairs = arr.combination(2)\n pairs.any? { |pair| pair.sum == target }\nend", "def bad_two_sum?(arr, target)\n (0...arr.length).each do |idx1|\n return true if arr[idx1] == target\n (idx1+1...arr.length).each do |idx2|\n return true if (arr[idx1] + arr[idx2]) == target\n end\n end\n false\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 bad_two_sum?(arr, target)\n (0...(arr.length - 1)).each do |idx1|\n ((idx1 + 1)...arr.length).each do |idx2|\n return true if arr[idx1] + arr[idx2] == target\n end\n end\n false\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 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 bad_two_sum?(arr, target_sum)\n arr.length.times do |i|\n (arr.length - i - 1).times do |j|\n return true if arr[i] + arr[j + i + 1] == target_sum\n end\n end\n false\nend", "def bad_two_sum?(arr, target)\n (0...arr.length).each do |i|\n (i+1...arr.length).each do |j|\n return true if arr[i] + arr[j] == target\n end\n end\n false\nend", "def bad_two_sum?(arr, target_sum) \n arr.each_with_index do |num, idx|\n arr.each_with_index do |num2, idx2|\n next if idx2 == idx\n return true if num2 + num == target_sum\n end\n end\n false\nend", "def bad_two_sum?(arr, target_sum)\n arr.each_with_index do |num1, i|\n arr[i..-1].each do |num2|\n next if num1 == num2\n\n return true if (num1 + num2) == target_sum\n end\n end\n\n false\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 bad_two_sum?(arr, target)\n arr.each_with_index do |num1,idx1|\n i = idx1 + 1\n while i < arr.length\n return true if num1 + arr[i] == target\n i+=1\n end\n end\n false\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 hardcore_two_sum?(arr, target)\n nums = {}\n arr.each{ |n| nums[n] = n }\n\n nums.each do |n,_|\n needed = target - n\n return true if !nums[needed].nil? && nums[needed] != n\n end\n\n false\nend", "def bad_two_sum?(arr, target_sum)\n arr.each_with_index do |o_el, o_idx|\n arr.each_with_index do |i_el, i_idx|\n next if o_idx == i_idx\n return true if o_el + i_el == target_sum\n end\n end\n false\nend", "def bad_two_sum?(arr, target_sum)\n arr.size.times do |start|\n (start + 1...arr.size).each do |stop|\n return true if arr[start] + arr[stop] == target_sum\n end\n end\n false\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?(arr, target_sum)\n (0...arr.length).each do |i|\n (0...arr.length).each do |j|\n next if i == j\n return true if arr[i] + arr[j] == target_sum\n end\n end\n\n false\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(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 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 bad_two_sum?(arr, target_sum)\n (0...arr.length - 1).each do |i|\n (i + 1..arr.length - 1).each do |j|\n return true if arr[i] + arr[j] == target_sum\n end\n end\n false\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(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 bad_two_sum?(arr, target)\n\n arr.each.with_index do |x, idx|\n arr.each.with_index do |y, idy|\n if idx == idy\n next\n else\n if (x + y) == target\n return true\n end\n end\n end\n end\n\n return false\n\nend", "def okay_two_sum?(array, target)\n array.sort!\n (1...array.length).each do |idx|\n return true if array[idx-1] + array[idx] == target\n end\n false\nend", "def bad_two_sum?(array, target)\n array.each.with_index do |el1, idx1|\n array.each.with_index do |el2, idx2|\n if el1 + el2 == target && idx2 > idx1\n return true \n end\n end\n end\n false \nend", "def bad_two_sum?(arr, target_sum)\n (0...arr.length - 1).each do |i|\n (i+1...arr.length).each do |j|\n return true if arr[i] + arr[j] == target_sum\n end\n end\n return false\nend", "def okay_two_sum?(arr, target_sum)\n arr.sort!\n i, j = 0, arr.length - 1\n\n until i == j\n this_sum = arr[i] + arr[j]\n return true if this_sum == target_sum\n this_sum < target_sum ? i += 1 : j -= 1\n end\n\n false\nend", "def okay_two_sum?(arr, target)\n # arr.sort.bsearch(target)\n # arr.combination(2).any? { |el,el2| return true if el + el2 == target }\n\n sorted = arr.sort\n (0...sorted.lentgh-1).each do |i|\n if arr[i] + arr[i+1] == target \n return true \n end \n end \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 bad_two_sum?(arr, target)\n zero_sum = false\n arr.each_with_index do |el1, idx1|\n arr.drop(idx1).each do |el2|\n zero_sum = true if el1 + el2 == target\n end\n end\n zero_sum\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort \n arr.each_with_index do |el, idx|\n new_arr = arr[0...idx]+arr[idx+1..-1]\n result = my_bs(new_arr, target-el)\n return true if result\n end\n false\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?(arr, target_sum) \n hash = Hash.new(0)\n arr.each do |num|\n hash[num] = 1 \n end \n\n arr.each do |num|\n num2 = target_sum - num\n next if num2 == num\n next if hash[num2].nil?\n return true if hash[num2] == 1\n end\n false\nend", "def two_sum?(array, target_sum)\n array_hash = {}\n array.each do |el|\n array_hash[el] = true\n end\n\n array.each_with_index do |el|\n next if target_sum - el == el\n return true if array_hash[target_sum - el]\n end\n false\nend", "def okay_two_sum?(arr, target)\n return false if arr.size < 2\n sum = arr.first + arr.last\n if sum > target\n arr.pop\n okay_two_sum?(arr, target)\n elsif sum < target\n arr.shift\n okay_two_sum?(arr, target)\n else\n true\n end\nend", "def bad_two_sum?(arr, target_sum)\n arr.each_with_index do |ele1, idx1|\n arr.each_with_index do |ele2,idx2|\n if idx2 > idx1 && arr[idx1] + arr[idx2] == target_sum\n return true\n end\n end\n end\n false\nend", "def sumTwo(array, sum)\n array.each do |number|\n array.each do |number2|\n if (number + number2) == sum\n return \"#{number}, #{number2}\"\n else\n return \"no pairs sum to this input\"\n end\n end\n end\nend", "def okay_two_sum?(arr, target) # => [0,1,5,7] \n sorted = qs(arr)\n\n (0...sorted.length-1).each do |i|\n return true if sorted[i] + sorted[i + 1] == target\n end\n\n false\nend", "def okay_two_sum?(arr, target)\n i = 0\n j = arr.length - 1\n\n while i < j\n if arr[i] + arr[j] == target\n return true\n elsif arr[i] + arr[j] < target\n i += 1\n else\n j -= 1\n end \n end\n false\nend", "def two_sum(array, target)\n arr_a = array.pop()\n var = false \n array.each { |x| \n return true if arr_a + x == target\n }\n return false \nend", "def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend", "def bad_two_sum?(arr, target_sum)\r\n arr.each_with_index do |ele1, i1|\r\n arr.each_with_index do |ele2, i2|\r\n return true if i2 != i1 && (ele1 + ele2 == target_sum)\r\n end\r\n end\r\n\r\n false\r\nend", "def two_number_sum(array, target_sum)\n i = 0\n while i <= array.length - 1\n j = array.length - 1\n while j >= 0\n if array[i] + array[j] == target_sum && i != j\n return [array[i], array[j]]\n end\n j -= 1\n end\n i += 1\n end\n return []\nend", "def two_numer_sum(array, target_sum)\n nums = {}\n array.each { |num|\n potential_match = target_sum - num\n if nums[:potential_match]\n return [potential_match, num]\n else\n nums[:num] = true\n end\n }\n return []\nend", "def okay_two_sum?(arr, target_sum)\n sorted = arr.sort\n (0...sorted.length).each do |i|\n (i + 1...sorted.length).each do |j|\n return true if sorted[i] + sorted[j] == target_sum\n break if sorted[i] + sorted[j] > target_sum\n end\n end\n false\nend", "def two_sum?(arr, target_sum)\n hash = Hash.new\n\n arr.each do |el|\n hash[el] = el\n end\n\n arr.each do |el|\n target = target_sum - el\n return false if target == el\n return true if hash.key?(target)\n end\n\n false\nend", "def okay_two_sum?(arr, target_sum)\n array = arr.sort #n log n\n i1 = 0\n i2 = array.length-1\n while i1 < i2\n case array[i1] + array[i2] <=> target_sum\n when 0\n return true\n when -1\n i1 += 1\n when 1\n i2 -= 1\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n\n arr.sort\n i = 0 \n j = arr.length\n until arr[i] + arr[j] == target || i == arr.length - 1\n return true \n end\n\n return false\n \n\nend", "def okay_two_sum?(arr, target_sum)\n\narr.sort!\n\nreturn false if arr[-1] < target_sum\n\ni = 0\ni += 1 until arr[i] > target_sum\n\nresult = []\nnew_arr = arr[0...i]\n(0...new_arr.length - 1).each do |i|\n (i+1...new_arr.length).each do |j|\n result << new_arr[i] + new_arr[j]\n end\n end\n result.include?(target_sum)\n\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 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, 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(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 bad_two_sum?(arr, target_sum) #O(n^2)\n (0...arr.length).each do |i|\n (i+1...arr.length).each do |j|\n return true if arr[i] + arr[j] == target_sum\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n\n arr = arr.sort!\n\n i = 0\n j = arr.length - 1\n\n while i < j\n sum = arr[i] + arr[j]\n if sum < target\n i += 1\n elsif sum > target\n j -=1\n else\n return true\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n\n arr = arr.sort\n i, j = 0, arr.length - 1\n\n while i < j \n case (arr[i] + arr[j]) <=> target\n when 0\n return true\n when -1\n i += 1\n when 1\n j -= 1\n end\n end\n false\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 good_two_sum?(arr, target)\n counter_hash = Hash.new(0)\n arr.each do |el|\n counter_hash[el] += 1\n end\n\n arr.each do |el|\n search_val = target - el\n if counter_hash[search_val] && search_val==el\n return true if counter_hash[search_val] >= 2\n elsif counter_hash[search_val] > 0\n return true\n end\n end\n false\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 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 better_two_sum?(arr, target_sum)\n hash = {}\n arr.each_with_index do |ele,i|\n hash[ele] = i\n end\n arr.each_with_index do |ele,i|\n target = target_sum - ele\n return true if !hash[target].nil? && i != hash[target]\n end\n \n false\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 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(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 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 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 two_sum?(arr, target)\n sum_hash = {}\n\n arr.each do |el|\n sum_hash[el] = (target-el)\n return true if sum_hash[target-el]\n end\n\n false\nend", "def okay_two_sum?(arr, target_sum)\n sorted_arr = arr.sort\n (0...sorted_arr.length).each do |i|\n next if i+1 == sorted_arr.length\n return true if sorted_arr[i] + sorted_arr[i+1] == target_sum\n end\n\n return false\nend", "def two_sum?(arr, target_sum)\n hash = Hash.new(0)\n arr.each_with_index do |num, idx|\n hash[num] = idx\n end\n arr.each_with_index do |num, idx|\n return true if hash.has_key?(target_sum - num) && idx != hash[target_sum - num]\n end\n false\nend", "def two_sum_brute nums\n (0...nums.length).each do |i|\n ((i + 1)...nums.length).each do |j|\n if nums[i] + nums[j] == 0\n return i, j\n end\n end\n end\n nil\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)\r\n arr = arr.sort #n log n\r\n i, j = 0, arr.length - 1 #2\r\n\r\n while j > i #n\r\n curr_sum = arr[i] + arr[j]\r\n if curr_sum > target\r\n j -= 1\r\n elsif curr_sum < target\r\n i += 1\r\n else\r\n return true\r\n end\r\n end\r\n false\r\nend", "def okay_two_sum(array, target_sum)\n array.sort\n i = 0\n j = array.length - 1\n while i < j\n case (array[i] + array[j]) <=> target_sum\n when -1\n i += 1\n when 0\n return true\n when 1\n j -= 1\n end\n end\n false\nend", "def two_sum?(arr,target)\n\n hash = Hash.new {|h,k| h[k] = [] }\n arr.each_with_index do |ele, i|\n hash[ele] << i\n end\n\n hash.each do |k, v|\n if k == target/2\n return true if v.length > 1\n elsif hash.has_key?(target-k)\n return true \n end\n end\n false\nend", "def okay_two_sum?(array,target_sum)\n array_sorted = array.sort\n i = 0\n j = array.length - 1\n\n until i == j\n sum = array_sorted[i] + array_sorted[j]\n return true if sum == target_sum\n if sum < target_sum\n i += 1\n elsif sum > target_sum\n j -= 1\n end\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n new_arr = arr.sort\n i = 0\n j = arr.length - 1\n while i < j \n if (arr[i] + arr[j] ) == target_sum\n return true\n elsif \n (arr[i] + arr[j] ) > target_sum\n j -= 1\n else\n i += 1\n end\n \n \n end\n false\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 okay_two_sum_a?(arr, target_sum)\n arr = arr.sort\n i, j = 0, arr.length - 1\n\n while i < j\n case (arr[i] + arr[j]) <=> target_sum\n when 0\n return true\n when -1\n i += 1\n when 1\n j -= 1\n end\n end\n\n false\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort\n\n lowest = 0\n highest = arr.length - 1\n\n while lowest != highest\n return true if sorted[lowest] + sorted[highest] == target\n if sorted[lowest] + sorted[highest] > target \n highest -= 1\n elsif sorted[lowest] + sorted[highest] < target\n lowest += 1 \n end \n end \n false\nend", "def two_sum?(arr, target_sum)\n arr_hash = Hash.new\n arr.each do |num|\n if num * 2 == target_sum\n return true if arr.count(num) == 2\n else\n arr_hash[num] = target_sum - num\n end\n end\n arr_hash.each_value do |v|\n return true if arr_hash[v]\n end\n false # if one of the key + one of the value = target_sum then return true\nend", "def two_sum?(arr, target_sum)\n summands = {}\n\n arr.each do |num|\n return true if summands[target_sum - num]\n\n summands[num] = true\n end\n\n false\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort\n (0...arr.length).each do |idx|\n diff = target - arr[idx]\n return true if arr.include?(diff) && idx != arr.index(diff)\n end\n false\nend", "def two_sum?(arr, target_sum)\n\n hash = {}\n arr.each_with_index do |i,idx|\n hash[i] = idx\n end\n arr.each_with_index do |j, idx2|\n return true if hash.has_key?(target_sum - j) && hash[target_sum-j] != idx2\n end\n false\n\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 okay_two_sum?(arr, target)\n arr.sort!\n\n lhs = 0\n rhs = arr.length - 1 \n\n while lhs < rhs\n total = arr[lhs] + arr[rhs]\n if total > target\n rhs -= 1\n elsif total < target\n lhs += 1\n elsif total == target\n return true\n end\n\n end\n\n return false\nend", "def two_sum(nums, target)\n table = {}\n i = 0\n while i < nums.length\n table[target - nums[i]] = i\n i += 1\n end\n \n j = 0\n while j < nums.length\n if table.key?(nums[j]) && j != table[nums[j]]\n return [j, table[nums[j]]] \n end\n j += 1\n end\nend", "def two_sum?(arr, target)\n hash = Hash.new(nil)\n\n arr.each do |ele|\n hash[ele] = target - ele\n end\n\n hash.values.any? do |value|\n hash[value] != nil && hash[value] != value\n end\nend", "def two_sum?(arr, target)\n hash = {}\n arr.each do |el|\n if hash[target - el]\n return true\n end\n hash[el] = true\n end\n false\nend", "def two_sum?(arr, target)\n hash = Hash.new { |h, k| h[k] = 0}\n arr.each do |el|\n hash[el] += 1\n end\n\n arr.each do |el|\n hash2 = hash.dup\n hash2[el] -= 1\n return true if hash2[target - el] > 0\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 two_sum?(arr,target)\n hash = Hash.new(0)\n arr.each do |el|\n hash[el] += 1\n difference = target - el\n if el == difference\n return true if hash[difference] > 1\n else\n return true if hash[difference] > 0\n end\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n sorted = arr.sort\n\n low, high = 0, arr.length - 1\n until low >= high\n case sorted[low] + sorted[high] <=> target_sum\n when -1\n low += 1\n when 0\n return true\n when 1\n high -= 1\n end\n end\n false\nend" ]
[ "0.793329", "0.78229356", "0.7804584", "0.78011733", "0.77942216", "0.7748239", "0.77399576", "0.7694916", "0.76921254", "0.76395905", "0.76329875", "0.7619972", "0.76186657", "0.7565763", "0.7555659", "0.755184", "0.7548577", "0.7542765", "0.75381136", "0.75241697", "0.75232756", "0.75107795", "0.75105935", "0.75028133", "0.74962276", "0.7485961", "0.7432527", "0.740335", "0.7402851", "0.7400185", "0.73932993", "0.7391281", "0.7386929", "0.7385469", "0.73790646", "0.73713934", "0.7360749", "0.73281926", "0.73257387", "0.73187995", "0.72897804", "0.72895175", "0.72838527", "0.7281089", "0.7275263", "0.7275022", "0.7259884", "0.7258472", "0.72556305", "0.7251498", "0.72472304", "0.7238447", "0.72287786", "0.72178316", "0.7213081", "0.721032", "0.7207184", "0.72043866", "0.7201973", "0.7170763", "0.71681637", "0.7167726", "0.7163452", "0.7157559", "0.715399", "0.7150864", "0.714769", "0.7146618", "0.7145639", "0.7143176", "0.71423864", "0.7135566", "0.71340317", "0.71279156", "0.7122386", "0.7118888", "0.7107268", "0.71035624", "0.7100132", "0.7095908", "0.7095064", "0.7093882", "0.70723146", "0.70698833", "0.70666647", "0.7065528", "0.7057992", "0.70535666", "0.70532274", "0.7049683", "0.703883", "0.70347506", "0.70342237", "0.70305526", "0.70301825", "0.70293534", "0.70208997", "0.70113826", "0.70094335", "0.7008257" ]
0.7509018
23
Use callbacks to share common setup or constraints between actions.
def set_product_in_storehouse @product_in_storehouse = ProductInStorehouse.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def set_actions\n actions :all\n end", "def define_action_helpers?; end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def before_action \n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def after_set_callback; end", "def initialize(*args)\n super\n @action = :set\nend", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def setup(&blk)\n @setup_block = blk\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def duas1(action)\n action.call\n action.call\nend", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def call\n setup_context\n super\n end" ]
[ "0.61642385", "0.60448", "0.5945487", "0.5915654", "0.58890367", "0.58330417", "0.5776098", "0.5703048", "0.5703048", "0.5654613", "0.5620029", "0.5423114", "0.540998", "0.540998", "0.540998", "0.5393666", "0.53783023", "0.53568405", "0.53391176", "0.5339061", "0.53310865", "0.5312988", "0.529798", "0.52968603", "0.52962637", "0.52577317", "0.5244704", "0.5236856", "0.5236856", "0.5236856", "0.5236856", "0.5236856", "0.5233461", "0.52322435", "0.5227552", "0.52224743", "0.5217851", "0.521241", "0.52069896", "0.5206555", "0.5176617", "0.51738507", "0.51725876", "0.51660734", "0.51605034", "0.51571786", "0.5152762", "0.5152164", "0.5151477", "0.5145819", "0.51408994", "0.5134412", "0.5114031", "0.5113695", "0.5113695", "0.5108603", "0.5107358", "0.5090405", "0.50889385", "0.50817686", "0.5081617", "0.50658226", "0.50551206", "0.5051746", "0.5049091", "0.5049091", "0.5034681", "0.5024972", "0.5021291", "0.5016024", "0.50134826", "0.50008893", "0.50000244", "0.4999155", "0.49907947", "0.49907947", "0.49853387", "0.49796683", "0.4979596", "0.49778128", "0.49673793", "0.49662578", "0.49587822", "0.4956063", "0.49550167", "0.49523485", "0.4951614", "0.49452996", "0.49442068", "0.49336892", "0.49306205", "0.49264124", "0.49259305", "0.4925823", "0.49229056", "0.4918999", "0.49171805", "0.49167436", "0.4916559", "0.49153692", "0.49148256" ]
0.0
-1
Only allow a trusted parameter "white list" through.
def product_in_storehouse_params params.require(:product_in_storehouse).permit(:quantity, :product_id, :storehouse_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def filtered_parameters; end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n [:rating, :review]\n end", "def valid_params?; end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def filter_parameters; end", "def filter_parameters; end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def check_params; true; end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def list_params\n params.permit(:name)\n end", "def check_params\n true\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def additional_permitted_params\n []\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end", "def allow_params_authentication!; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end", "def quote_params\n params.permit!\n end", "def list_params\n params.permit(:list_name)\n end", "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def all_params; end", "def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end", "def source_params\n params.require(:source).permit(all_allowed_params)\n end", "def user_params\n end", "def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\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 permitted_params\n @wfd_edit_parameters\n end", "def user_params\r\n end", "def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def params_permit\n params.permit(:id)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def filter_params\n params.permit(*resource_filter_permitted_params)\n end", "def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend", "def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end", "def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end", "def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def argument_params\n params.require(:argument).permit(:name)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def parameters\n nil\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end", "def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end", "def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end", "def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end" ]
[ "0.7123669", "0.7054077", "0.69472784", "0.6902165", "0.6736001", "0.671985", "0.6687218", "0.6676269", "0.66602534", "0.6556639", "0.6527985", "0.645892", "0.645072", "0.64494324", "0.6445436", "0.64350927", "0.6415061", "0.6415061", "0.6393001", "0.6378958", "0.6378958", "0.63741165", "0.636044", "0.63547933", "0.6285727", "0.6278816", "0.6246161", "0.6227885", "0.6225383", "0.622309", "0.62118614", "0.6209478", "0.6176166", "0.6172476", "0.6169111", "0.6158942", "0.6143792", "0.6136175", "0.6123085", "0.6108703", "0.6100308", "0.60760003", "0.6054003", "0.60426265", "0.6036683", "0.6029898", "0.6020772", "0.6020169", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.6019335", "0.60176134", "0.6006716", "0.6003403", "0.6001569", "0.5995689", "0.5994206", "0.599406", "0.5985532", "0.59828365", "0.5977637", "0.59767246", "0.5970349", "0.59662646", "0.5966073", "0.5966073", "0.5957612", "0.5951802", "0.5950822", "0.59498274", "0.5942674", "0.59319496", "0.5931201", "0.59265846", "0.59238476", "0.5918484", "0.59172106", "0.59133804", "0.59125537", "0.59080327", "0.59065026", "0.5906122", "0.59027356", "0.59009796", "0.589672", "0.5895543", "0.5893694" ]
0.0
-1
Public: serves as the getter and setter for the Array of Symbol column names. Union join the existing column names with those passed Example: ``` header.columns :name, :age, :location ``` `args` Array of Symbol arguments passed Returns as Array of Symbols
def columns(*args) @columns = @columns | args.map(&:to_sym) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def column(name, *args)\n define_method name do\n instance_variable_get(\"@_#{name}\")\n end\n define_method \"#{name}=\" do |val|\n instance_variable_set(\"@_#{name}\", val)\n end\n self.columns = columns.concat([[name].concat(args)])\n end", "def named_columns( names )\n @columns.values_at( *names )\n end", "def get_columns!( *headers )\n data.get_columns!( *headers ); self\n end", "def columns(names, options=nil)\n names.each do |name|\n column name, options\n end\n end", "def column_names\n @column_names ||= columns.collect(&:name)\n end", "def method_missing(name, *args)\n @columns[args[0]] = [name, args[1]]\n end", "def column_names\n columns.map(&:name)\n end", "def update_columns=(column_names)\n @update_columns = Array(column_names)\n end", "def header_array\n @columns.collect {|c|\n if @table[c]\n @table[c][:name].to_s\n else\n \"\"\n end\n }.compact\n end", "def column_list(columns)\n if columns.empty?\n WILDCARD\n else\n m = columns.map do |i|\n i.is_a?(Hash) ? i.map{|kv| \"#{literal(kv[0])} AS #{quote_identifier(kv[1])}\"} : literal(i)\n end\n m.join(COMMA_SEPARATOR)\n end\n end", "def column_names\n @column_names ||= @columns.keys\n end", "def column_names\n @column_names = columns_hash.keys\n end", "def paired_column_names\n column_names.select { |column| column_names.include? \"#{column}Label\" }.map(&:to_sym)\n end", "def column_names\n keys = COLUMN_NAMES\n keys.map{|key| [Person.field_name(key), key]}\n end", "def columns(table_name, name = nil) end", "def columns(cols, options = {})\n if cols.is_a? Array\n cols.each.map{|c| columns(c.first, c.count >= 2 ? c.second : {}) if c.is_a? Array }\n return\n end\n cols.split(/,\\s/).each do |col|\n n = col.split(':')\n id = n.first\n name = n.count > 1 ? n.second : nil\n search = col_by_id id\n tmp = search.nil? ? Flexigrid::Column.new(self, id, name) : search\n options.map{|key,value| tmp.send(key.to_s + \"=\",value)}\n tmp.update!\n @columns << tmp\n @columns_hash[tmp.id] = tmp\n end\n end", "def columns(*array)\n unless array.empty?\n if (array.class == Array)\n options[:columns] = array\n else\n raise \"Report columns must be specified.\"\n end\n else\n options[:columns]\n end\n end", "def column_names\n @column_names || owner.column_names\n end", "def wanted_column_names\n nil # nil => select all columns\n end", "def all\n __getobj__.column_names\n end", "def column_names\n @columns.keys\n end", "def columns\n @columns = columns_hash.values\n end", "def column_names\n raise NotSupportedError\n end", "def columns\n raise NotImplementedError\n end", "def columns\n @columns ||= [];\n end", "def column_names\n columns_in_order.map { |c| c.name }\n end", "def columns_param(column_names)\n column_names.map! { |name| escape(name) }\n \"columns:!(#{column_names.join(',')})\"\n end", "def columns(*cs)\n if cs.empty?\n super\n else\n self.columns = cs\n self\n end\n end", "def columns\n @columns ||= []\n end", "def columns\n @columns ||= begin\n column_indexes.map do |e|\n e.map do |e|\n @input[e]\n end\n end\n end\n end", "def columns; @columns_hash.values; end", "def columns *args\n if args.size > 0 && configurable?\n raise 'please call %s only inside #model block' % __method__ if model_defined?\n return @columns_opted = false if args.first == false\n @columns_opted = args\n end\n end", "def column_names\n self[0].keys\n end", "def my_quote_columns(*column_names)\n quoted_table_name = connection.quote_table_name(self.table_name)\n column_names.map { |column_name| \"#{ quoted_table_name }.#{ connection.quote_column_name(column_name) }\" }.join(\", \")\n end", "def columns\n if @column_names\n columns = []\n\n # First match against fully named columns, e.g. 'attribute:name'\n @column_names.each{|cn| columns << owner.columns_hash[cn] if owner.columns_hash.has_key?(cn)}\n\n # Now match against aliases if the number of columns found previously do not\n # match the expected @columns_names size, i.e. there's still some missing.\n if columns.size != @column_names.size\n columns_left = @column_names - columns.map{|column| column.name}\n owner.columns_hash.each { |name,column| columns << column if columns_left.include?(column.alias) }\n end\n\n columns\n else\n owner.columns\n end\n end", "def synthetic_columns\n @columns ||= [:id]\n end", "def quoted_columns_for_index(column_names, options = {})\n return [column_names] if column_names.is_a?(String)\n\n quoted_columns = Hash[\n column_names.map do |name|\n column_name, operator_name = split_column_name(name)\n\n result_name = if column_name =~ FUNCTIONAL_INDEX_REGEXP\n _name = column_name.gsub(/\\b#{$3}\\b/, quote_column_name($3))\n _name += \" #{operator_name}\"\n _name\n else\n quote_column_name(column_name).dup\n end\n [column_name.to_sym, result_name]\n end\n ]\n\n add_options_for_index_columns(quoted_columns, **options).values.join(\", \")\n end", "def headers\n columns.map(&:header)\n end", "def symbols cols\n decode_values :symbol, cols, true\n end", "def columns(*args,&block)\n if (args && args.any?) || block_given? || !@columns\n self.columns = Lolita::Configuration::Columns.new(dbi,*args,&block)\n end\n @columns\n end", "def symbol cols\n decode_values :symbol, cols\n end", "def get_columns_name\r\n columns = []\r\n if @columns != nil\r\n @columns.each do |column|\r\n columns.push column\r\n end\r\n end\r\n \r\n if @stats != nil and @stats.length > 0\r\n @stats.each do |stat|\r\n columns.push stat.to_column_name\r\n end\r\n end\r\n \r\n return columns\r\n end", "def column_header_names\r\n column_headers.collect {|header| header.name }\r\n end", "def columns!\n @columns = nil\n columns\n end", "def normalize_array_of_columns(arry)\n arry.map do |f| \n if f.is_a?(Hash)\n f.symbolize_keys\n else\n f.to_sym\n end\n end\n end", "def options_to_columns(options)\n columns = []\n options[:columns].each do |column|\n if column.kind_of? Symbol # a column from the database, we don't need to do anything\n columns << {:name => column, :attribute => column}\n elsif column.kind_of? Hash\n columns << {:name => column[:name], :special => column}\n end\n end\n columns\n end", "def colnames(_J=:*)\n return @colnames if _J == :*\n case _J\n when Array then\n _J.collect do |j| colnames(j) end.flatten(1)\n when Range then\n first = if _J.first < 0 then ncols + _J.first else _J.first end\n last = if _J.last < 0 then ncols + _J.last else _J.last end\n first.upto(last).collect do |j| @colnames[j] end\n when Integer then\n _J = ncols + _J if _J < 0\n [@colnames[_J]]\n when Regexp then\n colnames.select do |colname| _J.match?(colname) end\n else\n [_J]\n end\n end", "def modify_columns(columns)\n columns\n end", "def method_missing(name, *args, &block)\n if args.empty?\n RibColumn.new(name, @columns, @primary_keys, @to_avoid, @default_values)\n else\n hsh = args.grep(Hash).first || {}\n args.grep(Symbol).each do |ss|\n hsh[ss] = true\n end\n \n hsh = {:column => name}.merge(hsh)\n \n if hsh[:primary_key]\n @primary_keys << name.to_s\n end\n\n if hsh[:avoid]\n @to_avoid << name.to_s.downcase\n if hsh[:default]\n @default_values[name.to_s.downcase] = hsh[:default]\n end\n end\n \n @columns[name.to_s] = [hsh[:column].to_s, hsh]\n nil\n end\n end", "def include_columns(mod, args = {})\n mod.columns.each do |column|\n column = args[:record] ? DerefColumn.new(column, args[:record]) : column\n columns_hash[column.name] = column\n end\n end", "def list_columns\n columns\n end", "def columns_hash\n @columns_hash ||= columns.inject({}){|r,c| r.merge(c[:name].to_sym => c)}\n end", "def columns\n _columns || columns!\n end", "def columns(table = nil)\n if table\n @columns[table]\n else\n ActiveSupport::Deprecation.warn('call columns with a table name!')\n @columns.dup\n end\n end", "def unique_index_columns\n inventory_collection.manager_ref_to_cols.map(&:to_sym)\n end", "def columns\n select.inject([]) do |columns, column|\n columns << {\n :type => all_columns[column][:type]\n }.merge({\n :id => column.to_s,\n :label => column_label(column)\n })\n end\n end", "def column_named(name) #nodoc\n @_column_hashes[name.to_sym]\n end", "def columns_statement(properties, qualify)\n properties.map { |property| property_to_column_name(property, qualify) }.join(', ')\n end", "def columns()\n cols = {}\n prefix = \"#{@opts[:pname]}_\"\n fspec = @opts[:fspec]\n\n fspec.params.each do |name, opts|\n cols[prefix + name] = opts\n end\n cols \n end", "def columns\n @header.to_a\n end", "def columns; @columns; end", "def field_names\n @field_names ||= (columns_hash.keys.map(&:to_sym) rescue [])\n end", "def multi_get_columns(column_family, keys, *options)\n OrderedHash[*keys.map { |key| [key, get_columns(column_family, key, *options)] }._flatten_once]\n end", "def get_columns\n return @columns\n end", "def columns\n @columns_hash.values\n end", "def col(cname)\n map {|x| x[cname]}\n end", "def searchable_columns\n # Declare strings in this format: ModelName.column_name\n #@searchable_columns ||= ['Take.name', 'Movement_Group.name', 'SensorType.name', 'Mover.name', 'DataTrack.technician', 'DataTrack.recorded_on']\n @searchable_columns ||= ['Take.name', 'MovementGroup.name', 'Mover.name']\n end", "def columns\n @columns ||= ControllerAction.columns.map(&:name).map(&:to_sym).reject{|c|c==:id}\n end", "def appropriate_column_listing(columns = columns_joined)\n has_config_defined_cols? == true ? \", #{columns}\" : \"\"\n end", "def quote_returning_column_names(table_ref, pk, action)\n returning_columns = []\n returning_columns << pk if suppress_composite_primary_key(pk)\n returning_columns += ApplicationRecord.custom_returning_columns(table_ref, action)\n returning_columns.map { |column| quote_column_name(column) }\n end", "def raw cols\n ret = get_values [*cols]\n\n case cols\n when Array\n ret\n else\n ret.first\n end\n end", "def columns\n @columns ||= [].tap do |fields|\n @model.columns.reject { |a| a.name.match(/_id$/) }.each do |column|\n fields << resolve(column.type, column.name)\n end\n end\n end", "def cols_array\n arr = Array.new\n @columns_hash.each{|k,v| arr << k}\n return arr\n end", "def to_a\n columns.map { |column| @attributes[column.name.underscore] }\n end", "def association_columns(*by_associations) #:nodoc:\n if @object.present?\n @object.class.reflections.collect do |name, _|\n if by_associations.present?\n name if by_associations.include?(_.macro)\n else\n name\n end\n end.compact\n else\n []\n end\n end", "def columns\n [\"#{@base}.*\"]\n end", "def columns(table_name, *rest)\n @table.fields.map {|s| ::ActiveRecord::ConnectionAdapters::Column.new(s.to_s, nil, String)}\n end", "def searchable_columns\n # Declare strings in this format: ModelName.column_name\n @searchable_columns ||= ['DataTrack.name', 'Take.name', 'SensorType.name', 'Mover.name', 'DataTrack.technician', 'DataTrack.recorded_on']\n end", "def query_part_column_names\n remote_query_column_types.map{|name, type| name}.join(\"\\n , \")\n end", "def wire_jqgrid_columns\n omit_options = [:custom, :action, :object, :field]\n (@columns.map {|c| jqgrid_make_js(c.dup.delete_if{|k,v| omit_options.include?(k)})}).join(',')\n end", "def importable_columns\n @column_names ||= self.class.spreadsheet_columns\n end", "def column(column_name, options={})\n columns_object.merge(column_name.to_sym => options)\n end", "def columns\n @columns ||= @stats.values.flatten.map { |a| a.column_name }\n end", "def sql_columns\n columns.map(&:sql_names).compact.flatten.uniq.map(&:to_s)\n end", "def quoted_columns_for_index(column_names, options = {})\n option_strings = Hash[column_names.map {|name| [name, '']}]\n\n if supports_index_length?\n option_strings = add_index_length(option_strings, column_names, options)\n end\n\n if supports_index_collation?\n option_strings = add_index_collation(option_strings, column_names, options)\n end\n\n if supports_index_operator_class?\n option_strings = add_index_operator_class(option_strings, column_names, options)\n end\n\n if supports_index_sort_order?\n option_strings = add_index_sort_order(option_strings, column_names, options)\n end\n\n if supports_index_null_order?\n option_strings = add_index_null_order(option_strings, column_names, options)\n end\n\n column_names.map {|name| quote_column_name(name) + option_strings[name]}\n end", "def order_by *columns\n @order += [columns].flatten\n end", "def columns_with_redhillonrails_core\n unless @columns\n columns_without_redhillonrails_core\n cols = columns_hash\n indexes.each do |index|\n next if index.columns.blank?\n column_name = index.columns.reverse.detect { |name| name !~ /_id$/ } || index.columns.last\n column = cols[column_name]\n column.case_sensitive = index.case_sensitive?\n column.unique_scope = index.columns.reject { |name| name == column_name } if index.unique\n end\n end\n @columns\n end", "def columns\n @columns ||= @csv_data[0].zip(*@csv_data[1..])\n end", "def column_names\n @entity_columns.map(&:name).map(&:to_s)\n end", "def query_columns\n explicit_columns\n end", "def columns!\n ds = clone(opts.merge(:sql => \"SELECT TOP 1 [T1].* FROM (#{opts[:sql]}) \\\"T1\\\"\"))\n ds.each{break}\n\n if cols = ds.cache[:_columns]\n self.columns = cols\n else\n []\n end\n end", "def sortable_columns\n # list columns inside the Array in string dot notation.\n # Example: 'users.email'\n # @sortable_columns ||= []\n @sortable_columns ||= ['users.name' ,'users.phone', 'users.address']\n end", "def prepared_columns(cols)\n RUBY_VERSION >= '1.9' ? cols.sort : cols.sort_by(&:to_s)\n end", "def def_column_accessor(*columns)\n clear_setter_methods_cache\n columns, bad_columns = columns.partition{|x| /\\A[A-Za-z_][A-Za-z0-9_]*\\z/.match(x.to_s)}\n bad_columns.each{|x| def_bad_column_accessor(x)}\n im = instance_methods.map(&:to_s)\n columns.each do |column|\n meth = \"#{column}=\"\n overridable_methods_module.module_eval(\"def #{column}; self[:#{column}] end\", __FILE__, __LINE__) unless im.include?(column.to_s)\n overridable_methods_module.module_eval(\"def #{meth}(v); self[:#{column}] = v end\", __FILE__, __LINE__) unless im.include?(meth)\n end\n end", "def association_columns(*by_associations) #:nodoc:\n if @object.present? && @object.class.respond_to?(:reflections)\n @object.class.reflections.collect do |name, association_reflection|\n if by_associations.present?\n name if by_associations.include?(association_reflection.macro)\n else\n name\n end\n end.compact\n else\n []\n end\n end", "def column_aliases\n @column_aliases ||= Hash.new\n end", "def all_columns\n datasource_columns.merge(virtual_columns)\n end", "def [](name)\n @columns_hash[name.to_s]\n end", "def columns \n []\n end", "def def_column_accessor(*columns)\n clear_setter_methods_cache\n columns, bad_columns = columns.partition{|x| /\\A[A-Za-z_][A-Za-z0-9_]*\\z/.match(x.to_s)}\n bad_columns.each{|x| def_bad_column_accessor(x)}\n im = instance_methods\n columns.each do |column|\n meth = \"#{column}=\"\n overridable_methods_module.module_eval(\"def #{column}; self[:#{column}] end\", __FILE__, __LINE__) unless im.include?(column)\n overridable_methods_module.module_eval(\"def #{meth}(v); self[:#{column}] = v end\", __FILE__, __LINE__) unless im.include?(meth)\n end\n end" ]
[ "0.67176396", "0.6573496", "0.6359476", "0.63251394", "0.6318875", "0.6301126", "0.6283622", "0.62174606", "0.6158545", "0.61454654", "0.61317384", "0.6100073", "0.60494655", "0.60126406", "0.6001964", "0.59973043", "0.59882694", "0.59270465", "0.58921254", "0.5890751", "0.5879554", "0.58632505", "0.5859514", "0.58445877", "0.58433115", "0.5813035", "0.5804172", "0.578813", "0.5785983", "0.5772055", "0.57697964", "0.57561785", "0.57552475", "0.5744248", "0.5739374", "0.57369065", "0.5734505", "0.5710341", "0.5709958", "0.5704033", "0.5699825", "0.56797457", "0.5671941", "0.5667485", "0.56642014", "0.56620455", "0.5659264", "0.565045", "0.5639256", "0.5627633", "0.56246734", "0.5624557", "0.56205875", "0.559875", "0.5587956", "0.55808234", "0.55803984", "0.5574807", "0.5563041", "0.5562522", "0.5560808", "0.55581594", "0.5554901", "0.55514413", "0.55257165", "0.5524733", "0.55116475", "0.5511481", "0.5508301", "0.55040133", "0.54984117", "0.5485019", "0.54653066", "0.54648376", "0.54524785", "0.5447025", "0.54448056", "0.5442083", "0.5439166", "0.54207736", "0.54169774", "0.540996", "0.5408238", "0.54039466", "0.53885245", "0.5381067", "0.5378162", "0.5377837", "0.53742003", "0.53705096", "0.5364946", "0.5354191", "0.5352294", "0.53437936", "0.53431463", "0.534258", "0.53415245", "0.53384346", "0.5333076", "0.531719" ]
0.81415546
0
Public: Define mappings of the Symbol column names to nicer, human names Example: ``` header.mappings name: 'Full name', age: 'Age of person' ``` `hash` Hash of mappings where the key is the column name to map and the value is the human readable value Returns a Hash of mappings
def mappings(hash = {}) @mappings.merge!(hash) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_column_mapping\n self.column_mapping = Hash.new.tap do |mapping|\n headers.collect { |h| canonicalize_header(h) }.each.with_index do |header, index|\n raise RuntimeError, \"Unrecognized canonical header #{header}\" unless HEADER_MAPPING.has_key?(header)\n if value = HEADER_MAPPING[header]\n mapping[index] = value\n end\n end\n end\n end", "def order_values_by_mappings(hash, column_mappings)\n column_mappings.map { |column_mapping| hash[column_name_from(column_mapping)].to_s }\n end", "def columns_hash\n @columns_hash ||= columns.inject({}){|r,c| r.merge(c[:name].to_sym => c)}\n end", "def column_names(column_mappings)\n column_mappings.map { |c| (c['column'] || c['standard_mapping']).downcase }\n end", "def set_column_mapping\n @columns_maps = {}\n\n column_alias = MC_COLUMNS_ALIAS.invert\n\n # check if column name in worksheet has an alias - if so - save the column id\n column_names = get_columns_names\n column_names.each_index do |i|\n if column_alias[column_names[i]] != nil\n @columns_maps[column_alias[column_names[i]]] = i\n end\n end\n\n @columns_maps # we return it only for tests\n end", "def get_column_mappings(row)\r\n mappings = {}\r\n row.each_with_index do |heading, index|\r\n # Stop collecting headings, if heading is empty\r\n if not heading.blank?\r\n mappings[heading.downcase.gsub(/\\A\\s*/, '').chomp.gsub(/\\s/, '_').to_sym] = index\r\n else\r\n break\r\n end\r\n end\r\n mappings\r\n end", "def column_hash\n @table.hashes.reduce({}) do |h, row|\n row.each do |k,v|\n (h[k.symbolize] ||= []) << parse_formula(v)\n end\n h\n end\n end", "def mapped_columns\n @columns.map do |column|\n @mappings[column] || column.to_s.send(@inflector)\n end\n end", "def columns_hash\n @columns_hash ||= columns.inject({}) { |hash, column| hash[column.name] = column; hash }\n end", "def convert map\n hsh = Hash.new\n\n map.each { |key, value| hsh[to_symbol(key)] = to_symbol(value)}\n\n return hsh\nend", "def symbolize(hash)\n {}.tap do |h|\n hash.each { |key, value| h[key.to_sym] = map_value_symbol(value) }\n end\n end", "def hfor(ta, h)\n out = {}\n @column_maps[ta].each{|ca, c| out[c] = h[ca]}\n out\n end", "def hash_correct(hash)\n\tHash[hash.map {|k,v| [(v[0].to_sym), v]}]\nend", "def keys_to_symbols(hash)\n\t\thash.keys.inject({}) do |hsh, key|\n\t\t\thsh[key.to_sym] = hash[key]\n\t\t\thsh\n\t\tend\n\tend", "def to_hsh\n {name => {:columns => columns, :unqiue => unique}}\n end", "def symbolize_keys!(hash)\n map_keys!(hash, Transproc(:to_symbol).fn)\n end", "def column_headings\n {\n :line_count => \"Lines\",\n :loc_count => \"LOC\",\n :file_count => \"Classes\",\n :method_count => \"Methods\",\n :average_methods => \"M/C\",\n :method_length => \"LOC/M\",\n :class_length => \"LOC/C\"\n }\n end", "def convert_header_keys_into_symbols(headers)\n headers.inject({}) do |final, (key,value)|\n key = key.to_s.gsub(/-/, \"_\").downcase.to_sym\n final[key] = value\n final\n end\n end", "def columns_hash(table = nil)\n if table\n @columns_hash[table]\n else\n ActiveSupport::Deprecation.warn('call columns_hash with a table name!')\n @columns_hash.dup\n end\n end", "def raw_table_to_hash tbl\n fixd_hsh = tbl.reject{|arr| arr.blank?}.inject({}) do |h,arr|\n title = arr.first.downcase.gsub(/[-\\s]/, '_').to_sym\n val = arr.last.gsub(\",\",\"\")\n h[title] = val\n h\n end\n fixd_hsh\n end", "def to_hash\n Hash.new.tap do |out|\n @map.each { |col| out[col.to] = translate(col) }\n end\n end", "def build_mapping(symbols, name)\n mapping = {}.tap do |hash|\n if symbols.is_a?(Hash)\n validate_user_defined_values!(symbols, name)\n hash.merge!(symbols.sort_by{|k,v| v}.to_h)\n else\n symbols.each_with_index do |key, i|\n hash[key] = 2**i\n end\n end\n hash[:empty] = 0\n end\n # put mapping in unique constant\n const_mapping_name = \"#{name}_mapping\".upcase\n const_set(const_mapping_name, mapping)\n end", "def raw_hash\n Hash.new.tap do |out|\n @map.each { |col| out[col.to] = @table[col.from] }\n end\n end", "def column_code_of_hash_keys\n code_col_name_hash ={}\n code_col_name_hash[:event_id] =1\n code_col_name_hash[:event_name] =2\n code_col_name_hash[:event_start_time] =3\n code_col_name_hash[:event_end_time] =4\n code_col_name_hash[:event_description] =5\n\n code_col_name_hash[:event_place_id] =6\n code_col_name_hash[:event_place_name] =7\n code_col_name_hash[:event_place_location_data] =8\n 9==9\n code_col_name_hash[:event_place_city] =10\n code_col_name_hash[:event_place_country] =11\n code_col_name_hash[:event_place_latitude] =12\n code_col_name_hash[:event_place_longitude] =13\n code_col_name_hash[:event_place_street] =14\n code_col_name_hash[:event_place_zip] =15\n\n code_col_name_hash[:\"event_event_times_data\"] =16\n code_col_name_hash[:\"event_id\"] =17\n code_col_name_hash[:\"event_start_time\"] =18\n code_col_name_hash[:\"event_end_time\"] =19\n\n\n code_col_name_hash[:event_paging_data] =20\n code_col_name_hash[:event_paging_previous] =21\n code_col_name_hash[:event_paging_next] =22\n\n code_col_name_hash[:event_attending_count] =23\n code_col_name_hash[:event_admins] =24\n code_col_name_hash[:event_owner_id] =25\n code_col_name_hash[:event_owner_name] =26\n code_col_name_hash[:event_picture_data_url] =27\n code_col_name_hash[:event_attending] =28\n code_col_name_hash[:event_interested] =29\n return code_col_name_hash\n end", "def machine_hash(headers,rows)\n # This is just to give a nice data structure (a hash of )\n rows.each_with_index.map do |row, index|\n # todo - rearrange the hash so it is sorted - do we need the row index?\n Hash[headers.each_with_index.map { |header, pos| \n [header, row[pos] ]}\n ].merge('row' => index+2)\n end\n end", "def humanize_keys(hash)\n Hash[hash.map { |k, v| [k.humanize, v] }]\n end", "def column_aliases\n @column_aliases ||= Hash.new\n end", "def map_data_types(hsh)\n hsh.each_with_object({}) { |(column_name, column_type), hash| hash[column_name] = map_value(column_type) }\n end", "def columns_hash(connection, table_name)\n @columns_hash.fetch(table_name) do\n @columns_hash[deep_deduplicate(table_name)] = columns(connection, table_name).index_by(&:name).freeze\n end\n end", "def to_h\n ret = ActiveSupport::OrderedHash.new\n get_all_sorted_columns.each{|col| ret[col.id] = col.name }\n return ret\n end", "def column_hash\n data_subject.df.to_h.reduce({}) do |h, (k,v)|\n h[k.symbolize] = v.to_a\n h\n end\n end", "def symbols cols\n decode_values :symbol, cols, true\n end", "def symbol cols\n decode_values :symbol, cols\n end", "def mapping\n {key => name}\n end", "def table_to_hash_lookup table, key_column, symbol_key = false, value_column=\"id\"\n key_column = key_column.to_s #allows for accepting symbols or strings\n value_column = value_column.to_s\n\n o=table.find_as_hashes(:all, :select => \"#{key_column}, #{value_column}\")\n #returns array of form\n # [{\"id\"=>\"1\", \"column\"=>\"value\"},{\"id\" => \"2\", \"column\" => \"value2\"}....]\n\n #convert to form\n #{'value' => 1, 'value2' => 2,...}\n\n dictionary=o.inject({}) {|result, element|\n #only get values that have a key column\n \n unless element[key_column].nil?\n entry = element[key_column].to_s#.force_encoding(\"utf-8\")\n entry = entry.to_sym if symbol_key\n #insert into the hash\n result[entry] = element[value_column].to_i \n end\n result\n }\n\n return dictionary\n end", "def determine_index_column_names(column_definitions)\n column_definitions.split(\", \").map do |name|\n name = $1 if name =~ /^LOWER\\(([^:]+)(::text)?\\)$/i\n name = $1 if name =~ /^\"(.*)\"$/\n name\n end\n end", "def column_named(name) #nodoc\n @_column_hashes[name.to_sym]\n end", "def symbolize_hash hash\n hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}\n end", "def graph_alias_columns(graph_aliases)\n gas = {}\n identifiers = graph_aliases.map do |col_alias, tc| \n table, column, value = Array(tc)\n column ||= col_alias\n gas[col_alias] = [table, column].freeze\n identifier = value || SQL::QualifiedIdentifier.new(table, column)\n identifier = SQL::AliasedExpression.new(identifier, col_alias) if value || column != col_alias\n identifier\n end\n [identifiers, gas]\n end", "def symbolify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tkeysym = key.to_s.dup.untaint.to_sym\n\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ keysym ] = symbolify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ keysym ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend", "def symbolify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tkeysym = key.to_s.dup.untaint.to_sym\n\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ keysym ] = symbolify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ keysym ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend", "def symbolify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tkeysym = key.to_s.dup.untaint.to_sym\n\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ keysym ] = symbolify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ keysym ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend", "def symbolify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tkeysym = key.to_s.dup.untaint.to_sym\n\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ keysym ] = symbolify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ keysym ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend", "def to_hash\n @table.inject(Hash.new) { |h, arr| k, v = arr; h[k.id2name] = v; h }\n end", "def normalize_array_of_columns(arry)\n arry.map do |f| \n if f.is_a?(Hash)\n f.symbolize_keys\n else\n f.to_sym\n end\n end\n end", "def symbols_first_pass\n symbol_defs = {}\n @data.each do |address, byte|\n next unless byte.is_a? Hash\n symbol = byte.keys.first\n value = byte.values.first\n # Store the symbol and its address for the second pass\n symbol_defs[symbol] = address\n # Replace the definition with just the value\n @data[address] = value\n end\n symbol_defs\n end", "def transform_keys_to_symbols(hash)\n return hash if not hash.is_a?(Hash)\n hash.inject({}) { |result, (key, value)|\n new_key = case key\n when String then key.to_sym\n else key\n end\n new_value = case value\n when Hash\n if key.eql? 'attributes'\n value\n else\n transform_keys_to_symbols(value)\n end\n else value\n end\n result[new_key] = new_value\n result\n }\n end", "def column_mappings\n @column_mappings ||= raw_column_mappings.map do |column_mapping|\n NdrImport::NonTabular::ColumnMapping.new(column_mapping)\n end\n end", "def transform_keys_to_symbols(hash)\n return hash if not hash.is_a?(Hash)\n hash.inject({}) { |result, (key, value)|\n new_key = case key\n when String then\n key.to_sym\n else\n key\n end\n new_value = case value\n when Hash\n if key.eql? 'attributes'\n value\n else\n transform_keys_to_symbols(value)\n end\n else\n value\n end\n result[new_key] = new_value\n result\n }\n end", "def build_formatted_headers(_widths = {})\n # Don't decorate if this Formatter calls for alignment. It will be done\n # in the second pass.\n decorate = !aligned?\n map = {}\n table.headers.each do |h|\n istruct = format_at[:header][h]\n map[h] = [h, format_cell(h.as_string, istruct, decorate: decorate)]\n end\n map\n end", "def build_formatted_headers(_widths = {})\n # Don't decorate if this Formatter calls for alignment. It will be done\n # in the second pass.\n decorate = !aligned?\n map = {}\n table.headers.each do |h|\n istruct = format_at[:header][h]\n map[h] = [h, format_cell(h.as_string, istruct, decorate: decorate)]\n end\n map\n end", "def hformat(hash = {})\n hash.map { |k, v| [k.to_sym, vformat(v)] }.to_h\nend", "def map(property_name, column_letter)\n @property_map[column_letter] = property_name\n end", "def symbolize_hash(hash)\n hash.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }\n end", "def column_names\n @column_names = columns_hash.keys\n end", "def to_java_map(hash)\n return nil if hash.nil?\n map = java.util.HashMap.new\n hash.each_pair do |k, v|\n case v\n when Symbol\n map[k.to_s] = v.to_s\n else\n map[k.to_s] = v\n end\n end\n map\n end", "def format_schema_helper(hsh)\n hsh = map_data_types(hsh)\n hsh.map { |column_name,column_type| [\"#{column_type}\".to_sym,\"#{column_name}\"] }\n end", "def table_symbol_from x\n x.to_s.tableize.to_sym\n end", "def identifier_hash(columns)\n h = {}\n columns.each{|k,v| h[Sequel.identifier(k)] = v}\n h\n end", "def column_headers(data)\n headers = { :types => [], :names => [] }\n\n data.map do |header|\n name = Utils.unprefix(header['name'])\n type = header['dataType'].downcase.to_sym\n type = :date if name == :date\n\n headers[:types] << type\n headers[:names] << name\n end\n\n headers\n end", "def format_hash(entry_hash)\n formatted = {}\n entry_hash.each do |column, value|\n if column =~ /fname|lname|addr|city/\n formatted[column] = capitalize_items(value)\n elsif column == \"state\"\n formatted[column] = value.upcase\n else\n formatted[column] = value\n end\n end\n return formatted\nend", "def to_normal_hash(hash)\n hash.to_h.transform_keys(&:to_sym)\n end", "def to_h\n words = {}\n @table.each do |spelling, word|\n words[spelling] = word.rank\n end\n words\n end", "def symbolize_keys(hash)\n Hash[hash.map { |k, v| [k.to_sym, v] }]\n end", "def string_hash(hash)\n hash.map { |k, v| [k.to_s, v.to_s] }.to_h\n end", "def to_hash\n h = {}\n each do |key,val|\n h[ UniMap.key_to_symbol( key ) ] = val\n end\n h\n end", "def symbolize_keys(hash)\n hash.inject({}) { |memo, (k, v)| memo[k.to_sym] = v; memo }\n end", "def mappings=(hash)\n fail ArgumentError unless hash.is_a?(Hash)\n\n @standard_mappings = hash\n end", "def to_sym hash\n hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}\nend", "def normalize_column(field)\n field.is_a?(Symbol) ? {:name => field} : field\n end", "def map_columns\n @map_columns ||= attribute_definitions.values.select { |c| c.type == :map }\n end", "def to_hash\n Hash[([column_names, column_values]).transpose]\n end", "def to_hash\n Hash[([column_names, column_values]).transpose]\n end", "def normalize_row(row)\n Hash[row.map{|column_name, row_value| [column_name.parameterize.underscore.to_sym, row_value.to_s]}]\n end", "def field_names\n @field_names ||= (columns_hash.keys.map(&:to_sym) rescue [])\n end", "def symbolize_keys_of(hash)\n hash2 = {}\n hash.each {|k,v| hash2[k.to_sym] = v}\n hash2\n end", "def keys_to_sym hash\n return hash unless hash.is_a? Hash\n hash.inject({}){ |opts,(k,v)| opts[k.to_sym] = v; opts }\n end", "def paired_column_names\n column_names.select { |column| column_names.include? \"#{column}Label\" }.map(&:to_sym)\n end", "def semantic_search_map \n # Hash[] conveniently takes an array of k-v pairs. \n return Hash[\n search_field_definitions.collect do |field, defn|\n [ defn[:semantic].to_s, field ] if defn && defn[:semantic]\n end.compact \n ]\n end", "def hash_correct(hash)\n \n Hash[hash.map {|k, v| [(k.to_s.ord + 1).chr.to_sym, v]}]\nend", "def to_hash\n index_hash = Hash.new\n self.each do |predef|\n index_hash[predef.name] = predef.to_s\n end\n index_hash\n end", "def renamed\n {\n \"supply_consumption\" => \"supply_use\",\n \"max_organisation\" => \"org\",\n \"max_strength\" => \"hp\",\n \"default_morale\" => \"recovery_rate\",\n }\n end", "def _protobuf_map_columns(force = false)\n return unless table_exists?\n\n @_protobuf_mapped_columns = false if force\n return if _protobuf_mapped_columns?\n\n @_protobuf_columns = {}\n @_protobuf_column_types = Hash.new { |h,k| h[k] = [] }\n\n columns.map do |column|\n @_protobuf_columns[column.name.to_sym] = column\n @_protobuf_column_types[column.type.to_sym] << column.name.to_sym\n end\n\n @_protobuf_mapped_columns = true\n end", "def create_column_headers_index_hash\n collect_column_headers\n @column_hash = Hash[(0...@column_headers.size).zip(@column_headers)] # ==> {0=>102231711, 1=>103244134, 2=>103285344, 3=>103293593}\nend", "def _column_hashes\n @_column_hashes ||= {}\n end", "def mapping\n {\n \"ch\" => 4,\n \"co\" => 3,\n \"gen\" => 0,\n \"char\" => 4,\n \"copy\" => 3,\n \"art\" => 1,\n \"meta\" => 5,\n \"general\" => 0,\n \"character\" => 4,\n \"copyright\" => 3,\n \"artist\" => 1,\n }\n end", "def data_column_info_for_columnheader(columnheader)\r\n method_index = method_index_for_columnheader(columnheader)\r\n\r\n data_header_ch = {}\r\n data_header_ch[:columnheader] = columnheader\r\n data_header_ch[:columnnr] = 1 + columnheaders_raw.index(columnheader)\r\n\r\n if method_index.nil? # columnheader does not appear in the method sheet\r\n data_header_ch[:definition] = columnheader\r\n else\r\n data_header_ch[:definition] = Array(data_description_sheet.column(*WBF[:column_definition_col]))[method_index].blank? ? columnheader : clean_string(Array(data_description_sheet.column(*WBF[:column_definition_col]))[method_index])\r\n data_header_ch[:unit] = clean_string(Array(data_description_sheet.column(*WBF[:column_unit_col]))[method_index])\r\n data_header_ch[:comment] = clean_string(Array(data_description_sheet.column(*WBF[:column_keywords_col]))[method_index])\r\n data_header_ch[:import_data_type] = clean_string(Array(data_description_sheet.column(*WBF[:group_methodvaluetype_col]))[method_index])\r\n end\r\n\r\n return data_header_ch\r\n\r\n end", "def symbolize_keys hsh\n new_hsh = Hash.new\n\n hsh.each_pair do |k,v|\n v = symbolize_keys v if v.is_a?(Hash)\n new_hsh[k.downcase.to_sym] = v\n end\n\n new_hsh\n end", "def master_hfor(h)\n out = {}\n @master_column_map.each{|ca, c| out[c] = h[ca]}\n out\n end", "def hash_proc_4symstr\n @hash_proc_4symstr ||= proc do |hash, key|\n case key\n when String\n tmp = key.to_sym\n hash.key?(tmp) ? hash[tmp] : nil\n when Symbol\n tmp = key.to_s\n hash.key?(tmp) ? hash[tmp] : nil\n end\n end\n end", "def headers(hash = {})\n hash.each_pair do |k,v|\n header[k] = v\n end\n end", "def table_mappings\n Thread.current[:scoped_table_names] ||= {}\n end", "def symbolize_hash_keys(hash); end", "def symbolize_keys(hash)\n hash.inject({}){|result, (key, value)|\n new_key = case key\n when String then key.to_sym\n else key\n end\n new_value = case value\n when Hash then symbolize_keys(value)\n else value\n end\n result[new_key] = new_value\n result\n }\n end", "def named_route_tables\n @named_route_tables ||= Hash[route_tables.map { |rt| [rt.name || rt.route_table_id, rt] }]\n .reject { |k, v| !k or !v }\n end", "def column_methods_hash #:nodoc:\n @dynamic_methods_hash ||= column_names.inject(Hash.new(false)) do |methods, attr|\n attr_name = attr.to_s\n methods[attr.to_sym] = attr_name\n methods[\"#{attr}=\".to_sym] = attr_name\n methods[\"#{attr}?\".to_sym] = attr_name\n methods[\"#{attr}_before_type_cast\".to_sym] = attr_name\n methods\n end\n end", "def symbol_attributes\n attributes.map {|k, v| [k.to_sym, v]}.to_h\n end", "def humanize(symbol)\n human_attr = symbol.to_s.split('_').map(&:capitalize).join(' ')\n end", "def rename_keys!(hash, mapping)\n mapping.each { |k, v| hash[v] = hash.delete(k) }\n hash\n end", "def map_column(old_name, new_name)\n unless @map.include?(old_name)\n raise ActiveRecord::ActiveRecordError, \"column #{old_name} not found, can't be mapped\"\n end\n if new_name.nil?\n @map.delete old_name\n @columns.delete old_name\n else\n @map[old_name] = new_name\n end\n end" ]
[ "0.65578604", "0.6396888", "0.63724834", "0.6246082", "0.621029", "0.61389667", "0.6048265", "0.5995724", "0.5842687", "0.5771993", "0.5653656", "0.5561997", "0.55097145", "0.5494023", "0.54799503", "0.5443157", "0.54364485", "0.54269636", "0.5408039", "0.54055625", "0.537429", "0.5338499", "0.53362596", "0.53346145", "0.53332555", "0.53287596", "0.5322463", "0.5295561", "0.5290134", "0.5270516", "0.52665246", "0.5257749", "0.5257741", "0.5255383", "0.52400166", "0.5187868", "0.5183431", "0.51771975", "0.5175697", "0.51648384", "0.51648384", "0.51648384", "0.51648384", "0.51630026", "0.51493114", "0.51436144", "0.5137005", "0.5134683", "0.5128396", "0.51217145", "0.51217145", "0.51155335", "0.5114058", "0.51094913", "0.5108126", "0.5097998", "0.50909555", "0.50839216", "0.50826746", "0.508024", "0.50780547", "0.507741", "0.5072587", "0.5066589", "0.5065647", "0.50332487", "0.50265867", "0.50100404", "0.5004945", "0.5000572", "0.5000306", "0.49680763", "0.49680763", "0.49532065", "0.49456343", "0.49433705", "0.4938238", "0.49363467", "0.4935155", "0.49335143", "0.49334738", "0.4923373", "0.4923336", "0.49218023", "0.49177396", "0.49138337", "0.49051735", "0.4901044", "0.4892436", "0.48903134", "0.4890213", "0.48811942", "0.48761365", "0.48720896", "0.48679206", "0.48674402", "0.48546657", "0.48448655", "0.48343718", "0.4832275" ]
0.513987
46
Public: Convert column names, default inflector is :humanize Example: ``` header.inflector :titleize ``` `:titleize` one of ruby inflectors
def inflector(header_inflector) @inflector = header_inflector end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def camerize(tablename)\n tablename.split(\"_\").map {|word| word.capitalize }.join(\"\")\n end", "def columnName_to_fieldname (name)\n return name.downcase.gsub(' ','-')\nend", "def mapped_columns\n @columns.map do |column|\n @mappings[column] || column.to_s.send(@inflector)\n end\n end", "def columns_title\n self.columns.collect{|c|c.label}\n end", "def humanize(capitalize: true, keep_id_suffix: false)\n ActiveSupport::Inflector.humanize(self, capitalize: capitalize, keep_id_suffix: keep_id_suffix)\n end", "def tableize\n ActiveSupport::Inflector.tableize(self)\n end", "def inflect_names(name) #:nodoc:\n camel = name.camelize\n under = camel.underscore\n plural = under.pluralize\n [camel, under, plural]\n end", "def humanize\n\t\tself.gsub('_',' ').titlecase\n\tend", "def humanize\n MotionSupport::Inflector.humanize(self)\n end", "def humanize(options = {})\n result = self.dup\n\n #inflections.humans.each { |(rule, replacement)| break if result.sub!(rule, replacement) }\n\n result.sub!(/\\A_+/, '')\n result.sub!(/_id\\z/, '')\n result.tr!('_', ' ')\n\n #result.gsub!(/([a-z\\d]*)/i) do |match|\n # \"#{inflections.acronyms[match] || match.downcase}\"\n #end\n\n if options.fetch(:capitalize, true)\n result.sub!(/\\A\\w/) { |match| match.upcase }\n end\n\n result\n end", "def titleize\n MotionSupport::Inflector.titleize(self)\n end", "def tableize\n MotionSupport::Inflector.tableize(self)\n end", "def titles\n fields.map{|f| f.to_s.gsub('_',' ').titleize }\n end", "def column_name(column)\n tmp = ''\n column.name.gsub(/_/, ' ').gsub(/id/,\"\").split.each{|word| tmp += word.capitalize + ' '}\n return tmp\n end", "def title_processor\n\n column_titles = create_column_titles('../data/census_column_metadata.csv')\n\n processed_titles = column_titles.map { |o|\n\t\to.flatten.compact.reverse.join\n\t}\nend", "def translated_columns(klass); end", "def titleize\n # TODO\n # Inflector.titleize(self)\n end", "def titleize\n self.class.new underscore.split(CLASSIFY_SEPARATOR).map(&:capitalize).join(TITLEIZE_SEPARATOR)\n end", "def tableize\n # TODO\n # Inflector.demodulize(self)\n end", "def humanize\n self.downcase.gsub(/_/, \" \").capitalize\n end", "def titleize\n self.gsub(/\\s/, \"_\").split('_').map(&:capitalize).join(' ')\n end", "def translate_column_names(json_data)\n data_string = JSON.dump json_data\n @column_translation.each do |old_name, new_name|\n data_string = data_string.gsub(old_name, new_name)\n end\n JSON.load data_string\n end", "def humanize\n\t\tlower_case_and_underscored_word = self\n\t\tresult = lower_case_and_underscored_word.to_s.dup\n#\t\tinflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }\n\t\tresult.gsub!(/_id$/, \"\")\n\t\tresult.gsub!(/_/, ' ')\n#\t\tresult.gsub(/([a-z\\d]*)/) { |match|\n#\t\t\"#{inflections.acronyms[match] || match.downcase}\"\n#\t\t}.gsub(/^\\w/) { $&.upcase }\n\tend", "def column_names(column_mappings)\n column_mappings.map { |c| (c['column'] || c['standard_mapping']).downcase }\n end", "def titleize\n lambda do |_rec, acc|\n acc.collect!(&:titleize)\n end\n end", "def fixup_column_names(columns)\n columns.map { |column| column.sub(/_$/, '') }\n end", "def camelize_methodname\n self.titleize.gsub(' ', '').camelize(:lower)\n end", "def titleize_names\n self.first_name = self.first_name.titleize\n self.last_name = self.last_name.titleize\n end", "def titleize(object)\n object.to_s.split('_').each{ |word| word.capitalize! }.join(' ')\n end", "def autoreport_association_name_columns(reflection)\n %w(name email title)\n end", "def human_to_name; end", "def columns(model, options)\n if cols = options[:columns]\n cols\n else\n cols = model.keys.collect do |k|\n { :key => k.to_sym, :label => \"#{k.capitalize}\" }\n end\n end\n end", "def csv_data\n cols = {names: [], titles: []}\n resource_class.columns.map do |col|\n cols[:names].push col.name\n end\n cols[:titles] = titleize(cols[:names])\n cols\n end", "def camelize!\n self.titleize!\n self.replace(self[0, 1].downcase + self[1..-1])\n end", "def humanize(lower_case_and_underscored_word)\n result = lower_case_and_underscored_word.to_s.dup\n\n inflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }\n result.gsub(/_id$/, \"\").gsub(/_/, \" \").capitalize\n end", "def humanize(lower_case_and_underscored_word)\n result = lower_case_and_underscored_word.to_s.dup\n\n inflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }\n result.gsub(/_id$/, \"\").gsub(/_/, \" \").capitalize\n end", "def human_relation_column(column_name)\n cattr_accessor :_human_relation_column\n self._human_relation_column = column_name.to_s\n end", "def fb_to_ar_case(column_name)\n column_name =~ /[[:lower:]]/ ? column_name : column_name.downcase\n end", "def humanize\n # TODO\n # Inflector.humanize(self)\n end", "def titleize(keep_id_suffix: false)\n ActiveSupport::Inflector.titleize(self, keep_id_suffix: keep_id_suffix)\n end", "def humanize(lower_case_and_underscored_word)\n lower_case_and_underscored_word.to_s.gsub(/_id$/, \"\").gsub(/_/, \" \").capitalize\n end", "def titlelize_property(property)\n property.name.camelize(:upper)\n end", "def titleize_proper_names\n self.author = self.author.titleize\n self.editor = self.editor.titleize if self.editor\n self.buyed_from = self.buyed_from.titleize if self.buyed_from\n end", "def humanize\n self.gsub(/_/, \" \").capitalize\n end", "def ar_to_fb_case(column_name)\n column_name =~ /[[:upper:]]/ ? column_name : column_name.upcase\n end", "def attribute_titles\n attribute_names.map {|f| f.to_s.capitalize.sub(/$/, \":\").gsub(/_/, \" \") }\n end", "def titleize\n self.underscore.humanize.gsub(/\\b(?<!['’`])[a-z]/) { $&.capitalize }\n end", "def humanize(lower_case_and_underscored_word, options = {})\n Geode::FastInflector.humanize(lower_case_and_underscored_word, options.fetch(:capitalize, true))\n end", "def tableize(class_name)\n pluralize(underscore(class_name))\n end", "def titleize\n#\t\thumanize(underscore(self)).gsub(/\\b('?[a-z])/) { $1.capitalize }\n#\t\thumanize(self.underscore).gsub(/\\b('?[a-z])/) { $1.capitalize }\n\t\tself.underscore.humanize.gsub(/\\b('?[a-z])/) { $1.capitalize }\n\tend", "def field_human_name(field)\n I18n.translate(\"#{model_name}.attributes.#{field}\", :count => 1, :default => Inflections.humanize(field), :scope => :models)\n end", "def humanize(lower_case_and_underscored_word)\n lower_case_and_underscored_word.to_s.gsub(/_id$/, '').tr('_', ' ').capitalize\n end", "def downcase_fields\n self.handle.downcase!\n end", "def title_case\n\t\tself.split.collect{ |s| s.capitalize_first }.join(\" \")\n\tend", "def tableize(class_name)\n pluralize(underscore(class_name))\n end", "def tableize(class_name)\n pluralize(underscore(class_name))\n end", "def fb_to_ar_case(column_name)\n column_name =~ /[[:lower:]]/ ? column_name : column_name.downcase\n end", "def test_column_human_name\n assert_equal @attribute_names[:name], Address.columns.find{|c| c.name == 'name'}.human_name\n end", "def titleize_name\r\n self.name = name.titleize\r\n end", "def titleize(title) \r\n title.en.titlecase\r\nend", "def human_name\n @human_name ||= self.to_s.demodulize.titleize\n end", "def display_sort_column_headers(search)\n user_column_headers.reduce(String.new) do |string, field|\n string << (tag.th sort_link(search, field, {}, method: action))\n end +\n post_title_header_labels.reduce(String.new) do |str, i|\n str << (tag.th \"Post #{i} title\")\n end\n end", "def set_converted_headers\n header_conversion_chart = @import_rows_to_class.const_get(:RECORD_HEADERS).invert\n @converted_headers = importable_columns.map { |col| header_conversion_chart[col] }\n end", "def capitalize_keys\n transform_keys { |key| key.to_s.capitalize rescue key }\n end", "def scaffold_column_name(column_name)\n @scaffold_column_names ||= {}\n @scaffold_column_names[column_name] ||= if n = SCAFFOLD_OPTIONS[:column_names][column_name]\n n\n elsif scaffold_association(column_name)\n scaffold_associated_human_name(column_name)\n else\n column_name.to_s.humanize\n end \n end", "def camelize\n ActiveSupport::Inflector.camelize(self)\n end", "def override_human_condition_column(column)\n \"#{column.name}_human_condition_column\"\n end", "def get_name_column(options) #:nodoc:\n if options.has_key?(:name_column) && !options[:name_column].blank? then\n options[:name_column].to_s.to_sym\n else\n :name\n end\n end", "def determine_index_column_names(column_definitions)\n column_definitions.split(\", \").map do |name|\n name = $1 if name =~ /^LOWER\\(([^:]+)(::text)?\\)$/i\n name = $1 if name =~ /^\"(.*)\"$/\n name\n end\n end", "def normalize_column(field)\n field.is_a?(Symbol) ? {:name => field} : field\n end", "def column_names\n case csv_columns\n when 'index'\n index_column_names\n else\n collection.first.class.column_names if collection.present?\n end\n end", "def model_column_names(models_columns)\n model_names = \"\"\n models_columns.each do |mc|\n if model_names.empty?\n model_names = mc[:model].name\n else\n model_names = model_names + ', ' + mc[:model].name\n end\n end\n return model_names\n end", "def convert_name\n self.name = I18n.transliterate(self.name).upcase\n end", "def convert_name\n self.name = I18n.transliterate(self.name).upcase\n end", "def dehumanize(v)\n v.is_a?(String) ? v.gsub(/\\s/,'_').downcase.to_sym : v\n end", "def human_attribute_name(attribute_key_name)\n attribute_key_name.gsub(/_/, \" \").capitalize unless attribute_key_name.nil?\n end", "def ar_to_fb_case(column_name)\n column_name =~ /[[:upper:]]/ ? column_name : column_name.upcase\n end", "def list_name\n value = model_table_name.humanize\n return 'author-title headings' if value == 'Name titles'\n value\n end", "def camelize\n self.split('_').collect{|mot| mot.capitalize}.join(\"\")\n end", "def transform(a)\n a.map(&:capitalize)\n \n end", "def human_name\n cn = name\n\n if respond_to?(:is_dynamic_model) && is_dynamic_model || respond_to?(:is_activity_log) && is_activity_log\n cn = cn.split('::').last\n end\n\n cn.underscore.humanize.captionize\n end", "def clean_col_header (hdr)\r\n\t\t\t# Conversion is:\r\n\t\t\t# - strip flanking space\r\n\t\t\t# - convert all internal non-alphanumerics to underscores\r\n\t\t\t# reduce consequetive underscores to a single one\r\n\t\t\t# TODO: strip flanking underscores\r\n\t\t\tclean_str = hdr.downcase.strip.gsub(/\\W+/, '_')\r\n\t\t\treturn clean_str.gsub(/_+/, '_')\r\n\t\tend", "def downcase_columns\n return if self.email.nil?\n self.email = self.email.downcase\n end", "def create_column_titles(filename)\ncolumn_titles = {}\n\t\n\tload_csv(filename).map do |row|\n\tcolumn_titles[row[:column_id]] =\n\trow[:column_title],\n\tcolumn_titles[row[:parent_column_id]]\n\tend\nend", "def t(column)\n object.class.human_attribute_name(column.to_sym)\n end", "def upcase_first\n ActiveSupport::Inflector.upcase_first(self)\n end", "def to_initials(name)\n # Write your code here\nend", "def translation_for(field)\n object.class.human_attribute_name(field)\n end", "def downcase_fields\n self.guess.downcase!\n end", "def humanize(string)\n attribute = string.tr(\".\", \"_\")\n if attribute.respond_to?(:humanize)\n attribute.humanize\n else\n attribute.tr(\"_\", \" \").capitalize\n end\n end", "def namify\n self.name.split(\" \").map{|x| x.first.capitalize}[0..1].join(\"\")\n end", "def titlecase\n\t\tsplit(/(\\W)/).map(&:capitalize).join\n\tend", "def downcase_first\n ActiveSupport::Inflector.downcase_first(self)\n end", "def capitalize_names!\n @artist_name = StringUtils.mixed_case(@artist_name)\n @name = StringUtils.mixed_case(@name)\n @genre = StringUtils.mixed_case(@genre)\n \n @remix = capitalize_remix_name(@remix)\n\n @featured_artists.collect! { |artist| StringUtils.mixed_case(artist) }\n end", "def heading_name\n if @pluralize\n ix(@name.pluralize).to_sym\n else\n ix(@name).to_sym\n end\n end", "def to_s\n return self.name.split.map(&:capitalize)*' '\n end", "def capitalize_names!\n @artist_name = StringUtils.mixed_case(@artist_name)\n @name = StringUtils.mixed_case(@name)\n @genre = StringUtils.mixed_case(@genre)\n @mixer = StringUtils.mixed_case(@mixer)\n end", "def capitalize() end", "def titleize(x)\n arr = \"#{x}\".split('_')\n caps = arr.map { |i| i.capitalize }\n caps.join\nend", "def titlecase_title\n self.title = self.title.titlecase\n end" ]
[ "0.67739445", "0.65588963", "0.65565646", "0.65240276", "0.6446608", "0.6302299", "0.6291594", "0.62675285", "0.6259997", "0.6253621", "0.6251851", "0.6222456", "0.6161914", "0.6135314", "0.61333627", "0.61024654", "0.6081763", "0.60761696", "0.60680443", "0.60675", "0.6057655", "0.6057405", "0.60573655", "0.6038102", "0.6033566", "0.60215276", "0.601568", "0.5997277", "0.59795225", "0.5978589", "0.59634537", "0.5944722", "0.59442043", "0.58922124", "0.5890259", "0.5890259", "0.58737975", "0.5871956", "0.5864492", "0.5861516", "0.5859997", "0.5850578", "0.58451974", "0.58391047", "0.58324635", "0.58114433", "0.58041245", "0.57820326", "0.578186", "0.57715863", "0.5744061", "0.5732522", "0.57205033", "0.5719158", "0.57088894", "0.57088894", "0.57046545", "0.57023543", "0.569139", "0.56894124", "0.568268", "0.5681373", "0.5680194", "0.5661127", "0.5660457", "0.5660003", "0.5659639", "0.5656083", "0.565026", "0.56433207", "0.5635939", "0.5627595", "0.5626752", "0.5626752", "0.5622755", "0.56215066", "0.56202364", "0.5610707", "0.5601427", "0.56004184", "0.5599675", "0.5597792", "0.55909276", "0.55873996", "0.5583525", "0.55824536", "0.5580212", "0.5573515", "0.55683243", "0.55682343", "0.556538", "0.55633193", "0.5552489", "0.5550521", "0.5549308", "0.55477005", "0.5546405", "0.554633", "0.5533857", "0.5529064" ]
0.6427629
5
Public: converts columns and mappings into mapped columns ready for encoding. If a mapped value is found that is used, else the Symbol column name is humanized by default or can be specified with header_inflector option Returns an Array of Strings
def mapped_columns @columns.map do |column| @mappings[column] || column.to_s.send(@inflector) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def column_names(column_mappings)\n column_mappings.map { |c| (c['column'] || c['standard_mapping']).downcase }\n end", "def make_column_mapping\n self.column_mapping = Hash.new.tap do |mapping|\n headers.collect { |h| canonicalize_header(h) }.each.with_index do |header, index|\n raise RuntimeError, \"Unrecognized canonical header #{header}\" unless HEADER_MAPPING.has_key?(header)\n if value = HEADER_MAPPING[header]\n mapping[index] = value\n end\n end\n end\n end", "def symbols cols\n decode_values :symbol, cols, true\n end", "def symbol cols\n decode_values :symbol, cols\n end", "def header_array\n @columns.collect {|c|\n if @table[c]\n @table[c][:name].to_s\n else\n \"\"\n end\n }.compact\n end", "def column_names\n columns.map(&:name)\n end", "def options_to_columns(options)\n columns = []\n options[:columns].each do |column|\n if column.kind_of? Symbol # a column from the database, we don't need to do anything\n columns << {:name => column, :attribute => column}\n elsif column.kind_of? Hash\n columns << {:name => column[:name], :special => column}\n end\n end\n columns\n end", "def order_values_by_mappings(hash, column_mappings)\n column_mappings.map { |column_mapping| hash[column_name_from(column_mapping)].to_s }\n end", "def column_mappings\n raise SolidusImportProducts::AbstractMthodCall\n end", "def association_columns(*by_associations) #:nodoc:\n if @object.present?\n @object.class.reflections.collect do |name, _|\n if by_associations.present?\n name if by_associations.include?(_.macro)\n else\n name\n end\n end.compact\n else\n []\n end\n end", "def column_names\n @entity_columns.map(&:name).map(&:to_s)\n end", "def normalize_array_of_columns(arry)\n arry.map do |f| \n if f.is_a?(Hash)\n f.symbolize_keys\n else\n f.to_sym\n end\n end\n end", "def column_names\n @column_names = columns_hash.keys\n end", "def strings cols\n decode_values :string, cols, true\n end", "def string cols\n decode_values :string, cols\n end", "def column_names\n keys = COLUMN_NAMES\n keys.map{|key| [Person.field_name(key), key]}\n end", "def map_columns\n @map_columns ||= attribute_definitions.values.select { |c| c.type == :map }\n end", "def column_mappings\n @column_mappings ||= raw_column_mappings.map do |column_mapping|\n NdrImport::NonTabular::ColumnMapping.new(column_mapping)\n end\n end", "def paired_column_names\n column_names.select { |column| column_names.include? \"#{column}Label\" }.map(&:to_sym)\n end", "def association_columns(*by_associations) #:nodoc:\n if @object.present? && @object.class.respond_to?(:reflections)\n @object.class.reflections.collect do |name, association_reflection|\n if by_associations.present?\n name if by_associations.include?(association_reflection.macro)\n else\n name\n end\n end.compact\n else\n []\n end\n end", "def columns\n map.keys\n end", "def field_names\n @field_names ||= (columns_hash.keys.map(&:to_sym) rescue [])\n end", "def column_names\n columns_in_order.map { |c| c.name }\n end", "def serialized_columns\n serialization_map.keys\n end", "def _protobuf_map_columns(force = false)\n return unless table_exists?\n\n @_protobuf_mapped_columns = false if force\n return if _protobuf_mapped_columns?\n\n @_protobuf_columns = {}\n @_protobuf_column_types = Hash.new { |h,k| h[k] = [] }\n\n columns.map do |column|\n @_protobuf_columns[column.name.to_sym] = column\n @_protobuf_column_types[column.type.to_sym] << column.name.to_sym\n end\n\n @_protobuf_mapped_columns = true\n end", "def column_names\n @column_names ||= columns.collect(&:name)\n end", "def to_a\n columns.map { |column| @attributes[column.name.underscore] }\n end", "def column_names\n klass.properties.keys\n end", "def column_names\n @columns.keys\n end", "def column_names\n @column_names ||= @columns.keys\n end", "def to_s_columns(columns = T.unsafe(nil)); end", "def normalize_column(field)\n field.is_a?(Symbol) ? {:name => field} : field\n end", "def columns(model, options)\n if cols = options[:columns]\n cols\n else\n cols = model.keys.collect do |k|\n { :key => k.to_sym, :label => \"#{k.capitalize}\" }\n end\n end\n end", "def value_column_names\n value_columns.map(&:name)\n end", "def get_columns_name\r\n columns = []\r\n if @columns != nil\r\n @columns.each do |column|\r\n columns.push column\r\n end\r\n end\r\n \r\n if @stats != nil and @stats.length > 0\r\n @stats.each do |stat|\r\n columns.push stat.to_column_name\r\n end\r\n end\r\n \r\n return columns\r\n end", "def convert_columns(arr)\n if ccs = @column_converters\n arr.zip(ccs).map{|v, pr| (v && pr) ? pr.call(v) : v}\n else\n arr \n end\n end", "def columns; @columns_hash.values; end", "def column_header_names\r\n column_headers.collect {|header| header.name }\r\n end", "def determine_index_column_names(column_definitions)\n column_definitions.split(\", \").map do |name|\n name = $1 if name =~ /^LOWER\\(([^:]+)(::text)?\\)$/i\n name = $1 if name =~ /^\"(.*)\"$/\n name\n end\n end", "def process_select_columns(select_columns)\n select_columns.map do |column|\n if column.is_a?(String) or column.is_a?(Symbol)\n as_table[column]\n else\n column\n end\n end\n end", "def column_list(columns)\n if columns.empty?\n WILDCARD\n else\n m = columns.map do |i|\n i.is_a?(Hash) ? i.map{|kv| \"#{literal(kv[0])} AS #{quote_identifier(kv[1])}\"} : literal(i)\n end\n m.join(COMMA_SEPARATOR)\n end\n end", "def headers\n columns.map(&:header)\n end", "def get_column_mappings(row)\r\n mappings = {}\r\n row.each_with_index do |heading, index|\r\n # Stop collecting headings, if heading is empty\r\n if not heading.blank?\r\n mappings[heading.downcase.gsub(/\\A\\s*/, '').chomp.gsub(/\\s/, '_').to_sym] = index\r\n else\r\n break\r\n end\r\n end\r\n mappings\r\n end", "def col(cname)\n map {|x| x[cname]}\n end", "def to_sym_arr\n @by_symbol.keys\n end", "def columns\n @columns ||= [].tap do |fields|\n @model.columns.reject { |a| a.name.match(/_id$/) }.each do |column|\n fields << resolve(column.type, column.name)\n end\n end\n end", "def column_aliases\n @column_aliases ||= Hash.new\n end", "def appropriate_column_listing(columns = columns_joined)\n has_config_defined_cols? == true ? \", #{columns}\" : \"\"\n end", "def format_schema_helper(hsh)\n hsh = map_data_types(hsh)\n hsh.map { |column_name,column_type| [\"#{column_type}\".to_sym,\"#{column_name}\"] }\n end", "def translated_columns(klass); end", "def transformed_columns\n @transformed_columns ||= computed_columns.map do |key, value|\n transform_column(key, value)\n end\n end", "def autoreport_association_name_columns(reflection)\n %w(name email title)\n end", "def column_names(table_name)\n columns(table_name).map(&:name)\n end", "def _protobuf_map_columns(force = false)\n COLUMN_TYPE_MAP_MUTEX.synchronize do\n @_protobuf_mapped_columns = false if force\n\n return unless table_exists?\n return if _protobuf_mapped_columns?\n\n @_protobuf_columns = {}\n @_protobuf_column_types = ::Hash.new { |h, k| h[k] = ::Set.new }\n @_protobuf_date_datetime_time_or_timestamp_column = ::Set.new\n\n columns.map do |column|\n column_name_symbol = column.name.to_sym\n column_type_symbol = column.type.to_sym\n @_protobuf_columns[column_name_symbol] = column\n @_protobuf_column_types[column_type_symbol] << column_name_symbol\n\n if DATE_OR_TIME_TYPES.include?(column_type_symbol)\n @_protobuf_date_datetime_time_or_timestamp_column << column_name_symbol\n end\n end\n\n @_protobuf_mapped_columns = true\n end\n end", "def column_headers\n use_column_headers ? columns.map(&:heading) : true\n end", "def content_columns #:nodoc:\n model_name.constantize.content_columns.collect { |c| c.name.to_sym }.compact rescue []\n end", "def column_names\n klass.attributes\n end", "def default_columns\n [\n {:name => \"id\", :attr_type => :integer, :meta => true},\n {:name => \"position\", :attr_type => :integer, :meta => true},\n {:name => \"attr_type\", :attr_type => :string, :meta => true},\n *config[:owner].class.meta_columns.map { |c| c[:name] == \"name\" ? inject_combo_for_name_column(c) : c }\n ]\n end", "def set_column_mapping\n @columns_maps = {}\n\n column_alias = MC_COLUMNS_ALIAS.invert\n\n # check if column name in worksheet has an alias - if so - save the column id\n column_names = get_columns_names\n column_names.each_index do |i|\n if column_alias[column_names[i]] != nil\n @columns_maps[column_alias[column_names[i]]] = i\n end\n end\n\n @columns_maps # we return it only for tests\n end", "def columns\n @columns = @clazz.columns_hash.map do |name, column|\n [name, @columns[name] || Column.new(column, @dump)]\n end.to_h.with_indifferent_access\n end", "def map_inbound_headers( klass, columns, options = {} )\n\n @mapped_class = klass\n\n # If klass not in Dictionary yet, add to dictionary all possible operators on klass\n # which can be used to map headers and populate an object of type klass\n model_method_mgr = ModelMethods::Manager.catalog_class(klass)\n\n [*options[:model_classes]].each do |c|\n ModelMethods::Manager.catalog_class(c)\n end if options[:model_classes]\n\n forced = forced_inclusion_columns.compact.collect { |f| f.to_s.downcase }\n\n reset\n\n [*columns].each_with_index do |col_data, col_index|\n raw_col_data = col_data.to_s\n\n if raw_col_data.nil? || raw_col_data.empty?\n logger.warn(\"Column list contains empty or null column at index #{col_index}\")\n bindings << NoMethodBinding.new(raw_col_data, col_index)\n next\n end\n\n raw_col_name, where_field, where_value, *data = raw_col_data.split(column_delim)\n\n # Find the domain model method details\n model_method = model_method_mgr.search(raw_col_name)\n\n # if not found via raw name, try various alternatives\n unless model_method\n Binder.substitutions(raw_col_name).each do |n|\n model_method = model_method_mgr.search(n)\n break if model_method\n end\n end\n\n if(model_method.nil? && (options[:include_all] || forced.include?(raw_col_name.downcase)))\n logger.debug(\"Operator #{raw_col_name} not found but forced inclusion set - adding as :method\")\n model_method = model_method_mgr.insert(raw_col_name, :method)\n end\n\n if(model_method)\n\n binding = MethodBinding.new(raw_col_name, col_index, model_method)\n\n # we slurped up all possible data in split, turn it back into original string\n binding.add_column_data(data.join(column_delim))\n\n if where_field\n logger.info(\"Lookup query field [#{where_field}] - specified for association #{model_method.operator}\")\n\n begin\n binding.add_lookup(model_method, where_field, where_value)\n rescue\n add_missing(raw_col_data, col_index,\n \"Field [#{where_field}] Not Found for [#{raw_col_name}] (#{model_method.operator})\")\n next\n end\n\n end\n\n logger.debug(\"Column [#{col_data}] (#{col_index}) - mapped to :\\n#{model_method.pp}\")\n\n bindings << binding\n\n else\n logger.debug(\"No operator or association found for Header [#{raw_col_name}]\")\n\n add_missing(raw_col_data, col_index, \"No operator or association found for Header [#{raw_col_name}]\")\n end\n end\n\n bindings\n end", "def prepared_columns(cols)\n RUBY_VERSION >= '1.9' ? cols.sort : cols.sort_by(&:to_s)\n end", "def csv_data\n cols = {names: [], titles: []}\n resource_class.columns.map do |col|\n cols[:names].push col.name\n end\n cols[:titles] = titleize(cols[:names])\n cols\n end", "def columns\n return [{:id=>\"one\", :display =>'One', :searchable=>false}, {:id=>'two', :display => 'three'}]\n end", "def column_names\n self[0].keys\n end", "def encode_name(col)\n if col.name == 'id'\n :_id\n elsif col.name == 'type'\n :_type\n else\n col.name.to_sym\n end\n end", "def column_names\n klass.new.attributes.keys\n end", "def column_names\n raise NotSupportedError\n end", "def column_names(table)\n self.table_column_names ||= {}\n unless table_column_names.include? table\n table_column_names[table] = columns(table).map {|c| c.name}\n end\n table_column_names[table]\n end", "def decode_name(col)\n end", "def columns\n @columns = columns_hash.values\n end", "def columnheaders_raw\r\n columns = Array(raw_data_sheet.row(0)).compact\r\n columns = columns.collect!{ |col| clean_string(col) } unless columns.nil?\r\n columns\r\n end", "def columns_hash\n @columns_hash ||= columns.inject({}){|r,c| r.merge(c[:name].to_sym => c)}\n end", "def columns\n select.inject([]) do |columns, column|\n columns << {\n :type => all_columns[column][:type]\n }.merge({\n :id => column.to_s,\n :label => column_label(column)\n })\n end\n end", "def to_columns\n @columns = transpose_to_columns\n end", "def synthetic_columns\n @columns ||= [:id]\n end", "def columns\n @header.to_a\n end", "def column_names\n case csv_columns\n when 'index'\n index_column_names\n else\n collection.first.class.column_names if collection.present?\n end\n end", "def serialized_columns\n Sequel::Deprecation.deprecate(\"#{self}.serialized_columns in the serialization plugin\", \"Use #{self}.serialization_map.keys instead\")\n serialization_map.keys\n end", "def names\n @column_families.keys\n end", "def table_symbol_from x\n x.to_s.tableize.to_sym\n end", "def get_headers\n headers = []\n @data.each do |druid, column_hash|\n headers << column_hash.keys\n end\n headers_out = headers.flatten.uniq\n end", "def initialize_columns\n @columns = []\n valid_table = table.alias('valid_taxon_names')\n\n @columns.push({ header: 'ro', projected: rank_over(table, valid_table) })\n\n @columns.push({header: 'taxon_name_id', projected: table[:id].as('taxon_name_id') } )\n @columns.push({header: 'cached_valid_taxon_name_id', projected: table[:cached_valid_taxon_name_id].as('cached_valid_taxon_name_id') } )\n @columns.push({header: 'cached', projected: table[:cached].as('cached') } )\n @columns.push({header: 'cached_author_year', projected: table[:cached_author_year].as('cached_author_year') } )\n @columns.push({header: 'cached_is_valid', projected: table[:cached_is_valid].as('cached_is_valid') } )\n\n if fieldsets.include?('observations')\n @columns.push({header: 'otu_id', projected: otu_table[:id].as('otu_id') } )\n @columns.push({header: 'otu_name', projected: otu_table[:name].as('otu_name')} )\n end\n end", "def column_name\n name.to_sym\n end", "def column_named(name) #nodoc\n @_column_hashes[name.to_sym]\n end", "def get_data_colnames(d)\n if d == nil or d.empty?\n return []\n end\n return d.first().keys()\n end", "def attribute_values\n @columns.map do |column|\n @attributes[column.to_sym]\n end\n end", "def predefined_columns\n helper_module = \"Netzke::Helpers::#{short_widget_class_name}#{data_class.name}\".constantize rescue nil\n \n data_class_columns = data_class && data_class.column_names.map(&:to_sym) || []\n \n if helper_module\n exposed_attributes = helper_module.respond_to?(:exposed_attributes) ? normalize_array_of_columns(helper_module.exposed_attributes) : nil\n virtual_attributes = helper_module.respond_to?(:virtual_attributes) ? helper_module.virtual_attributes : []\n excluded_attributes = helper_module.respond_to?(:excluded_attributes) ? helper_module.excluded_attributes : []\n attributes_config = helper_module.respond_to?(:attributes_config) ? helper_module.attributes_config : {}\n \n res = exposed_attributes || data_class_columns + virtual_attributes\n \n res = normalize_columns(res)\n \n res.reject!{ |c| excluded_attributes.include? c[:name] }\n\n res.map!{ |c| c.merge!(attributes_config[c[:name]] || {})}\n else\n res = normalize_columns(data_class_columns)\n end\n \n res\n end", "def grouped_column_names_for(object)\n object.column_names.map { |column| \"#{object.table_name}.#{column}\" }.join(', ')\n end", "def column_names\n\t\t@validated_gets.map{|f| f[:external]} + [\"usd_2009\", \"usd_current\", \"count\", \"min_year\", \"max_year\"]\n\tend", "def all\n __getobj__.column_names\n end", "def col_types\n result = {}\n columns.each do |c|\n result[c.header] = c.type\n end\n result\n end", "def routing_tags_column(column_name, name_column:)\n col_value = model.public_send(column_name)\n if col_value.present?\n value = col_value.map { |id| h.routing_tags_map[id] }.join(', ')\n else\n value = model.public_send(name_column)\n end\n\n wrap_changed_column(column_name) { value }\n end", "def title_processor\n\n column_titles = create_column_titles('../data/census_column_metadata.csv')\n\n processed_titles = column_titles.map { |o|\n\t\to.flatten.compact.reverse.join\n\t}\nend", "def to_a\n column_names = [@query.klass.primary_key] | connect_by_columns\n column_names.map { |name| @query.table[name] }\n end", "def source_to_headers\n\n # TODO: This collection can now be sorted\n collection = ModelMethods::Manager.catalog_class(source)\n\n if collection\n collection.each do |mm|\n next if(DataShift::Transformer::Remove.association?(mm))\n\n if(mm.association_type?)\n association_to_headers(mm)\n else\n @headers << mm.operator\n end if(configuration.op_type_in_scope?(mm))\n end\n\n DataShift::Transformer::Remove.unwanted_columns(@headers)\n end\n end", "def value_columns\n return [ ] unless @low_card_model.table_exists?\n\n @low_card_model.columns.select do |column|\n column_name = column.name.to_s.strip.downcase\n\n use = true\n use = false if column_names_to_skip.include?(column_name)\n use\n end\n end", "def model_column_names(models_columns)\n model_names = \"\"\n models_columns.each do |mc|\n if model_names.empty?\n model_names = mc[:model].name\n else\n model_names = model_names + ', ' + mc[:model].name\n end\n end\n return model_names\n end", "def column_headers(data)\n headers = { :types => [], :names => [] }\n\n data.map do |header|\n name = Utils.unprefix(header['name'])\n type = header['dataType'].downcase.to_sym\n type = :date if name == :date\n\n headers[:types] << type\n headers[:names] << name\n end\n\n headers\n end", "def column_names\n @column_names || owner.column_names\n end" ]
[ "0.6813702", "0.6511555", "0.646128", "0.6441469", "0.6000217", "0.5928535", "0.5883122", "0.58591306", "0.5849231", "0.5843938", "0.58433", "0.5836539", "0.58239007", "0.5813955", "0.58128095", "0.580976", "0.57861865", "0.5762714", "0.57607377", "0.5745558", "0.5744659", "0.5729151", "0.5704081", "0.56963044", "0.5695534", "0.5670052", "0.56504595", "0.5648252", "0.56352425", "0.563467", "0.55959696", "0.55490077", "0.554787", "0.5539909", "0.55239326", "0.5523177", "0.5519913", "0.55148274", "0.549214", "0.548035", "0.5464133", "0.5460411", "0.5458076", "0.5454557", "0.54488605", "0.5432531", "0.54320717", "0.5392591", "0.53886706", "0.53881854", "0.5386026", "0.5379264", "0.53658956", "0.5364081", "0.5352105", "0.53510123", "0.53433126", "0.53407925", "0.5330195", "0.5311326", "0.530833", "0.5306538", "0.5299996", "0.52886707", "0.52769595", "0.5275439", "0.52753806", "0.5274969", "0.5273028", "0.52664024", "0.5266026", "0.52647483", "0.5263989", "0.5260626", "0.52563745", "0.52562654", "0.5252293", "0.5247576", "0.52404135", "0.52392906", "0.5222938", "0.52178097", "0.52167606", "0.52153784", "0.52083266", "0.5201443", "0.51978403", "0.51956403", "0.51853704", "0.5183965", "0.5181452", "0.5181288", "0.51706046", "0.5167064", "0.5143666", "0.5141755", "0.5129423", "0.5127988", "0.5126413", "0.5117764" ]
0.76826763
0
TODO bootstrap formatting TODO cache data TODO format output
def index #get new data @attributes=["name","price","block","nextretarget","blocksleft","measured","difficulty","estdifficulty","timeretarget"] @data={} @data["btc"]=generateBTCData(2016) @data["ltc"]=generateMapData("ltc","http://litecoinscout.com/chain/litecoin/q",150,2016) @data["ftc"]=generateMapData("ftc","http://explorer.feathercoin.com/chain/Feathercoin/q",150,504) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def formatter; end", "def formatter; end", "def formatter; end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def preformatting\n\n end", "def output(data); end", "def formats; end", "def formats; end", "def tidy(data); end", "def formatters; end", "def format_data data\r\n\tresult = []\r\n\t#split entry to array\r\n\tarr = data.read.split '>'\r\n\tarr.each do |item|\r\n\t\tname = item.split('|')[0]\r\n\t\tnext if !name\r\n\r\n\t\tprotein = []\r\n\t\t#format name\r\n\t\tname.delete! ' '\r\n\t\tname.tr! '|', ''\r\n\r\n\t\t#format sequence\r\n\t\ttmp = item.split \"\\n\"\r\n\t\ttmp.shift\r\n\t\tsequence = tmp.join\r\n\r\n\t\tprotein.push name, sequence\r\n\r\n\t\tresult.push protein\r\n\tend\t\r\n\tresult\r\n\r\nend", "def data\n \"_target: #{target}\\ndatacite.creator: #{creator}\\ndatacite.title: #{title}\\ndatacite.publisher: #{publisher}\\ndatacite.publicationyear: #{publicationyear}\\n\"\n end", "def format!; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def formatted_cache_data\n {\n id: id,\n name: name,\n symbol: symbol,\n status: status\n }\n end", "def processEntries(data)\n # Initialise output hash and kick if no data\n out = {:log => initLog(data), :data => String.new()}\n # Loop over the data, if any\n data[:data].each_with_index do |dat, i|\n # Boot if frowns\n if dat[\"smiles\"].nil?\n out[:log] += \" No SMILES code for entry #{i + 1}\\n\"\n next\n end\n # Get OpenBabel output\n out[:data] += obabelOutput(data[:names].join(\"; \"), dat[\"smiles\"])\n end\n return out\nend", "def formatted_cache_data\n {\n id: id,\n name: name,\n symbol: symbol,\n decimal: decimal,\n contract_address: contract_address,\n constants: constants,\n status: status\n }\n end", "def formatted_cache_data\n {\n id: id,\n client_id: client_id,\n name: name,\n symbol: symbol,\n conversion_factor: conversion_factor.present? ? conversion_factor.to_s : conversion_factor, # should be string as it goes to FE\n decimal: decimal,\n status: status,\n stake_currency_id: stake_currency_id,\n properties: properties.present? ? Token.get_bits_set_for_properties(properties) : [],\n }\n end", "def data\n [@name, @format, @entry, @processors]\n end", "def predict_format_converter usages\r\n @date = []\r\n @total = []\r\n @lines = []\r\n @labels = []\r\n @table_array = []\r\n usages[:daily_usage].each do |usage|\r\n @date.append(usage[:date].to_s)\r\n\r\n @total.append(usage[:usage])\r\n end\r\n @table_array.append(\"date[i]\")\r\n @table_array.append(\"total[i]\")\r\n usages[:daily_time_periods].each_with_index do |period, index|\r\n @name =\"lines[#{index.to_s}][i]\"\r\n @table_array.append(@name)\r\n @lines.append([])\r\n @labels.append(period[:label])\r\n period[:daily_usage].each do |usage|\r\n @lines[index].append(usage[:usage])\r\n\r\n end\r\n end\r\n end", "def format_issue i, width = columns\n return unless i['created_at']\n ERB.new(<<EOF).result binding\n<% p = i['pull_request']['html_url'] if i.key?('pull_request') %>\\\n<%= bright { no_color { indent '%s%s: %s' % [p ? '↑' : '#', \\\n*i.values_at('number', 'title')], 0, width } } %>\n@<%= i['user']['login'] %> opened this <%= p ? 'pull request' : 'issue' %> \\\n<%= format_date DateTime.parse(i['created_at']) %>. \\\n<% if i['merged'] %><%= format_state 'merged', format_tag('merged'), :bg %><% end %> \\\n<%= format_state i['state'], format_tag(i['state']), :bg %> \\\n<% unless i['comments'] == 0 %>\\\n<%= fg('aaaaaa'){\n template = \"%d comment\"\n template << \"s\" unless i['comments'] == 1\n '(' << template % i['comments'] << ')'\n} %>\\\n<% end %>\\\n<% if i['assignee'] || !i['labels'].empty? %>\n<% if i['assignee'] %>@<%= i['assignee']['login'] %> is assigned. <% end %>\\\n<% unless i['labels'].empty? %><%= format_labels(i['labels']) %><% end %>\\\n<% end %>\\\n<% if i['milestone'] %>\nMilestone #<%= i['milestone']['number'] %>: <%= i['milestone']['title'] %>\\\n<%= \" \\#{bright{fg(:yellow){'⚠'}}}\" if past_due? i['milestone'] %>\\\n<% end %>\n<% if i['body'] && !i['body'].empty? %>\n<%= indent i['body'], 4, width %>\n<% end %>\n\nEOF\n end", "def format data\n data\n end", "def format_data model,data, &block\n data.collect{|row| \n tmp=model.collect{|c| \n s = ''\n s = row[c] if row[c] \n s\n }\n tmp=yield(row,tmp) if block\n tmp\n }\n end", "def setup_abst_info(record)\n text = []\n record.find_all{|f| f.tag === \"520\" }.each do |field|\n textstr = ''\n field.each do |sf|\n textstr << sf.value + ' ' unless [\"c\", \"2\",\"3\",\"6\"].include?(sf.code)\n end\n text << textstr\n end\n Rails.logger.debug \"********es287_dev #{__FILE__} #{__LINE__} #{__method__} #{text[0]}\"\n text\n end", "def line_cache; end", "def to_html(datums)\n #, :id, :description, :conditions, :explanation, :format\n require 'markaby'\n mab = Markaby::Builder.new\n mab.html do\n head { title \"Loonheffing stuff\" }\n body do \n datums.each do |d|\n h1 d.name\n table do\n tr { td \"Identifier\"; td d.id }\n tr { td \"Description\"; td d.description }\n cs = d.conditions.split(/\\[[0-9]+\\]/)\n cs = cs[1..-1] # get strange first thing out of the way\n tr do \n td \"Conditions\"; td do\n ul do \n cs.each do |c|\n li c\n end\n end\n end\n end\n tr { td \"Explanation\"; td d.explanation }\n tr { td \"Format\"; td d.format }\n end\n end\n end\n end\n puts mab.to_s\nend", "def format_data(data, private_allowed)\n # Store all formatted data in this array\n formatted_data = []\n\n # Format name with flags\n # Name Mark Diez (student, employee, staff)\n # IAM ID 1234566\n if !data[\"basic_info\"].empty?\n data[\"basic_info\"].each do |info|\n name = \"*Name* \" + info[\"dFullName\"]\n\n flags = []\n if info[\"isEmployee\"]\n flags.push \"employee\"\n end\n if info[\"isHSEmployee\"]\n flags.push \"hs employee\"\n end\n if info[\"isFaculty\"]\n flags.push \"faculty\"\n end\n if info[\"isStudent\"]\n flags.push \"student\"\n end\n if info[\"isStaff\"]\n flags.push \"staff\"\n end\n if info[\"isExternal\"]\n flags.push \"external\"\n end\n flags = \" _(\" + flags.join(\", \") + \")_\"\n name += flags\n\n formatted_data.push name\n formatted_data.push \"*IAM ID* #{info[\"iamId\"]}\"\n if private_allowed\n formatted_data.push \"*Student ID* #{info[\"studentId\"]}\" unless info[\"studentId\"] == nil\n formatted_data.push \"*PPS ID* #{info[\"ppsId\"]}\" unless info[\"ppsId\"] == nil\n end\n end\n end\n\n # Format Kerberos information\n # Login ID msdiez, anotherid, ...\n if !data[\"kerberos_info\"].empty?\n ids = []\n data[\"kerberos_info\"].each do |info|\n id = info[\"userId\"] == nil ? \"Not Listed\" : info[\"userId\"]\n ids.push id\n end\n\n formatted_data.push \"*Login ID* \" + ids.join(\", \")\n else\n login_id = \"*Login ID* Not Listed\"\n formatted_data.push login_id\n end\n\n\n # Format contact information\n # E-mail my@email.com, my@otheremail.com\n # Office kerr 186, social science 133, ...\n if !data[\"contact_info\"].empty?\n email = []\n office = []\n data[\"contact_info\"].each do |info|\n email.push info[\"email\"] unless info[\"email\"] == nil\n office.push info[\"addrStreet\"] unless info[\"addrStreet\"] == nil\n end\n formatted_data.push \"*E-mail* \" + email.join(\", \")\n formatted_data.push \"*Office* \" + office.join(\", \")\n else\n formatted_data.push \"*E-mail* Not Listed\"\n formatted_data.push \"*Office* Not Listed\"\n end\n\n # Format ODR information\n # ODR Affiliation DSSIT: STD4 (Casual)\n require 'pp'\n pp data\n if !data['odr_info'].empty?\n data['odr_info'].each do |info|\n odr = '*ODR Affiliation* '\n odr += info['deptDisplayName'] + ': ' unless info['deptDisplayName'].nil?\n odr += info['titleDisplayName'] unless info['titleDisplayName'].nil?\n\n formatted_data.push odr\n end\n end\n\n # Format PPS information\n # PPS Affiliation DSSIT: STD4\n if !data['pps_info'].empty?\n data['pps_info'].each do |info|\n dept_name = info['deptDisplayName'] || 'Unknown Department'\n dept_code = info['deptCode'] || 'Unknown Department Code'\n title_name = info['titleDisplayName'] || 'Unknown Title'\n title_code = info['titleCode'] || 'Unknown Title Code'\n position_type = info['positionType'] || 'Unknown Position Type'\n employee_class = info['emplClassDesc'] || 'Unknown Employee Class'\n\n formatted_data.push \"*PPS Affiliation*\"\n formatted_data.push \" Department: #{dept_name} (#{dept_code})\"\n formatted_data.push \" Title: #{title_name} (#{title_code}) (#{position_type})\"\n formatted_data.push \" Employee Class: #{employee_class}\"\n end\n end\n\n # Format student information\n # Student Affiliation Computer Science (Undergraduate, Junior)\n if !data['student_info'].empty?\n data['student_info'].each do |info|\n student = '*Student Affiliation* '\n student += info['majorName'] + ' ('\n student += info['levelName'].scan(/\\S+/)[0] # Only grab the first word\n student += ', ' + info['className'] + ')'\n\n formatted_data.push student\n end\n end\n\n return formatted_data.join(\"\\n\")\n end", "def format_data(data)\n case format\n when :json\n JSON.pretty_generate(data)\n else # default to YAML\n data.to_yaml.sub(/\\A\\-\\-\\-\\n/, '')\n end\n end", "def format_metadata(obj)\n '<table class=\"table table-sm table-responsive\">' +\n obj.metadata.data.map do |k, v|\n case k\n when /^run_/, :plugins, :user\n next\n when :web_assembly_gz\n v = \"<a href='#{v}'>#{v[0..50]}...</a>\"\n when :datasets\n v = v.size\n end\n \"<tr><td class='text-right pr-4'><b>#{format_name(k)}</b></td>\" \\\n \"<td>#{v}</td></tr>\"\n end.compact.join('') +\n '</table>'\n end", "def to_output_format(data)\n records = []\n data.each do |arr|\n records << {\n last_name: arr[0],\n first_name: arr[1],\n gender: arr[2],\n favorite_color: arr[3],\n birthdate: arr[4]\n } \n end\n records\n end", "def generate_workflow_data(format, cgi, item_entry, item, required_item_version, wf_version, download_allowed)\n workflow_data = \"\"\n workflow_metadata = generate_item_metadata(format, cgi, item_entry)\n \n case format.downcase\n when \"html\"\n workflow_data += cgi.li(\"class\" => \"workflow\"){\n cgi.div(\"class\" => \"workflow_item\") do\n cgi.div(\"class\" => \"item_data\") do\n \"<b>Workflow: </b>\" + cgi.a(location_string(item_entry.contributable_type, item.id, wf_version)){required_item_version.title} + \n (download_allowed ? (\"&nbsp;&nbsp;&nbsp;[ \" + cgi.a(\"./workflows/\" + item.filename(wf_version)){\"open local copy\"} + \" ]\") : \"\") + \"<br/>\" +\n \"Type: <span class='workflow_type'>\" + item.type_display_name() + \"</span><br/>\" +\n \"Originally uploaded by: \" + uploader_string(item.contribution.contributor_type, item.contribution.contributor_id, true, false) + \"<br/>\" +\n \"Version: #{wf_version} (created on: #{required_item_version.created_at.strftime(\"%d/%m/%Y\")}, last edited on: #{required_item_version.updated_at.strftime(\"%d/%m/%Y\")})<br/>\" +\n \"Version uploaded by: \" + uploader_string(required_item_version.contributor_type, required_item_version.contributor_id, true, false) + \"<br/>\"\n end +\n workflow_metadata \n end\n }\n \n when \"text\"\n workflow_data += \"+ Workflow: #{item.title}\"\n if download_allowed\n workflow_data += \" (local copy: workflows/#{item.filename(wf_version)})\"\n end\n workflow_data += \"\\n Type: \" + item.type_display_name()\n workflow_data += \"\\n Location: \" + location_string(item_entry.contributable_type, item.id, wf_version)\n workflow_data += \"\\n Originally uploaded by: \" + uploader_string(item.contribution.contributor_type, item.contribution.contributor_id, false, false)\n workflow_data += \"\\n Version: #{wf_version} (created on: #{required_item_version.created_at.strftime(\"%d/%m/%Y\")}, last edited on: #{required_item_version.updated_at.strftime(\"%d/%m/%Y\")})\"\n workflow_data += \"\\n Version uploaded by: \" + uploader_string(required_item_version.contributor_type, required_item_version.contributor_id, false, false) + \"\\n\"\n workflow_data += workflow_metadata\n else\n return \"ERROR\"\n end\n \n return workflow_data\n end", "def summary; end", "def summary; end", "def summary; end", "def summary; end", "def process_data(data)\n print_headline\n tmp = data.dup\n\n # TELNETコマンドを抽出しダンプする.\n tmp.gsub!(/#{IAC}(\n [#{DONT}#{DO}#{WONT}#{WILL}].|\n #{SB}.(#{IAC}#{IAC}|[^#{IAC}])*#{IAC}#{SE}|\n [#{NOP}-#{GA}#{0.chr}-#{239.chr}]\n )/xon){\n case $1[0].chr\n when DONT; print \"> IAC DONT #{$1[1]}\\n\"\n when DO ; print \"> IAC DO #{$1[1]}\\n\"\n when WONT; print \"> IAC WONT #{$1[1]}\\n\"\n when WILL; print \"> IAC WILL #{$1[1]}\\n\"\n when SB ; print \"> IAC SB #{$1[1]} #{$1[2..-3].dump} IAC SE\\n\"\n else ; print \"> IAC #{$1[1]}\\n\"\n end\n }\n\n # 残りの部分を出力.\n tmp.each { |line| print line.dump, \"\\n\" } if tmp.size > 0\n end", "def rendered_format; end", "def rendered_format; end", "def print_day date\n @list ||= Array.read TODO\n @done ||= Array.read DONE\n @deleted ||= Array.read DELETED\n\n=begin\n YAML.load_file(RECURRENT).each do |taskstr,dates|\n if dates.include? date.wday #and !@deleted.select{|t| t[:scheduled] == date and t[:description] == taskstr}.empty?\n task = Task.new(taskstr.split(\" \"))\n task[:scheduled] = date.to_datetime\n @list << task if (@done+@list).select{|t| t.scheduled_at?(date) and t[:description] == task[:description]}.empty?\n end\n end\n @list.save TODO\n=end\n\n not_scheduled = (@list+@done).select{|t| t.day_dur(date) > 0.0 and !t.scheduled_at? date}\n all_stat = Stat.new not_scheduled, date, date#[@list,@done]\n done_stat = Stat.new @done, date, date\n todo_stat = Stat.new @list, date, date\n\n puts yellow(\"#{(date).strftime('%a %d %b %Y')} w#{todo_stat[:work][:planned].to_f.to_datetime}/f#{todo_stat[:not_work][:planned].to_f.to_datetime}/t#{todo_stat[:total][:planned].to_f.to_datetime}\")\n @list.each{|t| @list.print t if t[:scheduled] and t[:scheduled].to_date == date}\n\n if date == Date.today\n puts blue(\" Done: w#{done_stat[:work][:measured].to_f.to_datetime}/f#{done_stat[:not_work][:measured].to_f.to_datetime}/t#{done_stat[:total][:measured].to_f.to_datetime}\")\n @done.each do |t|\n if t[:finished] == date\n print \" \"\n @done.print t\n end\n end\n #puts cyan(\" Not scheduled: w#{all_stat[:work][:measured].to_f.to_datetime}/f#{all_stat[:not_work][:measured].to_f.to_datetime}/t#{all_stat[:total][:measured].to_f.to_datetime}\")\n @list.each do |t|\n unless t.day_dur(date) == 0.0 or t.scheduled_at? date\n print \" \"\n @list.print t\n end\n end\n @done.each do |t|\n unless t.day_dur(date) == 0.0 or t.scheduled_at? date\n print \" \"\n @done.print t\n end\n end\n end\nend", "def content\n lines = super.lines.to_a\n fixed = []\n current_line = 0\n offset = 0\n formatted_lines = markup.lines.to_a\n lines.each_with_index do |line, index|\n formatted_line = formatted_lines[index + offset]\n if line.strip == \"\" and (formatted_line and formatted_lines[index + offset].strip != \"\")\n offset -= 1\n else\n fixed << line\n end\n end\n lines = fixed.join(\"\")\n lines\n end", "def process_debug_info(inputfile, outputfile, view)\r\n \r\n input_data = File.open(inputfile){|f| f.readlines }\r\n \r\n output_data = Array.new\r\n\r\n input_data.each{|l|\r\n l.gsub!(@view_pattern){|p| \r\n if $1.strip == \"all\" then\r\n color=\"black\"\r\n else\r\n color=\"red\"\r\n end\r\n \r\n \"\\\\color{#{color}}\\\\rule{2cm}{0.5mm}\\\\marginpar{#{$1.strip}}\"\r\n\r\n }\r\n \r\n l.gsub!(/todo:|TODO:/){|p| \"#{p}\\\\marginpar{TODO}\"}\r\n \r\n output_data << l\r\n }\r\n\r\n File.open(outputfile, \"w\"){|f| f.puts output_data.join }\r\n end", "def template_data_format(data)\n data = data.to_smash\n Smash.new.tap do |result|\n result[:config] = data.fetch(:config, Smash.new)\n result[:imports] = data.fetch(:imports, []).map do |item|\n begin\n Smash.new(\n :name => item[:name],\n :content => YAML.load(item[:content])\n )\n rescue\n item\n end\n end\n if(result.get(:config, :content))\n result[:config][:content] = YAML.load(result[:config][:content]) || Smash.new\n else\n result[:config][:content] = Smash.new\n end\n end\n end", "def create_output(descriptions)\n# render view which will create actual mail report\n body = DcApplicationController.new.render_to_string(\n :template => 'models/dump_models',\n :locals => { descriptions: descriptions },\n :layout => 'models' \n ) \n File.open(Rails.root.join('public','models_dump.html'),'w') {|f| f.write(body)}\n#\n body = ''\n descriptions.each do |description|\n collection = description.first\n all_fields = description.last \n body << \"#\\n# == Schema information\\n#\\n\"\n body << \"# Collection name: #{collection['id']} : #{collection['description']}\\n#\\n\"\n \n all_fields.each do |field|\n body << \"# #{field['field'].ljust(20)} #{field['type'].to_s.ljust(20)} #{field['description']}\\n\"\n end\n body << \"\\n\\n\"\n end \n File.open(Rails.root.join('public','description_dump.html'),'w') {|f| f.write(body)}\nend", "def update_readme(data_hash)\n \n puts \"Updating README measure order...\"\n \n table_flag_start = \"MEASURE_WORKFLOW_START\"\n table_flag_end = \"MEASURE_WORKFLOW_END\"\n \n readme_path = \"README.md\"\n \n # Create table\n table_lines = []\n table_lines << \"|Group|Measure|Dependencies*|\\n\"\n table_lines << \"|:---|:---|:---|\\n\"\n data_hash.each do |group|\n new_group = true\n group[\"group_steps\"].each do |group_step|\n grp = \"\"\n if new_group\n grp = group[\"group_name\"]\n end\n name = group_step['name']\n deps = group_step['dependencies']\n table_lines << \"|#{grp}|#{name}|#{deps}|\\n\"\n new_group = false\n end\n end\n \n # Embed table in README text\n in_lines = IO.readlines(readme_path)\n out_lines = []\n inside_table = false\n in_lines.each do |in_line|\n if in_line.include? table_flag_start\n inside_table = true\n out_lines << in_line\n out_lines << table_lines\n elsif in_line.include? table_flag_end\n inside_table = false\n out_lines << in_line\n elsif not inside_table\n out_lines << in_line\n end\n end\n \n File.write(readme_path, out_lines.join(\"\"))\n \nend", "def formatted_data\n self.data['bids'] = adjusted('bids')\n self.data['asks'] = adjusted('asks')\n data\n end", "def render\n buffer = []\n _guess_col_widths\n rows = @list.size.to_s.length\n @rows = rows\n _prepare_format\n \n str = \"\"\n if @numbering\n str = \" \"*(rows+1)+@y\n end\n str << @fmstr % @columns\n buffer << str\n #puts \"-\" * str.length\n buffer << separator\n if @list\n if @numbering\n @fmstr = \"%#{rows}d \"+ @y + @fmstr\n end\n #@list.each { |e| puts e.join(@y) }\n count = 0\n @list.each_with_index { |r,i| \n value = convert_value_to_text r, count\n buffer << value\n count += 1\n }\n end\n buffer\n end", "def parse_from_summary(data)\n # \n end", "def format_arguments; end", "def to_s\n str = \"# #{@path}\\n#\\n# This file is managed by Chef\\n# Local changes may be lost!\\n\"\n\n last_had_comment = true\n @entries.sort.each do |entry|\n str << \"\\n\" if entry.comment || last_had_comment\n str << entry.format(columns)\n str << \"\\n\"\n last_had_comment = !entry.comment.nil?\n end\n\n str << \"\\n# End of file (#{@entries.size} #{@entries.size == 1 ? 'limit' : 'limits'})\\n\"\n str\n end", "def general_info\n return <<HERE\n Manuscript Title: #{self.title}<br />\n Manuscript Type: #{self.manuscript_type.name}<br />\n Main Subject Category: #{self.article_section.article_section_name}<br />\n Manuscript Counts<br />\n Pages: #{self.num_pages}<br />\n References: #{self.num_refs}<br />\n Tables: #{self.num_tables}<br />\n Figures: #{self.num_figures}<br />\n Supplemental Materials: #{self.num_suppl_mtrls}<br />\n Co-Authors: #{self.coauthors.count}<br />\nHERE\n end", "def outputs data\n data.each do |data|\n #puts \"DATA: #{data.inspect}\"\n #puts \" data mapping: #{data.map}\"\n #puts \"-----\"\n data.output\n end\nend", "def view args\n db = get_db\n id = args[0].nil? ? db.max_bug_id : args[0]\n db, row = validate_id id\n die \"No data found for #{id}\" unless row\n puts \"[#{row['type']} \\##{row['id']}] #{row['title']}\"\n puts \"Description:\"\n puts Cmdapp.indent(row['description'],3) if row['description']\n puts \"\\nAdded by #{row['created_by']} on #{row['date_created']}. Updated #{row['date_modified']}.\"\n comment_count = 0\n #puts row\n row.each_pair { |name, val| \n x = (name =~ /[A-Za-z]/)\n next unless x # 2011-09-21 skip names that are just numbers\n next if name == \"project\" && !$use_project\n next if name == \"version\" && !$use_version\n next if name == \"component\" && !$use_component\n next if %w{ id title description created_by date_created date_modified }.include? name\n comment_count = val.to_i if name == \"comment_count\"\n val = Cmdapp.indent2(val, 18) if name == \"fix\"\n n = sprintf(\"%-15s\", name); \n puts \"#{n} : #{val}\" \n }\n puts\n if comment_count > 0\n puts \"Comments :\"\n ctr = 0\n db.select_where \"comments\", \"id\", id do |r|\n #puts \"(#{r['date_created']}) [ #{r['created_by']} ] #{r['comment']}\"\n ctr += 1\n puts \"------- (#{r['date_created']}) #{r['created_by']} (#{ctr})------\"\n puts r['comment']\n end\n puts\n end\n puts \"Log:\"\n ctr = 0\n db.select_where \"log\", \"id\", id do |r|\n ctr += 1\n #puts \"------- (#{r['date_created']}) #{r['created_by']} ------\"\n puts \"------- #{r['date_created']} - #{r['created_by']} (#{ctr})------\"\n puts \" * [#{r['field']}]: #{r['log']} \"\n end\n #pp r\n end", "def fast_export_data(data)\n # add a newline if one isn't present\n lines = data.sub(/(?<!\\n)\\Z/, \"\\n\")\n size = lines.size\n return <<DATA.chomp\ndata #{size}\n#{data}\nDATA\nend", "def entries() end", "def pp_data(db, table, data = nil)\n if data == nil\n data = view_table(db, table)\n end\n pp_string = ''\n\n data.each do |entry|\n entry.each do |id, val| \n if id.is_a? String\n pp_string += \"#{id}: #{val}\\t| \" \n end \n end\n pp_string += \"\\n\"\n end\n pp_string\nend", "def beautify; end", "def beautify; end", "def formatStruct(theLines)\n\t# TODO\nend", "def format_data\n\t\n\t\n\tr = Rserve::Connection.new\n\tr.eval(\"file_path='/home/ruby/appdata/R1/'\")\n\tr.void_eval <<-EOF\n\n\tlibrary(xml2, warn.conflicts = FALSE)\n\tsuppressMessages(library(foreach, warn.conflicts = FALSE))\n\tsuppressMessages(library(doSNOW, warn.conflicts = FALSE))\n\tlibrary(plyr, warn.conflicts = FALSE)\n\tsuppressMessages(library(data.table, warn.conflicts = FALSE))\n\tlibrary(dtplyr, warn.conflicts = FALSE)\n\tlibrary(dplyr, warn.conflicts = FALSE)\n\tlibrary(purrr, warn.conflicts = FALSE)\n\tlibrary(stringr, warn.conflicts = FALSE)\n\tlibrary(pipeR, warn.conflicts = FALSE)\n\tlibrary(rlist, warn.conflicts = FALSE)\n\tlibrary(tidyr)\n\t \n\tdat <- fread(paste(file_path,\"input/input.csv\",sep=\"\"))\n\tdat$統計日期 <- dat$統計日期 %>>% as.Date\n\tdat %>>% group_by(課別名稱,統計日期,商品類別名稱,卡友分群類別名稱) %>>%\n\t summarise(全館消費金額=sum(全館消費金額)) %>>% ungroup %>>%\n\t write.csv(paste(file_path,\"output/output.csv\",sep=\"\"))\n\tEOF\n # r.eval(\"file_path\").to_ruby\n\n end", "def project_to_line\n end", "def formation; end", "def formatForLIMSUpload()\n result = \"TOTAL_READS \" + @totalReadsProduced.to_s +\n \" DUPLICATE_READS \" + @numDuplicateReads.to_s +\n \" PERCENT_DUPLICATE_READS \" + @perDuplicateReads.to_s +\n \" TOTAL_ALIGNED_READS \" + @numAlignedReads.to_s +\n \" PERCENT_ALIGNED_READS \" + @perAlignedReads.to_s +\n \" READS_PAIRED \" + @numReadsPaired.to_s + \n \" READS_PAIRED_MAPPED_MATES \" + @numReadAndMatePaired.to_s +\n \" BUFFER_ALIGNED_READS \" + @numBufferAlignedReads.to_s +\n \" PERCENT_BUFFER_ALIGNED_READS \" + @perBufferAlignedReads.to_s +\n \" TARGET_ALIGNED_READS \" + @numTargetAlignedReads.to_s +\n \" PERCENT_TARGET_ALIGNED_READS \" + @perTargetAlignedReads.to_s +\n \" AVERAGE_COVERAGE \" + @avgCoverage.to_s +\n \" READS_ON_TARGET_OR_BUFFER \" + @numReadsTargetBuffer.to_s +\n \" PERCENT_READS_ON_TARGET_OR_BUFFER \" + @perReadsTargetBuffer.to_s +\n \" TOTAL_EXPECTED_ALIGNED_READS \" + @totalExpAlignedReads.to_s +\n \" TOTAL_CALC_ALIGNED_READS \" + @totalCalcAlignedReads.to_s + \n \" TARGETS_HIT \" + @numTargetsHit.to_s + \" PERCENT_TARGETS_HIT \" + @perTargetsHit.to_s +\n \" TARGET_BUFFERS_HIT \" + @numTargetBuffersHit.to_s +\n \" PER_TARGET_BUFFERS_HITS \" + @perTargetBuffersHit.to_s +\n \" TOTAL_TARGETS \" + @numTotalTargets.to_s +\n \" HIGH_COVERAGE_NON_TARGET_HITS \" + @numNonTarget.to_s +\n \" BASES_ON_TARGET \" + @numTargetedBases.to_s + \" BASES_ON_BUFFER \" + @numBufferBases.to_s +\n \" ONE_COVERAGE_BASES \" + @numBases1Coverage.to_s +\n \" PER_ONE_COVERAGE_BASES \" + @perBases1Coverage.to_s +\n \" FOUR_COVERAGE_BASES \" + @numBases4Coverage.to_s +\n \" PER_FOUR_COVERAGE_BASES \" + @perBases4Coverage.to_s +\n \" TEN_COVERAGE_BASES \" + @numBases10Coverage.to_s +\n \" PER_TEN_COVERAGE_BASES \" + @perBases10Coverage.to_s +\n \" TWENTY_COVERAGE_BASES \" + @numBases20Coverage.to_s +\n \" PER_TWENTY_COVERAGE_BASES \" + @perBases20Coverage.to_s +\n \" FORTY_COVERAGE_BASES \" + @numBases40Coverage.to_s +\n \" PER_FORTY_COVERAGE_BASES \" + @perBases40Coverage.to_s\n return result\n end", "def make_info_mano_onlogs\r\n @log.debug \"make_info_mano_onlogs\"\r\n @mano_coll = []\r\n curr_ix = 0\r\n curr_mano_info = {:ix => curr_ix, :data => []}\r\n @data_logs.each do |line|\r\n #p line\r\n if line =~ /new_mano/\r\n @mano_coll << curr_mano_info if curr_mano_info.size > 0\r\n curr_ix += 1\r\n curr_mano_info = {:ix => curr_ix, :data => []}\r\n else\r\n curr_mano_info[:data] << line \r\n end\r\n end\r\n end", "def build_output(items, no_of_issues, v_name, r_date, n_branch, target)\n target = target\n\n output_filename = v_name + '_changelog_for_' + target + '.txt'\n out_file = File.new(output_filename, 'w')\n\n # Categories counter\n c_cnt = 0\n # Issues with category counter\n i_cnt = 0\n # Issues without category counter\n nc_i_cnt = 0\n\n if target == 'packaged_file'\n out_file << \"== #{r_date} v#{v_name}\\n\\n\"\n elsif target == 'website'\n out_file << \"h1. Changelog #{v_name}\\n\\n\" if n_branch == true\n out_file << \"h2. version:#{v_name} (#{r_date})\\n\\n\"\n end\n\n # Print the categories...\n items.each do |key, values|\n key = key.empty? ? '-none-' : key\n\n if target == 'packaged_file'\n out_file << \"=== [#{key}]\\n\"\n elsif target == 'website'\n out_file << \"h3. [#{key}]\\n\"\n end\n out_file << \"\\n\"\n (c_cnt += 1) unless key == '-none-'\n\n # ...and their associated issues\n values.each do |val|\n out_file << \"* #{val['tracker']} ##{val['id']}: #{val['subject']}\\n\"\n key == '-none-' ? (nc_i_cnt += 1) : (i_cnt += 1)\n end\n out_file << \"\\n\"\n end\n\n summary(v_name, target, i_cnt, nc_i_cnt, no_of_issues, c_cnt)\n\n out_file.close\n end", "def parse_file_data\n current_category = nil\n todo_lines = []\n File.open(@config_file) {|fl| todo_lines = fl.readlines() }\n line_count = 0\n todo_lines.each do |todo_line|\n todo_line.strip!.chomp!\n next if todo_line.nil? or todo_line.empty?\n case todo_line\n when /^\\*{1}\\ (.+)?/\n current_category = $1\n line_count = 0\n @todo_container[current_category] ||= []\n when /^(\\*{2,})\\ TODO\\ (.+)?/\n priority = $1.size\n item = OpenStruct.new(:priority => priority, :flag => true, :text => $2,:index => line_count )\n line_count += 1\n @todo_container[current_category] << item\n when /^(\\*{2,})\\ DONE\\ (.+)?/\n priority = $1.size\n item = OpenStruct.new(:priority => priority, :flag => false, :text => $2,:index => line_count )\n line_count += 1\n @todo_container[current_category].push(item)\n end\n end\n end", "def get_data()\t\n\tend", "def toDataMetaForm\n result = <<DATAMETAFORM_HEADER\n/*\n Backspace codes specified as standard ASCII:\n http://www.december.com/html/spec/ascii.html\n\n There may be extra codes introduced later\n*/\nrecord\nDATAMETAFORM_HEADER\n indent = ' ' * 4\n @items.each { |i|\n result << indent << i.toDataMetaForm\n result << \"\\n\" if i.kind_of?(Field) # skip a line for a field for looks\n }\n result << \"\\n\" unless result[-1..-1] == \"\\n\"\n result << \"end\\n\"\n end", "def parse_table; end", "def showData\n $page = $page +\n \"<dl>\\n\" +\n \" <dt>name\\n\" +\n \" <dd>\" + $name + \"\\n\" +\n \" <dt>organization\\n\" +\n \" <dd>\" + $organization + \"\\n\" +\n \" <dt>email\\n\" +\n \" <dd>\" + $email + \"\\n\" +\n \" <dt>source\\n\" +\n \" <dd>\" + $source + \"\\n\" +\n \" <dt>use\\n\" +\n \" <dd>\" + $use + \"\\n\" +\n \" <dt>notification\\n\" +\n \" <dd>\" + $notification + \"\\n\" +\n \"</dl>\\n\"\nend", "def inspect\n tmp = @data\n begin\n @data = nil\n @data_summary = (\"#{tmp.size},#{tmp[0,256]}\" if tmp)\n return super\n ensure\n @data = tmp\n @data_summary = nil\n end\n end", "def format_list(items); end", "def private; end", "def to_s\n header_output = build_header_output\n data_output = build_data_output\n\n string = ''\n string << Yummi.colorize(@title, @style[:title]) << $/ if @title\n string << Yummi.colorize(@description, @style[:description]) << $/ if @description\n table_data = header_output + data_output\n if @layout == :vertical\n # don't use array transpose because the data may differ in each line size\n table_data = rotate table_data\n end\n string << content(table_data)\n end", "def handle_notes(notes)\n\n notes.each do |note|\n\n prefix = case note['type']\n when 'dimensions'; \"Dimensions\"\n when 'physdesc'; \"Physical Description note\"\n when 'materialspec'; \"Material Specific Details\"\n when 'physloc'; \"Location of resource\"\n when 'phystech'; \"Physical Characteristics / Technical Requirements\"\n when 'physfacet'; \"Physical Facet\"\n when 'processinfo'; \"Processing Information\"\n when 'separatedmaterial'; \"Materials Separated from the Resource\"\n else; nil\n end\n\n #20160829LJD: Add additional note types for export.\n marc_args = case note['type']\n\n when 'arrangement', 'fileplan'\n ['351','b']\n when 'odd', 'dimensions', 'physdesc', 'materialspec', 'physloc', 'phystech', 'physfacet', 'processinfo', 'separatedmaterial'\n ['500','a']\n when 'accessrestrict'\n ['506','a']\n # when 'scopecontent'\n # ['520', '2', ' ', 'a']\n when 'abstract'\n ['520', '3', ' ', 'a']\n when 'prefercite'\n ['524', '8', ' ', 'a']\n when 'acqinfo'\n ind1 = note['publish'] ? '1' : '0'\n ['541', ind1, ' ', 'a']\n when 'relatedmaterial'\n ['544','n']\n # when 'bioghist'\n # ['545','a']\n when 'custodhist'\n ind1 = note['publish'] ? '1' : '0'\n ['561', ind1, ' ', 'a']\n when 'appraisal'\n ind1 = note['publish'] ? '1' : '0'\n ['583', ind1, ' ', 'a']\n when 'accruals'\n ['584', 'a']\n when 'altformavail'\n ['535', '2', ' ', 'a']\n when 'originalsloc'\n ['535', '1', ' ', 'a']\n when 'userestrict', 'legalstatus'\n ['540', 'a']\n when 'langmaterial'\n ['546', 'a']\n # when 'otherfindaid'\n # ['555', '0', ' ', 'a']\n else\n nil\n end\n\n unless marc_args.nil?\n text = prefix ? \"#{prefix}: \" : \"\"\n text += ASpaceExport::Utils.extract_note_text(note, @include_unpublished, true)\n\n # only create a tag if there is text to show (e.g., marked published or exporting unpublished)\n if text.length > 0\n df!(*marc_args[0...-1]).with_sfs([marc_args.last, *Array(text)])\n end\n end\n\n end\n end", "def details_data\n# column_widths = @settings.collect{|s| pdf.width_of(s[:header].last, :size => pdf.font_size) + 5 }\n\n font_size = pdf.font_size\n padding = (cell_padding + cell_border_width)*2\n @rows.collect do |r|\n @settings.collect{|s|\n content = \"\"\n align = :left\n contents = []\n \n if s[:header].first == \"remark\"\n content = r.remark.to_s\n contents += content.split(/\\r?\\n/)\n elsif s[:header].first == \"revision_no\"\n case r\n when HeaderRow\n content = r.latest_revision_no.to_s\n when RevisionRow\n content = r.rev_no.to_s\n when DetailRow\n content = r.revision_row.rev_no.to_s\n end\n contents << content\n else\n field = Field.field_by_row(s[:header].first, r)\n actual_row = Field.row_by_field(field, r)\n content = Field.value_by_field_name(field, actual_row) unless actual_row.nil?\n contents += content.to_s.split(/\\r?\\n/)\n\n case field\n when Fields::Formula, Fields::Accumulation\n align = :right\n else\n case field.custom_field\n when CustomFields::NumericField\n align = :right\n when CustomFields::DateTimeField\n align = :center\n end\n end\n end\n \n max_content_width = contents.collect{|c| pdf.width_of(c, :size => font_size) }.max\n\n width = max_content_width.to_i + padding\n \n {\n :content => content,\n :align => align,\n :width => width\n }\n }\n end\n end", "def main_description; end", "def output; end", "def output; end", "def output; end", "def output; end", "def output; end", "def output; end", "def output; end" ]
[ "0.62854195", "0.62854195", "0.62854195", "0.603524", "0.603524", "0.603524", "0.603524", "0.603524", "0.603524", "0.603524", "0.603524", "0.59537464", "0.59504", "0.59374535", "0.59374535", "0.5783593", "0.5762262", "0.57610136", "0.5756537", "0.5734288", "0.5711039", "0.5711039", "0.5711039", "0.5711039", "0.5711039", "0.5711039", "0.5711039", "0.5711039", "0.5711039", "0.5711039", "0.5711039", "0.5711039", "0.5699439", "0.5673612", "0.56694263", "0.5667206", "0.56415343", "0.5620876", "0.5570986", "0.5550518", "0.55389863", "0.55032957", "0.5481749", "0.54570234", "0.5442121", "0.54297054", "0.5427755", "0.5420854", "0.5409467", "0.5384633", "0.5384633", "0.5384633", "0.5384633", "0.5382687", "0.5377469", "0.5377469", "0.5353304", "0.5352998", "0.5352021", "0.5350758", "0.53423214", "0.5335133", "0.5330788", "0.5328886", "0.53280807", "0.5326671", "0.5324996", "0.5304428", "0.5296372", "0.52921796", "0.5291137", "0.5288696", "0.52844965", "0.52837336", "0.52837336", "0.5279487", "0.52736104", "0.52730054", "0.5269729", "0.5268301", "0.5256188", "0.52503955", "0.52465534", "0.52448255", "0.5217034", "0.52167404", "0.5214447", "0.5203544", "0.51993746", "0.51938015", "0.51899636", "0.51899594", "0.5186382", "0.51857823", "0.5184379", "0.5184379", "0.5184379", "0.5184379", "0.5184379", "0.5184379", "0.5184379" ]
0.0
-1
GET /tipo_convenios/1 GET /tipo_convenios/1.json
def show @tipo_convenio = TipoConvenio.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @tipo_convenio } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @tipo_contrato = TipoContrato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_contrato }\n end\n end", "def index\n @cooperativas = Cooperativa.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cooperativas }\n end\n end", "def show\n @consumo = Consumo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @consumo }\n end\n end", "def show\n @concurso = Concurso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @concurso }\n end\n end", "def show\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_vehiculo }\n end\n end", "def show\n @tipo_negocio = TipoNegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_negocio }\n end\n end", "def show\n @categorias_tipo = CatTipo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @categorias_tipo }\n end\n end", "def index\n @subcategorias = Subcategoria.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @subcategorias }\n end\n end", "def index\n @categorias = Categoria.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @categorias }\n end\n end", "def show\n @tipo_pensum = TipoPensum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_pensum }\n end\n end", "def index\n @concursos = Concurso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @concursos }\n end\n end", "def show\n @concedente = Concedente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @concedente }\n end\n end", "def show\n @denuncia_tipo = DenunciaTipo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @denuncia_tipo }\n end\n end", "def show\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pago }\n end\n end", "def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end", "def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end", "def show\n @tipo_actividad = TipoActividad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_actividad }\n end\n end", "def show\n @colegio = Colegio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colegio }\n end\n end", "def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @tecnico }\n end\n end", "def show\n @tipo_documento = TipoDocumento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_documento }\n end\n end", "def new\n @tipo_convenio = TipoConvenio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_convenio }\n end\n end", "def show\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @veiculo }\n end\n end", "def index\n @ofertas = Oferta.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ofertas }\n end\n end", "def show\n @categorialivro = Categorialivro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @categorialivro }\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.json { render json: @tipo_usuario }\n end\n end", "def show\n @tipo_atendimento = TipoAtendimento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_atendimento }\n end\n end", "def show\n @venta = Venta.find(params[:id])\n\n @domicilios = Domicilio.where(usuario_id: @venta.usuario.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @venta }\n end\n end", "def show\n @contratacao = Contratacao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contratacao }\n end\n end", "def show\n @conta = Conta.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @conta, :include => {\n :movimentos => {\n :include => [:nota, :pessoa],\n :methods => [:favorecido],\n :except => [:created_at, :updated_at]\n }\n },\n :methods => [:saldo]\n }\n end\n end", "def show\n @tipo_pregunta = TipoPregunta.find(params[:id])\n\n render json: @tipo_pregunta\n end", "def show\n @articulo = Articulo.find(params[:id])\n @noticias = Articulo.where(\"tipo = 'noticia'\").order(\"created_at desc\")\n @title = @articulo.titulo\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @articulo }\n end\n end", "def index\n @tipo_veiculos = TipoVeiculo.all\n end", "def index\n @conseilles = Conseille.all\n respond_to do |format|\n format.html\n format.json { render json: @conseilles}\n end\n end", "def show\n\n @evento = Evento.find(params[:id])\n @comentarios = Comentario.where(:comentavel_id => @evento.id, :comentavel_type => \"Evento\").order('created_at DESC')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evento }\n end\n end", "def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end", "def show\n @contato_produto = ContatoProduto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contato_produto }\n end\n end", "def index\n if params[:site_id].nil? or params[:site_id].empty?\n @comentarios = Comentario.all # path: /types\n else\n @comentarios = Site.find(params[:site_id]).comentarios # path: /sites/id/comentarios\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comentarios }\n end\n end", "def show\n @comentario = Comentario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comentario }\n end\n end", "def show\n @comentario = Comentario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comentario }\n end\n end", "def show\n @cuerpo = Cuerpo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cuerpo }\n end\n end", "def show\n @core_tipo_unidade = Core::TipoUnidade.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @core_tipo_unidade }\n end\n end", "def show\n @colegiatura = Colegiatura.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colegiatura }\n end\n end", "def index\n\n if params[:ventas_seguimiento]\n cliente_id = params[:ventas_seguimiento][:cliente_id]\n @ventas_seguimientos = Ventas::Seguimiento.where(\"cliente_id = ?\",cliente_id).order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 5)\n @seguimientos = Ventas::Seguimiento.new(:cliente_id => cliente_id)\n else\n @ventas_seguimientos = Ventas::Seguimiento.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 5)\n @seguimientos = Ventas::Seguimiento.new\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_seguimientos }\n end\n end", "def show\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @servicio }\n end\n end", "def show\n @tipo_contrato = TipoContrato.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipo_contrato }\n end\n end", "def show\n @core_status_selo_fiscal_tipo = Core::StatusSeloFiscalTipo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @core_status_selo_fiscal_tipo }\n end\n end", "def show\n @indicativo = Indicativo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indicativo }\n end\n end", "def show\n @tipo_curso = TipoCurso.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipo_curso }\n end\n end", "def show\n @recurso = Recurso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recurso }\n end\n end", "def index\n @formatos = Formato.where(ativo: true)\n \t\n render json: @formatos\n end", "def index\n if params[:categoria_producto]\n render json: Producto.find(params[:producto_id]).categorias\n else\n\t\t @categorias = Categoria.all\n render json: @categorias\n end\n\tend", "def index\n @tipo_denuncia = TipoDenuncium.all\n\n render json: @tipo_denuncia\n end", "def show\n @ativo_outro = AtivoOutro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ativo_outro }\n end\n end", "def show\n @tipo_product = TipoProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_product }\n end\n end", "def index\n @tipo_usuarios = TipoUsuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipo_usuarios }\n end\n end", "def show\n @arquivo = Arquivo.find(params[:id])\n @comentarios = Comentario.where(:comentavel_id => @arquivo.id, :comentavel_type => \"Arquivo\").order('created_at DESC')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @arquivo }\n end\n end", "def new\n @consumo = Consumo.new\n @consumo.cliente = Cliente.find(params[:cliente])\n #@cliente = params[:cliente] # \"value1\"\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @consumo }\n end\n end", "def index\n @categorias = Categoria.where(ativo: true)\n \t\n render json: @categorias\n end", "def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end", "def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end", "def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end", "def show\n @observacao_vocacionada = ObservacaoVocacionada.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observacao_vocacionada }\n end\n end", "def show\n @ventas_seguimiento = Ventas::Seguimiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ventas_seguimiento }\n end\n end", "def show\n @competicao = Competicao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competicao }\n end\n end", "def show\n @fulcliente = Fulcliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fulcliente }\n end\n end", "def show\n @tipo_item = TipoItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_item }\n end\n end", "def show\n @lista_contato = ListaContato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lista_contato }\n end\n end", "def show\n @plato = Plato.find(params[:id])\n\n if !@plato.comentario.first.nil?\n render json: @plato.as_json(only: [:id, :nombre, :precio, :categoria, :tipo, :calificaciones, :total, :soda_id], include: [comentario:{only: [:id]}])\n else\n render json: @plato.as_json(only: [:id, :nombre, :precio, :categoria, :tipo, :calificaciones, :total, :soda_id])\n end\n end", "def new\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pago }\n end\n end", "def index\n @tipo_de_servicios = TipoDeServicio.all\n end", "def show\n @reconocimiento = Reconocimiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @reconocimiento }\n end\n end", "def show\n @cliente = Cliente.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end", "def show\n @plannegocio = Plannegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plannegocio }\n end\n end", "def index\n @peticion_servicio_tis = Peticion::ServicioTi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peticion_servicio_tis }\n end\n end", "def index\n @contas = Conta.all\n respond_to do |format|\n format.json { render json: @contas.to_json, status: :ok }\n end\n end", "def show\n @perfilnegocio = Perfilnegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @perfilnegocio }\n end\n end", "def show\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @solicitud_servicio }\n end\n end", "def show\n @tipo_vinculo = TipoVinculo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipo_vinculo }\n end\n end", "def index\n @tipo_venta = TipoVentum.all\n end", "def show\n @documentotipo = Documentotipo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @documentotipo }\n end\n end", "def show\n if params[:id]\n @cooperativa = Cooperativa.find(params[:id])\n else\n @cooperativa = Cooperativa.find(params[:cooperativa_id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cooperativa }\n end\n end", "def show\n @coisa = Coisa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @coisa }\n end\n end", "def show\n render json: @itemtipo\n end", "def show\n @seguro = Seguro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seguro }\n end\n end", "def show\n @areco = Areco.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @areco }\n end\n end", "def show\n @requerimiento ||= Requerimiento.where(:numero => params[:id]).first\n @areas = Area.where(\" nombre like '%DIT%' \")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @requerimiento }\n end\n end", "def get\n @cine = Cine.find(params[:cine_id], :select => [\"nombre\",\"id\",\"direccion\",\"localidad\"])\n render :json => [ @cine, :peliculas => @cine.peliculas.select('titulo,horas,pelicula_id') ]\n end", "def find_client\n cliente = get_cliente(params[:id])\n\n respond_to do |format|\n format.json {render json: {client: cliente}}\n end\n end", "def index\n @contratos = Contrato.all\n end", "def show\n @dependencia = Dependencia.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dependencia }\n end\n end", "def show\n @contrato = Contrato.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @contrato }\n format.js\n end\n end", "def show\n @status_de_la_inscripcion = StatusDeLaInscripcion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @status_de_la_inscripcion }\n end\n end", "def index\n @convidados = Convidado.all\n end", "def index\n @tipo_products = TipoProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipo_products }\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 @sezione = Sezione.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sezione }\n end\n end", "def index\n if params[:propietario]\n @usuario = Usuario.find(params[:usuario_id])\n authorize! :show, @usuario\n @negocios_propios = Usuario.find(params[:usuario_id]).negocios_propios\n render json: @negocios_propios,\n root: 'negocios_propios',\n each_serializer: NegocioPropioSerializer\n else\n @negocios = Negocio.all\n render json: @negocios\n end\n end", "def index\n @contas = Conta.where(nil) #Inicia Escopo\n @contas = @contas.conta_numero(params[:contaNumero]) if params[:contaNumero].present?\n @contas = @contas.conta_descricao(params[:contaDescricao]) if params[:contaDescricao].present?\n @contas = @contas.agencia_numero(params[:agenciaNumero]) if params[:agenciaNumero].present?\n @contas = @contas.banco_id(params[:bancoId]) if params[:bancoId].present?\n\n @contas = @contas.paginate(:page => params[:page], :per_page => params[:per_page])\n respond_to do |format|\n format.html { render :index }\n format.json { render json: {contas: @contas.as_json(:include => [:banco], methods: [:conta, :agencia, :saldo]), total: @contas.total_entries}}\n end\n end", "def show \n est = @establecimiento\n respond_to do |format|\n format.html\n format.json { \n\n if (params[:appkey].eql? appkey) #si el appkey es correcto\n render :json => {:nombre => @establecimiento.nombre, direccion: @establecimiento.direccion, :latitud => @establecimiento.latitud,\n :longitud => @establecimiento.longitud, :descripcion => @establecimiento.descripcion, :imagen => @establecimiento.foto.url(:small),\n :comentarios => @establecimiento.EstComentarios.map { |comentario| { :descripcion => comentario.descripcion, :usuario => comentario.usuario.nombre } } } \n\n else\n render json: {:error => \"No autorizado\"}\n end\n\n\n }\n end\n #No tiene restricciones, queda abierto para el API\n end", "def index\n \n if current_user.tipo == 2\n @receita_medicas = ReceitaMedica.where(:medico_id => current_user.id)\n elsif current_user.tipo == 1\n @receita_medicas = ReceitaMedica.where(:paciente_id => current_user.id)\n elsif current_user.tipo == 3\n @receita_medicas = Venda.receitas_medicas(current_user.id)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @receita_medicas }\n end\n end" ]
[ "0.7094906", "0.67918247", "0.67725545", "0.6759573", "0.67560804", "0.6745839", "0.65608364", "0.6555574", "0.6537344", "0.65112025", "0.64990485", "0.6467223", "0.6427331", "0.6426641", "0.6419957", "0.6419957", "0.6414807", "0.63988423", "0.6375387", "0.63596445", "0.63534874", "0.6337377", "0.6328032", "0.63040763", "0.6300594", "0.62949383", "0.6291169", "0.62798285", "0.62513566", "0.6247659", "0.62399685", "0.62385386", "0.6237401", "0.62334955", "0.6226582", "0.6219183", "0.6207237", "0.61925125", "0.61925125", "0.6191299", "0.6175607", "0.6161775", "0.6161466", "0.61609197", "0.61563987", "0.61400825", "0.6138087", "0.6134107", "0.61319834", "0.6126966", "0.6122196", "0.611889", "0.6116581", "0.6111461", "0.61110485", "0.610817", "0.6093761", "0.6093184", "0.6090535", "0.6090535", "0.6090535", "0.6077865", "0.60728985", "0.6069435", "0.6069249", "0.6064927", "0.6051372", "0.6040972", "0.604055", "0.60366255", "0.60338366", "0.6031943", "0.60311043", "0.60258603", "0.6025767", "0.60189563", "0.59989977", "0.5995989", "0.59918857", "0.5988914", "0.59789443", "0.59681576", "0.5959849", "0.5957144", "0.5955341", "0.595082", "0.5949461", "0.59444034", "0.5941486", "0.5940084", "0.5928376", "0.59251314", "0.5924874", "0.59194887", "0.5918933", "0.5918249", "0.5915764", "0.59145826", "0.59111005", "0.5908901" ]
0.7124635
0
GET /tipo_convenios/new GET /tipo_convenios/new.json
def new @tipo_convenio = TipoConvenio.new respond_to do |format| format.html # new.html.erb format.json { render json: @tipo_convenio } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @tipo_negocio = TipoNegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_negocio }\n end\n end", "def new\n @tipo_pensum = TipoPensum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_pensum }\n end\n end", "def new\n @tipo_vehiculo = TipoVehiculo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_vehiculo }\n end\n end", "def new\n @tipo_actividad = TipoActividad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_actividad }\n end\n end", "def new\n @categorias_tipo = CatTipo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @categorias_tipo }\n end\n end", "def new\n @tipo_usuario = TipoUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_usuario }\n end\n end", "def new\n @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recurso }\n end\n end", "def new\n @tecnico = Tecnico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tecnico }\n end\n end", "def new\n @tipo_atendimento = TipoAtendimento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_atendimento }\n end\n end", "def new\n @concurso = Concurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @concurso }\n end\n end", "def new\n @tipo_documento = TipoDocumento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_documento }\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 @tecnico = Tecnico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @tecnico }\n end\n end", "def new\n @contrato = Contrato.new\n\n respond_to do |format|\n format.html { render layout: nil } # new.html.erb\n format.json { render json: @contrato }\n end\n end", "def new\n @veiculo = Veiculo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @veiculo }\n end\n end", "def new\n @denuncia_tipo = DenunciaTipo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @denuncia_tipo }\n end\n end", "def create\n @tipo_negocio = TipoNegocio.new(params[:tipo_negocio])\n\n respond_to do |format|\n if @tipo_negocio.save\n format.html { redirect_to @tipo_negocio, notice: 'Tipo negocio was successfully created.' }\n format.json { render json: @tipo_negocio, status: :created, location: @tipo_negocio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_negocio.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @cliente = Cliente.new\n localidad_new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cliente }\n end\n end", "def new\n @tipo_product = TipoProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_product }\n end\n end", "def new\n puts 'NEW METHOD'\n @pessoa = Pessoa.new\n @pessoa.enderecos.build\n 2.times { @pessoa.telefones.build }\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pessoa }\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 @tipo_curso = TipoCurso.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_curso }\n end\n end", "def new\n @tipo_item = TipoItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_item }\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 @venta = Venta.new(:fecha => Date.today, confirmada: true)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @venta }\n end\n end", "def new\n @peso = Peso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @peso }\n end\n end", "def create\n @tipo_convenio = TipoConvenio.new(params[:tipo_convenio])\n\n respond_to do |format|\n if @tipo_convenio.save\n format.html { redirect_to @tipo_convenio, notice: 'Tipo convenio was successfully created.' }\n format.json { render json: @tipo_convenio, status: :created, location: @tipo_convenio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_convenio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :create, Tipo\n @tipo = Tipo.new(tipo_params)\n log(\"Se ha creado la nomina #{@lt}\", 0)\n\n respond_to do |format|\n if @tipo.save\n format.html { redirect_to tipos_path, notice: 'La nómina fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @tipo }\n else\n format.html { render :new }\n format.json { render json: @tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @comentario = Comentario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comentario }\n end\n end", "def new\n @noto = Noto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @noto }\n end\n end", "def new\n @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 @colegio = Colegio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @colegio }\n end\n end", "def new\n @categorialivro = Categorialivro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @categorialivro }\n end\n end", "def new\n @plannegocio = Plannegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plannegocio }\n end\n end", "def create\n @tipo_veiculo = TipoVeiculo.new(tipo_veiculo_params)\n\n respond_to do |format|\n if @tipo_veiculo.save\n format.html { redirect_to @tipo_veiculo, notice: 'Tipo veiculo was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_veiculo }\n else\n format.html { render :new }\n format.json { render json: @tipo_veiculo.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @perfilnegocio = Perfilnegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @perfilnegocio }\n end\n end", "def new\n @servicio = Servicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @servicio }\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 @persona_tipo = PersonaTipo.new\n if current_user.is_admin?\n @congresos = Congreso.all(:order => \"nombre\")\n else\n @congresos = current_user.congresos(:order => \"nombre\")\n end\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @persona_tipo }\n end\n end", "def new\n @caixa = Caixa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @caixa }\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 @cuerpo = Cuerpo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cuerpo }\n end\n end", "def new\n @categoria = Categoria.new\n @categoria.status = Status.find_by_descricao('Ativo')\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @categoria }\n end\n end", "def new\n @pologeno = Pologeno.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pologeno }\n end\n end", "def new\n @projeto = Projeto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projeto }\n end\n end", "def new\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cliente }\n end\n end", "def new\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cliente }\n end\n end", "def new\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cliente }\n end\n end", "def new\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cliente }\n end\n end", "def new\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cliente }\n end\n end", "def new\n @core_tipo_unidade = Core::TipoUnidade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @core_tipo_unidade }\n end\n end", "def new\n @premio = Premio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @premio }\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 @coisa = Coisa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @coisa }\n end\n end", "def new\n @reconocimiento = Reconocimiento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @reconocimiento }\n end\n end", "def new\n @trnodo = Trnodo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trnodo }\n end\n end", "def new\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pago }\n end\n end", "def new\n @categoria = Categoria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @categoria }\n end\n end", "def new\n @clasificacion_pegi = ClasificacionPegi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clasificacion_pegi }\n end\n end", "def new\n @premio = Premio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @premio }\n end\n end", "def new\n DebugLog(params.inspect)\n @lancamentorapido = Lancamentorapido.new\n \n @categorias = Category.all\n @centrosdecusto = Centrodecusto.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lancamentorapido }\n end\n end", "def new\n @status_de_la_inscripcion = StatusDeLaInscripcion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @status_de_la_inscripcion }\n end\n end", "def new\n @vocacionada = Vocacionada.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vocacionada }\n end\n end", "def new\n @requerimiento = Requerimiento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @requerimiento }\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 @peticion_servicio_ti = Peticion::ServicioTi.new\n load_data\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @peticion_servicio_ti }\n end\n end", "def new\n @produto = Produto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @produto }\n end\n end", "def new\n @propuesta = Propuesta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @propuesta }\n end\n end", "def new\n @competicao = Competicao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competicao }\n end\n end", "def new\n @tipo_conta = TipoConta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_conta }\n end\n end", "def new\n @sistema = Sistema.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sistema }\n end\n end", "def new\n @pagamento = Pagamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pagamento }\n end\n end", "def new\n @tipo_tel = TipoTel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_tel }\n end\n end", "def create\n @evolucao_tipo = EvolucaoTipo.new(evolucao_tipo_params)\n\n respond_to do |format|\n if @evolucao_tipo.save\n format.html { redirect_to @evolucao_tipo, notice: 'Evolucao tipo was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evolucao_tipo }\n else\n format.html { render action: 'new' }\n format.json { render json: @evolucao_tipo.errors, status: :unprocessable_entity }\n end\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 @prioridade = Prioridade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prioridade }\n end\n end", "def new\n @vano = Vano.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vano }\n end\n end", "def new\n @capacidad = Capacidad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @capacidad }\n end\n end", "def new\n @documentotipo = Documentotipo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @documentotipo }\n end\n end", "def new\n @indicacao = Indicacao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indicacao }\n end\n end", "def new\n @areco = Areco.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @areco }\n end\n end", "def new\n @pedido = Pedido.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pedido }\n end\n end", "def create\n @veiculo = Veiculo.new(params[:veiculo])\n\n respond_to do |format|\n if @veiculo.save\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully created.' }\n format.json { render :json => @veiculo, :status => :created, :location => @veiculo }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @comisaria = Comisaria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comisaria }\n end\n end", "def new\n @seguro = Seguro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seguro }\n end\n end", "def new\n @colegiatura = Colegiatura.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @colegiatura }\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 @congreso = Congreso.new\n @campos = Campo.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @congreso }\n end\n end", "def create\n authorize! :create, Tipo\n @tipo = Tipo.new(tipo_params)\n\n\n respond_to do |format|\n if @tipo.save\n format.html { redirect_to tipos_path, notice: '<i class=\"fa fa-check-square fa-lg\"></i> La nómina fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @tipo }\n else\n format.html { render :new }\n format.json { render json: @tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @ventas_seguimiento = Ventas::Seguimiento.new params[:ventas_seguimiento]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ventas_seguimiento }\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 @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 @tipo_iva = TipoIva.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_iva }\n end\n end", "def new\n @titulacionesdoctipo = Titulacionesdoctipo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @titulacionesdoctipo }\n end\n end", "def new\n @ctype = Ctype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ctype }\n end\n end", "def new\n @carrera = Carrera.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @carrera }\n end\n end", "def create\n @tipo_vehiculo = TipoVehiculo.new(params[:tipo_vehiculo])\n\n respond_to do |format|\n if @tipo_vehiculo.save\n format.html { redirect_to @tipo_vehiculo, notice: 'Tipo vehiculo was successfully created.' }\n format.json { render json: @tipo_vehiculo, status: :created, location: @tipo_vehiculo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_vehiculo.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @po = Po.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @po }\n end\n end", "def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end", "def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end" ]
[ "0.77312815", "0.7632935", "0.7581101", "0.7501306", "0.7468367", "0.74403334", "0.74272454", "0.7398976", "0.73842394", "0.7372472", "0.7366392", "0.733274", "0.73322", "0.7308771", "0.7290168", "0.7282418", "0.7263765", "0.7245985", "0.72378975", "0.72123754", "0.7205718", "0.7198557", "0.71949685", "0.71810406", "0.7168977", "0.7165633", "0.7129922", "0.7129397", "0.71279985", "0.71156836", "0.7114584", "0.71089864", "0.71022874", "0.71009034", "0.70959395", "0.7094811", "0.7087755", "0.7085962", "0.7079139", "0.7078915", "0.7078312", "0.70723677", "0.7059555", "0.7059008", "0.70528364", "0.70494103", "0.70494103", "0.70494103", "0.70494103", "0.70494103", "0.70483315", "0.70428985", "0.704196", "0.70417583", "0.70403445", "0.70382655", "0.70161456", "0.70072734", "0.70051676", "0.7000154", "0.69973385", "0.69969785", "0.69961256", "0.69926953", "0.6984802", "0.69832885", "0.69818604", "0.69791645", "0.697655", "0.6974378", "0.6974241", "0.69718546", "0.6959279", "0.69582057", "0.6952932", "0.6952655", "0.69501275", "0.69490695", "0.6947996", "0.6941169", "0.69402164", "0.6937929", "0.6932109", "0.69308096", "0.6930397", "0.69299906", "0.6925389", "0.6923757", "0.69160455", "0.6915033", "0.6910853", "0.690944", "0.69059265", "0.6905497", "0.69021654", "0.6899563", "0.68943274", "0.6892928", "0.68899965", "0.68899965" ]
0.7872798
0
POST /tipo_convenios POST /tipo_convenios.json
def create @tipo_convenio = TipoConvenio.new(params[:tipo_convenio]) respond_to do |format| if @tipo_convenio.save format.html { redirect_to @tipo_convenio, notice: 'Tipo convenio was successfully created.' } format.json { render json: @tipo_convenio, status: :created, location: @tipo_convenio } else format.html { render action: "new" } format.json { render json: @tipo_convenio.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @cliente = Cliente.new\n if params[:type] == \"PessoaFisica\"\n @cliente.pessoa = PessoaFisica.new\n else\n @cliente.pessoa = PessoaJuridica.new\n end\n @cliente.assign_attributes(cliente_params)\n respond_to do |format|\n if @cliente.save\n format.html { redirect_to action: \"index\"}\n format.json { render json: @cliente.to_json(include: [:pessoa]) }\n else\n format.html { render :new }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @consumo = Consumo.new(params[:consumo])\n\n respond_to do |format|\n if @consumo.save\n format.html { redirect_to @consumo.cliente, :notice => 'Consumo adicionado com sucesso.' }\n format.json { render :json => @consumo, :status => :created, :location => @consumo }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @consumo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_veiculo = TipoVeiculo.new(tipo_veiculo_params)\n\n respond_to do |format|\n if @tipo_veiculo.save\n format.html { redirect_to @tipo_veiculo, notice: 'Tipo veiculo was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_veiculo }\n else\n format.html { render :new }\n format.json { render json: @tipo_veiculo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @convidado = Convidado.new(convidado_params)\n\n respond_to do |format|\n if @convidado.save\n format.html { redirect_to @convidado, notice: 'Convidado was successfully created.' }\n format.json { render :show, status: :created, location: @convidado }\n else\n format.html { render :new }\n format.json { render json: @convidado.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_comunicacao = TipoComunicacao.new(tipo_comunicacao_params)\n\n respond_to do |format|\n if @tipo_comunicacao.save\n format.html { redirect_to @tipo_comunicacao, notice: 'Tipo comunicacao was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_comunicacao }\n else\n format.html { render :new }\n format.json { render json: @tipo_comunicacao.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_de_servicio = TipoDeServicio.new(tipo_de_servicio_params)\n\n respond_to do |format|\n if @tipo_de_servicio.save\n format.html { redirect_to @tipo_de_servicio, notice: 'Tipo de servicio was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_de_servicio }\n else\n format.html { render :new }\n format.json { render json: @tipo_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @persona_tipo = PersonaTipo.new(params[:persona_tipo])\n\n respond_to do |format|\n if @persona_tipo.save\n format.html { redirect_to @persona_tipo, notice: 'Tipo de Participante registrado correctamente.' }\n format.json { render json: @congreso, status: :created, location: @persona_tipo }\n else\n if current_user.is_admin?\n @congresos = Congreso.all(:order => \"nombre\")\n else\n @congresos = current_user.congresos(:order => \"nombre\")\n end\n format.html { render action: \"new\" }\n format.json { render json: @persona_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @congresso = Congresso.new(congresso_params)\n\n respond_to do |format|\n if @congresso.save\n format.html { redirect_to @congresso, notice: 'Congresso was successfully created.' }\n format.json { render :show, status: :created, location: @congresso }\n else\n format.html { render :new }\n format.json { render json: @congresso.errors, status: :unprocessable_entity }\n end\n end\n end", "def tipo_veiculo_params\n params.require(:tipo_veiculo).permit(:tipo)\n end", "def resource_params\n params.require(:tratamiento).permit(:tipo)\n end", "def create\n @tipo_negocio = TipoNegocio.new(params[:tipo_negocio])\n\n respond_to do |format|\n if @tipo_negocio.save\n format.html { redirect_to @tipo_negocio, notice: 'Tipo negocio was successfully created.' }\n format.json { render json: @tipo_negocio, status: :created, location: @tipo_negocio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_negocio.errors, status: :unprocessable_entity }\n end\n end\n end", "def tipo_conta_params\n params.require(:tipo_conta).permit(:codigo, :nome, :descricao)\n end", "def solicitacao_tipo_params\n params.require(:solicitacao_tipo).permit(:tipo)\n end", "def create\n @concurso = Concurso.new(params[:concurso])\n\n respond_to do |format|\n if @concurso.save\n format.html { redirect_to @concurso, notice: 'Concurso criado com sucesso.' }\n format.json { render json: @concurso, status: :created, location: @concurso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @concurso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_cancha = TipoCancha.new(tipo_cancha_params)\n\n respond_to do |format|\n if @tipo_cancha.save\n format.html { redirect_to @tipo_cancha, notice: 'Tipo cancha was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_cancha }\n else\n format.html { render :new }\n format.json { render json: @tipo_cancha.errors, status: :unprocessable_entity }\n end\n end\n end", "def tipo_fornecedor_params\n params.require(:tipo_fornecedor).permit(:nome, :condominio_id, :tenant_id)\n end", "def create\n @tecnico = Tecnico.new(params[:tecnico])\n\n respond_to do |format|\n if @tecnico.save\n format.html { redirect_to @tecnico, :notice => 'Tecnico was successfully created.' }\n format.json { render :json => @tecnico, :status => :created, :location => @tecnico }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tecnico.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @pessoacondominio = Pessoacondominio.new(pessoacondominio_params)\n\n respond_to do |format|\n if @pessoacondominio.save\n format.html { redirect_to @pessoacondominio, notice: 'Pessoa cadastrada com sucesso.' }\n format.json { render :show, status: :created, location: @pessoacondominio }\n else\n format.html { render :new }\n format.json { render json: @pessoacondominio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_vehiculo = TipoVehiculo.new(params[:tipo_vehiculo])\n\n respond_to do |format|\n if @tipo_vehiculo.save\n format.html { redirect_to @tipo_vehiculo, notice: 'Tipo vehiculo was successfully created.' }\n format.json { render json: @tipo_vehiculo, status: :created, location: @tipo_vehiculo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_vehiculo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evolucao_tipo = EvolucaoTipo.new(evolucao_tipo_params)\n\n respond_to do |format|\n if @evolucao_tipo.save\n format.html { redirect_to @evolucao_tipo, notice: 'Evolucao tipo was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evolucao_tipo }\n else\n format.html { render action: 'new' }\n format.json { render json: @evolucao_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :create, Tipo\n @tipo = Tipo.new(tipo_params)\n log(\"Se ha creado la nomina #{@lt}\", 0)\n\n respond_to do |format|\n if @tipo.save\n format.html { redirect_to tipos_path, notice: 'La nómina fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @tipo }\n else\n format.html { render :new }\n format.json { render json: @tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def tipo_venda_params\n params.require(:tipo_venda).permit(:tipo)\n end", "def create\n authorize! :create, Tipo\n @tipo = Tipo.new(tipo_params)\n\n\n respond_to do |format|\n if @tipo.save\n format.html { redirect_to tipos_path, notice: '<i class=\"fa fa-check-square fa-lg\"></i> La nómina fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @tipo }\n else\n format.html { render :new }\n format.json { render json: @tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tecnico = Tecnico.new(params[:tecnico])\n\n respond_to do |format|\n if @tecnico.save\n format.html { redirect_to @tecnico, notice: 'Tecnico criado com sucesso.' }\n format.json { render json: @tecnico, status: :created, location: @tecnico }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @denuncia_tipo = DenunciaTipo.new(params[:denuncia_tipo])\n\n respond_to do |format|\n if @denuncia_tipo.save\n format.html { redirect_to @denuncia_tipo, notice: 'Denuncia tipo was successfully created.' }\n format.json { render json: @denuncia_tipo, status: :created, location: @denuncia_tipo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @denuncia_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @consumo = Consumo.new(consumo_params)\n\n respond_to do |format|\n if @consumo.save\n format.html { redirect_to @consumo, notice: 'Consumo was successfully created.' }\n format.json { render :show, status: :created, location: @consumo }\n else\n format.html { render :new }\n format.json { render json: @consumo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # Crear nuevo voto\n @voto = Voto.new(params[:voto])\n\n # Asociarlo con el usuario\n @voto.usuario_id = current_usuario.id\n\n # Asociarlo con la Pregunta o Respuesta\n votable_type = params[:voto][:votable_type]\n votable_id = params[:voto][:votable_id]\n if votable_type=='Pregunta'\n @voto.votable = Pregunta.find(votable_id)\n else\n @voto.votable = Respuesta.find(votable_id)\n end\n\n respond_to do |format|\n if @voto.save\n resp = {\n :votos_total => @voto.votable.votos_total,\n :votos_menos => @voto.votable.votos_menos,\n :votos_mas => @voto.votable.votos_mas\n }\n format.json { render json: resp, status: :created, location: @voto }\n else\n format.json { render json: @voto.errors, status: :unprocessable_entity }\n end\n end\n end", "def evolucao_tipo_params\n params.require(:evolucao_tipo).permit(:nome, :inativo, campos_attributes: [ :id, :nome, :titulo, :requerido, :tipo_campo, :_destroy ])\n end", "def create\n @empresa = Empresa.find(params[:empresa_id])\n\n @tipo_de_imposto = TipoDeImposto.new(tipo_de_imposto_params)\n @tipo_de_imposto.empresa_id = @empresa.id\n\n respond_to do |format|\n if @tipo_de_imposto.save\n format.html { redirect_to @empresa, notice: 'Tipo de imposto adicionado com sucesso.' }\n format.json { render :show, status: :created, location: @tipo_de_imposto }\n else\n format.html { render :new }\n format.json { render json: @tipo_de_imposto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_ventum = TipoVentum.new(tipo_ventum_params)\n\n respond_to do |format|\n if @tipo_ventum.save\n format.html { redirect_to @tipo_ventum, notice: 'Tipo ventum was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_ventum }\n else\n format.html { render :new }\n format.json { render json: @tipo_ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_fornecedor = TipoFornecedor.new(tipo_fornecedor_params)\n\n respond_to do |format|\n if @tipo_fornecedor.save\n #format.html { redirect_to @tipo_fornecedor, notice: 'Tipo de fornecedor foi criado com sucesso.' }\n format.html { redirect_to tenant_tipo_fornecedors_path(tenant_id: @tenant.id), notice: 'Tipo de fornecedor foi criado com sucesso.' }\n else\n format.html { render :new }\n format.json { render json: @tipo_fornecedor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_pensum = TipoPensum.new(params[:tipo_pensum])\n\n respond_to do |format|\n if @tipo_pensum.save\n format.html { redirect_to @tipo_pensum, notice: 'Tipo pensum was successfully created.' }\n format.json { render json: @tipo_pensum, status: :created, location: @tipo_pensum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_pensum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tiposveiculo = Tiposveiculo.new(tiposveiculo_params)\n\n respond_to do |format|\n if @tiposveiculo.save\n format.html { redirect_to tiposveiculos_url, notice: 'Tipo de Veículo criado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :new }\n format.json { render json: @tiposveiculo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipoenvolvido = Tipoenvolvido.new(tipoenvolvido_params)\n\n respond_to do |format|\n if @tipoenvolvido.save\n format.html { redirect_to @tipoenvolvido, notice: 'Tipoenvolvido was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tipoenvolvido }\n else\n format.html { render action: 'new' }\n format.json { render json: @tipoenvolvido.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contrato = Contrato.new(contrato_params)\n\n respond_to do |format|\n if @contrato.save\n @contrato.anadir_conceptosdepago(@contrato.fecha_inicio, @contrato.fecha_fin)\n format.html { redirect_to @contrato, notice: 'Contrato fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @contrato }\n else\n format.html { render :new }\n format.json { render json: @contrato.errors, status: :unprocessable_entity }\n end\n end\n end", "def socioeduk_tipo_contato_params\n params.require(:socioeduk_tipo_contato).permit(:descricao)\n end", "def convidado_params\n params.require(:convidado).permit(:nome, :nome_no_convite, :conjuge, :endereco, :bairro, :cidade, :descricao)\n end", "def create\n @servico_pacote = Servico::Pacote.new(servico_pacote_params)\n\n respond_to do |format|\n if @servico_pacote.save\n format.html { redirect_to @servico_pacote, notice: 'Pacote was successfully created.' }\n format.json { render action: 'show', status: :created, location: @servico_pacote }\n else\n format.html { render action: 'new' }\n format.json { render json: @servico_pacote.errors, status: :unprocessable_entity }\n end\n end\n end", "def tipo_params\n params.require(:tipo).permit(:descricao)\n end", "def representante_params\n params.require(:representante).permit(:responsavel, :nome_fantasia, :cpf_cnpj, :telefone, :email, :cep, :endereco, :logradouro, :bairro, :cidade, :estado, :status)\n end", "def create\n @concurso = Concurso.new(concurso_params)\n\n respond_to do |format|\n if @concurso.save\n format.html { redirect_to @concurso, notice: 'Concurso ha sido creado correctamente.' }\n format.json { render :show, status: :created, location: @concurso }\n else\n format.html { render :new }\n format.json { render json: @concurso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_pregunta = TipoPregunta.new(params[:tipo_pregunta])\n\n if @tipo_pregunta.save\n render json: @tipo_pregunta, status: :created, location: @tipo_pregunta\n else\n render json: @tipo_pregunta.errors, status: :unprocessable_entity\n end\n end", "def create\n @tipo_propiedad = TipoPropiedad.new(tipo_propiedad_params)\n\n respond_to do |format|\n if @tipo_propiedad.save\n format.html { redirect_to @tipo_propiedad, notice: 'Tipo propiedad was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_propiedad }\n else\n format.html { render :new }\n format.json { render json: @tipo_propiedad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_actividad = TipoActividad.new(params[:tipo_actividad])\n\n respond_to do |format|\n if @tipo_actividad.save\n format.html { redirect_to @tipo_actividad, notice: 'Tipo actividad was successfully created.' }\n format.json { render json: @tipo_actividad, status: :created, location: @tipo_actividad }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_actividad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cooperativa = Cooperativa.new(params[:cooperativa])\n\n respond_to do |format|\n if @cooperativa.save\n format.html { redirect_to [:admin, @cooperativa], :notice => 'Exemplo was successfully created.' }\n format.json { render :json => @cooperativa, :status => :created, :location => @cooperativa }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @cooperativa.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n \n @categorias_tipo = CatTipo.new(params[:cat_tipo])\n\n\t\trespond_to do |format|\n\t\t\tif @categorias_tipo.save\n \t\t\tcategories = @categorias_tipo.update_attributes(:tipo_acc_ids =>params[:tipo_accs])\n\t\t\t\t@categorias_tipo.update_attributes(:estado_ids =>params[:estados])\n\t\t\t\t\n\t\t\t\n\n format.html { redirect_to cat_tipos_path, notice: 'OK' }\n format.json { render json: @categorias_tipo, status: :created, location: @categorias_tipo }\n\t\t\telse\n format.html { render action: \"new\" }\n format.json { render json: @categorias_tipo.errors, status: :unprocessable_entity }\n \tend\t\n\t\tend\n\tend", "def create\n @administracao_concurso = Administracao::Concurso.new(administracao_concurso_params)\n\n respond_to do |format|\n if @administracao_concurso.save\n format.html { redirect_to @administracao_concurso, notice: 'Concurso was successfully created.' }\n format.json { render :show, status: :created, location: @administracao_concurso }\n else\n format.html { render :new }\n format.json { render json: @administracao_concurso.errors, status: :unprocessable_entity }\n end\n end\n end", "def convite_params\n params.require(:convite).permit(:anfitriao, :anos, :dataevento, :horainicio, :horafinal)\n end", "def create\n @tipo_actividad = TipoActividad.new(tipo_actividad_params)\n\n respond_to do |format|\n if @tipo_actividad.save\n format.html { redirect_to @tipo_actividad, notice: 'Tipo actividad se creó correctamente.' }\n format.json { render :show, status: :created, location: @tipo_actividad }\n else\n format.html { render :new }\n format.json { render json: @tipo_actividad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipocosto = Tipocosto.new(tipocosto_params)\n\n respond_to do |format|\n if @tipocosto.save\n format.html { redirect_to @tipocosto, notice: 'Tipocosto was successfully created.' }\n format.json { render :show, status: :created, location: @tipocosto }\n else\n format.html { render :new }\n format.json { render json: @tipocosto.errors, status: :unprocessable_entity }\n end\n end\n end", "def servico_pacote_params\n params.require(:servico_pacote).permit(:dataInicio, :dataRetorno, :destino, :localSaida, :nomeTrans, :veiculo, :cnpjTrans, :precoTrans, :nomeHotel, :cnpjHotel, :descHotel, :descQuarto, :precoHotel, :descPacote, :precoPacote, :status)\n end", "def tipo_ventum_params\n params.require(:tipo_ventum).permit(:tipoVenta)\n end", "def create\n @tipo_venda = TipoVenda.new(tipo_venda_params)\n\n respond_to do |format|\n if @tipo_venda.save\n format.html { redirect_to @tipo_venda, notice: 'Tipo venda was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_venda }\n else\n format.html { render :new }\n format.json { render json: @tipo_venda.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_orden = TipoOrden.new(tipo_orden_params)\n\n respond_to do |format|\n if @tipo_orden.save\n format.html { redirect_to @tipo_orden, notice: 'Tipo orden was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_orden }\n else\n format.html { render :new }\n format.json { render json: @tipo_orden.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # Crear nuevo comentario\n @comentario = Comentario.new(params[:comentario])\n\n # Asociarlo con el usuario\n @comentario.usuario_id = current_usuario.id\n\n # Asociarlo con la Pregunta o Respuesta\n comentable_type = params[:comentario][:comentable_type]\n comentable_id = params[:comentario][:comentable_id]\n if comentable_type=='Pregunta'\n @comentario.comentable = Pregunta.find(comentable_id)\n else\n @comentario.comentable = Respuesta.find(comentable_id)\n end\n\n respond_to do |format|\n if @comentario.save\n format.html do \n redirect_to pregunta_url(@pid, :anchor => \"comentario_#{@comentario.id}\")\n end\n format.json { render json: @comentario, status: :created, location: @comentario }\n else\n format.html do \n @respuesta = Respuesta.new\n @pregunta = Pregunta.find(@pid)\n render template: \"preguntas/show\"\n end\n format.json { render json: @comentario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_contrato = TipoContrato.new(params[:tipo_contrato])\n\n respond_to do |format|\n if @tipo_contrato.save\n format.html { redirect_to tipo_contratos_path, notice: 'Tipo de contrato criado com sucesso.' }\n format.json { render json: @tipo_contrato, status: :created, location: @tipo_contrato }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_contrato.errors, status: :unprocessable_entity }\n format.js { render json: @tipo_contrato.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @veiculo = Veiculo.new(params[:veiculo])\n\n respond_to do |format|\n if @veiculo.save\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully created.' }\n format.json { render :json => @veiculo, :status => :created, :location => @veiculo }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @copropietario = Copropietario.new(copropietario_params)\n\n respond_to do |format|\n if @copropietario.save\n format.html { redirect_to @copropietario, notice: 'Copropietario was successfully created.' }\n format.json { render :show, status: :created, location: @copropietario }\n else\n format.html { render :new }\n format.json { render json: @copropietario.errors, status: :unprocessable_entity }\n end\n end\n end", "def conta_params\n params.require(:conta).permit(:correntista_id, :flag_ativo, :created_at, :updated_at, :saldo, :saldoProvisorio)\n end", "def create\n @tipo_compra = TipoCompra.new(tipo_compra_params)\n\n respond_to do |format|\n if @tipo_compra.save\n format.html { redirect_to @tipo_compra, notice: 'Tipo compra was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_compra }\n else\n format.html { render :new }\n format.json { render json: @tipo_compra.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipoapreensao = Tipoapreensao.new(tipoapreensao_params)\n\n respond_to do |format|\n if @tipoapreensao.save\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tipoapreensao }\n else\n format.html { render action: 'new' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_contrato = TipoContrato.new(params[:tipo_contrato])\n \n respond_to do |format|\n if @tipo_contrato.save\n flash[:notice] = 'TiposContratos creada correctamente.'\n format.html { params[:oper].nil? ? redirect_to(@tipo_contrato) : render(:text => \"Ok\")}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tipo_contrato.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @condicao_pagamento = CondicaoPagamento.new(condicao_pagamento_params)\n\n respond_to do |format|\n if @condicao_pagamento.save\n format.html { redirect_to @condicao_pagamento, notice: 'Condicao pagamento was successfully created.' }\n format.json { render :show, status: :created, location: @condicao_pagamento }\n else\n format.html { render :new }\n format.json { render json: @condicao_pagamento.errors, status: :unprocessable_entity }\n end\n end\n end", "def socioeduk_contato_params\n params.require(:socioeduk_contato).permit(:jovem_id, :tipo_contato_id, :ddd, :numero)\n end", "def create\n @solicitacao_tipo = SolicitacaoTipo.new(solicitacao_tipo_params)\n\n respond_to do |format|\n if @solicitacao_tipo.save\n format.html { redirect_to @solicitacao_tipo, notice: 'Solicitacao tipo was successfully created.' }\n format.json { render action: 'show', status: :created, location: @solicitacao_tipo }\n else\n format.html { render action: 'new' }\n format.json { render json: @solicitacao_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def tipocosto_params\n params.require(:tipocosto).permit(:nombre, :descripcion)\n end", "def create\n @informativo_obra = InformativoObra.new(informativo_obra_params)\n\n @status = Statusobra.find_by_statusobra_type(\"Salvo\")\n @informativo_obra.statusobra_id = @status.id\n\n respond_to do |format|\n if @informativo_obra.save\n format.html { redirect_to @informativo_obra, notice: 'Informativo de obra foi criado com sucesso.' }\n format.json { render :show, status: :created, location: @informativo_obra }\n else\n format.html { render :new }\n format.json { render json: @informativo_obra.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @conveniado = Conveniado.new(params[:conveniado])\n \n\n respond_to do |format|\n if @conveniado.save\n flash[:notice] = 'Conveniado was successfully created.'\n format.html { redirect_to(@conveniado) }\n format.xml { render :xml => @conveniado, :status => :created, :location => @conveniado }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @conveniado.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_de_pago = TipoDePago.new(tipo_de_pago_params)\n\n respond_to do |format|\n if @tipo_de_pago.save\n format.html { redirect_to @tipo_de_pago, notice: 'Tipo de pago fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @tipo_de_pago }\n else\n format.html { render :new }\n format.json { render json: @tipo_de_pago.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ativo = Ativo.new(ativo_params)\n\n respond_to do |format|\n if @ativo.save\n format.html { redirect_to @ativo, notice: \"#{type} was successfully created.\" }\n format.json { render :show, status: :created, location: @ativo }\n else\n format.html { render :new }\n format.json { render json: @ativo.errors, status: :unprocessable_entity }\n end\n end\n end", "def caixa_params\n params.require(:caixa).permit(:data, :responsavel, :status)\n end", "def new\n @tipo_convenio = TipoConvenio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_convenio }\n end\n end", "def transacciontipo_params\n params.require(:transacciontipo).permit(:codigo, :nombre)\n end", "def cuenca_params\n params.require(:cuenca).permit(:id_vertiente, :nombre, :id_status)\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 tipo_params\n params.require(:tipo).permit(:nombre)\n end", "def tipo_params\n params.require(:tipo).permit(:nombre)\n end", "def create\r\n\r\n respond_to do |format|\r\n if @consejero.save\r\n format.html { redirect_to @consejero, notice: 'Se añadió un nombre de consejero correctamente.' }\r\n format.json { render :show, status: :created, location: @consejero }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @consejero.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n if params[:propietario]\n @negocio_propio = Negocio.find(params[:negocio_id])\n @propietario = Usuario.find(params[:usuario_id])\n authorize! :update, @propietario\n if @propietario.negocios_propios << @negocio_propio\n render json: @propietario.negocios_propios, status: :created\n else\n render json: @propietario.negocios_propios.errors, status: :unprocessable_entity\n end\n else\n @negocio = Negocio.new(parametros_negocio)\n authorize! :create, Negocio\n if @negocio.save\n render json: @negocio, status: :created\n else\n render json: @negocio.errors, status: :unprocessable_entity\n end\n end\n end", "def create\n @contatos_cliente = ContatosCliente.new(contatos_cliente_params)\n\n respond_to do |format|\n if @contatos_cliente.save\n format.html { redirect_to @contatos_cliente, notice: 'Contatos cliente was successfully created.' }\n format.json { render :show, status: :created, location: @contatos_cliente }\n else\n format.html { render :new }\n format.json { render json: @contatos_cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recurso = Recurso.new(params[:recurso])\n\n respond_to do |format|\n if @recurso.save\n format.html { redirect_to @recurso, notice: 'O recurso de auto de infração foi criado com sucesso.' }\n format.json { render json: @recurso, status: :created, location: @recurso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recurso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @anteproyecto_observacion = AnteproyectoObservacion.new(anteproyecto_observacion_params)\n\n respond_to do |format|\n if @anteproyecto_observacion.save\n format.html { redirect_to @anteproyecto_observacion, notice: 'Anteproyecto observacion was successfully created.' }\n format.json { render :show, status: :created, location: @anteproyecto_observacion }\n else\n format.html { render :new }\n format.json { render json: @anteproyecto_observacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n\t\t@tienda_cliente = @cliente.tiendas_clientes.build(tienda_cliente_params)\n\n respond_to do |format|\n if @tienda_cliente.save\n format.html { redirect_to @tienda_cliente, notice: 'La tienda se creó exitosamente.' }\n format.json { render :show, status: :created, location: @tienda_cliente }\n else\n format.html { render :new }\n format.json { render json: @tienda_cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipoocorrencium = Tipoocorrencium.new(tipoocorrencium_params)\n\n respond_to do |format|\n if @tipoocorrencium.save\n format.html { redirect_to @tipoocorrencium, notice: 'Tipoocorrencium was successfully created.' }\n format.json { render :show, status: :created, location: @tipoocorrencium }\n else\n format.html { render :new }\n format.json { render json: @tipoocorrencium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_aposta = TipoAposta.new(tipo_aposta_params)\n\n respond_to do |format|\n if @tipo_aposta.save\n format.html { redirect_to @tipo_aposta, notice: 'Tipo aposta was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_aposta }\n else\n format.html { render :new }\n format.json { render json: @tipo_aposta.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @intranet_financeiro_tipos_cobanca = Intranet::FinanceiroTiposCobanca.new(intranet_financeiro_tipos_cobanca_params)\n\n respond_to do |format|\n if @intranet_financeiro_tipos_cobanca.save\n format.html { redirect_to @intranet_financeiro_tipos_cobanca, notice: \"Financeiro tipos cobanca was successfully created.\" }\n format.json { render :show, status: :created, location: @intranet_financeiro_tipos_cobanca }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @intranet_financeiro_tipos_cobanca.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @usuario = Usuario.find(params[:usuario_id])\n @copenometro = Copenometro.new(copenometro_params)\n @copenometro.usuario = @usuario\n\n respond_to do |format|\n if @copenometro.save\n format.html { redirect_to @usuario, notice: 'Agregado con Exito' }\n format.json { render :show, status: :created, location: @copenometro }\n else\n format.html { render :new }\n format.json { render json: @copenometro.errors, status: :unprocessable_entity }\n end\n end\n end", "def consumo_params\n params.require(:consumo).permit(:idConsumo, :idEquipo, :idPersona, :idProveedor, :fecha, :valor, :comentario, :idTipoConsumo, :idEstadoConsumo, :idCategoriaConsumo, :kilometraje, :cant, :idUnidadMedida, :idRubro, :numFactura, :idUsuario, :eliminado, :idFacturas)\n end", "def create\n @conta = Conta.new(conta_params)\n\n # @conta.correntista = Correntista.find(params[:id])\n respond_to do |format|\n if @conta.save\n format.html { redirect_to correntista_conta_index_path, notice: 'Conta was successfully created.' }\n format.json { render :show, status: :created, location: @conta }\n else\n format.html { render :new }\n format.json { render json: @conta.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_de_imovel = TipoDeImovel.new(tipo_de_imovel_params)\n\n respond_to do |format|\n if @tipo_de_imovel.save\n format.html { redirect_to @tipo_de_imovel, notice: 'Tipo de imovel was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_de_imovel }\n else\n format.html { render :new }\n format.json { render json: @tipo_de_imovel.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @os_nivel_servico = OsNivelServico.new(os_nivel_servico_params)\n\n respond_to do |format|\n if @os_nivel_servico.save\n format.html { redirect_to @os_nivel_servico, notice: 'Os nivel servico foi criado(a)' }\n format.json { render :show, status: :created, location: @os_nivel_servico }\n else\n format.html { render :new }\n format.json { render json: @os_nivel_servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def troca\n @remetente = Sobrevivente.where(id: params[:de]).first\n @destinatario = Sobrevivente.where(id: params[:para]).first\n\n enviar = {agua: 1, comida: 2, medicamento: 3, municao: 4}\n receber = {agua: 0, comida: 2, medicamento: 3, municao: 8}\n\n trocou = @remetente.troca(@destinatario, enviar, receber)\n\n render json: { status: trocou }\n end", "def contato_params\n params.require(:contato).permit(:nome, :cargo, :telefone, :celular, :email, :facebook, :linkedin, :googleplus, :cliente_potencial_id)\n end", "def tipo_de_servicio_params\n params.require(:tipo_de_servicio).permit(:nombre)\n end", "def tipoapreensao_params\n params.require(:tipoapreensao).permit(:ttpcodigo, :ttpatualiza)\n end", "def contato_params\n params.require(:contato).permit(:nome, :email, :idade, :estado_id, :cargo)\n end", "def create\n @categorialivro = Categorialivro.new(params[:categorialivro])\n\n respond_to do |format|\n if @categorialivro.save\n format.html { redirect_to @categorialivro, :notice => 'Categorialivro was successfully created.' }\n format.json { render :json => @categorialivro, :status => :created, :location => @categorialivro }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @categorialivro.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @inventario_cosa = InventarioCosa.new(inventario_cosa_params)\n\n respond_to do |format|\n if @inventario_cosa.save\n format.html { redirect_to @inventario_cosa, notice: 'Inventario cosa was successfully created.' }\n format.json { render :show, status: :created, location: @inventario_cosa }\n else\n format.html { render :new }\n format.json { render json: @inventario_cosa.errors, status: :unprocessable_entity }\n end\n end\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 recursoshumanos_tipo_vinculo_params\n params.require(:recursoshumanos_tipo_vinculo).permit(:nome)\n end" ]
[ "0.6784479", "0.6755005", "0.6635388", "0.6617056", "0.6607979", "0.65592074", "0.6539847", "0.6523403", "0.6498797", "0.64897305", "0.6486794", "0.6445604", "0.641651", "0.6395924", "0.63954407", "0.6392188", "0.6383946", "0.6374849", "0.63693905", "0.6363753", "0.63596064", "0.6358854", "0.6348141", "0.6347555", "0.63395315", "0.6330355", "0.63227975", "0.6314842", "0.6309776", "0.6297417", "0.6285881", "0.6279583", "0.62584066", "0.6255567", "0.6255499", "0.62525845", "0.6250501", "0.62472683", "0.6245493", "0.6242057", "0.6241633", "0.6229992", "0.62279856", "0.6213537", "0.6213268", "0.6207266", "0.6194808", "0.61868876", "0.6186197", "0.61854464", "0.618476", "0.6183995", "0.6182554", "0.6173401", "0.6173281", "0.6167184", "0.6162263", "0.61615354", "0.6157445", "0.61516136", "0.61457145", "0.6145472", "0.61418205", "0.61323136", "0.6127866", "0.6119167", "0.61174566", "0.6111327", "0.61096203", "0.61066186", "0.61007077", "0.609932", "0.6096704", "0.6091985", "0.60907", "0.60892963", "0.60892963", "0.6085952", "0.6084926", "0.6082453", "0.60791504", "0.60790074", "0.6077318", "0.6073897", "0.6072369", "0.6068964", "0.6066329", "0.60661507", "0.60623014", "0.60603994", "0.6053773", "0.60503244", "0.60426396", "0.6041139", "0.60386854", "0.60308456", "0.60302037", "0.60245126", "0.60236436", "0.60235775" ]
0.66853106
2
PUT /tipo_convenios/1 PUT /tipo_convenios/1.json
def update @tipo_convenio = TipoConvenio.find(params[:id]) respond_to do |format| if @tipo_convenio.update_attributes(params[:tipo_convenio]) format.html { redirect_to @tipo_convenio, notice: 'Tipo convenio was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @tipo_convenio.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 authorize! :update, Tipo\n respond_to do |format|\n if @tipo.update(tipo_params)\n format.html { redirect_to tipos_path, notice: '<i class=\"fa fa-check-square fa-lg\"></i> Los datos de la nómina fueron actualizados exitosamente.' }\n format.json { head :no_content }\n end\n end\n end", "def update\n @tipo_contrato = TipoContrato.find(params[:id])\n\n respond_to do |format|\n if @tipo_contrato.update_attributes(params[:tipo_contrato])\n format.html { redirect_to tipo_contratos_path, notice: 'Tipo de contrato atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_contrato.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @consumo = Consumo.find(params[:id])\n\n respond_to do |format|\n if @consumo.update_attributes(params[:consumo])\n format.html { redirect_to @consumo.cliente, :notice => 'Consumo alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @consumo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_negocio = TipoNegocio.find(params[:id])\n\n respond_to do |format|\n if @tipo_negocio.update_attributes(params[:tipo_negocio])\n format.html { redirect_to @tipo_negocio, notice: 'Tipo negocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_negocio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_de_servicio.update(tipo_de_servicio_params)\n format.html { redirect_to @tipo_de_servicio, notice: 'Tipo de servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_de_servicio }\n else\n format.html { render :edit }\n format.json { render json: @tipo_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_veiculo.update(tipo_veiculo_params)\n format.html { redirect_to @tipo_veiculo, notice: 'Tipo veiculo was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_veiculo }\n else\n format.html { render :edit }\n format.json { render json: @tipo_veiculo.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_tipo_veiculo\n @tipo_veiculo = TipoVeiculo.find(params[:id])\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 respond_to do |format|\n if @tipo_comunicacao.update(tipo_comunicacao_params)\n format.html { redirect_to @tipo_comunicacao, notice: 'Tipo comunicacao was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_comunicacao }\n else\n format.html { render :edit }\n format.json { render json: @tipo_comunicacao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, Concepto\n if params[:concepto][:tipo_ids]\n params[:concepto][:tipo_ids] = params[:concepto][:tipo_ids].map { |k, _v| k }\n else\n params[:concepto][:tipo_ids] = []\n end\n\n respond_to do |format|\n if @concepto.update(concepto_params)\n\n\n format.html { redirect_to @concepto, notice: '<i class=\"fa fa-check-square fa-lg\"></i> Los datos del concepto fueron actualizados exitosamente.' }\n format.json { render :show, status: :ok, location: @concepto }\n else\n format.html { render :edit } if params[:concepto][:tipo_ids]\n format.json { render json: @concepto.errors, status: :unprocessable_entity }\n end\n end\n end", "def manage_convenios(resource)\n resource ||= JSON.parse(resource.to_json)\n resource.each do |_key, value|\n\n @cliente_convenio = self.cliente_convenios.find_by(id: value[\"cliente_convenio_id\"].to_i) if value[\"cliente_convenio_id\"].present?\n if value['option']==\"edit\" and !@cliente_convenio.nil?\n @cliente_convenio.update_attributes(convenio_id: value[\"convenio_id\"],\n status_convenio: value[\"status_convenio\"],\n validade_carteira: value[\"validade_carteira\"],\n matricula: value[\"matricula\"],\n produto: value[\"produto\"],\n titular: value[\"titular\"],\n plano: value[\"plano\"],\n via: value[\"via\"],\n observacoes: value[\"observacoes\"],\n utilizando_agora: value[\"utilizando_agora\"])\n else\n @cliente_convenio = self.cliente_convenios.build(convenio_id: value[\"convenio_id\"].to_i,\n status_convenio: value[\"status_convenio\"],\n validade_carteira: value[\"validade_carteira\"],\n matricula: value[\"matricula\"],\n produto: value[\"produto\"],\n titular: value[\"titular\"],\n plano: value[\"plano\"],\n via: value[\"via\"],\n observacoes: value[\"observacoes\"],\n utilizando_agora: value[\"utilizando_agora\"])\n @cliente_convenio.save!\n end\n end\n end", "def update\n respond_to do |format|\n if @evolucao_tipo.update(evolucao_tipo_params)\n format.html { redirect_to @evolucao_tipo, notice: 'Evolucao tipo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @evolucao_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n\n respond_to do |format|\n if @tipo_vehiculo.update_attributes(params[:tipo_vehiculo])\n format.html { redirect_to @tipo_vehiculo, notice: 'Tipo vehiculo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_vehiculo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @concurso = Concurso.find(params[:id])\n\n respond_to do |format|\n if @concurso.update_attributes(params[:concurso])\n format.html { redirect_to @concurso, notice: 'Concurso atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @concurso.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 respond_to do |format|\n if @tipoapreensao.update(tipoapreensao_params)\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_conta = TipoConta.find(params[:id])\n\n respond_to do |format|\n if @tipo_conta.update_attributes(params[:tipo_conta])\n flash[:notice] = 'TipoConta was successfully updated.'\n format.html { redirect_to(tipo_contas_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_conta.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_tipo_de_servicio\n @tipo_de_servicio = TipoDeServicio.find(params[:id])\n end", "def update\n respond_to do |format|\n if @tipo_de_imposto.update(tipo_de_imposto_params)\n format.html { redirect_to @empresa, notice: 'Tipo de imposto actualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @tipo_de_imposto }\n else\n format.html { render :edit }\n format.json { render json: @tipo_de_imposto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_ventum.update(tipo_ventum_params)\n format.html { redirect_to @tipo_ventum, notice: 'Tipo ventum was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_ventum }\n else\n format.html { render :edit }\n format.json { render json: @tipo_ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipocosto.update(tipocosto_params)\n format.html { redirect_to @tipocosto, notice: 'Tipocosto was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipocosto }\n else\n format.html { render :edit }\n format.json { render json: @tipocosto.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 @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n if @veiculo.update_attributes(params[:veiculo])\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_curso = TipoCurso.find(params[:id])\n\n respond_to do |format|\n if @tipo_curso.update_attributes(params[:tipo_curso])\n flash[:notice] = 'TipoCurso actualizado correctamente.'\n format.html { redirect_to(@tipo_curso) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_curso.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @proximo_codigo = @tipo_usuario.codigo\n respond_to do |format|\n if @tipo_usuario.update(tipo_usuario_params)\n format.html { redirect_to action: \"new\", notice: 'TIpo Usuário atualizado com sucesso..' }\n format.json { render :show, status: :ok, location: @tipo_usuario }\n else\n format.html { render :edit }\n format.json { render json: @tipo_usuario.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 respond_to do |format|\n if @tiposveiculo.update(tiposveiculo_params)\n format.html { redirect_to tiposveiculos_url, notice: 'Tipo de Veículo editado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @tiposveiculo.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_tipo_comunicacao\n @tipo_comunicacao = TipoComunicacao.find(params[:id])\n end", "def set_recursoshumanos_tipo_vinculo\n @recursoshumanos_tipo_vinculo = Recursoshumanos::TipoVinculo.find(params[:id])\n end", "def update\n respond_to do |format|\n if @solicitacao_tipo.update(solicitacao_tipo_params)\n format.html { redirect_to @solicitacao_tipo, notice: 'Solicitacao tipo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @solicitacao_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_documento = TipoDocumento.find(params[:id])\n\n respond_to do |format|\n if @tipo_documento.update_attributes(params[:tipo_documento])\n format.html { redirect_to @tipo_documento, notice: 'Tipo documento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_documento.errors, status: :unprocessable_entity }\n end\n end\n end", "def evolucao_tipo_params\n params.require(:evolucao_tipo).permit(:nome, :inativo, campos_attributes: [ :id, :nome, :titulo, :requerido, :tipo_campo, :_destroy ])\n end", "def update\n @cooperativa = Cooperativa.find(params[:id])\n\n respond_to do |format|\n if @cooperativa.update_attributes(params[:cooperativa])\n format.html { redirect_to [:admin, @cooperativa], :notice => 'Exemplo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @cooperativa.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @os_nivel_servico.update(os_nivel_servico_params)\n format.html { redirect_to @os_nivel_servico, notice: 'Os nivel servico foi atualizado(a)' }\n format.json { render :show, status: :ok, location: @os_nivel_servico }\n else\n format.html { render :edit }\n format.json { render json: @os_nivel_servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_contrato = TipoContrato.find(params[:id])\n respond_to do |format|\n if @tipo_contrato.update_attributes(params[:tipo_contrato])\n flash[:notice] = 'TiposContratos actualizado correctamente.'\n format.html { redirect_to(@tipo_contrato) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_contrato.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topico.update(topico_params)\n format.html { redirect_to set_path, notice: 'Tópico atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topico.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 respond_to do |format|\n if @tipoenvolvido.update(tipoenvolvido_params)\n format.html { redirect_to @tipoenvolvido, notice: 'Tipoenvolvido was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoenvolvido.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_venda.update(tipo_venda_params)\n format.html { redirect_to @tipo_venda, notice: 'Tipo venda was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_venda }\n else\n format.html { render :edit }\n format.json { render json: @tipo_venda.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @inventario_cosa.update(inventario_cosa_params)\n format.html { redirect_to @inventario_cosa, notice: 'Inventario cosa was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventario_cosa }\n else\n format.html { render :edit }\n format.json { render json: @inventario_cosa.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_socioeduk_tipo_contato\n @socioeduk_tipo_contato = Socioeduk::TipoContato.find(params[:id])\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 update\n respond_to do |format|\n if @consumo.update(consumo_params)\n format.html { redirect_to @consumo, notice: 'Consumo was successfully updated.' }\n format.json { render :show, status: :ok, location: @consumo }\n else\n format.html { render :edit }\n format.json { render json: @consumo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_cancha.update(tipo_cancha_params)\n format.html { redirect_to @tipo_cancha, notice: 'Tipo cancha was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_cancha }\n else\n format.html { render :edit }\n format.json { render json: @tipo_cancha.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_pregunta = TipoPregunta.find(params[:id])\n\n if @tipo_pregunta.update(params[:tipo_pregunta])\n head :no_content\n else\n render json: @tipo_pregunta.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @tipo_compra.update(tipo_compra_params)\n format.html { redirect_to @tipo_compra, notice: 'Tipo compra was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_compra }\n else\n format.html { render :edit }\n format.json { render json: @tipo_compra.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_aposta.update(tipo_aposta_params)\n format.html { redirect_to @tipo_aposta, notice: 'Tipo aposta was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_aposta }\n else\n format.html { render :edit }\n format.json { render json: @tipo_aposta.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 respond_to do |format|\n if @ativo.update(ativo_params)\n format.html { redirect_to @ativo, notice: \"#{type} was successfully updated.\" }\n format.json { render :show, status: :ok, location: @ativo }\n else\n format.html { render :edit }\n format.json { render json: @ativo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n obtener_datos()\n @status = params[:statusproyect]\n @cliente = params[:cliente] + \" \" +params[:cliente_apellido]\n respond_to do |format|\n if @ventum.update(cliente: @cliente, clave:@clave, fecha:@fecha, iva:@iva,subtotal:@preciofinal ,total:@totalcosto, descuentogeneral: @descglobal , distribuidor: @distribuidor, status: @status)\n @detail.each do |x|\n x.destroy\n end\n salvar()\n format.html { redirect_to @ventum, notice: 'Venta actualizada correctamente.' }\n format.json { render :show, status: :ok, location: @ventum }\n else\n format.html { render :edit }\n format.json { render json: @ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @servico.update(servico_params)\n format.html { redirect_to servicos_url, notice: 'Serviço atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @servico }\n else\n format.html { render :edit }\n format.json { render json: @servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ativo_outro = AtivoOutro.find(params[:id])\n\n respond_to do |format|\n if @ativo_outro.update_attributes(params[:ativo_outro])\n format.html { redirect_to @ativo_outro, notice: 'Ativo foi salvo com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ativo_outro.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_tipo_conta\n @tipo_conta = TipoConta.find(params[:id])\n end", "def update\n @tipo_actividad = TipoActividad.find(params[:id])\n\n respond_to do |format|\n if @tipo_actividad.update_attributes(params[:tipo_actividad])\n format.html { redirect_to @tipo_actividad, notice: 'Tipo actividad was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_actividad.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recurso = Recurso.find(params[:id])\n\n respond_to do |format|\n if @recurso.update_attributes(params[:recurso])\n format.html { redirect_to @recurso, notice: 'O recurso de auto de infração foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recurso.errors, status: :unprocessable_entity }\n end\n end\n end", "def aprovar\n @oferta = Oferta.new\n @oferta.cotacao = Cotacao.find(params[:id])\n @oferta.cotacao.update_attributes(:status => Status.find_by_descricao('Aprovado'))\n\n @oferta.administrador = Administrador.first\n @oferta.data_inicio = @oferta.cotacao.data_inicio\n @oferta.data_fim = @oferta.cotacao.data_fim\n @oferta.valor_convite = @oferta.cotacao.valor\n @oferta.status = Status.find 2\n\n respond_to do |format|\n format.html { render :action => \"new\" }\n format.json { render :json => @oferta }\n end\n end", "def update\n respond_to do |format|\n if @servico_pacote.update(servico_pacote_params)\n format.html { redirect_to @servico_pacote, notice: 'Pacote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @servico_pacote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @denuncia_tipo = DenunciaTipo.find(params[:id])\n\n respond_to do |format|\n if @denuncia_tipo.update_attributes(params[:denuncia_tipo])\n format.html { redirect_to @denuncia_tipo, notice: 'Denuncia tipo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @denuncia_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_iva = TipoIva.find(params[:id])\n\n respond_to do |format|\n if @tipo_iva.update_attributes(params[:tipo_iva])\n flash[:notice] = 'TipoIva was successfully updated.'\n format.html { redirect_to(@tipo_iva) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_iva.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 was successfully updated.' }\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 respond_to do |format|\n if @tipo_fornecedor.update(tipo_fornecedor_params)\n format.html { redirect_to tenant_tipo_fornecedors_path(tenant_id: @tenant.id), notice: 'Tipo fornecedor was successfully updated.' }\n\n else\n format.html { render :edit }\n format.json { render json: @tipo_fornecedor.errors, status: :unprocessable_entity }\n end\n end\n end", "def activo_update\n respond_to do |format|\n activo = params[:producto][:activo]\n id = params[:id]\n Producto.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\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 update\n respond_to do |format|\n if @objeto.update(tipo_referencia_base_params)\n format.html { redirect_to @objeto, notice: \"Tipo referencia base was successfully updated.\" }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_exame.update(tipo_exame_params)\n format.html { redirect_to @tipo_exame, notice: 'Tipo exame was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_exame }\n else\n format.html { render :edit }\n format.json { render json: @tipo_exame.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n\n respond_to do |format|\n if @tipo_vehiculo.update_attributes(params[:tipo_vehiculo])\n format.html { redirect_to(@tipo_vehiculo, :notice => 'TipoVehiculo was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_vehiculo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @oferta = Oferta.find(params[:id])\n\n respond_to do |format|\n if @oferta.update_attributes(params[:oferta])\n format.html { redirect_to [:admin, @oferta], :notice => 'Exemplo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @oferta.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_situacao\n logger.debug \"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ\"\n\n id_busca = params[:id]\n @os_id = params[:os_id]\n @os_tarefa = OsTarefa.find(id_busca)\n @os_tarefa.situacao=params[:situacao]\n @ordem_servico = OrdemServico.find(@os_id)\n logger.debug \"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ\"\n\n if @os_tarefa.situacao=='REJEITADA'\n @os_tarefa.ordem_servico_pagamento= nil\n @os_tarefa.situacao=OsTarefa.situacoes[2]\n else\n @os_tarefa.ordem_servico_pagamento= @ordem_servico\n @os_tarefa.situacao=OsTarefa.situacoes[0]\n end\n @os_tarefa.save\n respond_to do |format|\n\n format.json { head :no_content }\n format.js { render :layout => false }\n\n end\n end", "def update\n respond_to do |format|\n if @tipo_documento.update(tipo_documento_params)\n format.html { redirect_to @tipo_documento, notice: 'Se ha actualizado el Tipo de documento.' }\n format.json { render :show, status: :ok, location: @tipo_documento }\n else\n format.html { render :edit }\n format.json { render json: @tipo_documento.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @objeto.update(etiqueta_params)\n format.html { redirect_to @objeto, notice: 'Etiqueta was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_orden.update(tipo_orden_params)\n format.html { redirect_to @tipo_orden, notice: 'Tipo orden was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_orden }\n else\n format.html { render :edit }\n format.json { render json: @tipo_orden.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n pai = params[:pai] ? Conta.find_by_id(params[:pai]): nil\n \n respond_to do |format|\n if @conta.update(nome: conta_params[:nome], status: conta_params[:status], pai: pai) \n #format.json { render :show, status: :ok, location: @conta }\n format.json { render json: @conta.to_json, status: :ok }\n else \n format.json { render json: @conta.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @documentotipo = Documentotipo.find(params[:id])\n\n respond_to do |format|\n if @documentotipo.update_attributes(params[:documentotipo])\n format.html { redirect_to @documentotipo, notice: 'Documentotipo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @documentotipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def tipo_veiculo_params\n params.require(:tipo_veiculo).permit(:tipo)\n end", "def update\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n\n respond_to do |format|\n if @solicitud_servicio.update_attributes(params[:solicitud_servicio])\n format.html { redirect_to @solicitud_servicio, notice: 'Solicitud servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @solicitud_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @concurso.update(concurso_params)\n format.html { redirect_to @concurso, notice: 'Concurso ha sido actualizado correctamente..' }\n format.json { render :show, status: :ok, location: @concurso }\n else\n format.html { render :edit }\n format.json { render json: @concurso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @congresso.update(congresso_params)\n format.html { redirect_to @congresso, notice: 'Congresso was successfully updated.' }\n format.json { render :show, status: :ok, location: @congresso }\n else\n format.html { render :edit }\n format.json { render json: @congresso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_de_imovel.update(tipo_de_imovel_params)\n format.html { redirect_to @tipo_de_imovel, notice: 'Tipo de imovel was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_de_imovel }\n else\n format.html { render :edit }\n format.json { render json: @tipo_de_imovel.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n set_funcionario\n if @ordem_servico.update(ordem_servico_params)\n format.html { redirect_to @ordem_servico, notice: t('messages.cadastro_atualizado') }\n format.json { render :show, status: :ok, location: @ordem_servico }\n else\n format.html { render :edit }\n format.json { render json: @ordem_servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @observacao_vocacionada = ObservacaoVocacionada.find(params[:id])\n\n respond_to do |format|\n if @observacao_vocacionada.update_attributes(params[:observacao_vocacionada])\n format.html { redirect_to @observacao_vocacionada}\n flash[:notice] = \"Registro alterado com sucesso!\"\n else\n format.html { render action: \"edit\" }\n format.json { render json: @observacao_vocacionada.errors, status: :unprocessable_entity }\n end\n end\n end", "def resource_params\n params.require(:tratamiento).permit(:tipo)\n end", "def servico_params\n params.require(:servico).permit(:nome, :descricao, :status)\n end", "def update\n @orgao = Orgao.find(params[:id])\n\n params[:orgao][:tipo_atendimento_ids] ||= []\n respond_to do |format|\n if @orgao.update_attributes(params[:orgao])\n\t\tformat.html { redirect_to @orgao, notice: \"Local de atendimento: #{@orgao.nome}, foi atualizado com sucesso.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @orgao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tema_curso.update(tema_curso_params)\n format.html { redirect_to @tema_curso, notice: 'Tema do curso atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @tema_curso }\n else\n format.html { render :edit }\n format.json { render json: @tema_curso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @convidado.update(convidado_params)\n format.html { redirect_to @convidado, notice: 'Convidado was successfully updated.' }\n format.json { render :show, status: :ok, location: @convidado }\n else\n format.html { render :edit }\n format.json { render json: @convidado.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_atendimento = TipoAtendimento.find(params[:id])\n\n respond_to do |format|\n if @tipo_atendimento.update_attributes(params[:tipo_atendimento])\n format.html { redirect_to @tipo_atendimento, notice: \"Tipo de atendimento: #{@tipo_atendimento.descricao}, foi atualizado com sucesso.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_atendimento.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipos_contato.update(tipos_contato_params)\n format.html { redirect_to @tipos_contato, notice: 'Tipos contato was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipos_contato }\n else\n format.html { render :edit }\n format.json { render json: @tipos_contato.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_caracteristica_tipo_vehiculo\n @caracteristica_tipo_vehiculo = CaracteristicaTipoVehiculo.find(params[:id])\n end", "def update\n respond_to do |format|\n if @carrito_producto.update(params[:cantidad_productos])\n format.html { redirect_to @carrito_producto, notice: 'Carrito was successfully updated.' }\n format.json { render :show, status: :ok, location: @carrito_producto }\n else\n format.html { render :edit }\n format.json { render json: @carrito_producto.errors, status: :unprocessable_entity }\n end\n end\n end", "def veiculo_params\n params.require(:veiculo).permit(:placa, :chassi, :renavan, :ano, :modelo, :usuario_id, :cor)\n end", "def destroy\n @cooperativa = Cooperativa.find(params[:id])\n @cooperativa.update_attributes :status => Status.find_by_descricao('Inativo')\n\n respond_to do |format|\n format.html { redirect_to admin_cooperativas_path }\n format.json { head :ok }\n end\n end", "def update\n @venta = Venta.find(params[:id])\n\n respond_to do |format|\n if @venta.update_attributes(params[:venta])\n format.html { redirect_to @venta, notice: 'Venta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @venta.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @itemtipo = Itemtipo.find(params[:id])\n\n if @itemtipo.update(itemtipo_params)\n head :no_content\n else\n render json: @itemtipo.errors, status: :unprocessable_entity\n end\n end", "def put(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_put(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def update\n @categorias_tipo = CatTipo.find(params[:id])\n\n respond_to do |format|\n if @categorias_tipo.update_attributes(params[:cat_tipo])\n \t\tcategories = @categorias_tipo.update_attributes(:tipo_acc_ids =>params[:tipo_accs])\n\t\t\t\t@categorias_tipo.update_attributes(:estado_ids =>params[:estados])\n format.html { redirect_to cat_tipos_path, notice: 'Categorias tipo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @categorias_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n\n respond_to do |format|\n if @pago.update_attributes(params[:pago])\n format.html { redirect_to [@cliente, @pago], notice: 'Pago was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tiposervico.update(tiposervico_params)\n format.html { redirect_to @tiposervico, notice: 'Tiposervico was successfully updated.' }\n format.json { render :show, status: :ok, location: @tiposervico }\n else\n format.html { render :edit }\n format.json { render json: @tiposervico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @apoio.update(apoio_params)\n format.html { redirect_to @apoio, notice: 'Apoio was successfully updated.' }\n format.json { render :show, status: :ok, location: @apoio }\n else\n format.html { render :edit }\n format.json { render json: @apoio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n @lancamentorapido = Lancamentorapido.find(params[:id]) \n \n #Validações padrão\n @lancamentorapido.tipo = :receita if @lancamentorapido.tipo.blank?\n @lancamentorapido.valor = 0 if @lancamentorapido.valor.blank? \n \n\n respond_to do |format|\n if @lancamentorapido.update_attributes(params[:lancamentorapido])\n format.html { redirect_to lancamentorapidos_path, notice: 'Lancamento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lancamentorapido.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6576078", "0.6518064", "0.6465294", "0.6370377", "0.6358648", "0.6271851", "0.6269607", "0.6230175", "0.6226274", "0.6214361", "0.6193123", "0.6178852", "0.6170548", "0.6162425", "0.6105472", "0.6090012", "0.60784835", "0.60717624", "0.60652345", "0.6060631", "0.60520023", "0.6043906", "0.6021193", "0.6014026", "0.60136926", "0.6011958", "0.60016346", "0.59959877", "0.5995637", "0.5994497", "0.5991264", "0.5990692", "0.59901375", "0.59901047", "0.598867", "0.59827566", "0.5972503", "0.5966237", "0.59647465", "0.59493273", "0.594533", "0.59353596", "0.5934574", "0.5930858", "0.59272885", "0.5924434", "0.5920912", "0.5913592", "0.59104276", "0.5909818", "0.58796316", "0.5877827", "0.5874323", "0.5866369", "0.586519", "0.5857583", "0.5856106", "0.58484584", "0.5841713", "0.5836932", "0.5835815", "0.58351207", "0.583406", "0.5831259", "0.5830446", "0.5829635", "0.58197635", "0.5817983", "0.5815804", "0.58096063", "0.5806488", "0.5798544", "0.5795755", "0.57942975", "0.578986", "0.57859266", "0.578491", "0.578294", "0.5779891", "0.5777425", "0.5772895", "0.57719654", "0.5770996", "0.57683754", "0.5763787", "0.57618237", "0.5760061", "0.5759755", "0.5757968", "0.5757418", "0.5755242", "0.57414573", "0.57361406", "0.57346904", "0.57336235", "0.57321155", "0.5731703", "0.57299304", "0.57297045", "0.57272" ]
0.63716155
3
DELETE /tipo_convenios/1 DELETE /tipo_convenios/1.json
def destroy @tipo_convenio = TipoConvenio.find(params[:id]) @tipo_convenio.destroy respond_to do |format| format.html { redirect_to tipo_convenios_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @tipo_contrato = TipoContrato.find(params[:id])\n @tipo_contrato.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_contratos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @consumo = Consumo.find(params[:id])\n @consumo.destroy\n\n respond_to do |format|\n format.html { redirect_to consumos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_negocio = TipoNegocio.find(params[:id])\n @tipo_negocio.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_negocios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n @tipo_vehiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_vehiculos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @concedente.destroy\n respond_to do |format|\n format.html { redirect_to concedentes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @concedente = Concedente.find(params[:id])\n @concedente.destroy\n\n respond_to do |format|\n format.html { redirect_to concedentes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_de_imposto.destroy\n respond_to do |format|\n format.html { redirect_to @empresa, notice: 'Tipo de imposto removido com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @denuncia_tipo = DenunciaTipo.find(params[:id])\n @denuncia_tipo.destroy\n\n respond_to do |format|\n format.html { redirect_to denuncia_tipos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipoenvolvido.destroy\n respond_to do |format|\n format.html { redirect_to tipoenvolvidos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_unidad.destroy\n respond_to do |format|\n format.html { redirect_to tipo_unidades_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @veiculo = Veiculo.find(params[:id])\n @veiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to veiculos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_plan.destroy\n respond_to do |format|\n msg = { :status => \"ok\", :message => \"Eliminado!\" }\n format.json { render :json => msg }\n end\n end", "def destroy\n @reconocimiento = Reconocimiento.find(params[:id])\n @reconocimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to reconocimientos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @concurso = Concurso.find(params[:id])\n @concurso.destroy\n\n respond_to do |format|\n format.html { redirect_to concursos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipoapreensao.destroy\n respond_to do |format|\n format.html { redirect_to tipoapreensoes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #--ADICIONADO\n @cliente.perfilclientes.destroy\n #--ADICIONADO\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @servico_pacote.destroy\n respond_to do |format|\n format.html { redirect_to servico_pacotes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_documento = TipoDocumento.find(params[:id])\n @tipo_documento.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_documentos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @solicitacao_tipo.destroy\n respond_to do |format|\n format.html { redirect_to solicitacao_tipos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @convo = Convo.find(params[:id])\n @convo.destroy\n\n respond_to do |format|\n format.html { redirect_to convos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @objeto.destroy\n respond_to do |format|\n format.html { redirect_to tipo_referencia_bases_url, notice: \"Tipo referencia base was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @evolucao_tipo.destroy\n respond_to do |format|\n format.html { redirect_to evolucao_tipos_url }\n format.json { head :no_content }\n end\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 destroy\n @tipo_veiculo.destroy\n respond_to do |format|\n format.html { redirect_to tipo_veiculos_url, notice: 'Tipo veiculo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_de_servicio.destroy\n respond_to do |format|\n format.html { redirect_to tipo_de_servicios_url, notice: 'Tipo de servicio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_vinculo = TipoVinculo.find(params[:id])\n @tipo_vinculo.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_vinculos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @servicio = Servicio.find(params[:id])\n @servicio.destroy\n\n respond_to do |format|\n format.html { redirect_to servicios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_compra.destroy\n respond_to do |format|\n format.html { redirect_to tipo_compras_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @os_nivel_servico.destroy\n respond_to do |format|\n format.html { redirect_to os_nivel_servicos_url, notice: 'Os nivel servico foi excluído(a)' }\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 @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 @persona_tipo = PersonaTipo.find(params[:id])\n @persona_tipo.destroy\n\n respond_to do |format|\n format.html { redirect_to persona_tipos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @tiposveiculo.destroy\n respond_to do |format|\n format.html { redirect_to tiposveiculos_url, notice: 'Tipo de Veículo excluído com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_ventum.destroy\n respond_to do |format|\n format.html { redirect_to tipo_venta_url, notice: 'Tipo ventum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @indicativo = Indicativo.find(params[:id])\n @indicativo.destroy\n\n respond_to do |format|\n format.html { redirect_to indicativos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_pensum = TipoPensum.find(params[:id])\n @tipo_pensum.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_pensums_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @sistemas_consejero.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sistemas_consejeros_url, notice: 'El nombre del consejero de ingeniería de sistemas se eliminó correctamente.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @objeto.destroy\n respond_to do |format|\n format.html { redirect_to referencia_bases_url, notice: \"Referencia base was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_actividad = TipoActividad.find(params[:id])\n @tipo_actividad.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_actividads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tecnico = Tecnico.find(params[:id])\n @tecnico.destroy\n\n respond_to do |format|\n format.html { redirect_to tecnicos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tecnico = Tecnico.find(params[:id])\n @tecnico.destroy\n\n respond_to do |format|\n format.html { redirect_to tecnicos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tecnico = Tecnico.find(params[:id])\n @tecnico.destroy\n\n respond_to do |format|\n format.html { redirect_to tecnicos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nota_tecnica.destroy\n respond_to do |format|\n format.html { redirect_to nota_tecnicas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @core_tipo_unidade = Core::TipoUnidade.find(params[:id])\n @core_tipo_unidade.destroy\n\n respond_to do |format|\n format.html { redirect_to core_tipo_unidades_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @colegio = Colegio.find(params[:id])\n @colegio.destroy\n\n respond_to do |format|\n format.html { redirect_to colegios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @consumo.destroy\n respond_to do |format|\n format.html { redirect_to consumos_url, notice: 'Consumo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_consulta.destroy\n respond_to do |format|\n format.html { redirect_to tipo_consultas_url, notice: 'Tipo consulta was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @ordem_servico.destroy\n respond_to do |format|\n format.html { redirect_to ordem_servicos_url, notice: t('messages.cadastro_removido') }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_distribucion.destroy\n respond_to do |format|\n format.html { redirect_to tipos_distribuciones_url }\n format.json { head :no_content }\n end\n end", "def destroy\n contrato = @fatura.contrato\n @fatura.destroy\n respond_to do |format|\n format.html { redirect_to contrato, notice: 'Fatura excluída com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contatos_cliente.destroy\n respond_to do |format|\n format.html { redirect_to contatos_clientes_url, notice: 'Contatos cliente was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipocosto.destroy\n respond_to do |format|\n format.html { redirect_to tipocostos_url, notice: 'Tipocosto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cooperativa = Cooperativa.find(params[:id])\n @cooperativa.update_attributes :status => Status.find_by_descricao('Inativo')\n\n respond_to do |format|\n format.html { redirect_to admin_cooperativas_path }\n format.json { head :ok }\n end\n end", "def destroy\n @clientes_servico.destroy\n respond_to do |format|\n format.html { redirect_to clientes_servicos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fulcliente = Fulcliente.find(params[:id])\n @fulcliente.destroy\n\n respond_to do |format|\n format.html { redirect_to fulclientes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @core_status_selo_fiscal_tipo = Core::StatusSeloFiscalTipo.find(params[:id])\n @core_status_selo_fiscal_tipo.destroy\n\n respond_to do |format|\n format.html { redirect_to core_status_selo_fiscal_tipos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_actividad.destroy\n respond_to do |format|\n format.html { redirect_to tipo_actividads_url, notice: 'Tipo actividad se elimino correctamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @observacao_vocacionada = ObservacaoVocacionada.find(params[:id])\n @observacao_vocacionada.destroy\n\n respond_to do |format|\n format.html { redirect_to observacao_vocacionadas_url }\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 @recurso = Recurso.find(params[:id])\n @recurso.destroy\n\n respond_to do |format|\n format.html { redirect_to recursos_url }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @tipoveiculo.destroy\n respond_to do |format|\n format.html { redirect_to tipoveiculos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tarifas_servicio.destroy\n respond_to do |format|\n format.html { redirect_to tarifas_servicios_url, notice: 'Tarifas servicio Fue destruido con éxito.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_unidad.destroy\n respond_to do |format|\n format.html { redirect_to tipo_unidads_url, notice: 'Tipo unidad was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n unless possui_acesso?()\n return\n end\n @aviso = Aviso.find(params[:id])\n @aviso.destroy\n\n respond_to do |format|\n format.html { redirect_to avisos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ativo_outro = AtivoOutro.find(params[:id])\n @ativo_outro.destroy\n\n respond_to do |format|\n format.html { redirect_to ativo_outros_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ocorrencia.destroy\n respond_to do |format|\n format.html { redirect_to ocorrencias_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @opcao.destroy\n respond_to do |format|\n format.html { redirect_to opcaos_url, notice: 'Opção Apagada com sucesso!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipoocorrencium.destroy\n respond_to do |format|\n format.html { redirect_to tipoocorrencia_url, notice: 'Tipoocorrencium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_cancha.destroy\n respond_to do |format|\n format.html { redirect_to tipo_canchas_url, notice: 'Tipo cancha was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @anteproyecto_observacion.destroy\n respond_to do |format|\n format.html { redirect_to anteproyecto_observaciones_url, notice: 'Anteproyecto observacion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @venta = Venta.find(params[:id])\n @venta.destroy\n\n respond_to do |format|\n format.html { redirect_to ventas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @plannegocio = Plannegocio.find(params[:id])\n @plannegocio.destroy\n\n respond_to do |format|\n format.html { redirect_to plannegocios_url }\n format.json { head :no_content }\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.json { head :no_content }\n end\n end", "def destroy\n @ativo.destroy\n respond_to do |format|\n format.html { redirect_to ativos_url, notice: \"#{type} was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url, notice: 'Cliente removido com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @estatuto = Estatuto.find(params[:id])\n @estatuto.destroy\n\n respond_to do |format|\n format.html { redirect_to estatutos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_de_imovel.destroy\n respond_to do |format|\n format.html { redirect_to tipo_de_imovels_url, notice: 'Tipo de imovel was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n @tipo_vehiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_vehiculos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n #@clinica.destroy\n @clinica.update(:status => 0)\n respond_to do |format|\n format.html { redirect_to clinicas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n \n @lancamentorapido = Lancamentorapido.find(params[:id])\n @lancamentorapido.destroy \n\n respond_to do |format|\n format.html { redirect_to lancamentorapidos_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n @solicitud_servicio.destroy\n\n respond_to do |format|\n format.html { redirect_to solicitudes_servicios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ocorrencium.destroy\n respond_to do |format|\n format.html { redirect_to ocorrencia_url, notice: 'Registro excluído com sucesso.' }\n format.json { head :no_content }\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.json { head :no_content }\n end\n end", "def destroy\r\n @consejero.destroy\r\n respond_to do |format|\r\n format.html { redirect_to consejeros_url, notice: 'El nombre del consejero se eliminó corrctamente.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @oferta = Oferta.find(params[:id])\n @oferta.update_attributes :status => Status.find_by_descricao('Inativo')\n\n respond_to do |format|\n format.html { redirect_to admin_ofertas_path }\n format.json { head :ok }\n end\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asociado = Asociado.find(params[:id])\n @asociado.destroy\n\n respond_to do |format|\n format.html { redirect_to asociados_url }\n format.json { head :ok }\n end\n end", "def destroy\n @tipo_funcionario.destroy\n respond_to do |format|\n format.html { redirect_to tipo_funcionarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_aposta.destroy\n respond_to do |format|\n format.html { redirect_to tipo_apostas_url, notice: 'Tipo aposta was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\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" ]
[ "0.7294594", "0.7150272", "0.70917165", "0.70767593", "0.7062537", "0.7028968", "0.70284116", "0.70270693", "0.7021605", "0.70079625", "0.69910973", "0.6971971", "0.69699985", "0.6962163", "0.6960114", "0.6957955", "0.6947555", "0.69464463", "0.6946137", "0.69455266", "0.69327456", "0.6927514", "0.6924699", "0.6919811", "0.69186676", "0.69050586", "0.69039494", "0.69016975", "0.68992037", "0.6896818", "0.689482", "0.68837106", "0.68805623", "0.6876779", "0.6866269", "0.6862946", "0.6861426", "0.68572944", "0.68548036", "0.6849465", "0.6847518", "0.6838588", "0.68374187", "0.68363583", "0.68363583", "0.68363583", "0.6832068", "0.6832068", "0.6832068", "0.6829068", "0.68284976", "0.68277824", "0.6822846", "0.68224317", "0.6820653", "0.6817395", "0.6817157", "0.68170816", "0.6815001", "0.6814447", "0.6810933", "0.6808006", "0.6807204", "0.68051004", "0.6802963", "0.6802292", "0.6800294", "0.6797642", "0.67973155", "0.67965114", "0.67903936", "0.6783951", "0.67772394", "0.67764777", "0.6776368", "0.6769032", "0.6761121", "0.6759969", "0.67584896", "0.6754151", "0.6753873", "0.675364", "0.67525446", "0.6751236", "0.6749733", "0.6748624", "0.6746458", "0.67462146", "0.6744728", "0.6744209", "0.67409146", "0.67379", "0.67373747", "0.6736197", "0.6733781", "0.67317975", "0.67279303", "0.67248553", "0.67232347", "0.6720977" ]
0.7368083
0
SPACE WALK (CHANCE MISSION) ///////////////////////////////////
def spacewalk() puts " _..._ .' '. _ / .-\"\"-\\ _/ \\ .-| /:. | | | | \\ |:. /.-'-./ | .-'-;:__.' =/ .'= *=|NASA _.=' / _. | ; ;-.-'| \\ | / | \\ _\\ _\\ \\__/'._;. ==' ==\\ \\ \\ | / / / /-._/-._/ \\ `\\ \\ `-._/._/ _________ __ __ .__ __ / _____/__________ _____ ____ / \\ / \\_____ | | | | __ \\_____ \\| _ \\__ \\ / ___\\/ __ \\ \\ \\/\\/ /\\__ \\ | | | |/ / / \\ |_| / __ \\\\ \\__\\ ___/ \\ / / __ \\| |_| < /_______ / __(____ /\\____/\\___ > \\__/\\ / (____ /____/__|_ \\ \\/|__| \\/ \\/ \\/ \\/" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nasa_space_craft; end", "def award; end", "def backlog; end", "def backlog; end", "def starship; end", "def credits; end", "def wagner; end", "def who_we_are\r\n end", "def king_richard_iii; end", "def villian; end", "def online_special_ballot\n end", "def borrower\n end", "def waiver\n end", "def celebration; end", "def under_check\r\n # Define permitted moves for the king, when under check.\r\n end", "def witcher; end", "def strain; end", "def notations; end", "def cable; end", "def congrats_or_taunt\n\t\tif @current_state.include?(\" _ \")\n\t\t\tp \"Aw man, you didn't get it this time!\"\n\t\telse\n\t\t\tp \"Woot woot! You're a hangman expert now!\"\n\t\tend\n\tend", "def community; end", "def gen_washing\r\r\n end", "def award\n\tend", "def restriction \n end", "def Com6 # Recuperation Info\n \n end", "def production_curtailment; end", "def mechanic_quest; end", "def jack_handey; end", "def peacekeeper_quest; end", "def schubert; end", "def guct\n end", "def mambo_no_5; end", "def qiagen_buffs()\n kits = operations.map {|op| op.input('RNA Kit').val}.uniq\n log_info kits\n q_buffs = kits.map {|k| QIAGEN[k.downcase]}\n show do\n title \"From the RNA Qiagen Kit\"\n separator\n note '<b>Gather:</b>'\n q_buffs.flatten.each {|buff| check \"#{buff}\"}\n check \"Make sure ethanol is added to buffers that require it before use.\"\n note \"<b>Set buffers aside on bench until use.</b>\"\n end\n end", "def quest; end", "def skier_quest; end", "def schumann; end", "def groom\n end", "def channel_fee\n 1\n end", "def restriction\n end", "def competition; end", "def charge_for_chatroom_access(options = {})\n self.debit(Settings.chatroom_access_cost, options)\n end", "def plan; connection_space.plan end", "def room; end", "def key_skill; end", "def chase_preceding_character\r\r\n return if self.command_holding?\r\r\n unless moving? && !@force_chase\r\r\n dist = CXJ::FREE_MOVEMENT::FOLLOWERS_DISTANCE / 32.0\r\r\n mrgn = CXJ::FREE_MOVEMENT::FOLLOWERS_DISTANCE_MARGIN / 32.0\r\r\n \r\r\n far_dist = distance_preceding_character\r\r\n \r\r\n if far_dist > 3\r\r\n type = 1\r\r\n prevent_bug_cnt = 0\r\r\n else\r\r\n type = 2\r\r\n end\r\r\n \r\r\n if !move_poll.empty? && distance_preceding_leader < 0.8\r\r\n move_poll.clear\r\r\n end\r\r\n \r\r\n \r\r\n if type == 1 && move_poll.empty?\r\r\n reachable = false\r\r\n \r\r\n $game_player.followers.each do |follower|\r\r\n follower.move_poll.clear\r\r\n if follower.move_poll.empty? && follower.distance_preceding_leader > 3\r\r\n reachable = follower.move_to_position($game_player.x,$game_player.y)\r\r\n if move_poll.empty? || !reachable\r\r\n follower.moveto($game_player.x,$game_player.y) \r\r\n end\r\r\n \r\r\n end\r\r\n end\r\r\n elsif type == 2\r\r\n \r\r\n goal = @preceding_character\r\r\n sx = distance_x_from(goal.x)\r\r\n sy = distance_y_from(goal.y)\r\r\n sd = Math.hypot(sx, sy)\r\r\n if @board\r\r\n @x = goal.x\r\r\n @y = goal.y\r\r\n @board = false\r\r\n elsif(sd > dist && sx.abs > mrgn && sy.abs > mrgn)\r\r\n @move_poll += [[(sx > 0 ? -1 : 1) + (sy > 0 ? 8 : 2), true]]\r\r\n elsif sx.abs > dist && sx.abs > sy.abs\r\r\n @move_poll+=[[sx > 0 ? 4 : 6, true]]\r\r\n elsif sy.abs > dist && sx.abs < sy.abs\r\r\n @move_poll+=[[sy > 0 ? 8 : 2, true]]\r\r\n end\r\r\n end\r\r\n \r\r\n end\r\r\n end", "def status(act)\r\n extratext = \"\"\r\n moneytext = \"YOU HAVE NO MONEY\\n\"\r\n perkstext = \"\"\r\n help_text = \"\"\r\n\r\n if $strength <10\r\n extratext << \"WARNING, #{$name} , YOUR STRENGTH IS RUNNING LOW\\n\"\r\n end \r\n if $wealth >= 1\r\n moneytext = \"YOU HAVE $ #{$wealth}.\\n\"\r\n end\r\n if $food >= 1\r\n extratext << \"YOUR PROVISIONS SACK HOLDS #{$food} UNITS OF FOOD\\n\"\r\n end \r\n\r\n if $suit >= 1\r\n perkstext << \"YOU ARE WEARING ARMOR.\\n\"\r\n end\r\n\r\n if ($sword !=0 or $amulet !=0 or $axe !=0)\r\n perkstext << \"YOU ARE CARRYING \"\r\n if $sword >= 1\r\n perkstext << \"A SWORD \"\r\n end\r\n if $amulet >= 1\r\n if $sword != 0 and $axe != 0\r\n perkstext << \", \"\r\n elsif $sword != 0 and axe == 0\r\n perkstext << \"AND \"\r\n end\r\n perkstext << \"AN AMULET\"\r\n end\r\n\r\n if $axe >= 1\r\n if $sword != 0 or $amulet != 0\r\n perkstext << \" AND \"\r\n end\r\n perkstext << \"AN AXE\"\r\n end\r\n perkstext << \"\\n\"\r\n end\r\n\r\n if act == \"ROOM\" or act == \"GREETING\" or act == \"I\"\r\n if $light == 0 and $roomnumber != 6\r\n extratext << \"IT IS TOO DARK TO SEE ANYTHING\\n\"\r\n else\r\n extratext << \"#{room_descriptions_method} \\n\" \r\n end\r\n end\r\n\r\n if act == \"GREETING\"\r\n help_text = \"(YOU CAN PRESS H AT ANY MOMENT TO GET SOME HELP)\"\r\n end\r\n\r\n roomcontents = room_contents\r\n\r\n puts(\"#{$name}, YOUR STRENGTH IS #{$strength}.\\n#{moneytext}#{perkstext}\\n#{asterSick}\\n#{extratext}#{roomcontents}#{help_text}\\n\") \r\nend", "def coming_soon\n end", "def coming_soon\n end", "def someone_did_gain_privilege(stem, channel, nick, privilege, bestower)\n end", "def fence_quest; end", "def whiny; end", "def decay_conversation\n # we half-life the conversation every minute\n units = (Time.now - @last_faded_weights)/60\n if units > 1 \n @last_faded_weights = Time.now \n if incoming_weight > 0 or outgoing_weight > 0\n @outgoing_weight /= (2**units) if outgoing_weight > 0\n @incoming_weight /= (2**units) if incoming_weight > 0\n end\n end\n end", "def chargeable?; true; end", "def blg; end", "def internship_passed; end", "def bury\n @channel_control.bury\n end", "def add_passanger\n @seats_available -= 1 unless full?\n end", "def conwayFunction(curValue, countNeighbors)\n if curValue == \"*\" # is alive \n if countNeighbors == 2 || countNeighbors == 3 #2 or 3 neighbours\n return \"*\"\n else\n return \" \"\n end\n end\n if curValue != \"*\" #dead\n if countNeighbors == 3 #three neighbours\n return \"*\"\n else\n return \" \"\n end\n end\n end", "def superweening_adorningly(counterstand_pyrenomycetales)\n end", "def mech; end", "def mech; end", "def gbp(pence); end", "def get_actions ()\n\n #acciones del personaje que esta jugando\n player_character.base_card.base_actions.each do |action|\n actions.create!(base_action_id: action.id)\n end\n\n #acciones por distritos morados\n\n purple_districts = districts_on_game.where(\"colour = 'purple' AND name not in ('lighthouse', 'bell_tower')\")\n purple_districts.each do |district|\n district.base_card.base_actions.each do |action|\n actions.create!(base_action_id: action.id)\n end\n end\n\n\n character = player_character.base_card.name\n\n case character\n when 'merchant'\n current_coins = coins\n update_attribute(:coins, current_coins + 1)\n when 'architect'\n card_list = party.cards.districts.where(\"player_id is NULL\").order('position').limit(2)\n card_list.each do |card|\n Card.update(card.id, :state => 'ONHAND', :player_id => id)\n end\n end\n\n\n\n end", "def ragman_quest; end", "def planning_work\n self.planned_at = Time.now\n self.unfreeze_request! if self.frozen?\n self.push_msg\n end", "def the_doctor; end", "def enchantment; end", "def maintenance\n end", "def work_out\n self.happiness += 2\n self.hygiene -= 3\n return \"♪ another one bites the dust ♫\" \n end", "def soft_ace\n # softy method refactor for when an ace is played\nend", "def mascot; end", "def prapor_quest; end", "def company_bought(company, buyer); end", "def credits\n cast + crew\n end", "def announce; end", "def past_participle; end", "def buzzword; end", "def buzzword; end", "def promotion\r\n\r\n end", "def therapist_quest; end", "def transmissions; end", "def transmissions; end", "def cutoffs\n end", "def leeway; end", "def leeway; end", "def cheap_discounts\n # puts 'kanjus makkhi chus dont come again'\nend", "def policy; end", "def p15\n\t\nend", "def champions\n\t\t\t\n\t\tend", "def work_out\n self.happiness = @happiness + 2\n self.hygiene = @hygiene - 3\n \"♪ another one bites the dust ♫\"\n end", "def new_caps_count_gt_100\n NewCap.all(:seq_id => self.seq_id, :greater_than_100_away => true).count\n end", "def its_like_chicago\n assert @voted[msg.sender] && msg.value >= 1.ether\n @voted[msg.sender] = false\nend", "def mitch_hedberg; end", "def legal_moves\n # Fill this in\n end", "def latency_of(dist)\n len=(dist == 0) ? OVERHEAD_INNER : OVERHEAD_OUTER + dist\n if len <= 300 # [cm]\n #Copper cable\n len*4.4E-9 #HP BladeSystem c-Class 40G QSFP+ to QSFP+ Direct Attach Copper Cable\n else\n # Optical cable \n len*5.2E-9 #Speed of light in glass= 190000km/sec\n end\nend", "def check_for_open_board\n active_spaces.values.include?(\" \")\n end", "def canAfford?(cost, character)\n return cost <= character.gp\n end", "def new_caps_count_gt_twenty\n NewCap.all(:seq_id => self.seq_id, :greater_than_twenty_away => true).count\n end", "def start_conversation(friend, topic) \n case(topic)\nwhen \"politics\" \n friend.happiness -= 2\n self.happiness -= 2\n return \"blah blah partisan blah lobbyist\"\nwhen \"weather\"\n friend.happiness += 1\n self.happiness += 1\n return \"blah blah sun blah rain\"\n#use else because it tells us if none of the above check out then do the following\nelse \n return \"blah blah blah blah blah\" \n end \nend", "def wip\n end", "def surge; end" ]
[ "0.5873864", "0.5650388", "0.5633538", "0.5633538", "0.5548871", "0.5529054", "0.55225575", "0.5517337", "0.54853183", "0.54618436", "0.5410341", "0.53942347", "0.53899455", "0.5345536", "0.5343771", "0.532276", "0.53206104", "0.5315757", "0.53081286", "0.5297939", "0.52217793", "0.51832837", "0.5182749", "0.51747596", "0.51513267", "0.51463014", "0.51431876", "0.5117831", "0.50975114", "0.50639063", "0.5058467", "0.50495195", "0.5048082", "0.50459355", "0.503222", "0.50270855", "0.5012996", "0.5012663", "0.5005922", "0.49885115", "0.49778143", "0.49739653", "0.49680305", "0.49598375", "0.4955824", "0.49512458", "0.4945082", "0.4945082", "0.49393097", "0.4932549", "0.4932202", "0.49310288", "0.4929651", "0.49225298", "0.49192983", "0.4918427", "0.49077344", "0.490319", "0.48946765", "0.4893462", "0.4893462", "0.48893738", "0.48786947", "0.4877269", "0.48765528", "0.48689175", "0.48674095", "0.48647264", "0.48609167", "0.48536965", "0.48481578", "0.4846192", "0.4845291", "0.48443612", "0.48411208", "0.48400053", "0.48377532", "0.48377532", "0.4836158", "0.48344558", "0.48337206", "0.48337206", "0.4832242", "0.48318717", "0.48318717", "0.48303926", "0.48285004", "0.4818467", "0.4811429", "0.48066127", "0.47996533", "0.47941548", "0.4792673", "0.479009", "0.4789998", "0.4789908", "0.47863364", "0.47781947", "0.47759992", "0.4768144", "0.4764824" ]
0.0
-1
Returns true if the current user is following the other user.
def following?(other_user) following.include?(other_user) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def following?(other_user)\n following.include?(other_user)\n end", "def following?(other_user)\n following.include?(other_user)\n end", "def following?(other_user)\n following.include?(other_user)\n end", "def following?(other_user)\n following.include?(other_user)\n end", "def following?(other_user)\n following.include?(other_user)\n end", "def following?(other_user)\n following.include?(other_user)\n end", "def following?(other_user)\n following.include?(other_user)\n end", "def following?(other_user)\n following.include?(other_user)\n end", "def following?(other_user)\n\t\t\tfollowing.include?(other_user)\n\t\tend", "def following?(other_user)\n current_user.following.include?(other_user)\n end", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t\tfollowing.include?(other_user)\n\tend", "def following?(other_user)\n\t following.include?(other_user)\n\tend", "def following?(other_user)\n following.exists?(other_user.id)\n end", "def following?(other_user)\n\t following.include?(other_user)\n \tend" ]
[ "0.85306346", "0.85111505", "0.85111505", "0.85111505", "0.8480705", "0.8480705", "0.8480705", "0.8480705", "0.84233135", "0.8413255", "0.83404523", "0.83404523", "0.83404523", "0.83404523", "0.83404523", "0.83404523", "0.83404523", "0.83404523", "0.83404523", "0.83404523", "0.83404523", "0.83404523", "0.83404523", "0.83404523", "0.8332795", "0.83170986", "0.8313116" ]
0.83061314
91
GET /faxes GET /faxes.json
def index @faxes = Fax.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_faxes(opts = {})\n data, _status_code, _headers = get_faxes_with_http_info(opts)\n data\n end", "def get_faxes_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FaxesApi.get_faxes ...'\n end\n allowable_values = [\"inbound,outbound\", \"inbound\", \"outbound\"]\n if @api_client.config.client_side_validation && opts[:'filter_type'] && !allowable_values.include?(opts[:'filter_type'])\n fail ArgumentError, \"invalid value for \\\"filter_type\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [\"asc\", \"desc\"]\n if @api_client.config.client_side_validation && opts[:'order'] && !allowable_values.include?(opts[:'order'])\n fail ArgumentError, \"invalid value for \\\"order\\\", must be one of #{allowable_values}\"\n end\n if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] > 100\n fail ArgumentError, 'invalid value for \"opts[:\"per_page\"]\" when calling FaxesApi.get_faxes, must be smaller than or equal to 100.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"per_page\"]\" when calling FaxesApi.get_faxes, must be greater than or equal to 0.'\n end\n\n # resource path\n local_var_path = '/faxes'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'filter[type]'] = opts[:'filter_type'] if !opts[:'filter_type'].nil?\n query_params[:'filter[from_number]'] = opts[:'filter_from_number'] if !opts[:'filter_from_number'].nil?\n query_params[:'filter[to_number]'] = opts[:'filter_to_number'] if !opts[:'filter_to_number'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Fax>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxesApi#get_faxes\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n\n\n respond_to do |format|\n\n format.html { @axes = Axis.where(:user_id => current_user.id).all }\n format.json { render json: Axis.all }\n end\n end", "def get(id)\n response = Network.get(['Faxes', id])\n Fax.new(response)\n end", "def post_faxes_with_http_info(faxes, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FaxesApi.post_faxes ...'\n end\n # verify the required parameter 'faxes' is set\n if @api_client.config.client_side_validation && faxes.nil?\n fail ArgumentError, \"Missing the required parameter 'faxes' when calling FaxesApi.post_faxes\"\n end\n # resource path\n local_var_path = '/faxes'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(faxes) \n\n # return_type\n return_type = opts[:return_type] || 'Fax' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxesApi#post_faxes\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def post_faxes(faxes, opts = {})\n data, _status_code, _headers = post_faxes_with_http_info(faxes, opts)\n data\n end", "def index\n @techaxis_type = TechaxisType.find(params[:techaxis_type_id])\n @techaxes = Techaxis.where(\"techaxis_type_id = ?\", params[:techaxis_type_id]) \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @techaxes }\n end\n end", "def index\n @ftypes = Ftype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ftypes }\n end\n end", "def index\n @taxis = Taxi.where(:open_for_bidding => true).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @taxis }\n end\n end", "def index\n @ef_pares = EfPare.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ef_pares }\n end\n end", "def index\n @offices = Office.all\n json_response(@offices)\n end", "def index\n @faqs = Faq.all\n\n render json: @faqs\n end", "def index\n render json: @fiestas\n end", "def index\n @user_figures = UserFigure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_figures }\n end\n end", "def index\n @fretes = Frete.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fretes }\n end\n end", "def index\n faqs = Faq.all\n json_response(faqs)\n end", "def index\n\t @fares = Fare.all\n\n\t respond_to do |format|\n\t\tformat.html # index.html.erb\n\t\tformat.json { render json: @fares }\n\t end\n\tend", "def index\n @taxes = Tax.all\n\n render json: @taxes\n end", "def show\n @fax_typ = FaxTyp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fax_typ }\n end\n end", "def index\n @factions = Faction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @factions }\n end\n end", "def index\n @paxes = Pax.all\n end", "def index\n @fundamental_daily_position_stats = Fundamental::DailyPositionStat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fundamental_daily_position_stats }\n end\n end", "def index\n @techaxis_types = TechaxisType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @techaxis_types }\n end\n end", "def get_faxes_id_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FaxesApi.get_faxes_id ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling FaxesApi.get_faxes_id\"\n end\n # resource path\n local_var_path = '/faxes/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Fax' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxesApi#get_faxes_id\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_chart(options={})\n api_response = @api_client.make_api_request(:GET, \"artist/chart\", {}, options)\n @api_client.chart_item_digestor.list_from_xml(api_response.content.chart)\n end", "def axes_series(params)\n if params[:primary_axes] != 0\n primary_axes_series\n else\n secondary_axes_series\n end\n end", "def facets\n facet_name = request.params[\"f_name\"]\n if facet_name == nil\n render :json => nil\n return\n end\n @presenter = execute_search(-1)\n facet_data = @presenter.facets.find {|f| f.name == facet_name }\n render :json => facet_data.values\n rescue => ex\n backtrace = ex.backtrace.join(\"\\r\\n\")\n Rails.logger.error(\"Could not render facets as JSON. Exception: #{ex} \\r\\n #{backtrace}\")\n render :json => nil, status: 500\n end", "def axes_series(params)\n if params[:primary_axes] == 0\n secondary_axes_series\n else\n primary_axes_series\n end\n end", "def index\n @foros = Foro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foros }\n end\n end", "def consulta\n fiesta = Fiesta.all\n render json: fiesta\n end", "def index\n @charts = Chart.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @charts }\n end\n end", "def index\n @offices = Office.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offices }\n end\n end", "def index\n @axis_events = AxisEvent.all\n end", "def index\n @dev_folios = DevFolio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dev_folios }\n end\n end", "def index\n @cfos = Cfo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cfos }\n end\n end", "def index\n fact = to_json(Fact.last)\n tip = to_json(Tip.last)\n quote = to_json(Quote.last)\n expert_opinion = to_json(ExpertOpinion.last)\n faq = to_json(Faq.last)\n article = to_json(Article.last)\n testimony = to_json(Testimony.last)\n documentary = to_json(Documentary.last)\n \n json_response({ \n fact: fact,\n tip: tip, \n quote: quote,\n expert_opinion: expert_opinion,\n faq: faq,\n article: article,\n testimony: testimony,\n documentary: documentary\n })\n end", "def index\n @taxes = params['item_id'] ? Item.find(params['item_id']).taxes : Tax.all\n render json: @taxes\n end", "def get_faxes_id(id, opts = {})\n data, _status_code, _headers = get_faxes_id_with_http_info(id, opts)\n data\n end", "def index\n @essays = Essay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @essays }\n end\n end", "def index \n fans = Fan.all \n render json: fans \n end", "def index\n json_response(Spot.all)\n end", "def index\n @api_v1_frequency_periods = Api::V1::FrequencyPeriod.all\n end", "def index\n @futboladas = Futbolada.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @futboladas }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @chart }\n end\n end", "def index\n @flights = Flight.all\n render json: @flights\n end", "def index\n @spoofers = Spoofer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spoofers }\n end\n end", "def index\n \n @trends = Trend.order(\"as_of DESC\").limit(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trends }\n end\n\n end", "def index\n @foafs = Foaf.all\n # if all else fails, make RDF then\n # rapper -o dot -i turtle me.ttl | dot -Tsvg -o me.svg\n respond_to do |format|\n format.html #{ render text: convert_one_to_rdf(@foaf, :html) }\n format.ttl { render text: convert_many_to_rdf(@foafs, :ttl) }\n format.rj { render text: convert_many_to_rdf(@foafs, :json) }\n format.nt { render text: convert_many_to_rdf(@foafs, :ntriples) }\n format.rdf { render text: convert_many_to_rdf(@foafs, :rdf) }\n format.jsonld { render text: convert_many_to_rdf(@foafs, :jsonld) }\n end\n end", "def index\n @faceapis = Faceapi.all\n end", "def index\n @fax_jobs = FaxJob.all\n end", "def show\n @techaxis = Techaxis.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @techaxis }\n end\n end", "def questions\n @response = self.class.get(\"/data/2.5/forecast\", @options)\n end", "def index\n @filials = Filial.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @filials }\n end\n end", "def index\n @faq_categories = FaqCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @faq_categories }\n end\n end", "def get_price_chart\n @price_charts = EmailPriceList.where(category: \"Price Chart\").order(\"updated_at DESC\")\n\n render json: @price_charts , each_serializer: Web::V1::EmailPriceSerializer\n end", "def index\n @fbposts = Fbpost.all\n render json: @fbposts\n end", "def ajax_service_point\n sp_id = params['sp_id']\n url = ENV['OKAPI_URL']\n tenant = ENV['OKAPI_TENANT']\n sp = CUL::FOLIO::Edge.service_point(url, tenant, folio_token, sp_id)\n render json: sp\n end", "def index\n @formatoventa = Formatoventum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @formatoventa }\n end\n end", "def show\n @travel_chart = Travel::Chart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @travel_chart }\n end\n end", "def get_surf_data\n url = \"http://magicseaweed.com/api/#{ENV['MAGIC_SEAWEED_API_KEY']}/forecast/?spot_id=6128&units=UK\"\n uri = URI(url)\n\n response = Net::HTTP.get(uri)\n ActiveSupport::JSON.decode(response) if response != ''\n end", "def index\n @monthly_finances = MonthlyFinance.all\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @monthly_finances }\n # end\n end", "def index\n @forecast_wsizes = ForecastWsize.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @forecast_wsizes }\n end\n end", "def index\n #@future_tickers = FutureTicker.all\n @future_tickers = $influxdb.query(\"select * from ticker where contract_type='#{params[:contract_type]}' and symbol='#{params[:symbol]}'\").first[\"values\"]\n end", "def index\n @offices = Office.where(\"user_id = ?\", current_user).order('created_at DESC').page(params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offices }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @financials }\n end\n end", "def index\n @traxes = Trax.all\n end", "def index\n # @weekdays = Weekday.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@weekdays, mode: :compat) }\n end\n end", "def index\n @faculties = Faculty.all\n json_response(@faculties)\n end", "def index\n @cloth_measures = ClothMeasure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cloth_measures }\n end\n end", "def index\n @food_sliders = FoodSlider.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @food_sliders }\n end\n end", "def index\n @measures = current_user.account.measures.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @measures }\n end\n end", "def index\n authorize! :read, Roxiware::BookSeries\n @series = Roxiware::BookSeries.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @series }\n end\n end", "def index\n @timecharts = Timechart.find(:all, order: \"stop_time DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timecharts }\n end\n end", "def get_financials\n render json: [current_user]\n end", "def index\n @shop_fb_credit_offers = Shop::FbCreditOffer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shop_fb_credit_offers }\n end\n end", "def index\n @fine_scales = FineScale.all\n end", "def index\n @fax_documents = FaxDocument.accessible_by( current_ability, :index ).all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @fax_documents }\n end\n end", "def index\n @frais_annexes = FraisAnnex.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @frais_annexes }\n end\n end", "def index\n @pols = Pol.includes(:events).all\n respond_to do |format|\n format.json\n end\n end", "def index\n @formularies = Formulary.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @formularies }\n end\n end", "def index\n @fokeys = Fokey.all\n end", "def index\n @faqs = Faq.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @faqs }\n end\n end", "def index\n @admin_pricing_foams = Admin::Pricing::Foam.all.paginate(page: params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @admin_pricing_foams.map { |i| { value: i.id, text: i.to_s } }, status: :ok }\n end\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @funerals }\n end\n end", "def get_folio_data\n netid = params['netid']\n url = ENV['OKAPI_URL']\n tenant = ENV['OKAPI_TENANT']\n account = CUL::FOLIO::Edge.patron_account(url, tenant, folio_token, { username: netid })\n # Rails.logger.debug(\"mjc12test: Got FOLIO account #{account.inspect}\")\n render json: account\n end", "def forex_rates_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.forex_rates ...'\n end\n # resource path\n local_var_path = '/forex/rates'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'base'] = opts[:'base'] if !opts[:'base'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Forexrates' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#forex_rates\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @forecast_72s = Forecast72.all\n end", "def index\n @finance_documents = FinanceDocument.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @finance_documents\n end", "def index\n @faves_arr = []\n @favourites = current_user.favourites.map do |fave|\n @faves_arr << Location.find_by_id(fave.location_id)\n end\n\n render json: @faves_arr.map(&:transform_json), status: 201\n end", "def index\n @funcionarios = Funcionario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @funcionarios }\n end\n end", "def series_get_all\n begin\n api = \"#{$config['sonarr']['api_url']}/series\"\n\n url = URI.parse(api)\n\n req = Net::HTTP::Get.new(url.path)\n req.add_field('Content-Type', 'application/json')\n req.add_field('X-Api-Key',$config['sonarr']['api_key'])\n\n res = Net::HTTP.new(url.host, url.port).start do |http|\n http.request(req)\n end\n\n json = JSON.parse(res.body)\n #if json.class.to_s == 'Array'\n # json.each do |row|\n # log_debug (\"#{row['title']}\")\n # end\n #end\n\n rescue => e\n log_debug \"failed #{e}\"\n end\n return json\n end", "def axes\n end", "def show\n @fluxomatricula = Fluxomatricula.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fluxomatricula }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { \n taxt_rules = JqxConverter.jqxGrid(current_user.entity.tax_rules.where(record_status: 1))\n render json: taxt_rules\n }\n end\n end", "def index\n @taxe_values = Taxe::Value.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @taxe_values }\n end\n end", "def get_all_taxes\n self.class.get(\"/aldebaran-taxes/v2/taxes\", :basic_auth => @auth)\n end", "def index\n @ferias_funcionarios = FeriasFuncionario.all\n end", "def index\n @face_offs = FaceOff.all\n end", "def index\n @edge_types = EdgeType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @edge_types }\n end\n end", "def index\n @funs = Fun.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @funs }\n end\n end" ]
[ "0.7665524", "0.7437441", "0.68032384", "0.65644884", "0.64255446", "0.5986198", "0.59679914", "0.5958632", "0.5893894", "0.582781", "0.5819581", "0.5815399", "0.5805736", "0.5776036", "0.5769731", "0.5718689", "0.56752414", "0.565957", "0.564791", "0.5625505", "0.5612374", "0.5608229", "0.55913955", "0.5590934", "0.5585494", "0.55848235", "0.55752623", "0.557415", "0.55691785", "0.55427486", "0.55361736", "0.5518619", "0.55070657", "0.54976076", "0.54872465", "0.54811484", "0.5480288", "0.54633313", "0.5462365", "0.54541", "0.544625", "0.5443979", "0.54353714", "0.5429033", "0.5426297", "0.5423412", "0.5418316", "0.54167426", "0.5416689", "0.54150075", "0.54101646", "0.540905", "0.5400456", "0.5380338", "0.53734016", "0.53731686", "0.5361796", "0.53581595", "0.53541684", "0.5353787", "0.53532547", "0.53463537", "0.53456116", "0.5344677", "0.53415", "0.53363466", "0.53288484", "0.5328522", "0.5326957", "0.53249526", "0.5324179", "0.5321095", "0.5306043", "0.53038496", "0.5300247", "0.5294852", "0.529059", "0.5289651", "0.5286017", "0.5279291", "0.52766746", "0.5273835", "0.5271003", "0.5267507", "0.52669805", "0.5266249", "0.5263735", "0.5259229", "0.5254209", "0.52522296", "0.5244137", "0.52432424", "0.5241925", "0.5239471", "0.5237471", "0.523237", "0.52321565", "0.52320385", "0.523202", "0.52307844" ]
0.7159742
2
GET /faxes/1 GET /faxes/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @faxes = Fax.all\n end", "def get_faxes(opts = {})\n data, _status_code, _headers = get_faxes_with_http_info(opts)\n data\n end", "def get_faxes_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FaxesApi.get_faxes ...'\n end\n allowable_values = [\"inbound,outbound\", \"inbound\", \"outbound\"]\n if @api_client.config.client_side_validation && opts[:'filter_type'] && !allowable_values.include?(opts[:'filter_type'])\n fail ArgumentError, \"invalid value for \\\"filter_type\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [\"asc\", \"desc\"]\n if @api_client.config.client_side_validation && opts[:'order'] && !allowable_values.include?(opts[:'order'])\n fail ArgumentError, \"invalid value for \\\"order\\\", must be one of #{allowable_values}\"\n end\n if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] > 100\n fail ArgumentError, 'invalid value for \"opts[:\"per_page\"]\" when calling FaxesApi.get_faxes, must be smaller than or equal to 100.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"per_page\"]\" when calling FaxesApi.get_faxes, must be greater than or equal to 0.'\n end\n\n # resource path\n local_var_path = '/faxes'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'filter[type]'] = opts[:'filter_type'] if !opts[:'filter_type'].nil?\n query_params[:'filter[from_number]'] = opts[:'filter_from_number'] if !opts[:'filter_from_number'].nil?\n query_params[:'filter[to_number]'] = opts[:'filter_to_number'] if !opts[:'filter_to_number'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Fax>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxesApi#get_faxes\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n\n\n respond_to do |format|\n\n format.html { @axes = Axis.where(:user_id => current_user.id).all }\n format.json { render json: Axis.all }\n end\n end", "def get(id)\n response = Network.get(['Faxes', id])\n Fax.new(response)\n end", "def index\n @techaxis_type = TechaxisType.find(params[:techaxis_type_id])\n @techaxes = Techaxis.where(\"techaxis_type_id = ?\", params[:techaxis_type_id]) \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @techaxes }\n end\n end", "def post_faxes_with_http_info(faxes, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FaxesApi.post_faxes ...'\n end\n # verify the required parameter 'faxes' is set\n if @api_client.config.client_side_validation && faxes.nil?\n fail ArgumentError, \"Missing the required parameter 'faxes' when calling FaxesApi.post_faxes\"\n end\n # resource path\n local_var_path = '/faxes'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(faxes) \n\n # return_type\n return_type = opts[:return_type] || 'Fax' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxesApi#post_faxes\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @taxis = Taxi.where(:open_for_bidding => true).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @taxis }\n end\n end", "def show\n @fax_typ = FaxTyp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fax_typ }\n end\n end", "def index\n @ftypes = Ftype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ftypes }\n end\n end", "def index\n @user_figures = UserFigure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_figures }\n end\n end", "def index\n render json: @fiestas\n end", "def show\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @chart }\n end\n end", "def show\n @techaxis = Techaxis.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @techaxis }\n end\n end", "def index\n @faqs = Faq.all\n\n render json: @faqs\n end", "def index\n @fretes = Frete.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fretes }\n end\n end", "def index\n @factions = Faction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @factions }\n end\n end", "def show\n @travel_chart = Travel::Chart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @travel_chart }\n end\n end", "def show\n @fluxomatricula = Fluxomatricula.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fluxomatricula }\n end\n end", "def get_faxes_id_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FaxesApi.get_faxes_id ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling FaxesApi.get_faxes_id\"\n end\n # resource path\n local_var_path = '/faxes/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Fax' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxesApi#get_faxes_id\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @taxes = Tax.all\n\n render json: @taxes\n end", "def index\n @ef_pares = EfPare.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ef_pares }\n end\n end", "def index\n @api_v1_frequency_periods = Api::V1::FrequencyPeriod.all\n end", "def index\n @techaxis_types = TechaxisType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @techaxis_types }\n end\n end", "def show\n @fligh_scale = FlighScale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fligh_scale }\n end\n end", "def index\n @foros = Foro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foros }\n end\n end", "def index\n\t @fares = Fare.all\n\n\t respond_to do |format|\n\t\tformat.html # index.html.erb\n\t\tformat.json { render json: @fares }\n\t end\n\tend", "def index\n @offices = Office.all\n json_response(@offices)\n end", "def index\n @formularies = Formulary.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @formularies }\n end\n end", "def index\n @taxes = params['item_id'] ? Item.find(params['item_id']).taxes : Tax.all\n render json: @taxes\n end", "def index\n @charts = Chart.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @charts }\n end\n end", "def index\n faqs = Faq.all\n json_response(faqs)\n end", "def index\n @fundamental_daily_position_stats = Fundamental::DailyPositionStat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fundamental_daily_position_stats }\n end\n end", "def show\n @series = Series.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @series }\n end\n end", "def index\n @dev_folios = DevFolio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dev_folios }\n end\n end", "def show\n @rfq = Rfq.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rfq }\n end\n end", "def index\n fact = to_json(Fact.last)\n tip = to_json(Tip.last)\n quote = to_json(Quote.last)\n expert_opinion = to_json(ExpertOpinion.last)\n faq = to_json(Faq.last)\n article = to_json(Article.last)\n testimony = to_json(Testimony.last)\n documentary = to_json(Documentary.last)\n \n json_response({ \n fact: fact,\n tip: tip, \n quote: quote,\n expert_opinion: expert_opinion,\n faq: faq,\n article: article,\n testimony: testimony,\n documentary: documentary\n })\n end", "def show\n @series = Series.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @series }\n end\n end", "def index\n @filials = Filial.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @filials }\n end\n end", "def show\n @series = Series.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @series }\n end\n end", "def show\n @techaxis_type = TechaxisType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @techaxis_type }\n end\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @funerals }\n end\n end", "def index\n @cloth_measures = ClothMeasure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cloth_measures }\n end\n end", "def show\n @todolist_chart = TodolistChart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @todolist_chart }\n end\n end", "def index\n #@future_tickers = FutureTicker.all\n @future_tickers = $influxdb.query(\"select * from ticker where contract_type='#{params[:contract_type]}' and symbol='#{params[:symbol]}'\").first[\"values\"]\n end", "def index\n @formatoventa = Formatoventum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @formatoventa }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cn_curve }\n end\n end", "def consulta\n fiesta = Fiesta.all\n render json: fiesta\n end", "def index\n @cfos = Cfo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cfos }\n end\n end", "def index\n @flights = Flight.all\n render json: @flights\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @financials }\n end\n end", "def index\n get_data\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unit_of_measures }\n format.js\n end\n end", "def index\n @food_sliders = FoodSlider.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @food_sliders }\n end\n end", "def show\n @curve = Curve.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @curve }\n end\n end", "def index \n fans = Fan.all \n render json: fans \n end", "def index\n @dis_additive_frequencies = DisAdditiveFrequency.all\n respond_to do |format|\n format.html\n format.json { render json:DisAdditiveFrequencieDatatable.new(view_context) }\n end\n end", "def index\n @spoofers = Spoofer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spoofers }\n end\n end", "def show\n @facet = Facet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @facet }\n end\n end", "def show\n @quantile_period = QuantilePeriod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quantile_period }\n end\n end", "def index\n @essays = Essay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @essays }\n end\n end", "def index\n @foafs = Foaf.all\n # if all else fails, make RDF then\n # rapper -o dot -i turtle me.ttl | dot -Tsvg -o me.svg\n respond_to do |format|\n format.html #{ render text: convert_one_to_rdf(@foaf, :html) }\n format.ttl { render text: convert_many_to_rdf(@foafs, :ttl) }\n format.rj { render text: convert_many_to_rdf(@foafs, :json) }\n format.nt { render text: convert_many_to_rdf(@foafs, :ntriples) }\n format.rdf { render text: convert_many_to_rdf(@foafs, :rdf) }\n format.jsonld { render text: convert_many_to_rdf(@foafs, :jsonld) }\n end\n end", "def index\n @paxes = Pax.all\n end", "def index\n @funs = Fun.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @funs }\n end\n end", "def get_faxes_id(id, opts = {})\n data, _status_code, _headers = get_faxes_id_with_http_info(id, opts)\n data\n end", "def index\n @fine_scales = FineScale.all\n end", "def index\n @offices = Office.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offices }\n end\n end", "def get_chart(options={})\n api_response = @api_client.make_api_request(:GET, \"artist/chart\", {}, options)\n @api_client.chart_item_digestor.list_from_xml(api_response.content.chart)\n end", "def index\n @futboladas = Futbolada.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @futboladas }\n end\n end", "def axes_series(params)\n if params[:primary_axes] == 0\n secondary_axes_series\n else\n primary_axes_series\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { \n taxt_rules = JqxConverter.jqxGrid(current_user.entity.tax_rules.where(record_status: 1))\n render json: taxt_rules\n }\n end\n end", "def index\n @faq_categories = FaqCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @faq_categories }\n end\n end", "def show\n @funcionario = Funcionario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @funcionario }\n end\n end", "def post_faxes(faxes, opts = {})\n data, _status_code, _headers = post_faxes_with_http_info(faxes, opts)\n data\n end", "def index\n json_response(Spot.all)\n end", "def axes_series(params)\n if params[:primary_axes] != 0\n primary_axes_series\n else\n secondary_axes_series\n end\n end", "def facets\n facet_name = request.params[\"f_name\"]\n if facet_name == nil\n render :json => nil\n return\n end\n @presenter = execute_search(-1)\n facet_data = @presenter.facets.find {|f| f.name == facet_name }\n render :json => facet_data.values\n rescue => ex\n backtrace = ex.backtrace.join(\"\\r\\n\")\n Rails.logger.error(\"Could not render facets as JSON. Exception: #{ex} \\r\\n #{backtrace}\")\n render :json => nil, status: 500\n end", "def show\n @timechart = Timechart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @timechart }\n end\n end", "def index\n @monthly_finances = MonthlyFinance.all\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @monthly_finances }\n # end\n end", "def index\n @cn_curves = CnCurve.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cn_curves }\n end\n end", "def show\n\t\t@ptax = Ptax.find(params[:id])\n\t\trespond_to do |format|\t\t\n\t\t\tformat.html \n\t\t\tformat.xml { render :xml => @ptaxes }\t\t#Render to XML File\n\t\tend\n\tend", "def index\n @qandas = Qanda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qandas }\n end\n end", "def questions\n @response = self.class.get(\"/data/2.5/forecast\", @options)\n end", "def index\n @expression_relationships = ExpressionRelationship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expression_relationships }\n end\n end", "def index\n @axis_events = AxisEvent.all\n end", "def forex_rates_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.forex_rates ...'\n end\n # resource path\n local_var_path = '/forex/rates'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'base'] = opts[:'base'] if !opts[:'base'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Forexrates' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#forex_rates\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @faculties = Faculty.all\n json_response(@faculties)\n end", "def show\n @fundamental_daily_position_stat = Fundamental::DailyPositionStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fundamental_daily_position_stat }\n end\n end", "def show\n json_response(@faq)\n end", "def show\n # @foaf = Foaf.find(:id)\n respond_to do |format|\n format.html { render layout: false }#text: convert_one_to_rdf(@foaf, :html) }\n format.ttl { render text: convert_one_to_rdf(@foaf, :ttl) }\n format.rj { render text: convert_one_to_rdf(@foaf, :json) }\n format.nt { render text: convert_one_to_rdf(@foaf, :ntriples) }\n format.rdf { render text: convert_one_to_rdf(@foaf, :rdf) }\n format.jsonld { render text: convert_one_to_rdf(@foaf, :jsonld) }\n end\n end", "def index\n @frais_annexes = FraisAnnex.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @frais_annexes }\n end\n end", "def index\n @timecharts = Timechart.find(:all, order: \"stop_time DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timecharts }\n end\n end", "def index\n \n @trends = Trend.order(\"as_of DESC\").limit(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trends }\n end\n\n end", "def index\n @forecast_wsizes = ForecastWsize.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @forecast_wsizes }\n end\n end", "def index\n authorize! :read, Roxiware::BookSeries\n @series = Roxiware::BookSeries.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @series }\n end\n end", "def show\n render json: @finance_document\n end", "def index\n @estadios = Estadio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @estadios }\n end\n end", "def index\n # @weekdays = Weekday.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@weekdays, mode: :compat) }\n end\n end", "def get_price_chart\n @price_charts = EmailPriceList.where(category: \"Price Chart\").order(\"updated_at DESC\")\n\n render json: @price_charts , each_serializer: Web::V1::EmailPriceSerializer\n end", "def show\n @series_type = SeriesType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @series_type }\n end\n end", "def index\n @admin_pricing_foams = Admin::Pricing::Foam.all.paginate(page: params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @admin_pricing_foams.map { |i| { value: i.id, text: i.to_s } }, status: :ok }\n end\n end", "def index\n @faceapis = Faceapi.all\n end" ]
[ "0.6904066", "0.69012874", "0.6875912", "0.6721544", "0.670126", "0.6151941", "0.611589", "0.5987312", "0.5979005", "0.59687763", "0.5860933", "0.5857329", "0.5817248", "0.58118486", "0.5791591", "0.57756853", "0.575676", "0.5718606", "0.5710551", "0.5701459", "0.5699748", "0.56794876", "0.5665477", "0.56471014", "0.5630077", "0.5617696", "0.55994415", "0.5598313", "0.5557466", "0.55569035", "0.55538684", "0.55468875", "0.5544935", "0.55370355", "0.5534034", "0.55287915", "0.5519781", "0.5517709", "0.55172634", "0.55006427", "0.54999524", "0.5497566", "0.5496198", "0.5493635", "0.5492718", "0.54904175", "0.54887456", "0.54885465", "0.5487472", "0.548716", "0.5482802", "0.54794866", "0.5465946", "0.54634523", "0.54444313", "0.54420024", "0.5439479", "0.54347277", "0.54300445", "0.5417083", "0.5416427", "0.5410649", "0.54069686", "0.54017955", "0.54009664", "0.5399233", "0.53834236", "0.53765994", "0.5374959", "0.5372092", "0.536929", "0.5367546", "0.53645766", "0.53635764", "0.53634423", "0.5351152", "0.5349737", "0.5347697", "0.53397006", "0.53335", "0.53328186", "0.53313786", "0.53278095", "0.5325354", "0.5324844", "0.5322985", "0.53174543", "0.53144217", "0.53119296", "0.5310403", "0.5305073", "0.5297706", "0.52861613", "0.5280322", "0.5278649", "0.52763563", "0.5276253", "0.5267806", "0.52677864", "0.5264563", "0.5263904" ]
0.0
-1
POST /faxes POST /faxes.json
def create @fax = Fax.new(fax_params) respond_to do |format| if @fax.save format.html { redirect_to @fax, notice: 'Fax was successfully created.' } format.json { render :show, status: :created, location: @fax } else format.html { render :new } format.json { render json: @fax.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_faxes(faxes, opts = {})\n data, _status_code, _headers = post_faxes_with_http_info(faxes, opts)\n data\n end", "def post_faxes_with_http_info(faxes, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FaxesApi.post_faxes ...'\n end\n # verify the required parameter 'faxes' is set\n if @api_client.config.client_side_validation && faxes.nil?\n fail ArgumentError, \"Missing the required parameter 'faxes' when calling FaxesApi.post_faxes\"\n end\n # resource path\n local_var_path = '/faxes'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(faxes) \n\n # return_type\n return_type = opts[:return_type] || 'Fax' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxesApi#post_faxes\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_faxes(opts = {})\n data, _status_code, _headers = get_faxes_with_http_info(opts)\n data\n end", "def get_faxes_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FaxesApi.get_faxes ...'\n end\n allowable_values = [\"inbound,outbound\", \"inbound\", \"outbound\"]\n if @api_client.config.client_side_validation && opts[:'filter_type'] && !allowable_values.include?(opts[:'filter_type'])\n fail ArgumentError, \"invalid value for \\\"filter_type\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [\"asc\", \"desc\"]\n if @api_client.config.client_side_validation && opts[:'order'] && !allowable_values.include?(opts[:'order'])\n fail ArgumentError, \"invalid value for \\\"order\\\", must be one of #{allowable_values}\"\n end\n if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] > 100\n fail ArgumentError, 'invalid value for \"opts[:\"per_page\"]\" when calling FaxesApi.get_faxes, must be smaller than or equal to 100.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"per_page\"]\" when calling FaxesApi.get_faxes, must be greater than or equal to 0.'\n end\n\n # resource path\n local_var_path = '/faxes'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'filter[type]'] = opts[:'filter_type'] if !opts[:'filter_type'].nil?\n query_params[:'filter[from_number]'] = opts[:'filter_from_number'] if !opts[:'filter_from_number'].nil?\n query_params[:'filter[to_number]'] = opts[:'filter_to_number'] if !opts[:'filter_to_number'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Fax>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxesApi#get_faxes\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @faxes = Fax.all\n end", "def create(to, from, url, optional_params = {})\n opts = { :To => to, :From => from, :Url => url }.merge(optional_params)\n response = Network.post(['Faxes'], opts)\n Fax.new(response)\n end", "def fax_post(api_key, fax_number, opts = {})\n fax_post_with_http_info(api_key, fax_number, opts)\n return nil\n end", "def send_fax()\n begin\n bodyParams = {\n to: [{ phoneNumber: RECIPIENT }],\n # To send fax to multiple recipients, add more 'phoneNumber' object. E.g.\n #\n # to: [\n # { phoneNumber: \"Recipient1-Phone-Number\" },\n # { phoneNumber: \"Recipient2-Phone-Number\" }\n # ],\n faxResolution: \"High\",\n coverPageText: \"This is a demo Fax page from Ruby\"\n }\n files = [\n ['test.jpg', 'image/jpeg']\n ]\n\n endpoint = \"/restapi/v1.0/account/~/extension/~/fax\"\n resp = $platform.post(endpoint, payload: bodyParams, files: files)\n puts (\"Fax sent. Message id: \" + resp.body['id'].to_s)\n check_fax_message_status(resp.body['id'])\n rescue StandardError => e\n puts (e)\n end\nend", "def create\n @fax_typ = FaxTyp.new(params[:fax_typ])\n\n respond_to do |format|\n if @fax_typ.save\n format.html { redirect_to @fax_typ, notice: 'Fax typ was successfully created.' }\n format.json { render json: @fax_typ, status: :created, location: @fax_typ }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fax_typ.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @axis = Axis.new(axis_params)\n # @axis.user = current_user\n # respond_to do |format|\n # if @axis.save\n # format.html { redirect_to @axis, notice: 'Axis was successfully created.' }\n # format.json { render :show, status: :created, location: @axis }\n # else\n # format.html { render :new }\n # format.json { render json: @axis.errors, status: :unprocessable_entity }\n # end\n # end\n\n respond_to do |format|\n\n format.json { render json: Axis.create( name: params[:name]) }\n end\n end", "def create\n Rails.logger.debug \"Creating a FAX\"\n @fax_job = FaxJob.new(fax_job_params)\n\n respond_to do |format|\n if @fax_job.save\n\t@fax_job.send_fax\n format.html { redirect_to @fax_job, notice: 'Fax job was successfully created.' }\n format.json { render :show, status: :created, location: @fax_job }\n else\n format.html { render :new }\n format.json { render json: @fax_job.errors, status: :unprocessable_entity }\n end\n end\n end", "def fax_params\n params.require(:fax).permit(:fax)\n end", "def index\n\n\n respond_to do |format|\n\n format.html { @axes = Axis.where(:user_id => current_user.id).all }\n format.json { render json: Axis.all }\n end\n end", "def create\n fax_request = FaxRequest.new(fax_params)\n fax_request.client_receipt_date = Time.now\n fax_request.save!\n response = send_fax(fax_params)\n update_fax_request(fax_request,response)\n end", "def postEntityFax( entity_id, number, description)\n params = Hash.new\n params['entity_id'] = entity_id\n params['number'] = number\n params['description'] = description\n return doCurl(\"post\",\"/entity/fax\",params)\n end", "def fax_post_with_http_info(api_key, fax_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: FaxApi.fax_post ...\"\n end\n # verify the required parameter 'api_key' is set\n fail ArgumentError, \"Missing the required parameter 'api_key' when calling FaxApi.fax_post\" if api_key.nil?\n # verify the required parameter 'fax_number' is set\n fail ArgumentError, \"Missing the required parameter 'fax_number' when calling FaxApi.fax_post\" if fax_number.nil?\n # resource path\n local_var_path = \"/fax\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'api_key'] = api_key\n\n # header parameters\n header_params = {}\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params[\"fax_number\"] = fax_number\n form_params[\"document_id\"] = opts[:'document_id'] if !opts[:'document_id'].nil?\n form_params[\"file\"] = opts[:'file'] if !opts[:'file'].nil?\n form_params[\"delete_file\"] = opts[:'delete_file'] if !opts[:'delete_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxApi#fax_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get(id)\n response = Network.get(['Faxes', id])\n Fax.new(response)\n end", "def create\n @rfx = Rfx.new(rfx_params)\n\n respond_to do |format|\n if @rfx.save\n format.html { redirect_to rfxes_url, notice: 'Rfx was successfully created.' }\n format.json { render :show, status: :created, location: @rfx }\n else\n format.html { render :new }\n format.json { render json: @rfx.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @faq = Faq.new(faq_params)\n\n if @faq.save\n render json: @faq, status: :created\n else\n render json: @faq.errors, status: :unprocessable_entity\n end\n end", "def create\n @axis_event = AxisEvent.new(axis_event_params)\n # raise session[:axis_id].inspect\n @axis_event.axis_id = Rails.class_variable_get(:@@axis_id)\n respond_to do |format|\n if @axis_event.save\n format.html { redirect_to @axis_event, notice: 'Axis event was successfully created.' }\n format.json { render :show, status: :created, location: @axis_event }\n else\n format.html { render :new }\n format.json { render json: @axis_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def axis_params\n params.require(:axis).permit(:name)\n end", "def destroy\n @fax.destroy\n respond_to do |format|\n format.html { redirect_to faxes_url, notice: 'Fax was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @face_off = FaceOff.new(face_off_params)\n\n respond_to do |format|\n if @face_off.save\n format.json { render json: @face_off, status: :created }\n else\n format.json { render json: @face_off.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_evaluate(excon, body)\n excon.request(\n method: :post,\n path: '/evaluate',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend", "def new\n @fax_typ = FaxTyp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fax_typ }\n end\n end", "def send_fax_status(fax_requests_queue_id)\n begin\n conn = Faraday.new(url: FAX_SERVER_URL, ssl: { ca_file: 'C:/Ruby200/cacert.pem' }) do |faraday|\n faraday.request :url_encoded\n faraday.response :logger\n faraday.adapter Faraday.default_adapter\n end\n token = FaxServices::Fax.get_token()\n parts = [\"sendfaxstatus?\",\n \"token=#{CGI.escape(token)}\",\n \"ApiKey=#{CGI.escape(APIKEY)}\",\n \"SendFaxQueueId=#{(fax_requests_queue_id)}\"]\n path = \"/api/\"+parts.join(\"&\")\n response = conn.get path do |req|\n req.body = {}\n end\n return JSON.parse(response.body)\n rescue Exception => e\n HelperMethods::Logger.app_logger('error', \"send_fax_status: #{e.message}\")\n service_alive?\n return {}\n end\n end", "def axes_series(params)\n if params[:primary_axes] != 0\n primary_axes_series\n else\n secondary_axes_series\n end\n end", "def get_faxes_id_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FaxesApi.get_faxes_id ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling FaxesApi.get_faxes_id\"\n end\n # resource path\n local_var_path = '/faxes/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Fax' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxesApi#get_faxes_id\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end", "def api_v11_timeseries_post_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi#api_v11_timeseries_post ...\"\n end\n \n # resource path\n path = \"/api/v11/timeseries\".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 _header_accept = []\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, 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: DefaultApi#api_v11_timeseries_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def send_fax(fax_message)\r\n # Validate required parameters.\r\n validate_parameters(\r\n 'fax_message' => fax_message\r\n )\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/fax/send'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare headers.\r\n _headers = {\r\n 'content-type' => 'application/json; charset=utf-8'\r\n }\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n headers: _headers,\r\n parameters: fax_message.to_json\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n\r\n # Validate response against endpoint and global error codes.\r\n return nil if _context.response.status_code == 404\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end", "def axes_series(params)\n if params[:primary_axes] == 0\n secondary_axes_series\n else\n primary_axes_series\n end\n end", "def axes\n end", "def create\n @ofx_transaction = OfxTransaction.new(ofx_transaction_params)\n\n if @ofx_transaction.save\n render json: @ofx_transaction, status: :created, location: @ofx_transaction\n else\n render json: @ofx_transaction.errors, status: :unprocessable_entity\n end\n end", "def post endpoint, data\n do_request :post, endpoint, data\n end", "def call method, args = {}\n unless args.is_a? Hash\n raise ArgumentError.new \"argument must be a Hash\"\n end\n\n args.each_key do |key|\n if args[key].is_a?(Array) || args[key].is_a?(Hash)\n args[key] = JSON.dump(args[key])\n end\n end\n\n @faraday.post method, args\n end", "def create\n @ferias_funcionario = FeriasFuncionario.new(ferias_funcionario_params)\n\n respond_to do |format|\n if @ferias_funcionario.save\n format.html { redirect_to @ferias_funcionario, notice: 'Ferias funcionario was successfully created.' }\n format.json { render :show, status: :created, location: @ferias_funcionario }\n else\n format.html { render :new }\n format.json { render json: @ferias_funcionario.errors, status: :unprocessable_entity }\n end\n end\n end", "def ajax_service_point\n sp_id = params['sp_id']\n url = ENV['OKAPI_URL']\n tenant = ENV['OKAPI_TENANT']\n sp = CUL::FOLIO::Edge.service_point(url, tenant, folio_token, sp_id)\n render json: sp\n end", "def create\n @fish_poly = FishPoly.new(fish_poly_params)\n\n respond_to do |format|\n if @fish_poly.save\n format.html { redirect_to @fish_poly, notice: 'Fish poly was successfully created.' }\n format.json { render :show, status: :created, location: @fish_poly }\n else\n format.html { render :new }\n format.json { render json: @fish_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_fax(options = {})\n params = options.merge(to: @fax_number, string_data: 'test')\n @send_fax_response = Phaxio.send_fax(params)\n sleep(5)\n end", "def create\n @fabricsofaset = Fabricsofaset.new(fabricsofaset_params)\n\n respond_to do |format|\n if @fabricsofaset.save\n format.html { redirect_to @fabricsofaset, notice: 'Fabricsofaset was successfully created.' }\n format.json { render :show, status: :created, location: @fabricsofaset }\n else\n format.html { render :new }\n format.json { render json: @fabricsofaset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fax.update(fax_params)\n format.html { redirect_to @fax, notice: 'Fax was successfully updated.' }\n format.json { render :show, status: :ok, location: @fax }\n else\n format.html { render :edit }\n format.json { render json: @fax.errors, status: :unprocessable_entity }\n end\n end\n end", "def fpr_axis\n axis = []\n @p.each_index do |i|\n axis << fpr(i)\n end\n axis\n end", "def to_flot\n [\n { label: \"Pageviews\", data: pageviews },\n { label: \"Downloads\", data: downloads }\n ]\n end", "def use_axes=(pagesettings)\n end", "def post(_endpoint_path, _body, _extra_headers = {})\n response\n end", "def forex_symbols_with_http_info(exchange, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.forex_symbols ...'\n end\n # verify the required parameter 'exchange' is set\n if @api_client.config.client_side_validation && exchange.nil?\n fail ArgumentError, \"Missing the required parameter 'exchange' when calling DefaultApi.forex_symbols\"\n end\n # resource path\n local_var_path = '/forex/symbol'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'exchange'] = exchange\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<ForexSymbol>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#forex_symbols\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @travel_chart = Travel::Chart.new(params[:travel_chart])\n\n respond_to do |format|\n if @travel_chart.save\n format.html { redirect_to @travel_chart, notice: 'Travel chart was successfully created.' }\n format.json { render json: @travel_chart, status: :created, location: @travel_chart }\n else\n format.html { render action: \"new\" }\n format.json { render json: @travel_chart.errors, status: :unprocessable_entity }\n end\n end\n end", "def execute(postVariables)\n logger.debug postVariables.merge(defaults)\n # Redirect where necessary.\n res = RestClient.post(BASE_URL, postVariables.merge(defaults), { accept: :json })\n unless res.code == 200\n return { 'Status' => 'Failed', 'Result' => res.body }.with_indifferent_access\n end\n\n return_data = JSON.parse(res.body).with_indifferent_access\n\n if return_data['Status'] == 'Failed'\n logger.debug 'Execution of SR Fax command not successful'\n end\n return_data\n end", "def axes=(value)\n @axes = value\n end", "def destroy\n @axis.destroy\n respond_to do |format|\n format.html { redirect_to axes_url, notice: 'Axis was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_faxes_id_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FaxesApi.delete_faxes_id ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling FaxesApi.delete_faxes_id\"\n end\n # resource path\n local_var_path = '/faxes/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxesApi#delete_faxes_id\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @trax = Trax.new(trax_params)\n\n respond_to do |format|\n if @trax.save\n format.html { redirect_to @trax, notice: 'Trax was successfully created.' }\n format.json { render :show, status: :created, location: @trax }\n else\n format.html { render :new }\n format.json { render json: @trax.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(parameters, options, consts)\n begin\n response = client.post('https://echo.epa.gov/app/proxy/proxy.php', parameters)\n\n if response.status == 200\n results = response.body.fetch('Results')\n if results.key?('Error')\n error_message = results['Error'].fetch('ErrorMessage')\n if error_message.match(/\\ARows Returned would be \\d+\\. Queryset Limit would be exceeded - please make search parmeters more selective!\\z/)\n # If too many rows are returned, add a \"County\" parameter.\n # Needed for p_st=CA, FL, IL, MN, NJ, NY, TX.\n if !parameters.key?(:p_fips)\n options[:p_fips][parameters[:p_st]].each do |v|\n post(parameters.merge(p_fips: v), options, consts)\n end\n else\n logger.warn(\"#{response.status}: #{error_message}\")\n end\n else\n # NOTE: The following spurious error occurs intermittently:\n # \"Invalid character in callback function name - only alphabetic and numeric characters are allowed.\"\n logger.warn(\"#{response.status}: #{error_message}\")\n end\n else\n response = client.post('https://ofmpub.epa.gov/echo/echo_rest_services2.get_download', {\n qid: results.fetch('QueryID'),\n # NOTE: When resubmitting a query, the application appends the new\n # column IDs, resulting in duplicate column IDs. This code doesn't.\n qcolumns: consts.fetch(:qcolumns),\n })\n\n basename = [:p_st, :p_fips].map{|parameter| parameters[parameter]}.compact.join('-')\n \n File.open(File.join('downloads', \"#{basename}.csv\"), 'w') do |f|\n f.write(response.body)\n end\n end\n else\n logger.warn(\"#{response.status}: #{response.body}\")\n end\n rescue Faraday::ClientError => e\n logger.error(\"#{e.class} #{e.message} #{e.response}\")\n end\n end", "def fax_job_params\n params.require(:fax_job).permit(:fax, :file_name, :sender_email, :sender_name)\n end", "def create\n @fokey = Fokey.new(fokey_params)\n\n respond_to do |format|\n if @fokey.save\n format.html { redirect_to @fokey, notice: 'Fokey was successfully created.' }\n format.json { render :show, status: :created, location: @fokey }\n else\n format.html { render :new }\n format.json { render json: @fokey.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @periodo_academico = PeriodoAcademico.new(params[:periodo_academico])\n\n if @periodo_academico.save\n render json: @periodo_academico, status: :created, location: @periodo_academico\n else\n render json: @periodo_academico.errors, status: :unprocessable_entity\n end\n end", "def create\n @fine_scale = FineScale.new(fine_scale_params)\n\n respond_to do |format|\n if @fine_scale.save\n format.html { redirect_to fine_scales_url, notice: 'Fine scale was successfully created.' }\n format.json { render :show, status: :created, location: @fine_scale }\n else\n format.html { render :new }\n format.json { render json: @fine_scale.errors, status: :unprocessable_entity }\n end\n end\n end", "def api_v11_timeseries_dashboards_post_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi#api_v11_timeseries_dashboards_post ...\"\n end\n \n # resource path\n path = \"/api/v11/timeseries/dashboards\".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 _header_accept = []\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, 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: DefaultApi#api_v11_timeseries_dashboards_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n render json: @fiestas\n end", "def create\n @powe_factor_nozzle_x = PoweFactorNozzleX.new(powe_factor_nozzle_x_params)\n\n respond_to do |format|\n if @powe_factor_nozzle_x.save\n format.html { redirect_to @powe_factor_nozzle_x, notice: 'Powe factor nozzle x was successfully created.' }\n format.json { render :show, status: :created, location: @powe_factor_nozzle_x }\n else\n format.html { render :new }\n format.json { render json: @powe_factor_nozzle_x.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fpsignal = Fpsignal.new(fpsignal_params)\n\n respond_to do |format|\n if @fpsignal.save\n format.html { redirect_to fpsignals_path, notice: 'Запись успешно добавлена.' }\n format.json { render :show, status: :created, location: fpsignals_path }\n else\n format.html { render :new }\n format.json { render json: @fpsignal.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end", "def create\n @offices = Office.create!(office_params)\n json_response(@offices, :created)\n end", "def index\n @techaxis_type = TechaxisType.find(params[:techaxis_type_id])\n @techaxes = Techaxis.where(\"techaxis_type_id = ?\", params[:techaxis_type_id]) \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @techaxes }\n end\n end", "def create\n\n @frasco = Frasco.new(frasco_params)\n\n respond_to do |format|\n if @frasco.save\n format.html { redirect_to @frasco, notice: 'Frasco was successfully created.' }\n format.json { render :show, status: :created, location: @frasco }\n else\n format.html { render :new }\n format.json { render json: @frasco.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @series = Series.new(params[:series])\n\n respond_to do |format|\n if @series.save\n format.html { redirect_to @series, notice: 'Series se ha creado con éxito.' }\n format.json { render json: @series, status: :created, location: @series }\n else\n format.html { render action: \"new\" }\n format.json { render json: @series.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customf = Customf.new(customf_params)\n\n respond_to do |format|\n if @customf.save\n format.html { redirect_to @customf, notice: 'Customf was successfully created.' }\n format.json { render action: 'show', status: :created, location: @customf }\n else\n format.html { render action: 'new' }\n format.json { render json: @customf.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fluxomatricula = Fluxomatricula.new(params[:fluxomatricula])\n\n respond_to do |format|\n if @fluxomatricula.save\n format.html { redirect_to @fluxomatricula, notice: 'Fluxomatricula was successfully created.' }\n format.json { render json: @fluxomatricula, status: :created, location: @fluxomatricula }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fluxomatricula.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @ftypes = Ftype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ftypes }\n end\n end", "def get_faxes_id(id, opts = {})\n data, _status_code, _headers = get_faxes_id_with_http_info(id, opts)\n data\n end", "def create\n @falta = Falta.new(falta_params)\n\n respond_to do |format|\n if @falta.save\n format.html { redirect_to @falta, notice: \"Falta was successfully created.\" }\n format.json { render :show, status: :created, location: @falta }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @falta.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_check(excon, body)\n excon.request(\n method: :post,\n path: '/check',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend", "def create\n @faq = Faq.new(faq_params)\n @faq.business_id = @business.id\n respond_to do |format|\n if @faq.save\n format.html { redirect_to @faq, notice: 'Faq was successfully created.' }\n format.json { render :show, status: :created, location: @faq }\n format.js\n else\n format.html { render :new }\n format.json { render json: @faq.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @folevent = Folevent.new(folevent_params)\n\n respond_to do |format|\n if @folevent.save\n format.html { redirect_to :back, notice: 'Vous suivez desormais cette événement' }\n format.json { render :show, status: :created, location: @folevent }\n else\n format.html { render :back }\n format.json { render json: @folevent.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @taxes = Tax.all\n\n render json: @taxes\n end", "def forex_rates_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.forex_rates ...'\n end\n # resource path\n local_var_path = '/forex/rates'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'base'] = opts[:'base'] if !opts[:'base'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Forexrates' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#forex_rates\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @faves_arr = []\n @favourites = current_user.favourites.map do |fave|\n @faves_arr << Location.find_by_id(fave.location_id)\n end\n\n render json: @faves_arr.map(&:transform_json), status: 201\n end", "def api_v11_timeseries_post(opts = {})\n api_v11_timeseries_post_with_http_info(opts)\n return nil\n end", "def xhr_post *args, params_or_action\n Presto::Browser.new(@controller, env, 'POST', true).body *args, params_or_action\n end", "def chart_feature \n @feature = params[:feature]\n chart = Ziya::Charts::Column.new( @license ) \n chart.add( :axis_category_text, @date_series )\n chart.add( :series, @feature, MoleLog.compute_series( @feature, @app_name, @min_date, @max_date ) )\n chart.add( :theme, \"moles\" ) \n chart.add( :user_data, :delay, rand( 10 ) + REFRESH_RATE )\n chart.add( :user_data, :url, \"/graphs/update_feature?feature=#{CGI.escape(@feature)}\") \n render :xml => chart.to_xml\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 add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend", "def create_faq_using_post_with_http_info(faq_request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FAQApi.create_faq_using_post ...'\n end\n # verify the required parameter 'faq_request' is set\n if @api_client.config.client_side_validation && faq_request.nil?\n fail ArgumentError, \"Missing the required parameter 'faq_request' when calling FAQApi.create_faq_using_post\"\n end\n # resource path\n local_var_path = '/faq'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(faq_request)\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Faq')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FAQApi#create_faq_using_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @forecast_72 = Forecast72.new(forecast_72_params)\n\n respond_to do |format|\n if @forecast_72.save\n format.html { redirect_to @forecast_72, notice: 'Forecast 72 was successfully created.' }\n format.json { render :show, status: :created, location: @forecast_72 }\n else\n format.html { render :new }\n format.json { render json: @forecast_72.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name].compact.join('/')\n url += \"/\"\n return HTTParty.post(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end", "def index\n fact = to_json(Fact.last)\n tip = to_json(Tip.last)\n quote = to_json(Quote.last)\n expert_opinion = to_json(ExpertOpinion.last)\n faq = to_json(Faq.last)\n article = to_json(Article.last)\n testimony = to_json(Testimony.last)\n documentary = to_json(Documentary.last)\n \n json_response({ \n fact: fact,\n tip: tip, \n quote: quote,\n expert_opinion: expert_opinion,\n faq: faq,\n article: article,\n testimony: testimony,\n documentary: documentary\n })\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 @fiestum = Fiestum.new(fiestum_params)\n\n respond_to do |format|\n if @fiestum.save\n format.html { redirect_to @fiestum, notice: 'Fiestum was successfully created.' }\n format.json { render :show, status: :created, location: @fiestum }\n else\n format.html { render :new }\n format.json { render json: @fiestum.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_fax\n @fax = Fax.find(params[:id])\n end", "def post\n Salesforce.set_http(session[:accesstoken], session[:accessurl])\n \t@response = Salesforce.create_post(params)\n \trespond_to do |format|\n format.json { render :json => @response.to_json}\n # example of multiple reponses mapped to one object\n # format.json { render :json => {:data => @response, :meta => @describe}.to_json}\n \tend\n end", "def create\n if params[:cros]!='y'\n #create from page query. @xieyinghua\n @faq = Faq.new(faq_params)\n else\n #create from cros post. @xieyinghua\n new_faq_params=Hash.new\n new_faq_params[:question]=params[:question]\n new_faq_params[:answer]=params[:answer]\n\n @faq=Faq.new(new_faq_params)\n end\n\n respond_to do |format|\n if @faq.save\n format.html { redirect_to @faq, notice: 'Faq was successfully created.' }\n format.json { render :show, status: :created, location: @faq }\n else\n format.html { render :new }\n format.json { render json: @faq.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @qux = Qux.new(qux_params)\n\n respond_to do |format|\n if @qux.save\n format.html { redirect_to @qux, notice: 'Qux was successfully created.' }\n format.json { render :show, status: :created, location: @qux }\n else\n format.html { render :new }\n format.json { render json: @qux.errors, status: :unprocessable_entity }\n end\n end\n end", "def ajax_fines\n @fines = params['fines']&.values.to_a\n render json: { record: render_to_string('_fines', layout: false), locals: { fines: @fines } }\n end", "def create\n @techaxis = Techaxis.new(params[:techaxis])\n @techaxis.techaxis_type_id = params[:techaxis_type_id]\n \n respond_to do |format|\n if @techaxis.save\n format.html { redirect_to techaxis_type_techaxes_path, :notice => t('controllermessage.insert') }\n format.json { render :json => @techaxis, :status => :created, :location => @techaxis }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @techaxis.errors, :status => :unprocessable_entity }\n end\n end\n end", "def forex_candles_with_http_info(symbol, resolution, from, to, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.forex_candles ...'\n end\n # verify the required parameter 'symbol' is set\n if @api_client.config.client_side_validation && symbol.nil?\n fail ArgumentError, \"Missing the required parameter 'symbol' when calling DefaultApi.forex_candles\"\n end\n # verify the required parameter 'resolution' is set\n if @api_client.config.client_side_validation && resolution.nil?\n fail ArgumentError, \"Missing the required parameter 'resolution' when calling DefaultApi.forex_candles\"\n end\n # verify the required parameter 'from' is set\n if @api_client.config.client_side_validation && from.nil?\n fail ArgumentError, \"Missing the required parameter 'from' when calling DefaultApi.forex_candles\"\n end\n # verify the required parameter 'to' is set\n if @api_client.config.client_side_validation && to.nil?\n fail ArgumentError, \"Missing the required parameter 'to' when calling DefaultApi.forex_candles\"\n end\n # resource path\n local_var_path = '/forex/candle'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'symbol'] = symbol\n query_params[:'resolution'] = resolution\n query_params[:'from'] = from\n query_params[:'to'] = to\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'ForexCandles' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#forex_candles\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @todolist_chart = TodolistChart.new(params[:todolist_chart])\n\n respond_to do |format|\n if @todolist_chart.save\n flash[:notice] = 'TodolistChart was successfully created.'\n format.html { redirect_to(@todolist_chart) }\n format.xml { render :xml => @todolist_chart, :status => :created, :location => @todolist_chart }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @todolist_chart.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add datapoints, opts={}\n datapoints = [*datapoints]\n\n datapoints.each do |dp|\n # we grab these datapoints for ourselves\n dp.goal = self\n \n data = {\n \"sendmail\" => opts[:sendmail] || false\n }.merge(dp.to_hash)\n\n # TODO create_all doesn't work because Ruby's POST encoding of arrays is broken.\n @user.post \"users/me/goals/#{@slug}/datapoints.json\", data\n end\n end", "def create\n @ship_fitting = ShipFitting.new(ship_fitting_params)\n\n respond_to do |format|\n if @ship_fitting.save\n format.html { redirect_to @ship_fitting, notice: 'Ship fitting was successfully created.' }\n format.json { render :show, status: :created, location: @ship_fitting }\n else\n format.html { render :new }\n format.json { render json: @ship_fitting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_datafactory(name) \n\n factory_create = {\n \"location\": \"centralus\"\n }\n\n response = HTTParty.put(\"https://management.azure.com/subscriptions/#{subscriptionId}/resourceGroups/#{resourceGroupName}/providers/Microsoft.DataFactory/factories/#{name}?api-version=2018-06-01\", {\n\n body: factory_create.to_json,\n\n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Content-Type\" => 'application/json', \n \"Accept\" => '*/*',\n \"Cache-Control\" => 'no-cache',\n \"Connection\" => 'keep-alive',\n \"cache-control\" => 'no-cache'\n },\n \n verify: true,\n })\n\n return JSON.parse response.read_body\n end" ]
[ "0.7567552", "0.7502427", "0.6328821", "0.6292444", "0.5744277", "0.5717272", "0.57033557", "0.564159", "0.5538465", "0.5445058", "0.54337585", "0.5377283", "0.5369761", "0.5325375", "0.53133285", "0.52752966", "0.5209369", "0.5077021", "0.50402325", "0.5030058", "0.5025962", "0.5012452", "0.50024", "0.4968599", "0.49194768", "0.49004558", "0.48905003", "0.48807964", "0.4873267", "0.48686627", "0.4868056", "0.48625106", "0.4836847", "0.48336706", "0.4830579", "0.48159528", "0.48132047", "0.48065618", "0.47800562", "0.47575602", "0.4746617", "0.47382239", "0.4726771", "0.47215018", "0.47051215", "0.47039187", "0.46955624", "0.4694632", "0.46849677", "0.468221", "0.46817756", "0.4669304", "0.46660772", "0.46644384", "0.46571836", "0.46558908", "0.46551174", "0.46529853", "0.46502092", "0.46448815", "0.46308732", "0.46294165", "0.46280646", "0.46265364", "0.46240714", "0.46175066", "0.46163556", "0.460697", "0.45982066", "0.4594969", "0.45939654", "0.45931873", "0.45922104", "0.458928", "0.45886657", "0.4581376", "0.45769843", "0.45726755", "0.45709792", "0.45702323", "0.45637202", "0.4563626", "0.45599234", "0.45593786", "0.4558906", "0.45538187", "0.45528856", "0.4552226", "0.45521718", "0.45494974", "0.45449817", "0.45419964", "0.45405957", "0.4538274", "0.45354035", "0.4534611", "0.45340392", "0.45335683", "0.45327723", "0.45305058" ]
0.58929026
4
PATCH/PUT /faxes/1 PATCH/PUT /faxes/1.json
def update respond_to do |format| if @fax.update(fax_params) format.html { redirect_to @fax, notice: 'Fax was successfully updated.' } format.json { render :show, status: :ok, location: @fax } else format.html { render :edit } format.json { render json: @fax.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 update\n @fax_typ = FaxTyp.find(params[:id])\n\n respond_to do |format|\n if @fax_typ.update_attributes(params[:fax_typ])\n format.html { redirect_to @fax_typ, notice: 'Fax typ was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fax_typ.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @spoofer = Spoofer.find(params[:id])\n\n respond_to do |format|\n if @spoofer.update_attributes(params[:spoofer])\n format.html { redirect_to @spoofer, notice: 'Spoofer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spoofer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'FOAF was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fabricsofaset.update(fabricsofaset_params)\n format.html { redirect_to @fabricsofaset, notice: 'Fabricsofaset was successfully updated.' }\n format.json { render :show, status: :ok, location: @fabricsofaset }\n else\n format.html { render :edit }\n format.json { render json: @fabricsofaset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fokey.update(fokey_params)\n format.html { redirect_to @fokey, notice: 'Fokey was successfully updated.' }\n format.json { render :show, status: :ok, location: @fokey }\n else\n format.html { render :edit }\n format.json { render json: @fokey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'Foaf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n respond_to do |format|\n if @rfx.update(rfx_params)\n format.html { redirect_to rfxes_url, notice: 'Rfx was successfully updated.' }\n format.json { render :show, status: :ok, location: @rfx }\n else\n format.html { render :edit }\n format.json { render json: @rfx.errors, status: :unprocessable_entity }\n end\n end\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n respond_to do |format|\n if @fish_poly.update(fish_poly_params)\n format.html { redirect_to @fish_poly, notice: 'Fish poly was successfully updated.' }\n format.json { render :show, status: :ok, location: @fish_poly }\n else\n format.html { render :edit }\n format.json { render json: @fish_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fax_job.update(fax_job_params)\n format.html { redirect_to @fax_job, notice: 'Fax job was successfully updated.' }\n format.json { render :show, status: :ok, location: @fax_job }\n else\n format.html { render :edit }\n format.json { render json: @fax_job.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customf.update(customf_params)\n format.html { redirect_to @customf, notice: 'Customf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @customf.errors, status: :unprocessable_entity }\n end\n end\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def UpdateField params = {}\n \n APICall(path: 'ticket_fields.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n @f = F.find(params[:id])\n\n respond_to do |format|\n if @f.update_attributes(params[:f])\n format.html { redirect_to software_package_fs_path(@software, @package) }\n format.js\n format.json { head :ok }\n else\n format.html { redirect_to software_package_fs_path(@software, @package) }\n format.js\n format.json { render json: @package.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def update\n respond_to do |format|\n if @rfq.update(rfq_params)\n format.html { redirect_to @rfq, notice: 'Request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rfq.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @rfq = Rfq.find(params[:id])\n\n respond_to do |format|\n if @rfq.update_attributes(params[:rfq])\n format.html { redirect_to @rfq, notice: 'Rfq was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rfq.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_faxes_with_http_info(faxes, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FaxesApi.post_faxes ...'\n end\n # verify the required parameter 'faxes' is set\n if @api_client.config.client_side_validation && faxes.nil?\n fail ArgumentError, \"Missing the required parameter 'faxes' when calling FaxesApi.post_faxes\"\n end\n # resource path\n local_var_path = '/faxes'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(faxes) \n\n # return_type\n return_type = opts[:return_type] || 'Fax' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxesApi#post_faxes\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n @faq.update(faqs_params)\n json_response(@faq)\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fluxomatricula = Fluxomatricula.find(params[:id])\n\n respond_to do |format|\n if @fluxomatricula.update_attributes(params[:fluxomatricula])\n format.html { redirect_to @fluxomatricula, notice: 'Fluxomatricula was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fluxomatricula.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo83.update(foo83_params)\n format.html { redirect_to @foo83, notice: \"Foo83 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo83 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo83.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo78.update(foo78_params)\n format.html { redirect_to @foo78, notice: \"Foo78 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo78 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo78.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cof.update(cof_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cof.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fax_document = FaxDocument.find(params[:id])\n \n respond_to do |format|\n if @fax_document.update_attributes(params[:fax_document])\n format.html { redirect_to(@fax_document, :notice => t(:fax_document_updated)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @fax_document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo8.update(foo8_params)\n format.html { redirect_to @foo8, notice: \"Foo8 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo8 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo8.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @add_fuel.update(add_fuel_params)\n format.html { redirect_to @add_fuel, notice: (t 'add_fuels.title')+(t 'actions.updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @add_fuel.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @wing.update(wing_params)\n @wing.floors.each { |f| f.touch }\n format.html { redirect_to @wing, notice: t('.update_ok', item: @wing.name) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @wing.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if params[:cros]=='y'\n #update from cros post. @xieyinghua\n new_faq_params=faq_params\n new_faq_params[:question]=params[:question]\n new_faq_params[:answer]=params[:answer]\n\n faq_params=new_faq_params\n end\n\n respond_to do |format|\n if @faq.update(faq_params)\n format.html { redirect_to @faq, notice: 'Faq was successfully updated.' }\n format.json { render :show, status: :ok, location: @faq }\n else\n format.html { render :edit }\n format.json { render json: @faq.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @techaxis = Techaxis.find(params[:id])\n\n respond_to do |format|\n if @techaxis.update_attributes(params[:techaxis])\n format.html { redirect_to techaxis_type_techaxis_path, :notice => t('controllermessage.update') }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @techaxis.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \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 respond_to do |format|\n if @foo1.update(foo1_params)\n format.html { redirect_to @foo1, notice: \"Foo1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @axis_event.update(axis_event_params)\n format.html { redirect_to @axis_event, notice: 'Axis event was successfully updated.' }\n format.json { render :show, status: :ok, location: @axis_event }\n else\n format.html { render :edit }\n format.json { render json: @axis_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_radios_for_array(args = {}) \n put(\"/radios.json/#{args[:arrayId]}\", args)\nend", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n feature.update_attributes(feature_params)\n\n respond_with(feature)\n end", "def put!\n request! :put\n end", "def update\n respond_to do |format|\n if @foo71.update(foo71_params)\n format.html { redirect_to @foo71, notice: \"Foo71 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo71 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo71.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @appraisal_fee.update(appraisal_fee_params)\n format.html { redirect_to appraisal_fees_path, notice: 'Appraisal fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @appraisal_fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @falta.update(falta_params)\n format.html { redirect_to @falta, notice: \"Falta was successfully updated.\" }\n format.json { render :show, status: :ok, location: @falta }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @falta.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tenant_fee.update(tenant_fee_params)\n format.html { redirect_to @tenant_fee, notice: 'Tenant fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @tenant_fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @calf.update(calf_params)\n format.html { redirect_to @calf, notice: 'Calf was successfully updated.' }\n format.json { render :show, status: :ok, location: @calf }\n else\n format.html { render :edit }\n format.json { render json: @calf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @qux.update(qux_params)\n format.html { redirect_to @qux, notice: 'Qux was successfully updated.' }\n format.json { render :show, status: :ok, location: @qux }\n else\n format.html { render :edit }\n format.json { render json: @qux.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo7.update(foo7_params)\n format.html { redirect_to @foo7, notice: \"Foo7 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo7 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo7.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo77.update(foo77_params)\n format.html { redirect_to @foo77, notice: \"Foo77 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo77 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo77.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @folevent.update(folevent_params)\n format.html { redirect_to @folevent, notice: 'Folevent was successfully updated.' }\n format.json { render :show, status: :ok, location: @folevent }\n else\n format.html { render :edit }\n format.json { render json: @folevent.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foca.update(foca_params)\n format.html { redirect_to @foca, notice: 'Foca atualizada com sucesso.' }\n format.json { render :show, status: :ok, location: @foca }\n else\n format.html { render :edit }\n format.json { render json: @foca.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @extrainfo.update(extrainfo_params)\n format.html { redirect_to @extrainfo, notice: 'Extrainfo was successfully updated.' }\n format.json { render :show, status: :ok, location: @extrainfo }\n else\n format.html { render :edit }\n format.json { render json: @extrainfo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @core_funcional.update(core_funcional_params)\n format.html { redirect_to @core_funcional, notice: 'Funcional was successfully updated.' }\n format.json { render :show, status: :ok, location: @core_funcional }\n else\n format.html { render :edit }\n format.json { render json: @core_funcional.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo10.update(foo10_params)\n format.html { redirect_to @foo10, notice: \"Foo10 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo10 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo10.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 respond_to do |format|\n if @frat.update(frat_params)\n format.html { redirect_to @frat, notice: 'Frat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @frat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fee.update(fee_params)\n format.html { redirect_to @fee, notice: 'Fee was successfully updated.' }\n format.json { render :show, status: :ok, location: @fee }\n else\n format.html { render :edit }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fee.update(fee_params)\n format.html { redirect_to @fee, notice: 'Fee was successfully updated.' }\n format.json { render :show, status: :ok, location: @fee }\n else\n format.html { render :edit }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo81.update(foo81_params)\n format.html { redirect_to @foo81, notice: \"Foo81 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo81 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo81.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pax.update(pax_params)\n format.html { redirect_to @pax, notice: 'Pax was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pax.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 @ship_fitting.update(ship_fitting_params)\n format.html { redirect_to @ship_fitting, notice: 'Ship fitting was successfully updated.' }\n format.json { render :show, status: :ok, location: @ship_fitting }\n else\n format.html { render :edit }\n format.json { render json: @ship_fitting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @face_off.update(face_off_params)\n format.html { redirect_to @face_off, notice: 'Face off was successfully updated.' }\n format.json { render :show, status: :ok, location: @face_off }\n else\n format.html { render :edit }\n format.json { render json: @face_off.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lifepointe.update(lifepointe_params)\n format.html { redirect_to @lifepointe, notice: 'Lifepointe was successfully updated.' }\n format.json { render :show, status: :ok, location: @lifepointe }\n else\n format.html { render :edit }\n format.json { render json: @lifepointe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def jsonapi_update!(attributes)\n assign_jsonapi_attributes(attributes)\n save!\n end", "def update\n respond_to do |format|\n if @tick.update(tick_params)\n format.html { redirect_to @tick, notice: 'Tick was successfully updated.' }\n format.json { render :show, status: :ok, location: @tick }\n else\n format.html { render :edit }\n format.json { render json: @tick.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @socio_cpf.update(socio_cpf_params)\n format.html { redirect_to @socio_cpf, notice: 'Socio cpf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @socio_cpf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fee = Fee.find(params[:id])\n\n respond_to do |format|\n if @fee.update_attributes(params[:fee])\n format.html { redirect_to fees_path, notice: 'Fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo37.update(foo37_params)\n format.html { redirect_to @foo37, notice: \"Foo37 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo37 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo37.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fip.update(fip_params)\n format.html { redirect_to @fip, notice: 'Fip was successfully updated.' }\n format.json { render :show, status: :ok, location: @fip }\n else\n format.html { render :edit }\n format.json { render json: @fip.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end", "def update\n @foam = Foam.find(params[:id])\n\n respond_to do |format|\n if @foam.update_attributes(params[:foam])\n format.html { redirect_to @foam, notice: 'Foam was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @foam.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def update\n respond_to do |format|\n if @dependence.update(dependence_params)\n format.html { redirect_to @dependence, notice: 'Dependence was successfully updated.' }\n format.json { render :show, status: :ok, location: @dependence }\n else\n format.html { render :edit }\n format.json { render json: @dependence.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @microfinance_service_provider_typology.update(microfinance_service_provider_typology_params)\n format.html { redirect_to @microfinance_service_provider_typology, notice: 'Microfinance service provider typology was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @microfinance_service_provider_typology.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @endpoint.update(endpoint_params)\n format.html { redirect_to root_url, notice: 'Endpoint was successfully updated.' }\n format.json { head :ok }\n else\n format.html { head :unprocessable_entity }\n format.json { render json: @endpoint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo56.update(foo56_params)\n format.html { redirect_to @foo56, notice: \"Foo56 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo56 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo56.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateTicket params = {}\n \n APICall(path: 'tickets.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n @fucker = Fucker.find(params[:id])\n\n respond_to do |format|\n if @fucker.update_attributes(params[:fucker])\n format.json { head :no_content }\n else\n format.json { render json: @fucker.errors, status: :internal_server_error }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo73.update(foo73_params)\n format.html { redirect_to @foo73, notice: \"Foo73 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo73 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo73.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_with []\n end", "def update\n respond_to do |format|\n if @foo93.update(foo93_params)\n format.html { redirect_to @foo93, notice: \"Foo93 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo93 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo93.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n respond_to do |format|\n if @foo34.update(foo34_params)\n format.html { redirect_to @foo34, notice: \"Foo34 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo34 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo34.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_radios_for_array(args = {}) \n id = args['id']\n temp_path = \"/radios.json/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"radioId\")\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 @faq = Helpdesk::Faq.find(params[:id])\n\n respond_to do |format|\n if @faq.update_attributes(faq_params)\n format.html { redirect_to admin_faqs_url, notice: 'Faq was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @faq.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ofx_transaction = OfxTransaction.find(params[:id])\n\n if @ofx_transaction.update(ofx_transaction_params)\n head :no_content\n else\n render json: @ofx_transaction.errors, status: :unprocessable_entity\n end\n end", "def update\n @taf = Taf.find(params[:id])\n\n respond_to do |format|\n if @taf.update_attributes(params[:taf])\n format.html { redirect_to @taf, notice: 'Taf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :manage, @selectf\n\n respond_to do |format|\n if @selectf.update(selectf_params)\n format.html { redirect_to [@selectf.metric, @selectf ], notice: 'Selectf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @selectf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @facet = Facet.find(params[:id])\n\n respond_to do |format|\n if @facet.update_attributes(params[:facet])\n format.html { redirect_to @facet, notice: 'Facet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @facet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # actions\n path = URI(@endpoint).path\n action = URI(@req.request_uri).path.sub(path, '').split('/')\n action -= ['']\n if action.include?('_history')\n @actions = [action[0], '_history']\n else\n @actions = [action[0]]\n end\n\n # search param\n req_query = URI(@req.request_uri).query\n unless req_query.nil?\n @req_params = URI::decode_www_form(req_query).to_h\n end\n\n # requst method\n if @req.request_method == \"GET\" and @actions.include? '_history'\n @req_method = 'vread'\n elsif @req.request_method == \"GET\" and @req_params != nil\n @req_method = 'search-type'\n elsif @req.request_method == \"PUT\"\n @req_method = 'update'\n elsif @req.request_method == \"POST\"\n @req_method = 'create'\n else\n @req_method = 'read'\n end\n\n # interaction\n int1 = Interaction.last type: @actions[0], code: @req_method\n if int1.nil?\n @present = 0\n else\n @present = int1.id\n @intCode = int1.valueCode\n end\n end", "def update\n respond_to do |format|\n if @endpoint.update(endpoint_params)\n format.html { redirect_to [@project,@endpoint], notice: 'Endpoint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @endpoint.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end", "def update\n respond_to do |format|\n if @taxfree.update(taxfree_params)\n format.html { redirect_to @taxfree, notice: 'Taxfree was successfully updated.' }\n format.json { render :show, status: :ok, location: @taxfree }\n else\n format.html { render :edit }\n format.json { render json: @taxfree.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n put :update\n end", "def update\n respond_to do |format|\n if @feature_request.update(feature_request_params)\n format.html { redirect_to @feature_request, notice: 'Feature request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @feature_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cpf.update(cpf_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cpf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foo11.update(foo11_params)\n format.html { redirect_to @foo11, notice: \"Foo11 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo11 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo11.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6405743", "0.6095538", "0.5998256", "0.5961049", "0.5931614", "0.58949435", "0.5893845", "0.5871725", "0.58678293", "0.5815141", "0.5793186", "0.5777657", "0.577376", "0.57529545", "0.57525903", "0.57495207", "0.5748024", "0.57470715", "0.5735325", "0.5734178", "0.571494", "0.5704854", "0.56859523", "0.5678022", "0.5674891", "0.5671778", "0.5668948", "0.5665434", "0.56459814", "0.5645433", "0.563752", "0.56350446", "0.56196404", "0.5609679", "0.5609679", "0.56062084", "0.56038916", "0.56028354", "0.5597277", "0.5590324", "0.5589612", "0.5586348", "0.5585363", "0.5581103", "0.55808306", "0.5578969", "0.5577651", "0.55693746", "0.55638707", "0.55550784", "0.55530155", "0.5548146", "0.5534273", "0.55328405", "0.5528952", "0.5526294", "0.5524193", "0.55239195", "0.55195135", "0.55195135", "0.5518305", "0.551643", "0.5515589", "0.55130047", "0.55123377", "0.5505165", "0.5501085", "0.5499644", "0.5499032", "0.5496197", "0.5496051", "0.54954696", "0.5492641", "0.54868263", "0.548632", "0.5486293", "0.548539", "0.54812425", "0.5477603", "0.5475232", "0.54705197", "0.5468288", "0.5462436", "0.54559916", "0.54544234", "0.5453839", "0.5452493", "0.5450289", "0.5449866", "0.54441136", "0.54388773", "0.54367906", "0.54348606", "0.54344326", "0.5432937", "0.54307914", "0.54299784", "0.5421882", "0.5419497", "0.54146516" ]
0.62733513
1
DELETE /faxes/1 DELETE /faxes/1.json
def destroy @fax.destroy respond_to do |format| format.html { redirect_to faxes_url, notice: 'Fax was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end", "def destroy\n @axis.destroy\n respond_to do |format|\n format.html { redirect_to axes_url, notice: 'Axis was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fax_typ = FaxTyp.find(params[:id])\n @fax_typ.destroy\n\n respond_to do |format|\n format.html { redirect_to fax_typs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customf.destroy\n respond_to do |format|\n format.html { redirect_to customfs_url }\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 delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end", "def deleteEntityFax( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/fax\",params)\n end", "def delete_complete\n @todolist_chart = TodolistChart.find(:all, :conditions => {:status => \"completed\"})\n \n @todolist_chart.each do |todolist_chart|\n todolist_chart.destroy\n end\n \n respond_to do |format|\n format.html { redirect_to(todolist_charts_url) }\n format.xml { head :ok }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "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 @fokey.destroy\n respond_to do |format|\n format.html { redirect_to fokeys_url, notice: 'Fokey was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fabricsofaset.destroy\n respond_to do |format|\n format.html { redirect_to fabricsofasets_url, notice: 'Fabricsofaset was successfully destroyed.' }\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 @fluxomatricula = Fluxomatricula.find(params[:id])\n @fluxomatricula.destroy\n\n respond_to do |format|\n format.html { redirect_to fluxomatriculas_url }\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.json { head :no_content }\n end\n end", "def destroy\n @hdfs_path = HdfsPath.find(params[:id])\n @hdfs_path.destroy\n\n respond_to do |format|\n format.html { redirect_to hdfs_paths_url }\n format.json { head :ok }\n end\n end", "def destroy\n @rfx.destroy\n respond_to do |format|\n format.html { redirect_to rfxes_url, notice: 'Rfx was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @techaxis = Techaxis.find(params[:id])\n @techaxis.destroy\n\n respond_to do |format|\n format.html { redirect_to techaxis_type_techaxes_url, :notice => t('controllermessage.delete') }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxi = Taxi.find(params[:id])\n @taxi.destroy\n\n respond_to do |format|\n format.html { redirect_to taxis_url }\n format.json { head :ok }\n end\n end", "def destroy\n @qux.destroy\n respond_to do |format|\n format.html { redirect_to quxes_url, notice: 'Qux 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 @foaf.destroy\n\n respond_to do |format|\n format.html { redirect_to foafs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @foaf.destroy\n\n respond_to do |format|\n format.html { redirect_to foafs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @chart = Chart.find(params[:id])\n @chart.chartnodes.destroy_all\n @chart.destroy\n\n respond_to do |format|\n format.html { redirect_to charts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @todolist_chart = TodolistChart.find(params[:id])\n @todolist_chart.destroy\n\n respond_to do |format|\n format.html { redirect_to(todolist_charts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @pax.destroy\n respond_to do |format|\n format.html { redirect_to paxes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rfq = Rfq.find(params[:id])\n @rfq.destroy\n\n respond_to do |format|\n format.html { redirect_to rfqs_url }\n format.json { head :ok }\n end\n end", "def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end", "def destroy\n @line_item1 = LineItem1.find(params[:id])\n @line_item1.destroy\n\n respond_to do |format|\n format.html { redirect_to line_item1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cb_axiento_det.destroy\n respond_to do |format|\n format.html { redirect_to cb_axiento_dets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sub1_line_item.destroy\n respond_to do |format|\n format.html { redirect_to sub1_line_items_url, notice: 'Sub1 line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @datapoint.destroy\n respond_to do |format|\n format.html { redirect_to datapoints_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @svgpost = Svgpost.find(params[:id])\n @svgpost.destroy\n\n respond_to do |format|\n format.html { redirect_to svgposts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxinomy = Taxinomy.find(params[:id])\n @taxinomy.destroy\n\n respond_to do |format|\n format.html { redirect_to taxinomies_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete_chart(chart_index)\n begin\n if(@filename=='')\n raise \"Base file not specified\"\n end\n if(@worksheetname=='')\n raise \"Worksheet is not specified\"\n end\n str_uri = $productURI + \"/cells/\" + @filename + \"/worksheets/\" + @worksheetname + \"/charts/\" + chart_index.to_s\n signed_uri = Common::Utils.sign(str_uri)\n \n response = RestClient.delete signed_uri, {:accept => 'application/json'}\n v_output = Common::Utils.validate_output(response)\n if(v_output==nil || v_output=='')\n folder = SaasposeStorage::Folder.new\n outputstream = folder.getfile(@filename)\n outputstream\n outputpath = $OutPutLocation + @filename\n Common::Utils.saveFile(outputstream, outputpath)\n return \"Chart deleted\"\n else\n return v_output\n end\n rescue Exception=>e\n print e\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @fax_document = FaxDocument.find(params[:id])\n @fax_document.destroy\n \n respond_to do |format|\n format.html { redirect_to(fax_documents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @travel_chart = Travel::Chart.find(params[:id])\n @travel_chart.destroy\n\n respond_to do |format|\n format.html { redirect_to travel_charts_url }\n format.json { head :no_content }\n end\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def destroy\n record = TaxRule.find(params[:id])\n record.trash\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @baz72.destroy\n respond_to do |format|\n format.html { redirect_to baz72s_url, notice: \"Baz72 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @cof.destroy\n respond_to do |format|\n format.html { redirect_to cofs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxon_determination.destroy\n respond_to do |format|\n format.html { redirect_to taxon_determinations_url }\n format.json { head :no_content }\n end\n end", "def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end", "def destroy\n @etx_file = EtxFile.find(params[:id])\n \n arr = @etx_file.ques_no.split(\",\")\n Question.destroy(arr)\n @etx_file.update_attributes(status: true)\n #@etx_file.destroy\n\n respond_to do |format|\n format.html { redirect_to etx_files_url }\n format.json { head :ok }\n end\n end", "def destroy\n @extrainfo.destroy\n respond_to do |format|\n format.html { redirect_to extrainfos_url, notice: 'Extrainfo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @foo71.destroy\n respond_to do |format|\n format.html { redirect_to foo71s_url, notice: \"Foo71 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @chart.destroy\n respond_to do |format|\n format.html { redirect_to charts_path, notice: '削除しました' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fax_job.destroy\n respond_to do |format|\n format.html { redirect_to fax_jobs_url, notice: 'Fax job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @f5_node = F5Node.find(params[:id])\n @f5_node.destroy\n\n respond_to do |format|\n format.html { redirect_to f5_nodes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @core_uf = Core::Uf.find(params[:id])\n @core_uf.destroy\n\n respond_to do |format|\n format.html { redirect_to core_ufs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cpf.destroy\n respond_to do |format|\n format.html { redirect_to cpfs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @core_funcional.destroy\n respond_to do |format|\n format.html { redirect_to core_funcionals_url, notice: 'Funcional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @foam = Foam.find(params[:id])\n @foam.destroy\n\n respond_to do |format|\n format.html { redirect_to foams_url }\n format.json { head :ok }\n end\n end", "def destroy\n @frat.destroy\n respond_to do |format|\n format.html { redirect_to frats_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @futbolada = Futbolada.find(params[:id])\n @futbolada.destroy\n\n respond_to do |format|\n format.html { redirect_to gestion_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fabric = Fabric.find(params[:id])\n @fabric.destroy\n\n respond_to do |format|\n format.html { redirect_to fabrics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fascicle.destroy\n respond_to do |format|\n format.html { redirect_to fascicles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @foo64.destroy\n respond_to do |format|\n format.html { redirect_to foo64s_url, notice: \"Foo64 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @databox.destroy\n render json: { post: @databox }\n# respond_to do |format|\n# format.html { redirect_to databoxes_url }\n# format.json { head :no_content }\n# end\n end", "def destroy\n @axis_event.destroy\n respond_to do |format|\n format.html { redirect_to axis_events_url, notice: 'Axis event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @f_sbj = FSbj.find(params[:id])\n @f_sbj.destroy\n\n respond_to do |format|\n format.html { redirect_to(f_sbjs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lineitem.destroy\n respond_to do |format|\n format.html { redirect_to lineitems_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @microfinance_service_provider_typology.destroy\n respond_to do |format|\n format.html { redirect_to microfinance_service_provider_typologies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @foo63.destroy\n respond_to do |format|\n format.html { redirect_to foo63s_url, notice: \"Foo63 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @alfresco = Alfresco.find(params[:id])\n @alfresco.destroy\n\n respond_to do |format|\n format.html { redirect_to(alfrescos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @foo83.destroy\n respond_to do |format|\n format.html { redirect_to foo83s_url, notice: \"Foo83 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @cfo.destroy\n respond_to do |format|\n format.html { redirect_to cfos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fbo.destroy\n respond_to do |format|\n format.html { redirect_to fbos_url, notice: 'Fbo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @rfx_item.destroy\n respond_to do |format|\n format.html { redirect_to rfx_rfx_items_url(@rfx), notice: 'Rfx item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def delete\n api(\"Delete\")\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 @foo1.destroy\n respond_to do |format|\n format.html { redirect_to foo1s_url, notice: \"Foo1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @ftype = Ftype.find(params[:id])\n @ftype.destroy\n\n respond_to do |format|\n format.html { redirect_to ftypes_url }\n format.json { head :no_content }\n end\n end", "def delete datapoints\n datapoints = [*datapoints]\n datapoints.each do |dp|\n @user.delete \"/users/me/goals/#{@slug}/datapoints/#{dp.id}.json\"\n end\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\n @trax.destroy\n respond_to do |format|\n format.html { redirect_to traxes_url, notice: 'Trax was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @powe_factor_nozzle_x.destroy\n respond_to do |format|\n format.html { redirect_to powe_factor_nozzle_xes_url, notice: 'Powe factor nozzle x was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxirequest = Taxirequest.find(params[:id])\n @taxirequest.destroy\n\n respond_to do |format|\n format.html { redirect_to taxirequests_url }\n format.json { head :no_content }\n end\n end", "def delete(payload = {})\n request! do\n options = {payload: to_payload(payload)}\n api(options)[url.path].delete(API_HEADERS)\n end\n end", "def destroy\n @body_measurement.destroy\n respond_to do |format|\n format.html { redirect_to body_measurements_url }\n format.json { head :no_content }\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 destroy\n @foo = Foo.find(params[:id])\n @foo.destroy\n\n respond_to do |format|\n format.html { redirect_to foos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @invoice_addon_line_item.destroy\n respond_to do |format|\n format.html { redirect_to invoice_addon_line_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @qx = Qx.find(params[:id])\n @qx.destroy\n\n respond_to do |format|\n format.html { redirect_to(qxes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @foo62.destroy\n respond_to do |format|\n format.html { redirect_to foo62s_url, notice: \"Foo62 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @faleconosco.destroy\n respond_to do |format|\n format.html { redirect_to faleconoscos_url, notice: 'Faleconosco was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :manage, @selectf\n\n @selectf.destroy\n respond_to do |format|\n format.html { redirect_to [@metric.service, @metric] }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @dcf = Dcf.find(params[:id])\r\n @dcf.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(dcfs_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @tipo_funcionario.destroy\n respond_to do |format|\n format.html { redirect_to tipo_funcionarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fnf_item.destroy\n respond_to do |format|\n format.html { redirect_to fnf_items_url, notice: 'Fnf item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @activity_type_f.destroy\n respond_to do |format|\n format.html { redirect_to activity_type_fs_url, notice: 'Activity type f was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @xpto = Xpto.find(params[:id])\n @xpto.destroy\n\n respond_to do |format|\n format.html { redirect_to xptos_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.668589", "0.6590102", "0.6529944", "0.64363027", "0.6378425", "0.6369021", "0.6350011", "0.634973", "0.6342679", "0.63381755", "0.63297445", "0.6305522", "0.6300163", "0.62862", "0.62728167", "0.6258868", "0.62525505", "0.6238768", "0.6234341", "0.6230245", "0.6223411", "0.6222023", "0.6222023", "0.6222023", "0.6222023", "0.6214313", "0.6214313", "0.62057596", "0.6198248", "0.61850256", "0.61699945", "0.6155456", "0.61536086", "0.6146614", "0.6143909", "0.613575", "0.6124131", "0.6123747", "0.6107776", "0.6104679", "0.60993093", "0.6088197", "0.60849553", "0.60752314", "0.60749644", "0.6072672", "0.6071955", "0.6056619", "0.6048303", "0.6044822", "0.604394", "0.6038236", "0.60372907", "0.6033738", "0.6026555", "0.6020833", "0.60186577", "0.6015858", "0.6015203", "0.6014068", "0.6009217", "0.60088366", "0.60072345", "0.6006449", "0.60022646", "0.60019004", "0.6001513", "0.6000119", "0.5997663", "0.59952676", "0.5989647", "0.59888697", "0.5986415", "0.59854287", "0.59839785", "0.5982776", "0.5981885", "0.598065", "0.5978632", "0.5978427", "0.5974817", "0.5971928", "0.59709924", "0.59700423", "0.5967405", "0.5964259", "0.5962493", "0.59623873", "0.5962135", "0.5957468", "0.5953885", "0.5953155", "0.595312", "0.5951847", "0.595146", "0.5945654", "0.59442085", "0.5942398", "0.59413874", "0.5941147" ]
0.666336
1
Use callbacks to share common setup or constraints between actions.
def set_fax @fax = Fax.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def fax_params params.require(:fax).permit(:fax) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def filtering_params\n params.permit(:email)\n end", "def active_code_params\n params[:active_code].permit\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def filter_parameters; end", "def filter_parameters; end", "def list_params\n params.permit(:name)\n end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.6981606", "0.6784227", "0.6746523", "0.67439264", "0.67361516", "0.6593381", "0.6506166", "0.64994407", "0.6483518", "0.64797056", "0.64578557", "0.6441216", "0.63811713", "0.63773805", "0.6366333", "0.63217646", "0.6301816", "0.63009787", "0.6294436", "0.62940663", "0.6292164", "0.62917984", "0.62836355", "0.6242686", "0.6241917", "0.62210834", "0.6214862", "0.62125784", "0.619428", "0.617912", "0.617705", "0.61735916", "0.6163706", "0.61532795", "0.6152666", "0.6148062", "0.6123372", "0.61180484", "0.61088324", "0.6106139", "0.60925204", "0.608326", "0.60711503", "0.606551", "0.60216546", "0.6018924", "0.6015004", "0.60106766", "0.6008301", "0.6008301", "0.60028726", "0.60020626", "0.5999236", "0.59931505", "0.5993037", "0.59917194", "0.5982164", "0.5968051", "0.5960277", "0.5960268", "0.5960012", "0.59594494", "0.5954652", "0.5954304", "0.59440255", "0.59404963", "0.59404963", "0.59401006", "0.593522", "0.5932182", "0.5925528", "0.5924541", "0.5918796", "0.59123147", "0.5910144", "0.5909186", "0.5907257", "0.5899382", "0.5897783", "0.58972496", "0.58958495", "0.58948576", "0.5892734", "0.5888056", "0.58843875", "0.58818483", "0.5873746", "0.58700997", "0.5870056", "0.5869255", "0.58668107", "0.58662325", "0.5865003", "0.5862908", "0.5862406", "0.58614665", "0.5859661", "0.585562", "0.5855185", "0.58523446", "0.58504915" ]
0.0
-1
Just store it for later processing
def receive(number) puts "received number #{number}" @queue << number end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store?; end", "def stored_data; end", "def store; end", "def store; end", "def store; end", "def store_result()\n #This is a stub, used for indexing\n end", "def private; end", "def autorestore; end", "def storage; end", "def result_of_setting; end", "def storage() @storage; end", "def used?; end", "def cache_value?; end", "def storage=(_arg0); end", "def extra_state; end", "def store=(_arg0); end", "def prepareForReuse; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def permanent; end", "def value_written; end", "def restore; end", "def cached?; end", "def set; end", "def set; end", "def store\n Thread.current\n end", "def transient?; end", "def use!\n self.used = true\n self.save\n end", "def store_merge_state; end", "def store_merge_state; end", "def state; end", "def state; end", "def state; end", "def state; end", "def state; end", "def state; end", "def state; end", "def state; end", "def post_process; end", "def data\n # This is a common memoization technique used in Ruby\n @data ||= normalize_data\nend", "def suivre; end", "def pausable; end", "def cache_store; end", "def cache_store; end", "def store_result(result); end", "def updated_data; end", "def cache(data); end", "def store_previous\n end", "def processor; end", "def save_pos; end", "def refutal()\n end", "def variable; end", "def variable; end", "def store_location!; end", "def processed_source=(_); end", "def processed_source=(_); end", "def previously_ran?; end", "def previously_ran?; end", "def getlocal() end", "def record; end", "def record; end", "def record; end", "def temp\n @temp\n end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data\n @cache ||= {}\n end", "def variables; end", "def variables; end", "def line_cache; end", "def final; end", "def probers; end", "def sitemaps; end", "def memo; end", "def metadata=(_); end", "def store\n @store ||= {}\n end", "def finalized; end", "def hash_more_data_state\n super\n end", "def cache_store=(_arg0); end", "def cache_store=(_arg0); end", "def store\n @store ||= Hash.new\n end", "def instance_cache; end", "def memo\n end", "def on_enter\n #@original_value = getvalue.dup rescue getvalue\n @original_value = @buffer.dup # getvalue.dup rescue getvalue\n super\n end", "def mark_used\n @used = true\n end", "def schubert; end", "def store\n @store\n end" ]
[ "0.67965674", "0.6711053", "0.66920036", "0.66920036", "0.66920036", "0.6384689", "0.63025093", "0.62964463", "0.62794805", "0.6087402", "0.60511476", "0.5983519", "0.59697706", "0.59503764", "0.59406257", "0.59190786", "0.5808031", "0.5806474", "0.5806474", "0.5806474", "0.5806474", "0.5806474", "0.5806474", "0.5806474", "0.5787736", "0.5780271", "0.5755422", "0.56827664", "0.5654376", "0.5654376", "0.56209725", "0.56117105", "0.561097", "0.56082505", "0.56082505", "0.5598263", "0.5598263", "0.5598263", "0.5598263", "0.5598263", "0.5598263", "0.5598263", "0.5598263", "0.5573529", "0.55725485", "0.55442244", "0.5533674", "0.55229175", "0.55229175", "0.5517799", "0.5514148", "0.55124843", "0.550942", "0.55009526", "0.54973537", "0.54703206", "0.5469549", "0.5469549", "0.54589736", "0.545426", "0.545426", "0.54538554", "0.54538554", "0.5453474", "0.5439018", "0.5439018", "0.5439018", "0.54363465", "0.54240763", "0.54240763", "0.54240763", "0.54240763", "0.54240763", "0.54240763", "0.54240763", "0.54240763", "0.54240763", "0.54240763", "0.54240763", "0.54240763", "0.54154193", "0.5410635", "0.5410635", "0.54101324", "0.5408945", "0.53999424", "0.53866833", "0.5380675", "0.53644085", "0.5347869", "0.5345888", "0.53414017", "0.5340896", "0.5340896", "0.5322625", "0.5319535", "0.531889", "0.5314845", "0.52994704", "0.5294379", "0.5293769" ]
0.0
-1
GET /descuento_adicionals GET /descuento_adicionals.json
def index @descuento_adicionals = DescuentoAdicional.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @item_adicionals = ItemAdicional.all\n end", "def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def set_descuento_adicional\n @descuento_adicional = DescuentoAdicional.find(params[:id])\n end", "def set_descuento_adicional\n @descuento_adicional = DescuentoAdicional.find(params[:id])\n end", "def index\n @anuncios = Anuncio.all\n render json: @anuncios, status: :ok\n end", "def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional fue eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end", "def index\n respond_with(deals)\n end", "def index\n @apoio_educacioanls = ApoioEducacioanl.all\n end", "def show\n @descuento = Descuento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @descuento }\n end\n end", "def etiquetas_por_aluno\n logger.info(params)\n @etiquetas_aluno = Etiqueta.all.where(aluno_id: params[:aluno_id])\n respond_with @etiquetas_aluno\n end", "def index\n @atividade_extras = AtividadeExtra.all\n end", "def descuento_adicional_params\n params.require(:descuento_adicional).permit(:detalle_descuento, :descuento_adicional)\n end", "def index\n @atividades_extras = AtividadesExtra.all\n end", "def index\n @cooperativas = Cooperativa.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cooperativas }\n end\n end", "def index\n @antecedentes = Antecedente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @antecedentes }\n end\n end", "def descuento_adicional_params\n params.require(:descuento_adicional).permit(:descuento_adicional, :detalle)\n end", "def create\n @descuento_adicional = DescuentoAdicional.new(descuento_adicional_params)\n\n respond_to do |format|\n if @descuento_adicional.save\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully created.' }\n format.json { render :show, status: :created, location: @descuento_adicional }\n else\n format.html { render :new }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @dis_generic_alcohol_interactions = DisGenericAlcoholInteraction.all\n end", "def index\n @atividades = Atividade.all\n end", "def index\n @adquisiciones = Adquisicione.all\n end", "def index\n @expedientes = Expediente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expedientes }\n end\n end", "def index\n @atencions = Atencion.all\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 index\n @excuses = Excuse.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @excuses }\n end\n end", "def index\n @inciting_incidents = IncitingIncident.all\n render json: @inciting_incidents\n end", "def index\n @indication_for_meals = IndicationForMeal.all\n end", "def create\n @descuento_adicional = DescuentoAdicional.new(descuento_adicional_params)\n\n respond_to do |format|\n if @descuento_adicional.save\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @descuento_adicional }\n else\n format.html { render :new }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @adquisicions = Adquisicion.all\n end", "def index\n @adversaires = Adversaire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @adversaires }\n end\n end", "def informacoes\n empregado = Empregado.find(params[:empregado_id])\n solicitacoes = Solicitacao.where(empregado_id: parametros[:empregado_id], mes_ano: parametros[:mes_ano])\n valor_ja_solicitado = solicitacoes.sum(&:valor)\n salario_disponivel = (empregado.salario || 0) - valor_ja_solicitado - solicitacoes.sum(&:taxa) # FIXME Romuloset - taxas\n\n render json: {\n valor_ja_solicitado: valor_ja_solicitado,\n salario_disponivel: salario_disponivel\n }\n end", "def index\n @deseases = Desease.order(:id)\n\n render json: @deseases\n end", "def index\n @ideas = Idea.current_ideas_for(current_user).entries\n respond_with(@ideas) do |format|\n format.json { render json: @ideas }\n end\n end", "def show\n @indicacao = Indicacao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indicacao }\n end\n end", "def index\n @status_del_admitidos = StatusDelAdmitido.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @status_del_admitidos }\n end\n end", "def meals\n get(\"/user/#{@user_id}/meals.json\")\n end", "def index\n \n @controles_asistencias = ControlAsistencia.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @controles_asistencias }\n end\n end", "def index\n @asociados = Asociado.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @asociados }\n end\n end", "def index\n @adecuacionactividads = Adecuacionactividad.all\n end", "def index\n @adscripciones = Adscripcion.all\n end", "def index\n @ways_of_admissions = WaysOfAdmission.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ways_of_admissions }\n end\n end", "def show\n @adicional_desconto = AdicionalDesconto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @adicional_desconto }\n end\n end", "def update\n respond_to do |format|\n if @descuento_adicional.update(descuento_adicional_params)\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully updated.' }\n format.json { render :show, status: :ok, location: @descuento_adicional }\n else\n format.html { render :edit }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @horas_disponibles = HorasDisponible.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @horas_disponibles }\n end\n end", "def index\n @admittings = Admitting.all\n render json: @admittings\n end", "def show\n\n @evento = Evento.find(params[:id])\n @comentarios = Comentario.where(:comentavel_id => @evento.id, :comentavel_type => \"Evento\").order('created_at DESC')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evento }\n end\n end", "def index\n @anuncios = Anuncio.all\n end", "def show\n @anuncio = Anuncio.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @anuncio }\n end\n end", "def index\n @adoption_responses = AdoptionResponse.all\n end", "def index\n @ofertas = Oferta.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ofertas }\n end\n end", "def index\n @opportunities = Opportunity.where('valid_until >= ?', Time.now)\n @opportunities_admin = Opportunity.all \n \n @title_content = 'Ofertas en Servicios para tu Matrimonios'\n \t@meta_description_content = 'Ofertas por tiempo limitado para contratar servicios como DJs, Maquillaje y muchas cosas más para tu matrimonio'\n \t\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @opportunities }\n end\n end", "def index\r\n @attestations = Attestation.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @attestations }\r\n end\r\n end", "def index\n @ativo_outros = AtivoOutro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ativo_outros }\n end\n end", "def show\n @indicativo = Indicativo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indicativo }\n end\n end", "def index\n #@incidentes = Incidente.all\n #@q = Incidente.ransack(params[:q])\n @incidentes = Incidente.accessible_by(current_ability).order('data_inicio DESC')\n end", "def index\n @pedido_responsabilidades = PedidoResponsabilidade.all\n end", "def all_deals(**args)\n params = parameters(args) do\n optional_params :user_id, :filter_id, :stage_id, :status, :start, :limit, :sort, :owned_by_you\n end\n request(:get, 'deals', params)\n end", "def index\n @acoes = Acao.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @acoes }\n end\n end", "def index\n @modalities = Modality.all\n json_response(@modalities)\n end", "def index\n @inspirations = Inspiration.all\n end", "def index\n @acuerdos = Acuerdo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @acuerdos }\n end\n end", "def emergencias_en_curso\n @emergencies = Emergency.where(:estado => 'f')\n render json: @emergencies\n end", "def index\n @solicitacoes = Solicitacao.all\n end", "def index\n @observacionactividadadecuacions = Observacionactividadadecuacion.all\n end", "def new\n @adicional_desconto = AdicionalDesconto.new\n @adicional_desconto_tipos = AdicionalDescontoTipo.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @adicional_desconto }\n end\n end", "def mostrar_impedimentos\n @impedimentos = Paciente.find(params[:id]).cuestionario_impedimentos\n end", "def index\n @representante_athletes = current_user.organization.athletes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @representante_athletes }\n end\n end", "def index\n @incidents = @quote.incidents.all\n respond_to do |format|\n format.json { render :json => @incidents }\n end\n end", "def index\n @contas = Conta.where(nil) #Inicia Escopo\n @contas = @contas.conta_numero(params[:contaNumero]) if params[:contaNumero].present?\n @contas = @contas.conta_descricao(params[:contaDescricao]) if params[:contaDescricao].present?\n @contas = @contas.agencia_numero(params[:agenciaNumero]) if params[:agenciaNumero].present?\n @contas = @contas.banco_id(params[:bancoId]) if params[:bancoId].present?\n\n @contas = @contas.paginate(:page => params[:page], :per_page => params[:per_page])\n respond_to do |format|\n format.html { render :index }\n format.json { render json: {contas: @contas.as_json(:include => [:banco], methods: [:conta, :agencia, :saldo]), total: @contas.total_entries}}\n end\n end", "def index\n\t\texecutar_acoes\n\t\t@pontos = PontoInteresse.all.order(\"enable DESC, denuncias_count DESC, created_at DESC\").page(params[:page])\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @pontos }\n\t\tend\n\tend", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @life_insurances }\n end\n end", "def index\n @apologetics = Apologetic.all\n end", "def index\n @consents = Consent.all\n render json: @consents\n end", "def index\n @interno_unidads = InternoUnidad.all\n render json: @interno_unidads\n end", "def index\n @apoios = Apoio.all\n end", "def new\n @indicacao = Indicacao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indicacao }\n end\n end", "def show\n @conta = Conta.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @conta, :include => {\n :movimentos => {\n :include => [:nota, :pessoa],\n :methods => [:favorecido],\n :except => [:created_at, :updated_at]\n }\n },\n :methods => [:saldo]\n }\n end\n end", "def index\n @disponibles = Disponible.take(50)\n\n render json: @disponibles, include: '**'\n end", "def show\n @chamado = Chamado.find(params[:id])\n\n #Traduz o tipo do chamado e seu status para string\n tipo = Chamado::CHAMADO_OPTIONS.invert[@chamado.tipochamado]\n status = Chamado::STATUS_OPTIONS.invert[@chamado.status]\n\n #Serializa o chamado\n chamado = @chamado.as_json(:except => [:tipochamado, :status])\n dtipo = { :tipochamado => tipo, :status => status }.as_json\n chamado = dtipo.merge(chamado)\n\n #Encontra o historico do chamado\n @audits = Audit.find_all_by_idchamado(params[:id])\n #Transforma o historico em json\n historico = @audits.as_json(:except => [:updated_at, :idchamado, :id])\n \n\n #Converte os valores armazenados no banco para os correspondentes nomes em\n #linguagem humana\n @audits.each do |h|\n if h.mudancas.has_key?(\"status\")\n h.mudancas[\"status\"].map!{ |j| Chamado::STATUS_OPTIONS.invert[j] }\n elsif h.mudancas.has_key?(\"tipochamado\")\n h.mudancas[\"tipochamado\"].map!{ |j| Chamado::CHAMADO_OPTIONS.invert[j] }\n end\n\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: { :chamado => chamado, :alteracoes => historico}}\n end\n end", "def index\n @assuntos = Assunto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assuntos }\n end\n end", "def index\n @diaries = current_user.diaries.all\n respond_to do |format|\n format.html {render :index}\n format.json { render json: @diaries }\n end\n end", "def index\n getProfile\n @availabilities = @therapist.get_availabilities\n @rec_Availabilities = @therapist.get_recuring_availabilities(2000,1)\n respond_to do |format|\n format.html { redirect_to availabitity_index, notice: \"Appointment declined.\"}\n format.json { render :status => 200, :json => { action: :index,\n availabilities: @availabilities,\n rec_availabilities: @rec_Availabilities,\n user: @user, therapist: @therapist}}\n end\n end", "def index\n @instituicao_responsavels = InstituicaoResponsavel.all\n end", "def index\n @disciplines = Discipline.paginate(:page => params[:page], per_page: 30)\n @number = Discipline.count\n respond_to do |format|\n format.html\n format.json { render :json => Discipline.all.to_json(include: :department) }\n end\n end", "def index\n @aliados = Aliado.all\n end", "def index\n @ocats = Ocat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ocats }\n end\n end", "def index\n @estacionamientos = Estacionamiento.all\n @serv_adicinales = ServAdicinale.all\n end", "def index\n @objectives = @goal.objectives.all \n render json: @objectives \n end", "def adcreatives(options = {})\n\t\t\tself.id = self.id + \"/adcreatives\"\n\t\t\tread options\n\t\tend", "def index\n @tipo_denuncia = TipoDenuncium.all\n\n render json: @tipo_denuncia\n end", "def update\n respond_to do |format|\n if @descuento_adicional.update(descuento_adicional_params)\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional fue actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @descuento_adicional }\n else\n format.html { render :edit }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @solicitacao_pontuals = SolicitacaoPontual.all\n end", "def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end", "def index\n @categorias = Categoria.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @categorias }\n end\n end", "def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end", "def index\n @paciente_serviciocomplementarios = PacienteServiciocomplementario.all\n end", "def get_info_to_delete\n\t\tdecision = GovernanceDecision.find(params[:idDec].to_i)\n\t\thijasToDelete = view_context.recursiveDarHijos(decision, [])\n\t\tdetailsToDelete = decision.map_details + view_context.darDetalles(hijasToDelete)\n\t\tfindingsToDelete = decision.findings + view_context.darHallazgos(hijasToDelete)\n\t\tcontent = [decision.description, hijasToDelete.size.to_s, detailsToDelete.size.to_s, findingsToDelete.size.to_s]\n\n\t\trespond_to do |format|\n\t\t\t# ES: Envia el texto:\n\t\t\t# EN: Send the text:\n\t\t\tformat.json {render json: content}\n\t end\n\tend", "def index\n @dia_eventos = DiaEvento.all\n render json: @dia_eventos\n end", "def index\n @notadedebito = Notadedebito.find(params[:notadecredito_id])\n @renglon_notadebitos = @notadedebito.renglon_notadebitos\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @renglon_notadebitos }\n end\n end", "def new\n @descuento = Descuento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @descuento }\n end\n end" ]
[ "0.6345408", "0.6147245", "0.6063977", "0.6063977", "0.5915792", "0.5871646", "0.585145", "0.5846302", "0.5790004", "0.5759359", "0.5753114", "0.57437164", "0.5739775", "0.57258624", "0.57", "0.5699348", "0.5662103", "0.5654298", "0.56452703", "0.5627805", "0.56223935", "0.5604864", "0.5604818", "0.56002307", "0.55943906", "0.5584098", "0.5580872", "0.5580498", "0.55731475", "0.5553681", "0.5538483", "0.5532945", "0.5529533", "0.5528877", "0.55154955", "0.55044526", "0.54914653", "0.54847395", "0.5482555", "0.54743254", "0.5472635", "0.54694957", "0.54688287", "0.54628545", "0.5462187", "0.5461576", "0.54591197", "0.5448506", "0.544604", "0.5445719", "0.5445706", "0.544461", "0.5440213", "0.54383683", "0.543132", "0.54222184", "0.5420478", "0.5419355", "0.5417428", "0.5413285", "0.54076725", "0.5407572", "0.53974503", "0.53952014", "0.5392104", "0.5391591", "0.5389747", "0.5385183", "0.538323", "0.5382123", "0.5379227", "0.5375408", "0.53693396", "0.53654766", "0.5360289", "0.5356036", "0.53560066", "0.5352404", "0.53522575", "0.5340623", "0.53343576", "0.53319126", "0.5330621", "0.5324772", "0.5324255", "0.5324183", "0.53211004", "0.53158134", "0.5312301", "0.53118163", "0.53084445", "0.5304903", "0.52958715", "0.5286944", "0.52865416", "0.5286282", "0.52860093", "0.5284878", "0.528295" ]
0.769354
1
GET /descuento_adicionals/1 GET /descuento_adicionals/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @descuento_adicionals = DescuentoAdicional.all\n end", "def index\n @descuento_adicionals = DescuentoAdicional.all\n end", "def set_descuento_adicional\n @descuento_adicional = DescuentoAdicional.find(params[:id])\n end", "def set_descuento_adicional\n @descuento_adicional = DescuentoAdicional.find(params[:id])\n end", "def index\n @item_adicionals = ItemAdicional.all\n end", "def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def show\n @descuento = Descuento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @descuento }\n end\n end", "def index\n @anuncios = Anuncio.all\n render json: @anuncios, status: :ok\n end", "def index\n @cooperativas = Cooperativa.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cooperativas }\n end\n end", "def show\n @indicacao = Indicacao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indicacao }\n end\n end", "def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional fue eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end", "def index\n @antecedentes = Antecedente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @antecedentes }\n end\n end", "def etiquetas_por_aluno\n logger.info(params)\n @etiquetas_aluno = Etiqueta.all.where(aluno_id: params[:aluno_id])\n respond_with @etiquetas_aluno\n end", "def show\n @anuncio = Anuncio.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @anuncio }\n end\n end", "def show\n @indicativo = Indicativo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indicativo }\n end\n end", "def show\n\n @evento = Evento.find(params[:id])\n @comentarios = Comentario.where(:comentavel_id => @evento.id, :comentavel_type => \"Evento\").order('created_at DESC')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evento }\n end\n end", "def create\n @descuento_adicional = DescuentoAdicional.new(descuento_adicional_params)\n\n respond_to do |format|\n if @descuento_adicional.save\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully created.' }\n format.json { render :show, status: :created, location: @descuento_adicional }\n else\n format.html { render :new }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @expedientes = Expediente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expedientes }\n end\n end", "def index\n @asociados = Asociado.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @asociados }\n end\n end", "def index\n @atividades_extras = AtividadesExtra.all\n end", "def create\n @descuento_adicional = DescuentoAdicional.new(descuento_adicional_params)\n\n respond_to do |format|\n if @descuento_adicional.save\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @descuento_adicional }\n else\n format.html { render :new }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @apoio_educacioanls = ApoioEducacioanl.all\n end", "def index\n @atividade_extras = AtividadeExtra.all\n end", "def index\n @adversaires = Adversaire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @adversaires }\n end\n end", "def index\n @ofertas = Oferta.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ofertas }\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 index\n @inciting_incidents = IncitingIncident.all\n render json: @inciting_incidents\n end", "def index\n respond_with(deals)\n end", "def obtenerOc(id) #CHECK\n\tjsonResponse = requestWebWithoutParams('GET', (ENV[\"url_oc\"]+\"obtener/\"+id.to_s))\n\tif(jsonResponse==false)\n\t\treturn jsonResponse\n\telse\n\t\tjsonResponse = jsonResponse.first\n\t\tparamsOc = { _id: jsonResponse['_id'],\n\t\t\t\tcliente: jsonResponse['cliente'],\n\t\t\t\tproveedor: jsonResponse['proveedor'],\n\t\t\t\tsku: jsonResponse['sku'],\n\t\t\t\tdireccion: '',\n\t\t\t\tfechaEntrega: jsonResponse['fechaEntrega'],\n\t\t\t\tprecioUnitario: jsonResponse['precioUnitario'],\n\t\t\t\tcantidadDespachada: jsonResponse['cantidadDespachada'],\n\t\t\t\tcantidad: jsonResponse['cantidad'],\n\t\t\t\tcanal: jsonResponse['canal'],\n\t\t\t\tfechaCreacion: jsonResponse['created_at'],\n\t\t\t\testado: jsonResponse['estado']\n\t\t}\n\t\treturn paramsOc\n\tend\nend", "def new\n @indicacao = Indicacao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indicacao }\n end\n end", "def index\n @status_del_admitidos = StatusDelAdmitido.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @status_del_admitidos }\n end\n end", "def show\n @serv_adicionale = ServAdicionale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @serv_adicionale }\n end\n end", "def index\n @categorias = Categoria.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @categorias }\n end\n end", "def show\n @chamado = Chamado.find(params[:id])\n\n #Traduz o tipo do chamado e seu status para string\n tipo = Chamado::CHAMADO_OPTIONS.invert[@chamado.tipochamado]\n status = Chamado::STATUS_OPTIONS.invert[@chamado.status]\n\n #Serializa o chamado\n chamado = @chamado.as_json(:except => [:tipochamado, :status])\n dtipo = { :tipochamado => tipo, :status => status }.as_json\n chamado = dtipo.merge(chamado)\n\n #Encontra o historico do chamado\n @audits = Audit.find_all_by_idchamado(params[:id])\n #Transforma o historico em json\n historico = @audits.as_json(:except => [:updated_at, :idchamado, :id])\n \n\n #Converte os valores armazenados no banco para os correspondentes nomes em\n #linguagem humana\n @audits.each do |h|\n if h.mudancas.has_key?(\"status\")\n h.mudancas[\"status\"].map!{ |j| Chamado::STATUS_OPTIONS.invert[j] }\n elsif h.mudancas.has_key?(\"tipochamado\")\n h.mudancas[\"tipochamado\"].map!{ |j| Chamado::CHAMADO_OPTIONS.invert[j] }\n end\n\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: { :chamado => chamado, :alteracoes => historico}}\n end\n end", "def index\n @horas_disponibles = HorasDisponible.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @horas_disponibles }\n end\n end", "def index\n @adquisiciones = Adquisicione.all\n end", "def show\n @adicional_desconto = AdicionalDesconto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @adicional_desconto }\n end\n end", "def index\n \n @controles_asistencias = ControlAsistencia.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @controles_asistencias }\n end\n end", "def index\n @atencions = Atencion.all\n end", "def index\n @acoes = Acao.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @acoes }\n end\n end", "def show\n @comentario = Comentario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comentario }\n end\n end", "def show\n @comentario = Comentario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comentario }\n end\n end", "def index\n @deseases = Desease.order(:id)\n\n render json: @deseases\n end", "def index\n @ativo_outros = AtivoOutro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ativo_outros }\n end\n end", "def index\n @atividades = Atividade.all\n end", "def index\n @indication_for_meals = IndicationForMeal.all\n end", "def index\n @consents = Consent.all\n render json: @consents\n end", "def index\n @contas = Conta.where(nil) #Inicia Escopo\n @contas = @contas.conta_numero(params[:contaNumero]) if params[:contaNumero].present?\n @contas = @contas.conta_descricao(params[:contaDescricao]) if params[:contaDescricao].present?\n @contas = @contas.agencia_numero(params[:agenciaNumero]) if params[:agenciaNumero].present?\n @contas = @contas.banco_id(params[:bancoId]) if params[:bancoId].present?\n\n @contas = @contas.paginate(:page => params[:page], :per_page => params[:per_page])\n respond_to do |format|\n format.html { render :index }\n format.json { render json: {contas: @contas.as_json(:include => [:banco], methods: [:conta, :agencia, :saldo]), total: @contas.total_entries}}\n end\n end", "def show\n @competicao = Competicao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competicao }\n end\n end", "def index\n @excuses = Excuse.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @excuses }\n end\n end", "def show\n @conta = Conta.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @conta, :include => {\n :movimentos => {\n :include => [:nota, :pessoa],\n :methods => [:favorecido],\n :except => [:created_at, :updated_at]\n }\n },\n :methods => [:saldo]\n }\n end\n end", "def index\n @acuerdos = Acuerdo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @acuerdos }\n end\n end", "def descuento_adicional_params\n params.require(:descuento_adicional).permit(:detalle_descuento, :descuento_adicional)\n end", "def show\n @historial_odt = HistorialOdt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @historial_odt }\n end\n end", "def index\n @tipo_denuncia = TipoDenuncium.all\n\n render json: @tipo_denuncia\n end", "def descuento_adicional_params\n params.require(:descuento_adicional).permit(:descuento_adicional, :detalle)\n end", "def index\n @pedidos = Pedido.find(:all, :conditions => [\"cliente_id=?\", session[:usuario_id]])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pedidos }\n end\n end", "def show\n @historial = Historial.find(params[:id])\n @receta = Recete.histori(@historial.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @historial }\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 index\n @adquisicions = Adquisicion.all\n end", "def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end", "def show\n @expediente = Expediente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expediente }\n end\n end", "def new\n @adicional_desconto = AdicionalDesconto.new\n @adicional_desconto_tipos = AdicionalDescontoTipo.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @adicional_desconto }\n end\n end", "def index\n @modalities = Modality.all\n json_response(@modalities)\n end", "def index\n @ideas = Idea.current_ideas_for(current_user).entries\n respond_with(@ideas) do |format|\n format.json { render json: @ideas }\n end\n end", "def index\n @anuncios = Anuncio.all\n end", "def show\n @status_del_admitido = StatusDelAdmitido.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @status_del_admitido }\n end\n end", "def new\n @descuento = Descuento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @descuento }\n end\n end", "def mostrar_impedimentos\n @impedimentos = Paciente.find(params[:id]).cuestionario_impedimentos\n end", "def update\n respond_to do |format|\n if @descuento_adicional.update(descuento_adicional_params)\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully updated.' }\n format.json { render :show, status: :ok, location: @descuento_adicional }\n else\n format.html { render :edit }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @opportunities = Opportunity.where('valid_until >= ?', Time.now)\n @opportunities_admin = Opportunity.all \n \n @title_content = 'Ofertas en Servicios para tu Matrimonios'\n \t@meta_description_content = 'Ofertas por tiempo limitado para contratar servicios como DJs, Maquillaje y muchas cosas más para tu matrimonio'\n \t\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @opportunities }\n end\n end", "def index\n @dis_generic_alcohol_interactions = DisGenericAlcoholInteraction.all\n end", "def index\n @apoios = Apoio.all\n end", "def index\n @assuntos = Assunto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assuntos }\n end\n end", "def show\n @advocacy = Advocacy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advocacy }\n end\n end", "def show\n @anuncio= set_anuncio\n render json: @anuncio, status: :ok\n end", "def index\n @interno_unidads = InternoUnidad.all\n render json: @interno_unidads\n end", "def index\n @adscripciones = Adscripcion.all\n end", "def index\r\n @attestations = Attestation.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @attestations }\r\n end\r\n end", "def meals\n get(\"/user/#{@user_id}/meals.json\")\n end", "def index\n @dia_eventos = DiaEvento.all\n render json: @dia_eventos\n end", "def getArrondissement\r\n \tvil = params[:id]\r\n \trender json: Arrondissement.where(vil_id: vil)\r\n end", "def index \n @lancamentorapido = Lancamentorapido.new \n @lancamentorapidos = Lancamentorapido.all\n \n @categorias = Category.all\n @centrosdecusto = Centrodecusto.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lancamentorapidos }\n end\n end", "def informacoes\n empregado = Empregado.find(params[:empregado_id])\n solicitacoes = Solicitacao.where(empregado_id: parametros[:empregado_id], mes_ano: parametros[:mes_ano])\n valor_ja_solicitado = solicitacoes.sum(&:valor)\n salario_disponivel = (empregado.salario || 0) - valor_ja_solicitado - solicitacoes.sum(&:taxa) # FIXME Romuloset - taxas\n\n render json: {\n valor_ja_solicitado: valor_ja_solicitado,\n salario_disponivel: salario_disponivel\n }\n end", "def index\n @incidents = @quote.incidents.all\n respond_to do |format|\n format.json { render :json => @incidents }\n end\n end", "def index\n @representante_athletes = current_user.organization.athletes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @representante_athletes }\n end\n end", "def index\n @ways_of_admissions = WaysOfAdmission.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ways_of_admissions }\n end\n end", "def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end", "def show\n @horas_disponible = HorasDisponible.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @horas_disponible }\n end\n end", "def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end", "def index\n @apologetics = Apologetic.all\n end", "def index\n @pedidos = Pedido.find(:all,:conditions=> {:status => [0], :user_id => current_user.id})\n if @pedidos.count > 0\n @imagen_pedidos = @pedidos[0].imagen_pedidos\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @imagen_pedidos }\n end\n else\n redirect_to pedidos_path, notice: 'No tiene pedidos pendientes'\n end\n end", "def show\n @aactio = Aactio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aactio }\n end\n end", "def index\n @contas = Conta.all\n respond_to do |format|\n format.json { render json: @contas.to_json, status: :ok }\n end\n end", "def show\n @asiento = Asiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @asiento }\n end\n end", "def index\n @adocao_animals = AdocaoAnimal.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @adocao_animals }\n end\n end", "def show\n @periodo_academico = PeriodoAcademico.find(params[:id])\n\n render json: @periodo_academico\n end", "def show\n @asociado = Asociado.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asociado }\n end\n end", "def index\n @solicitacoes = Solicitacao.all\n end", "def index\n @disciplines = Discipline.paginate(:page => params[:page], per_page: 30)\n @number = Discipline.count\n respond_to do |format|\n format.html\n format.json { render :json => Discipline.all.to_json(include: :department) }\n end\n end", "def index\n @asociaciones = Asociacion.all\n end" ]
[ "0.74628246", "0.74628246", "0.6197751", "0.6197751", "0.6161126", "0.6131787", "0.6063931", "0.6052714", "0.604076", "0.58766615", "0.58630943", "0.5843038", "0.5834659", "0.5828711", "0.58231443", "0.58036417", "0.57932264", "0.5739739", "0.57353437", "0.57251334", "0.57225794", "0.57162625", "0.57141507", "0.57106555", "0.57089126", "0.5705865", "0.5697236", "0.56924206", "0.5685293", "0.5680444", "0.5678249", "0.5672082", "0.5671814", "0.566959", "0.564385", "0.5633073", "0.5630754", "0.5629725", "0.5627515", "0.5624422", "0.5620157", "0.5620157", "0.56134605", "0.56033134", "0.5601892", "0.55975103", "0.55883247", "0.5582298", "0.5567956", "0.55666137", "0.5564938", "0.5556958", "0.55455136", "0.55453324", "0.5539808", "0.5538756", "0.5537407", "0.5536105", "0.5535081", "0.55347455", "0.55346274", "0.5534274", "0.5533293", "0.5525087", "0.5525", "0.5524696", "0.5523963", "0.55228317", "0.55182093", "0.55122477", "0.55074656", "0.55028754", "0.5501909", "0.5499962", "0.5494867", "0.54928017", "0.54920983", "0.54905945", "0.54894215", "0.5486622", "0.54860926", "0.54786545", "0.5475309", "0.5474206", "0.547274", "0.54692024", "0.5463988", "0.5461891", "0.54612076", "0.54607445", "0.54583067", "0.54498416", "0.54498345", "0.54475087", "0.54472953", "0.54448295", "0.54445183", "0.5443558", "0.5441712", "0.5436752", "0.5434061" ]
0.0
-1
POST /descuento_adicionals POST /descuento_adicionals.json
def create @descuento_adicional = DescuentoAdicional.new(descuento_adicional_params) respond_to do |format| if @descuento_adicional.save format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional fue creado exitosamente.' } format.json { render :show, status: :created, location: @descuento_adicional } else format.html { render :new } format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @descuento_adicional = DescuentoAdicional.new(descuento_adicional_params)\n\n respond_to do |format|\n if @descuento_adicional.save\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully created.' }\n format.json { render :show, status: :created, location: @descuento_adicional }\n else\n format.html { render :new }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @descuento_adicionals = DescuentoAdicional.all\n end", "def index\n @descuento_adicionals = DescuentoAdicional.all\n end", "def descuento_adicional_params\n params.require(:descuento_adicional).permit(:descuento_adicional, :detalle)\n end", "def descuento_adicional_params\n params.require(:descuento_adicional).permit(:detalle_descuento, :descuento_adicional)\n end", "def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def item_adicional_params\n params.require(:item_adicional).permit(:adicional_id, :item_pedido_id)\n end", "def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional fue eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end", "def set_descuento_adicional\n @descuento_adicional = DescuentoAdicional.find(params[:id])\n end", "def set_descuento_adicional\n @descuento_adicional = DescuentoAdicional.find(params[:id])\n end", "def create\n @adicional_desconto = AdicionalDesconto.new(params[:adicional_desconto])\n\n respond_to do |format|\n if @adicional_desconto.save\n flash[:notice] = 'Adicional / Desconto cadastrado com sucesso.'\n #format.html { redirect_to(@adicional_desconto) }\n format.html { redirect_to(adicional_descontos_path) }\n format.xml { render :xml => @adicional_desconto, :status => :created, :location => @adicional_desconto }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @adicional_desconto.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @item_adicional = ItemAdicional.new(item_adicional_params)\n\n respond_to do |format|\n if @item_adicional.save\n format.html { redirect_to @item_adicional, notice: 'Item adicional was successfully created.' }\n format.json { render :show, status: :created, location: @item_adicional }\n else\n format.html { render :new }\n format.json { render json: @item_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @discipline = Discipline.new(discipline_params)\n @discipline.users_id = current_user.id\n\n respond_to do |format|\n if @discipline.save\n @discipline.codigo = \"DISC-%04d\" % [@discipline.id]\n @discipline.save\n if params[:anexos]\n\n params[:anexos].each { |anx|\n @discanexo = Discanexo.new\n @discanexo.anexo = anx\n @discanexo.Discipline_id = @discipline.id\n @discanexo.save\n }\n end\n flash[:success] = \"Disciplina cadastrada com sucesso.\"\n format.html { redirect_to @discipline}\n format.json { render :show, status: :created, location: @discipline }\n else\n format.html { render :new }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @descuento_adicional.update(descuento_adicional_params)\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully updated.' }\n format.json { render :show, status: :ok, location: @descuento_adicional }\n else\n format.html { render :edit }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @apoio_educacioanl = ApoioEducacioanl.new(apoio_educacioanl_params)\n\n respond_to do |format|\n if @apoio_educacioanl.save\n format.html { redirect_to @apoio_educacioanl, notice: 'Apoio educacioanal foi cadastrado com Sucesso !' }\n format.json { render :show, status: :created, location: @apoio_educacioanl }\n else\n format.html { render :new }\n format.json { render json: @apoio_educacioanl.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @descuento_adicional.update(descuento_adicional_params)\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional fue actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @descuento_adicional }\n else\n format.html { render :edit }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @descuento = Descuento.new(params[:descuento])\n\n respond_to do |format|\n if @descuento.save\n format.html { redirect_to @descuento, notice: 'Descuento was successfully created.' }\n format.json { render json: @descuento, status: :created, location: @descuento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @descuento.errors, status: :unprocessable_entity }\n end\n end\n end", "def adopcion_params\n params.require(:adopcion).permit( :id_mascota, :numero_adultos, :numero_ninios, :numero_perros, :numero_gatos, :numero_otros, :referencia_casa, :numero_referencia1, :numero_referencia2, :id_persona, :id_adopcion, :observacion)\n end", "def create\n params.permit(:intitule, :estObligatoire, :nombreDeCaractere, :ordre, :sondage_id)\n ajout = QuestionOuverteService.instance.creerQuestionOuverte(params[:intitule], params[:estObligatoire], params[:nombreDeCaractere], params[:ordre], params[:sondage_id])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end", "def create\n @serv_adicionale = ServAdicionale.new(params[:serv_adicionale])\n\n respond_to do |format|\n if @serv_adicionale.save\n format.html { redirect_to @serv_adicionale, notice: 'Serv adicionale was successfully created.' }\n format.json { render json: @serv_adicionale, status: :created, location: @serv_adicionale }\n else\n format.html { render action: \"new\" }\n format.json { render json: @serv_adicionale.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @atividades_extra = AtividadesExtra.new(atividades_extra_params)\n\n respond_to do |format|\n if @atividades_extra.save\n format.html { redirect_to @atividades_extra, notice: 'Atividades extra was successfully created.' }\n format.json { render :show, status: :created, location: @atividades_extra }\n else\n format.html { render :new }\n format.json { render json: @atividades_extra.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @adversaire = Adversaire.new(params[:adversaire])\n @equipe = Equipe.find(params[:equipe_id])\n\n respond_to do |format|\n if @adversaire.save\n format.html { redirect_to @equipe, :notice => 'Adversaire was successfully created.' }\n format.json { render :json => @adversaire, :status => :created, :location => @equipe }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @adversaire.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @atividade_extra = AtividadeExtra.new(atividade_extra_params)\n respond_to do |format|\n if @atividade_extra.save\n format.html { redirect_to @atividade_extra, notice: 'Atividade criada com sucesso.' }\n format.json { render :show, status: :created, location: @atividade_extra }\n else\n format.html { render :new }\n format.json { render json: @atividade_extra.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @descuento = Descuento.new(descuento_params)\n\n respond_to do |format|\n if @descuento.save\n format.html { redirect_to @descuento, notice: 'Descuento fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @descuento }\n else\n format.html { render :new }\n format.json { render json: @descuento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @entrada_inventario = EntradaInventario.new(params[:entrada_inventario])\n\n respond_to do |format|\n if @entrada_inventario.save\n\n\t\t\t\tinventario=@entrada_inventario.inventario\n\t\t\t\tinventario.cantidad+=@entrada_inventario.cantidad\n\t\t\t\tinventario.save\n\n format.html { redirect_to @entrada_inventario, notice: 'Entrada inventario was successfully created.' }\n format.json { render json: @entrada_inventario, status: :created, location: @entrada_inventario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entrada_inventario.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @item_adicionals = ItemAdicional.all\n end", "def create\n @indicacao = Indicacao.new(params[:indicacao])\n\n respond_to do |format|\n if @indicacao.save\n format.html { redirect_to @indicacao, notice: 'A Indicação de Condutor foi criada com sucesso.' }\n format.json { render json: @indicacao, status: :created, location: @indicacao }\n else\n format.html { render action: \"new\" }\n format.json { render json: @indicacao.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @indicativo = Indicativo.new(params[:indicativo])\n\n respond_to do |format|\n if @indicativo.save\n format.html { redirect_to @indicativo, notice: 'Indicativo was successfully created.' }\n format.json { render json: @indicativo, status: :created, location: @indicativo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @indicativo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @atividade = Atividade.new(atividade_params)\n\n respond_to do |format|\n if @atividade.save\n format.html { redirect_to @atividade, notice: 'Atividade was successfully created.' }\n format.json { render :show, status: :created, location: @atividade }\n else\n format.html { render :new }\n format.json { render json: @atividade.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @autobus = Autobus.new(autobus_params)\n respond_to do |format|\n @autobus.is_taken = false\n if @autobus.save\n format.html { redirect_to @autobus, notice: 'Autobus creado exitosamente.' }\n format.json { render action: 'show', status: :created, location: @autobus }\n\n 1.upto(@autobus.capacidad.to_i) { |n| \n @asiento = Asiento.new\n @asiento.is_active = true\n @asiento.asiento_no = n\n @asiento.autobus_id = @autobus.id\n if (n < @autobus.capacidad.to_i/2)\n @asiento.tipo = 'V'\n else\n @asiento.tipo = 'P'\n end\n @asiento.save\n }\n else\n format.html { render action: 'new' }\n format.json { render json: @autobus.errors, status: :unprocessable_entity }\n end\n end\n end", "def atividade_params\n params.require(:atividade).permit(:nome, :tipo, :descricao, :observacao, :acompanhamento, :status, :oportunidade_id, :prioridade, :data_prevista_inicio, :data_realizada_fim, :data_realizada, :cliente_potencial_id)\n end", "def create\n @adopcion = Adopcion.new(adopcion_params)\n\n\n respond_to do |format|\n if @adopcion.save\n format.html { redirect_to @adopcion, notice: 'Adopcion Registrada.' }\n format.json { render :show, status: :created, location: @adopcion }\n else\n format.html { render :new }\n format.json { render json: @adopcion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @atencion = Atencion.new(atencion_params)\n\n respond_to do |format|\n if @atencion.save\n format.html { redirect_to @atencion, notice: 'Atencion creada satisfactoriamente.' }\n format.json { render :show, status: :created, location: @atencion }\n else\n format.html { render :new }\n format.json { render json: @atencion.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end", "def create\n interruption_type = -1\n if params[:interruption_type] == \"internal\"\n interruption_type = 1;\n elsif params[:interruption_type] == \"external\"\n interruption_type = 0;\n end\n \n @tomato = Tomato.find(params[:tomato_id])\n @interruption = @tomato.interruptions.create!(params[:interruption].merge(:interruption_type => interruption_type))\n @interruption.user_id = current_user.id\n \n respond_to do |format|\n if @interruption.save\n format.html { redirect_to @tomato, notice: 'Interruption was successfully created.' }\n format.json { render json: @tomato, status: :created, location: @tomato }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tomato.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @adquisicione = Adquisicione.new(adquisicione_params)\n\n respond_to do |format|\n if @adquisicione.save\n format.html { redirect_to @adquisicione, notice: 'Adquisicione was successfully created.' }\n format.json { render :show, status: :created, location: @adquisicione }\n else\n format.html { render :new }\n format.json { render json: @adquisicione.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @anuncio = Anuncio.new(anuncio_params)\n\n if @anuncio.save\n render :show, status: :created, location: @anuncio\n else\n render json: @anuncio.errors, status: :unprocessable_entity\n end\n end", "def create\n @atencion = Atencion.new(atencion_params)\n\n respond_to do |format|\n if @atencion.save\n format.html { redirect_to @atencion, notice: 'Atencion was successfully created.' }\n format.json { render :show, status: :created, location: @atencion }\n else\n format.html { render :new }\n format.json { render json: @atencion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dis_alcohol_interaction = DisAlcoholInteraction.new(dis_alcohol_interaction_params)\n\n respond_to do |format|\n if @dis_alcohol_interaction.save\n format.html { redirect_to @dis_alcohol_interaction, notice: 'Dis alcohol interaction was successfully created.' }\n format.json { render :show, status: :created, location: @dis_alcohol_interaction }\n else\n format.html { render :new }\n format.json { render json: @dis_alcohol_interaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asignacion_familiar = AsignacionFamiliar.new(asignacion_familiar_params)\n\n respond_to do |format|\n if @asignacion_familiar.save\n format.html { redirect_to @asignacion_familiar, notice: 'Asignacion familiar creada exitosamente.' }\n format.json { render :show, status: :created, location: @asignacion_familiar }\n else\n format.html { render :new }\n format.json { render json: @asignacion_familiar.errors, status: :unprocessable_entity }\n end\n end\n end", "def atencion_params\n params.require(:atencion).permit(:descripcion, :comentario)\n end", "def create\n authorize! :create, Solicitud\n @solicitante=Solicitante.find(params[:solicitante_id])\n @beneficiario=Beneficiario.find(params[:beneficiario_id])\n @solicitud = Solicitud.create(solicitud_params)\n @solicitud.solicitante_id=@solicitante.id\n @solicitud.beneficiario_id=@beneficiario.id\n\n respond_to do |format|\n if @solicitud.save\n format.html { redirect_to solicitante_beneficiario_path(@solicitante, @beneficiario), notice: 'Solicitud creada exitosamente.' }\n format.json { render :show, status: :created, location: solicitante_beneficiario_path(@solicitante, @beneficiario) }\n else\n format.html { render :new }\n format.json { render json: @solicitud.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contrato = Contrato.new(contrato_params)\n\n respond_to do |format|\n if @contrato.save\n @contrato.anadir_conceptosdepago(@contrato.fecha_inicio, @contrato.fecha_fin)\n format.html { redirect_to @contrato, notice: 'Contrato fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @contrato }\n else\n format.html { render :new }\n format.json { render json: @contrato.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @accion = Accion.new(accion_params)\n\n respond_to do |format|\n if @accion.save\n format.html { redirect_to @accion, notice: 'Accion creada exitosamente.' }\n format.json { render action: 'show', status: :created, location: @accion }\n else\n format.html { render action: 'new' }\n format.json { render json: @accion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #@incident = @quote.incidents.new(incident_params)\n logger.info params[:incident]\n params[:incident].each do |incident|\n @incident = @quote.incidents.new(incident)\n @incident.save\n end\n respond_to do |format|\n format.json { render :json => { :code => \"201\", :description => \"Created incidents\"} }\n end\n end", "def create\n @ingresso = Ingresso.new(ingresso_params)\n\n respond_to do |format|\n if @ingresso.save\n format.html { redirect_to @ingresso, notice: 'Ingresso was successfully created.' }\n format.json { render :show, status: :created, location: @ingresso }\n else\n format.html { render :new }\n format.json { render json: @ingresso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @status_del_admitido = StatusDelAdmitido.new(params[:status_del_admitido])\n\n respond_to do |format|\n if @status_del_admitido.save\n format.html { redirect_to @status_del_admitido, notice: 'Status del admitido was successfully created.' }\n format.json { render json: @status_del_admitido, status: :created, location: @status_del_admitido }\n else\n format.html { render action: \"new\" }\n format.json { render json: @status_del_admitido.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @observacionactividadadecuacion = Observacionactividadadecuacion.new(observacionactividadadecuacion_params)\n\n respond_to do |format|\n if @observacionactividadadecuacion.save\n format.html { redirect_to @observacionactividadadecuacion, notice: 'Observacionactividadadecuacion was successfully created.' }\n format.json { render :show, status: :created, location: @observacionactividadadecuacion }\n else\n format.html { render :new }\n format.json { render json: @observacionactividadadecuacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @instituicao_responsavel = InstituicaoResponsavel.new(instituicao_responsavel_params)\n\n respond_to do |format|\n if @instituicao_responsavel.save\n format.html { redirect_to @instituicao_responsavel, notice: 'Instituicao responsavel was successfully created.' }\n format.json { render :show, status: :created, location: @instituicao_responsavel }\n else\n format.html { render :new }\n format.json { render json: @instituicao_responsavel.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @item_adicional.destroy\n respond_to do |format|\n format.html { redirect_to item_adicionals_url, notice: 'Item adicional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n \n #Recupera e estância objetos\n @adocao_animal = AdocaoAnimal.new(params[:adocao_animal])\n @adocao_animal.build_confirmacao_adocao\n @adocao_animal.confirmacao_adocao.adocao_confirmacao_chave.build\n \n @animal = Animal.find(@adocao_animal.animal_id)\n \n #Persiste se o status do animal está disponível para adoção\n if @animal.status_animal_id=!1\n redirect_to @animal, notice: 'Este animal foi ou se enconta em processo de adoção!'\n return\n end\n \n #Inicia processo de adoção\n ActiveRecord::Base.transaction do\n begin\n \n if @adocao_animal.save\n \n #Altera o status para em adocão (2)\n @animal.altera_status(2)\n \n #Gera chave de confirmação\n adocao_confirmacao_chave_id = @adocao_animal.confirmacao_adocao.adocao_confirmacao_chave.first.id\n adocao_confirmacao_chave = AdocaoConfirmacaoChave.find(adocao_confirmacao_chave_id)\n adocao_confirmacao_chave.chave_confirmacao\n \n #Notifica envolvidos\n AdocaoAnimal.notifica_adocao(@adocao_animal)\n \n respond_to do |format|\n format.html { redirect_to @adocao_animal, notice: 'Adocao animal was successfully created.' }\n format.json { render json: @adocao_animal, status: :created, location: @adocao_animal }\n end\n \n else\n format.html { render action: \"new\" }\n format.json { render json: @adocao_animal.errors, status: :unprocessable_entity }\n end\n \n rescue => e\n puts e\n raise ActiveRecord::Rollback\n end\n end\n end", "def socio_economico_submit\n\n # responding for the first time\n if not session[:current_response_id]\n current_response = nil\n # preparing the object to store the surveys and requests data\n json_response = { 'surveys' => [], 'requests' => [] }\n else\n current_response = FormResponse.find(session[:current_response_id])\n json_response = JSON.parse current_response.json_response\n end\n\n # appending the new response to the array of surveys\n surveys_number = json_response['surveys'].size\n json_response['surveys'] = [] if surveys_number == 0\n json_response['surveys'].push(\n params.merge({\n :attempt => (surveys_number + 1),\n :sent_at => Time.zone.now\n })\n )\n\n if current_response\n current_response.update({\n json_response: json_response.to_json\n })\n else\n # the response must be created only in this form\n # and not in the request form!\n current_response = FormResponse.create({\n form_id: Form.where(reference_model: 'FormVagasRemanescentes').first.id,\n user: current_user.email,\n json_response: json_response.to_json\n })\n\n # storing the response id in session to access it\n # from the other form, the request form\n session[:current_response_id] = current_response.id\n end\n\n redirect_to action: 'pedido'\n end", "def create\n @adscripcion = Adscripcion.new(adscripcion_params)\n\n respond_to do |format|\n if @adscripcion.save\n format.html { redirect_to @adscripcion, notice: 'Adscripcion was successfully created.' }\n format.json { render :show, status: :created, location: @adscripcion }\n else\n format.html { render :new }\n format.json { render json: @adscripcion.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_obrigacao(conta_id, estabelecimento_id, obrigacao_id, dia_entrega)\n obest = Taxcalendario::Admin::Client::Entities::ObrigacaoEstabelecimento.new\n obest.dia_entrega = dia_entrega\n obest.obrigacao_id = obrigacao_id\n map = JSON.parse(post_and_give_me_a_json(\"/estabelecimentos/obrigacoes/#{conta_id}/#{estabelecimento_id}\",obest)) \n obj = Taxcalendario::Admin::Client::Entities::ObrigacaoEstabelecimento.new\n obj.from_hash(map)\n obj\n end", "def auditoria_antes(accion, tabla, objeto)\n auditoria = Auditoria.new\n auditoria.usuario = current_usuario.login\n auditoria.ip = request.remote_ip\n auditoria.accion = accion\n auditoria.tabla = tabla\n auditoria.pista_antes = objeto.to_json\n auditoria.sistema = \"RUE\"\n auditoria.save\n\n auditoria.id\n\n end", "def create\n @expediente = Expediente.new(params[:expediente])\n \n respond_to do |format|\n if @expediente.save\n format.html { redirect_to @expediente, notice: 'Expediente was successfully created.' }\n format.json { render json: @expediente, status: :created, location: @expediente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @expediente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @aactio = Aactio.new(params[:aactio])\n\n respond_to do |format|\n if @aactio.save\n format.html { redirect_to @aactio, notice: 'Aactio was successfully created.' }\n format.json { render json: @aactio, status: :created, location: @aactio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @aactio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @laboratorio = Laboratorio.new(laboratorio_params)\n get_responsavel\n puts \"O responsavel é: #{@laboratorio.responsavel_id}\"\n if (@responsavel != \"sem_responsavel\")\n @laboratorio.docentes << Docente.find(@laboratorio.responsavel_id)\n puts \"Add relação entre #{@laboratorio.nome} e #{Docente.find(@laboratorio.responsavel_id).user.nome}\"\n end\n respond_to do |format|\n if @laboratorio.save\n format.html { redirect_to @laboratorio, notice: 'Laboratorio was successfully created.' }\n format.json { render :show, status: :created, location: @laboratorio }\n else\n format.html { render :new }\n format.json { render json: @laboratorio.errors, status: :unprocessable_entity }\n end\n end\n end", "def candidat_params\n params.require(:candidat).permit(:formulaire_id , responses: {})\n end", "def create\n @method_of_use = MethodOfUse.new(method_of_use_params)\n @method_of_use.disease_ids = params[:method_of_use][:disease_ids]\n @method_of_use.indication_ids = params[:method_of_use][:indication_ids]\n @method_of_use.contraindication_ids = params[:method_of_use][:contraindication_ids]\n\n respond_to do |format|\n if @method_of_use.save\n format.html { redirect_to @method_of_use, notice: 'Метод использования успешно добавлен.' }\n format.json { render action: 'show', status: :created, location: @method_of_use }\n else\n format.html { render action: 'new' }\n format.json { render json: @method_of_use.errors, status: :unprocessable_entity }\n end\n end\n end", "def tb_avaliacao_params\n params.require(:tb_avaliacao).permit(:id,\n tb_respostas_attributes: %i(id tb_pergunta_id nota obs))\n end", "def crediario_params\n params.require(:crediario).permit(:client_id, :amount, :emission, :maturity, :doc_number, :printed, :status)\n end", "def create\n @asiento = Asiento.new(params[:asiento])\n\n respond_to do |format|\n if @asiento.save\n format.html { redirect_to @asiento, :notice => 'El apunte fue creado.' }\n format.json { render :json => @asiento, :status => :created, :location => @asiento }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @asiento.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n if @atividade_extra.answers.length >= 1\n respond_to do |format|\n format.html { redirect_to teachers_area_list_atividades_path , alert: 'Não é possível excluir a atividade pois alguns alunos já responderam.' }\n format.json { head :no_content }\n end\n else\n @atividade_extra.destroy\n respond_to do |format|\n format.html { redirect_to teachers_area_list_atividades_path , notice: 'A atividade foi excluir com sucesso.' }\n format.json { head :no_content }\n end\n end\n end", "def adquisicion_params\n params.require(:adquisicion).permit(:precio, :comentarios, :tipo_pago, :inicio, :fin, :empresa_id, :producto_id, cuotas_attributes: %i[id monto concepto fecha_vencimiento _destroy])\n end", "def create\n @dis_generic_alcohol_interaction = DisGenericAlcoholInteraction.new(dis_generic_alcohol_interaction_params)\n\n respond_to do |format|\n if @dis_generic_alcohol_interaction.save\n format.html { redirect_to @dis_generic_alcohol_interaction, notice: 'Dis generic alcohol interaction was successfully created.' }\n format.json { render :show, status: :created, location: @dis_generic_alcohol_interaction }\n else\n format.html { render :new }\n format.json { render json: @dis_generic_alcohol_interaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expense = Expense.new(params[:expense])\n if params[:expense][:item_id].present?\n @expense.categorie_id = Item.find(params[:expense][:item_id]).categorie_id\n end\n @expense.dossier_id = params[:dossier]\n \n if params[:activite_id].present?\n @expense.activite_id = params[:activite_id]\n end\n \n @expense.save\n respond_to do |format|\n format.json { render :json => { :success => true, :message => \"Created Expense #{@expense.id}\", :data => @expense.attributes.merge(:total_ht => @expense.total, :total_ttc => @expense.total_ttc, :activite_name => @expense.activite.try(:description))}}\n end\n \n end", "def create\n item_exists = false\n item_id = params[:detalle_ot_presupuesto][:repuesto_servicio_id].to_i\n @orden_trabajo_presupuesto.detalle_ot_presupuestos.each do |detail|\n if detail.repuesto_servicio_id == item_id\n # Ya existe el item en la factura, agregar cantidad\n item_exists = true\n @detalle_ot_presupuesto = detail\n @saved_sale_detail = detail.id\n break\n end\n end\n if item_exists\n @detalle_ot_presupuesto.cantidad += params[:detalle_ot_presupuesto][:cantidad].to_i\n @detalle_ot_presupuesto.precio_venta= params[:detalle_ot_presupuesto][:precio_venta].to_f\n @detalle_ot_presupuesto.save!\n else\n detalle_ot_presupuesto = DetalleOtPresupuesto.new(detalle_ot_presupuesto_params)\n @orden_trabajo_presupuesto.detalle_ot_presupuestos << detalle_ot_presupuesto\n end\n\n respond_to do |format|\n \n if @orden_trabajo_presupuesto.save\n format.html {redirect_to @orden_trabajo_presupuesto, notice: 'El detalle se agregó correctamente.'}\n format.json {render :show, status: :created, location: @detalle_compra}\n else\n format.html {render :new}\n format.json {render json: @detalle_ot_presupuesto.errors, status: :unprocessable_entity}\n end\n end\n end", "def atividade_params\n params.require(:atividade).permit(:dia_atividade, :hora_atividade, :acontecimento, :tema, :envolvidos)\n end", "def create\n @agenda = Agenda.new(agenda_params)\n respond_to do |format|\n if @agenda.save\n format.html { redirect_to @agenda, notice: 'Agenda was successfully created.' }\n format.json { render action: 'show', status: :created, location: @agenda }\n else\n @cidades = Cidade.order('cidade ASC')\n format.html { render action: 'new' }\n format.json { render json: @agenda.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n p = Prospectus.where(company_id: params[:company_id]).first\n do_mission = DoMission.create(prospectus_id: p.id, operator_id: current_user.id, status: 1, expired_at: Time.now + 10.days)\n render json: retval_wrapper({id: do_mission.id.to_s}) and return\n end", "def create\n @adquisicion = Adquisicion.new(adquisicion_params)\n\n respond_to do |format|\n if @adquisicion.save\n format.html { redirect_to @adquisicion, notice: 'Adquisicion was successfully created.' }\n format.json { render :show, status: :created, location: @adquisicion }\n else\n format.html { render :new }\n format.json { render json: @adquisicion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:orgao][:tipo_atendimento_ids] ||= []\n\trespond_to do |format|\n if @orgao.save\n format.html { redirect_to @orgao, notice: \"Local de atendimento: #{@orgao.nome}, foi criado com sucesso.\" }\n format.json { render json: @orgao, status: :created, location: @orgao }\n else\n format.html { render action: \"new\" }\n format.json { render json: @orgao.errors, status: :unprocessable_entity }\n end\n end\n end", "def atividade_params\n params.require(:atividade).permit(:nome, :descricao, :inicio, :fim, :estado)\n end", "def atividade_params\n params.require(:atividade).permit(:nome, :status, :professor, :motivo)\n end", "def destroy\n @adicional_desconto = AdicionalDesconto.find(params[:id])\n @adicional_desconto.destroy\n\n respond_to do |format|\n flash[:notice] = 'Adicional / Desconto excluído com sucesso.'\n #format.html { redirect_to(adicional_descontos_url) }\n format.html { redirect_to(adicional_descontos_path) }\n format.xml { head :ok }\n end\n end", "def create\n authorize! :create,Beneficiario\n solicitante=Solicitante.find(params[:solicitante_id])\n @beneficiario = Beneficiario.create(beneficiario_params)\n @beneficiario.historiales.build(parentesco: beneficiario_params[:parentesco], solicitante_id: solicitante.id)\n respond_to do |format|\n if @beneficiario.save\n format.html { redirect_to solicitante_beneficiario_path(solicitante, @beneficiario), notice: 'Beneficiario creado exitosamente.' }\n format.json { render :show, status: :created, location: solicitante_beneficiario_path(solicitante, @beneficiario) }\n else\n format.html { render :new }\n format.json { render json: @beneficiario.errors, status: :unprocessable_entity }\n end\n end\n end", "def ingresso_params\n params.require(:ingresso).permit(:apresentacao_id, :user_id)\n end", "def create\n @onda = Onda.new(onda_params)\n\n respond_to do |format|\n if @onda.save\n format.html { redirect_to ondas_path, notice: 'Onda was successfully created.' }\n format.json { render :show, status: :created, location: @onda }\n else\n format.html { render :new }\n format.json { render json: @onda.errors, status: :unprocessable_entity }\n end\n end\n end", "def crear_indice_respuestas_dudas respuestas_dudas\n texto = ''\n respuestas_dudas.each_with_index do |respuesta_duda, indice|\n texto += \" (*#{indice}*) (#{respuesta_duda.usuario.nombre_usuario}): \\t #{respuesta_duda.contenido}\\n\"\n end\n texto\n end", "def create\n @pedido = Pedido.new(pedido_params)\n @pedido.pedido_hash = get_pedido_hash\n @pedido.estado_actual = PEDIDO_SOLICITADO\n\n #redirect_to '/pedidos'\n respond_to do |format|\n if @pedido.save\n\n params[:item_cantidad].each do |a, b|\n newitem_pedido = ItemPedido.new\n newitem_pedido.cantidad = b\n newitem_pedido.item_id = a\n item = Item.find(a)\n newitem_pedido.nombre = item.nombre\n newitem_pedido.valor = ItemProveedor.find_by_item_id_and_proveedor_id(item.id,Categorium.find(item.categorium_id).proveedor_id).precio\n newitem_pedido.pedido_id = @pedido.id\n newitem_pedido.estado_actual = ITEM_SOLICITADO\n newitem_pedido.proveedor_id = Categorium.find(item.categorium_id).proveedor_id\n newitem_pedido.disponible = true\n newitem_pedido.save\n\n end\n format.html { redirect_to @pedido, notice: 'Pedido was successfully created.' }\n format.json { render :show, status: :created, location: @pedido }\n else\n format.html { render :new }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @respuestum = Respuestum.new(respuestum_params)\n # @comentario = Comentario.find(params[:id])\n #nombre = params[:nombre]\n #correo = params[:correo]\n #comentario = params[:comentario]\n\n #@respuestum = Respuestum.create(:nombre => string, :correo => string, :descripcion => text,:comentario_id => @comentario.id)\n\n respond_to do |format|\n if @respuestum.save\n format.html { redirect_to comentarios_url}\n format.json { render :show, status: :created, location: @respuestum }\n else\n format.html { render :new }\n format.json { render json: @respuestum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @inventario = Inventario.new(inventario_params)\n\n respond_to do |format|\n if @inventario.save\n format.html { redirect_to @inventario, notice: 'Inventario was successfully created.' }\n format.json { render :show, status: :created, location: @inventario }\n else\n format.html { render :new }\n format.json { render json: @inventario.errors, status: :unprocessable_entity }\n end\n end\n end", "def asignar_cliente\n @usuario = Usuario.find(params[:responsable])\n @clientes = params[:cliente]\n respond_to do |format|\n if @usuario.responsable? or @usuario.transcriptor?\n for cliente in @clientes.values\n nuevo = Cliente.create(:usuario_id => @usuario.id, :cliente_id => cliente)\n @usuario.clientes << nuevo\n end \n format.html { redirect_to @usuario, notice: 'Clientes asignados satisfactoriamente'}\n else \n format.html { redirect_to update_usuario_path, notice: 'Error en servidor. Intente más tarde' }\n end\n end\n end", "def solicitud_params\n params.require(:solicitud).permit(:status, :descripcion, :ayuda_id, :beneficiario_id, :solicitante_id)\n end", "def create\n # valor = params[:pedido][:valor]\n # params[:pedido][:valor] = valor.split( ',').join('.')\n conta = Conta.find_by_cliente_id(params[:pedido][:cliente_id])\n @proteinas_disponiveis = Proteina.where(:disponibilidade => true)\n @acompanhamentos_disponiveis = Acompanhamento.where(:disponibilidade => true)\n @guarnicoes_disponiveis = Guarnicao.where(:disponibilidade => true)\n @saladas_disponiveis = Salada.where(:disponibilidade => true)\n @bebidas_disponiveis = Bebida.where(:disponibilidade => true)\n @sobremesas_disponiveis = Sobremesa.where(:disponibilidade => true)\n #descricao = \"\"\n @pedido = Pedido.new(pedido_params)\n @pedido.conta_id = conta.id.to_i\n # if @pedido.cliente.nil?\n # @pedido.cliente = Cliente.find(current_usuario.cliente.id)\n # @pedido.conta = Conta.find_by_cliente_id(current_usuario.id)\n # end\n # ENTRADAS #\n # acompanhamentos = params[:pedido][:acompanhamento_ids]\n # acompanhamentos.each do |id|\n # if !id.blank?\n # acompanhamento = Acompanhamento.find(id.to_i)\n # @pedido.pedidos_acompanhamentos.new(:acompanhamento_id => id)\n # #@pedido.acompanhamentos << acompanhamento\n # end\n # end\n ###### FINAL ENTRADAS ########\n acompanhamentos = Acompanhamento.where(:disponibilidade => true).count\n for i in 0...acompanhamentos do\n if !params[\"acompanhamento_#{i}\"].blank?\n @pedido.pedidos_acompanhamentos.new(:acompanhamento_id => params[\"acompanhamento_#{i}\"], :quantidade => params[\"quantidade_acompanhamento_#{i}\"])\n end\n end\n\n proteinas = Proteina.where(:disponibilidade => true).count\n for i in 0...proteinas do\n if !params[\"proteina_#{i}\"].blank?\n @pedido.pedidos_proteinas.new(:proteina_id => params[\"proteina_#{i}\"], :quantidade => params[\"quantidade_proteina_#{i}\"])\n end\n end\n\n guarnicoes = Guarnicao.where(:disponibilidade => true).count\n for i in 0...guarnicoes do\n if !params[\"guarnicao_#{i}\"].blank?\n @pedido.pedidos_guarnicoes.new(:guarnicao_id => params[\"guarnicao_#{i}\"], :quantidade => params[\"quantidade_guarnicao_#{i}\"])\n end\n end\n\n saladas = Salada.where(:disponibilidade => true).count\n for i in 0...saladas do\n if !params[\"salada_#{i}\"].blank?\n @pedido.pedidos_saladas.new(:salada_id => params[\"salada_#{i}\"], :quantidade => params[\"quantidade_salada_#{i}\"])\n end\n end\n\n bebidas = Bebida.where(:disponibilidade => true).count\n for i in 0...bebidas do\n if !params[\"bebida_#{i}\"].blank?\n @pedido.pedidos_bebidas.new(:bebida_id => params[\"bebida_#{i}\"], :quantidade => params[\"quantidade_bebida_#{i}\"])\n end\n end\n\n sobremesas = Sobremesa.where(:disponibilidade => true).count\n for i in 0...sobremesas do\n if !params[\"sobremesa_#{i}\"].blank?\n @pedido.pedidos_sobremesas.new(:sobremesa_id => params[\"sobremesa_#{i}\"], :quantidade => params[\"quantidade_sobremesa_#{i}\"])\n end\n end\n\n\n #@pedido.proteinas << Proteina.where(:nome => params[:proteina]).first\n\n # debugger\n # if !params[:arroz].nil?\n # descricao = \"Arroz \"+ params[:arroz] + \",\"\n # end\n # if params[:feijao] = \"Sim\"\n # descricao = descricao + \" Feijao, \"\n # end\n\n # if params[:farofa] == \"Sim\"\n # descricao = descricao + \" Farofa,\"\n # end\n\n # descricao = descricao + params[:proteina] + \", \" + params[:acompanhamento] + \" Salada: \"+ params[:salada]\n # @pedido.descricao = descricao\n # itens = params[:pedido][:item_de_pedidos_attributes]\n\n # if !itens.nil?\n # for i in 0..params[:pedido][:item_de_pedidos_attributes].count do\n # if itens[\"#{i}\"] != nil\n # if itens[\"#{i}\"][:produto_id].blank?\n # itens.delete(\"#{i}\")\n # end\n # else\n # itens.delete(\"#{i}\")\n # end\n # end\n # end\n # if !itens.blank?\n # @pedido.calcular_valor\n # else\n # @pedido.item_de_pedidos.destroy_all\n # @pedido.valor = 0\n # end\n # if !itens.nil?\n # params[:pedido][:item_de_pedidos_attributes].replace(itens)\n # end\n\n @pedido.situacao = \"Em processamento\"\n #parametros[:valor] = @pedido.valor\n\n respond_to do |format|\n if @pedido.save\n @pedido.calcular_valor\n @pedido.conta.calcular_saldo\n #@pedido.adicionar_conta\n #proteina = @pedido.proteina\n #proteina.decrescer\n format.html { redirect_to @pedido }\n format.json { render action: 'show', status: :created, location: @pedido }\n else\n format.html { render action: 'new' }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asistencia_domingo = AsistenciaDomingo.new(asistencia_domingo_params)\n\n asistencia_reunion_evangelist_id = asistencia_reunion_evangelist_param[:asistencia_reunion_evangelist_id]\n asistencia_reunion_planificacion_id = asistencia_reunion_planificacion_param[:asistencia_reunion_planificacion_id]\n\n if @asistencia_domingo.save\n redirect_to controller: 'reporte_semanal_celulas', action: 'new', asistencia_domingo_id: @asistencia_domingo.id, asistencia_reunion_evangelist_id: asistencia_reunion_evangelist_id, asistencia_reunion_planificacion_id: asistencia_reunion_planificacion_id , notice: 'Asistencia domingos was successfully created.'\n return\n end\n\n respond_to do |format|\n if !@asistencia_domingo.save\n format.html { render :new }\n format.json { render json: @asistencia_domingo.errors, status: :unprocessable_entity }\n end\n end\n end", "def indicador_params\n params.require(:indicador).permit(:indicador_unidade_medida_id, :area_id, :melhor_sentido, :objetivo, :abrangencia, :periodicidade_coleta, :como_coletar, :periodicidade_avaliacao, :como_calcular, :assunto, :nome, :indicador_assunto_id)\n end", "def create\n @accounting_entry = AccountingEntry.new(accounting_entry_params)\n #@accounting_entry.cuenta=\"hola\"\n respond_to do |format|\n if @accounting_entry.save\n \n format.html { redirect_to accounting_entries_path, notice: 'El asiento ha sido agregado con exito' }\n format.json { render :show, status: :created, location: @accounting_entry }\n else\n format.html { render :new }\n format.json { render json: @accounting_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @adicional_desconto = AdicionalDesconto.new\n @adicional_desconto_tipos = AdicionalDescontoTipo.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @adicional_desconto }\n end\n end", "def create\n @corruption = current_citoyen.corruptions.build(corruption_params)\n\n respond_to do |format|\n if @corruption.save\n format.html { redirect_to @corruption, notice: 'Corruption was successfully created.' }\n format.json { render :show, status: :created, location: @corruption }\n else\n format.html { render :new }\n format.json { render json: @corruption.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @appointment = Appointment.new(params[:appointment])\n \n cita = @appointment\n respond_to do |format|\n if @appointment.save\n\n enviar_correo_cita_nueva_paciente cita\n enviar_correo_cita_nueva_odontologo cita \n\n format.html { redirect_to @appointment, notice: 'Appointment was successfully created.' }\n format.json { render json: @appointment, status: :created, location: @appointment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\n\n\n end", "def create\n @disponible = Disponible.new(disponible_params)\n\n if @disponible.save\n render json: @disponible, status: :created, location: @disponible\n else\n render json: @disponible.errors, status: :unprocessable_entity\n end\n end", "def create\n historial_params = params[:historial]\n with_bill = historial_params.delete(:with_bill)\n @historial = Historial.new(historial_params)\n\n respond_to do |format|\n if @historial.save\n if with_bill.present?\n format.html { redirect_to new_bill_path(\n client_id: @historial.cliente_id,\n historial_id: @historial.id\n ), notice: 'Presupuesto ha sido creado.' }\n else\n format.html { redirect_to @historial, notice: 'Presupuesto ha sido creado.' }\n end\n format.json { render json: @historial, status: :created, location: @historial }\n else\n format.html { render action: \"new\" }\n format.json { render json: @historial.errors, status: :unprocessable_entity }\n end\n end\n end", "def nuevo\n if params[:fechaacred].blank?\n else\n params[:fechaacred] = Date.civil params[:fechaacred][\"year\"].to_i, params[:fechaacred][\"month\"].to_i, params[:fechaacred][\"day\"].to_i\n end\n if params[:dcau_nroboletadeposito].blank?\n params[:dcau_nroboletadeposito] = '000'\n end\n if params[:chequetercero_ids].blank?\n else\n \t params[:chequetercero_ids].each { |item_id|\n @depositocaucion = Depositocaucion.new\n @depositocaucion.dcau_fechadeposito = params[:fechaacred].to_s.to_date\n @depositocaucion.conceptocaucion_id = params[:conceptocaucion].to_s\n @depositocaucion.dcau_nroboletadeposito = params[:dcau_nroboletadeposito].to_s\n @depositocaucion.chequetercero_id = item_id.to_i\n @depositocaucion.sucursal_id = 11\n @depositocaucion.dcau_ultmod = DateTime.now\n @depositocaucion.dcau_usuario = session[:user].usur_nombre\n @depositocaucion.save!\n \t\n if params[:conceptocaucion].to_s == \"2\" \n @cheterc = Chequetercero.find_by_id_and_sucursal_id(item_id, '11')\n @estadocheq = Estadocheter.find_by_chequetercero_id_and_sucursal_id(item_id, '11')\n #grabar devueltocaucions\n @devueltocaucion = Devueltocaucion.new\n @devueltocaucion.chequetercero_id = item_id\n @devueltocaucion.sucursal_id = 11\n @devueltocaucion.devc_tipo = \"R\"\n @devueltocaucion.devc_fecha = params[:fechaacred].to_s.to_date\n @devueltocaucion.devc_detalle = 'Devolucion(REINGRESO A CARTERA) Ch/Nº '+@cheterc.cter_nrocheque.to_s+' listado('+@cheterc.listadocaucion_id.to_s+')'\n @devueltocaucion.devc_importe = @cheterc.cter_importe\n @devueltocaucion.devc_cabsalidacarteraant = @estadocheq.cabsalidacartera_id\n @devueltocaucion.devc_usuario = session[:user].usur_nombre\n @devueltocaucion.devc_ultmod = DateTime.now\n @devueltocaucion.save\n\n #hacer asiento\n @cabasiento = Cabasiento.new\n @cabasiento.sucursal_id = 11\n @cabasiento.cabcaja_id = 0\n\t\t@cabasiento.casi_fecha = params[:fechaacred].to_s.to_date\n @cabasiento.casi_cerrado = \"No\"\n \t@cabasiento.casi_borrado = \"No\"\n\t\t@cabasiento.casi_importado = \"No\"\n @cabasiento.casi_descripcion = \"Reingreso de Caucion\"\n @cabasiento.casi_usuario = session[:user].usur_nombre\n @cabasiento.casi_ultmod = DateTime.now\n @cabasiento.save\n \n #renglones del asiento\n nrocabasiento = Cabasiento.maximum(:id)\n @renasiento = Renasiento.new\n @renasiento.cabasiento_id = nrocabasiento\n @renasiento.plandecuenta_id = 21\n @renasiento.rasi_importe = @cheterc.cter_importe\n @renasiento.save\n @renasiento = Renasiento.new\n @renasiento.cabasiento_id = nrocabasiento\n @renasiento.plandecuenta_id = 132\n @renasiento.rasi_importe = -@cheterc.cter_importe\n @renasiento.save\n \n # pone a cero los estadocheter\n @estadocheter = Estadocheter.find_by_chequetercero_id_and_sucursal_id(item_id, '11')\n @estadocheter.update_attribute(:cabsalidacartera_id, '0')\n @estadocheter.update_attribute(:destinocheter_id, '0')\n @estadocheter.update_attribute(:echt_usuario, session[:user].usur_nombre)\n @estadocheter.update_attribute(:echt_ultmod, DateTime.now)\n end\n if params[:conceptocaucion].to_s == \"3\" \n @cheterc = Chequetercero.find_by_id_and_sucursal_id(item_id, '11')\n @estadocheq = Estadocheter.find_by_chequetercero_id_and_sucursal_id(item_id, '11')\n #grabar devueltocaucion Gesv- Manual\n @devueltocaucion = Devueltocaucion.new\n @devueltocaucion.chequetercero_id = item_id\n @devueltocaucion.sucursal_id = 11\n @devueltocaucion.devc_tipo = \"R\"\n @devueltocaucion.devc_fecha = params[:fechaacred].to_s.to_date\n @devueltocaucion.devc_detalle = 'Devolucion (GESVAL - DEP.MANUAL) Ch/Nº '+@cheterc.cter_nrocheque.to_s+' listado('+@cheterc.listadocaucion_id.to_s+')'\n @devueltocaucion.devc_importe = @cheterc.cter_importe\n @devueltocaucion.devc_cabsalidacarteraant = @estadocheq.cabsalidacartera_id\n @devueltocaucion.devc_usuario = session[:user].usur_nombre\n @devueltocaucion.devc_ultmod = DateTime.now\n @devueltocaucion.save\n\n #hacer asiento\n @cabasiento = Cabasiento.new\n @cabasiento.sucursal_id = 11\n @cabasiento.cabcaja_id = 0\n\t\t @cabasiento.casi_fecha = params[:fechaacred].to_s.to_date\n @cabasiento.casi_cerrado = \"No\"\n \t @cabasiento.casi_borrado = \"No\"\n\t\t @cabasiento.casi_importado = \"No\"\n @cabasiento.casi_descripcion = \"GESVAL - DEP.MANUAL\"\n @cabasiento.casi_usuario = session[:user].usur_nombre\n @cabasiento.casi_ultmod = DateTime.now\n @cabasiento.save\n \n #renglones del asiento\n nrocabasiento = Cabasiento.maximum(:id)\n @renasiento = Renasiento.new\n @renasiento.cabasiento_id = nrocabasiento\n @renasiento.plandecuenta_id = 7\n @renasiento.rasi_importe = @cheterc.cter_importe\n @renasiento.save\n @renasiento = Renasiento.new\n @renasiento.cabasiento_id = nrocabasiento\n @renasiento.plandecuenta_id = 132\n @renasiento.rasi_importe = -@cheterc.cter_importe\n @renasiento.save\n \n # pone a cero los estadocheter\n @estadocheter = Estadocheter.find_by_chequetercero_id_and_sucursal_id(item_id, '11')\n @estadocheter.update_attribute(:cabsalidacartera_id, '0')\n @estadocheter.update_attribute(:destinocheter_id, '0')\n @estadocheter.update_attribute(:echt_usuario, session[:user].usur_nombre)\n @estadocheter.update_attribute(:echt_ultmod, DateTime.now)\n \n end\n }\n end\n # para actualizar las busquedas\n fechas()\n @depositocaucionpendis = Depositocaucion.busqueda(params[:fechadesde], params[:fechahasta], params[:nrocheq])\n @depositocaucions = Depositocaucion.busquedatodo(params[:fechadesde], params[:fechahasta], params[:nrocheq])\n #para sacar los subtotales\n agrup = []\n @depositocaucions.each do |v|\n agrup << v.dcau_nroboletadeposito.to_i\n end\n @agrups = agrup.uniq\n @totalvens = Depositocaucion.totalven(params[:fechadesde], params[:fechahasta])\n @acreditados = Depositocaucion.acreditado(params[:fechadesde], params[:fechahasta])\n render :partial => \"nuevo\", :layout => \"application\"\n\n #redirect_to :action => 'index'\n #render(:update) { |page| page.call 'location.reload' }\n #respond_to do |format| format.js {render(:update) { |page| page.call 'location.reload' }} end \n #render :update do |page| page.form.reset 'uploadPhotoForm' end\n end", "def create\n @aluno = Aluno.new(aluno_params)\n\n respond_to do |format|\n if @aluno.save\n format.html { redirect_to @aluno, notice: t('.new', default: t('helpers.messages.new')) }\n format.json { render :show, status: :created, location: @aluno }\n else\n format.html { render :new }\n format.json { render json: @aluno.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def accidente_params\n params.require(:accidente).permit(:nombre_del_diligenciador, :documento, :tipodoc_id, :tipo_de_vinculacion, :razon_social, :direccion_sede_principal, :direccion_reportada, :telefono_reportado, :actividad_economica_sede_principal, :codigo1, :telefono_sede_principal, :fax_sede_principal, :email_sede_principal, :departamento_id, :municipio_id, :zona1, :actividad_economica_centro_trabajo, :direccion_centro_trabajo, :telefono_ct, :fax_ct, :email_ct, :departamento2, :municipio2, :zona, :funcionario_id, :fecha_del_accidente, :hora_del_accidente, :dia_de_la_semana, :jornada_en_que_sucede, :realiza_su_labor, :ocupacion_no_habitual, :tiempo_laborado, :lugar_donde_ocurrio_el_at, :mecanismo_o_formato_del_at, :tipo_de_lesion, :sitio, :tipo_de_accidente, :parte_del_cuerpo_afectado, :agente_del_accidente, :departamento3, :municipio3, :zona3, :mortal, :fecha_mortal, :descripcion_del_at, :hubo_personas_que_presenciaron_el_accidente, :testigo1, :tipodoc2, :documento2, :testigo2, :tipodoc3, :documento3, :responsable_informe, :tipodoc4, :documento4)\n end", "def tecnicos_postulados\n coleccion = []\n self.request.each do |request|\n info = {}\n info[:id] = request.id\n info[:article] = request.article\n info[:servicio] = request.service.description\n info[:tecnicos] = request.proposal\n coleccion.append(info)\n end\n coleccion\n end", "def create\n @indication_for_meal = IndicationForMeal.new(indication_for_meal_params)\n\n respond_to do |format|\n if @indication_for_meal.save\n format.html { redirect_to @indication_for_meal, notice: 'Indication for meal was successfully created.' }\n format.json { render action: 'show', status: :created, location: @indication_for_meal }\n else\n format.html { render action: 'new' }\n format.json { render json: @indication_for_meal.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6745028", "0.6544405", "0.6544405", "0.6464977", "0.64624697", "0.6201955", "0.605923", "0.5940895", "0.58948404", "0.58948404", "0.58737224", "0.57324123", "0.57091653", "0.567408", "0.5621925", "0.55859756", "0.55783", "0.5558731", "0.55469257", "0.5537962", "0.55377775", "0.54934186", "0.5491934", "0.5480497", "0.5478703", "0.54579884", "0.5428334", "0.54257905", "0.5423189", "0.5419012", "0.5406238", "0.5405153", "0.53816247", "0.53792095", "0.5373068", "0.5360506", "0.53554726", "0.53532344", "0.53523034", "0.5336186", "0.53361523", "0.5304127", "0.52947", "0.5294324", "0.5287321", "0.5282513", "0.5273596", "0.5271146", "0.5268389", "0.52491283", "0.5247249", "0.5241089", "0.5235122", "0.523282", "0.5228427", "0.5227305", "0.52228904", "0.5222727", "0.52183783", "0.52172065", "0.5215348", "0.5212718", "0.5210838", "0.52072996", "0.5185936", "0.5181762", "0.5177865", "0.5161647", "0.515942", "0.5159394", "0.5158956", "0.5158259", "0.5156024", "0.51542574", "0.5153542", "0.51480985", "0.51427394", "0.5139678", "0.5139609", "0.51386184", "0.51324856", "0.51259667", "0.5122674", "0.5122558", "0.51193035", "0.51185036", "0.51181275", "0.51162654", "0.5112324", "0.5112276", "0.51110494", "0.51083237", "0.5100614", "0.50978726", "0.5097759", "0.50952536", "0.50946957", "0.5091036", "0.5089097", "0.5088033" ]
0.6690199
1
PATCH/PUT /descuento_adicionals/1 PATCH/PUT /descuento_adicionals/1.json
def update respond_to do |format| if @descuento_adicional.update(descuento_adicional_params) format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional fue actualizado exitosamente.' } format.json { render :show, status: :ok, location: @descuento_adicional } else format.html { render :edit } format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @descuento_adicional.update(descuento_adicional_params)\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully updated.' }\n format.json { render :show, status: :ok, location: @descuento_adicional }\n else\n format.html { render :edit }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @serv_adicionale = ServAdicionale.find(params[:id])\n\n respond_to do |format|\n if @serv_adicionale.update_attributes(params[:serv_adicionale])\n format.html { redirect_to @serv_adicionale, notice: 'Serv adicionale was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serv_adicionale.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @descuento = Descuento.find(params[:id])\n\n respond_to do |format|\n if @descuento.update_attributes(params[:descuento])\n format.html { redirect_to @descuento, notice: 'Descuento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @descuento.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @adicional_desconto = AdicionalDesconto.find(params[:id])\n\n respond_to do |format|\n if @adicional_desconto.update_attributes(params[:adicional_desconto])\n flash[:notice] = 'Adicional / Desconto alterado com sucesso.'\n #format.html { redirect_to(@adicional_desconto) }\n format.html { redirect_to(adicional_descontos_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @adicional_desconto.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @initiative = Initiative.find(params[:id])\n \n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n \n format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @initiative.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @indicacao = Indicacao.find(params[:id])\n\n respond_to do |format|\n if @indicacao.update_attributes(params[:indicacao])\n format.html { redirect_to @indicacao, notice: 'A Indicação do Condutor foi atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @indicacao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @dis_generic_alcohol_interaction.update(dis_generic_alcohol_interaction_params)\n format.html { redirect_to @dis_generic_alcohol_interaction, notice: 'Dis generic alcohol interaction was successfully updated.' }\n format.json { render :show, status: :ok, location: @dis_generic_alcohol_interaction }\n else\n format.html { render :edit }\n format.json { render json: @dis_generic_alcohol_interaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @dis_alcohol_interaction.update(dis_alcohol_interaction_params)\n format.html { redirect_to @dis_alcohol_interaction, notice: 'Dis alcohol interaction was successfully updated.' }\n format.json { render :show, status: :ok, location: @dis_alcohol_interaction }\n else\n format.html { render :edit }\n format.json { render json: @dis_alcohol_interaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @apologetic.update(apologetic_params)\n format.html { redirect_to @apologetic, notice: 'Apologetic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @apologetic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @indicativo = Indicativo.find(params[:id])\n\n respond_to do |format|\n if @indicativo.update_attributes(params[:indicativo])\n format.html { redirect_to @indicativo, notice: 'Indicativo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @indicativo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @aactio = Aactio.find(params[:id])\n\n respond_to do |format|\n if @aactio.update_attributes(params[:aactio])\n format.html { redirect_to @aactio, notice: 'Aactio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @aactio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n if @respuesta.update_attributes(params[:respuesta])\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asiento = Asiento.find(params[:id])\n\n respond_to do |format|\n if @asiento.update_attributes(params[:asiento])\n format.html { redirect_to @asiento, :notice => 'El apunte fue cambiado.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @asiento.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item_adicional.update(item_adicional_params)\n format.html { redirect_to @item_adicional, notice: 'Item adicional was successfully updated.' }\n format.json { render :show, status: :ok, location: @item_adicional }\n else\n format.html { render :edit }\n format.json { render json: @item_adicional.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @acao = Acao.find(params[:id])\n\n respond_to do |format|\n if @acao.update_attributes(params[:acao])\n format.html { redirect_to acao_url(@acao), notice: 'Acao atualizada.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @acao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @atracao = Atracao.find(params[:id])\n\n respond_to do |format|\n if @atracao.update_attributes(params[:atracao])\n format.html { redirect_to @atracao, :notice => 'Atracao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @atracao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sivic_discipulo.update(sivic_discipulo_params_netested)\n format.html { redirect_to @sivic_discipulo, notice: 'Registro alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sivic_discipulo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @competicao = Competicao.find(params[:id])\n\n respond_to do |format|\n if @competicao.update_attributes(params[:competicao])\n format.html { redirect_to @competicao, notice: 'Competicao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @competicao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @comentario = Comentario.find(params[:id])\n\n respond_to do |format|\n if @comentario.update_attributes(params[:comentario])\n format.html { redirect_to @comentario, notice: 'Comentario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comentario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @paciente = Paciente.find(params[:id])\n #verificar se existe atendimento cadastrado para o paciente\n #@atendimentos=Atendimento.find_all_by_paciente_id(params[:paciente_id])\n #if @atendimentos.empty?\n # @atendimento=Atendimento.new()\n # @atendimento.paciente_id=@paciente.id\n # @atendimento.save\n #else\n # @atendimento.update_attributes(params[:paciente_id])\n #end\n respond_to do |format|\n if @paciente.update_attributes(params[:paciente]) \n format.html { redirect_to pacientes_path, notice: 'Paciente atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @dis_alcohol_interaction.update(dis_alcohol_interaction_params)\n format.html { redirect_to @dis_alcohol_interaction, notice: 'Combination dose was successfully updated.' }\n format.json { render :show, status: :ok, location: @dis_alcohol_interaction }\n else\n format.html { render :edit }\n format.json { render json: @dis_alcohol_interaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @consumo = Consumo.find(params[:id])\n\n respond_to do |format|\n if @consumo.update_attributes(params[:consumo])\n format.html { redirect_to @consumo.cliente, :notice => 'Consumo alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @consumo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if @diet.update(diet_params)\n head :no_content, status: 204\n else\n render json: @diet.errors, status: 422\n end\n end", "def update\n respond_to do |format|\n if @representante_athlete.update_attributes(params[:representante_athlete])\n format.html { redirect_to representante_athletes_url, notice: 'Atleta atualizado com sucesso' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @representante_athlete.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @historial_odt = HistorialOdt.find(params[:id])\n\n respond_to do |format|\n if @historial_odt.update_attributes(params[:historial_odt])\n format.html { redirect_to @historial_odt, notice: 'Historial odt was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @historial_odt.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @apuesta_detail = ApuestaDetail.find(params[:id])\n\n respond_to do |format|\n if @apuesta_detail.update_attributes(params[:apuesta_detail])\n format.html { redirect_to @apuesta_detail, notice: 'Apuesta detail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @apuesta_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @agenda.update(agenda_params)\n format.html { redirect_to @agenda, notice: 'Agenda was successfully updated.' }\n format.json { head :no_content }\n else\n @cidades = Cidade.order('cidade ASC')\n format.html { render action: 'edit' }\n format.json { render json: @agenda.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @status_del_admitido = StatusDelAdmitido.find(params[:id])\n\n respond_to do |format|\n if @status_del_admitido.update_attributes(params[:status_del_admitido])\n format.html { redirect_to @status_del_admitido, notice: 'Status del admitido was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @status_del_admitido.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @responsavel = Responsavel.find(params[:id])\n\n if @responsavel.update(responsavel_params)\n head :no_content\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end", "def update\n @adversaire = Adversaire.find(params[:id])\n @equipe = Equipe.find(params[:equipe_id])\n respond_to do |format|\n if @adversaire.update_attributes(params[:adversaire])\n format.html { redirect_to @equipe, :notice => 'Adversaire was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @adversaire.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @descuento.update(descuento_params)\n format.html { redirect_to @descuento, notice: 'Descuento fue actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @descuento }\n else\n format.html { render :edit }\n format.json { render json: @descuento.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n if @paciente.update_attributes(params[:paciente])\n format.html { redirect_to @paciente, notice: 'Paciente atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ativo_outro = AtivoOutro.find(params[:id])\n\n respond_to do |format|\n if @ativo_outro.update_attributes(params[:ativo_outro])\n format.html { redirect_to @ativo_outro, notice: 'Ativo foi salvo com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ativo_outro.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @peticion = Peticion.find(params[:id])\n\n respond_to do |format|\n if @peticion.update_attributes(:solicitudrecurso_id => params[:solicitudrecurso_id],\n :diasemana => params[:diasemana].to_s,\n :horaini => params[:horaini].to_s, \n :horafin => params[:horafin].to_s)\n\n # flash.now[:notice] = 'Peticion was successfully updated.'\n @peticions=Peticion.all\n format.html { render :action => \"index\" }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @peticion.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @atividade_extra.update(atividade_extra_params)\n format.html { redirect_to @atividade_extra, notice: 'Atividade foi atualizada.' }\n format.json { render :show, status: :ok, location: @atividade_extra }\n else\n format.html { render :edit }\n format.json { render json: @atividade_extra.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n historial_params = params[:historial]\n with_bill = historial_params.delete(:with_bill)\n @historial = Historial.find(params[:id])\n\n respond_to do |format|\n if @historial.update_attributes(historial_params)\n if with_bill.present?\n format.html { redirect_to new_bill_path(\n client_id: @historial.cliente_id,\n historial_id: @historial.id\n ), notice: 'Presupuesto actualizado =)'}\n else\n format.html { redirect_to @historial, notice: 'Presupuesto actualizado =)' }\n end\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @historial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @respuesta = Respuesta.find(params[:id])\n\n if @respuesta.update(params[:respuesta])\n head :no_content\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def update\n @entrada_inventario = EntradaInventario.find(params[:id])\n\n respond_to do |format|\n if @entrada_inventario.update_attributes(params[:entrada_inventario])\n format.html { redirect_to @entrada_inventario, notice: 'Entrada inventario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entrada_inventario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @solicitacao.update(solicitacao_params)\n format.html { redirect_to @solicitacao, notice: 'Solicitacao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @solicitacao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_negocio = TipoNegocio.find(params[:id])\n\n respond_to do |format|\n if @tipo_negocio.update_attributes(params[:tipo_negocio])\n format.html { redirect_to @tipo_negocio, notice: 'Tipo negocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_negocio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_initiative.update(api_v1_initiative_params)\n format.html { redirect_to @api_v1_initiative, notice: 'Initiative was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @senha = @discipline.senha\n if @discipline.update(discipline_params)\n if @discipline.senha == \"\"\n @discipline.senha = @senha\n @discipline.update( senha: @senha)\n end\n if params[:anexos]\n\n params[:anexos].each { |anx|\n @discanexo = Discanexo.new\n @discanexo.anexo = anx\n @discanexo.Discipline_id = @discipline.id\n @discanexo.save\n }\n end\n flash[:success] = \"Disciplina atualizada com sucesso.\"\n format.html { redirect_to disciplines_url}\n format.json { render :show, status: :ok, location: @discipline }\n else\n format.html { render :edit }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @atividades_extra.update(atividades_extra_params)\n format.html { redirect_to @atividades_extra, notice: 'Atividades extra was successfully updated.' }\n format.json { render :show, status: :ok, location: @atividades_extra }\n else\n format.html { render :edit }\n format.json { render json: @atividades_extra.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n pai = params[:pai] ? Conta.find_by_id(params[:pai]): nil\n \n respond_to do |format|\n if @conta.update(nome: conta_params[:nome], status: conta_params[:status], pai: pai) \n #format.json { render :show, status: :ok, location: @conta }\n format.json { render json: @conta.to_json, status: :ok }\n else \n format.json { render json: @conta.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @inventario_cosa.update(inventario_cosa_params)\n format.html { redirect_to @inventario_cosa, notice: 'Inventario cosa was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventario_cosa }\n else\n format.html { render :edit }\n format.json { render json: @inventario_cosa.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @callout.update(callout_params)\n format.html { redirect_to @callout, notice: 'Callout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @callout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @indication_for_meal.update(indication_for_meal_params)\n format.html { redirect_to @indication_for_meal, notice: 'Indication for meal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @indication_for_meal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @selecao = Selecao.find(params[:id])\n\n respond_to do |format|\n if @selecao.update_attributes(params[:selecao])\n format.html { redirect_to @selecao, notice: 'Selecao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @selecao.errors, status: :unprocessable_entity }\n end\n end\n end", "def activo_update\n respond_to do |format|\n activo = params[:laboratorio][:activo]\n id = params[:id]\n Laboratorio.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end", "def update\n #indication\n @method_of_use.disease_ids = params[:method_of_use][:disease_ids]\n @method_of_use.indication_ids = params[:method_of_use][:indication_ids]\n @method_of_use.contraindication_ids = params[:method_of_use][:contraindication_ids]\n\n respond_to do |format|\n if @method_of_use.update(method_of_use_params)\n\n format.html { redirect_to @method_of_use, notice: 'Метод использования успешно обновлён.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @method_of_use.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @observation = Observation.find(params[:id])\n\n respond_to do |format|\n if @observation.update_attributes(observation_params)\n format.html { redirect_to coral_path(@observation.coral), flash: {success: 'Observation was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @observation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @historial = Historial.find(params[:id])\n\n respond_to do |format|\n if @historial.update_attributes(params[:historial])\n format.html { redirect_to @historial.cartucho, notice: 'Historial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @historial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fulcliente = Fulcliente.find(params[:id])\n\n respond_to do |format|\n if @fulcliente.update_attributes(params[:fulcliente])\n format.html { redirect_to @fulcliente, notice: 'Fulcliente was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fulcliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @solicitacoes_avaliacoes_servico.update(solicitacoes_avaliacoes_servico_params)\n format.html { redirect_to @solicitacoes_avaliacoes_servico, notice: 'Solicitacoes avaliacoes servico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @solicitacoes_avaliacoes_servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_contrato = TipoContrato.find(params[:id])\n\n respond_to do |format|\n if @tipo_contrato.update_attributes(params[:tipo_contrato])\n format.html { redirect_to tipo_contratos_path, notice: 'Tipo de contrato atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_contrato.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @status_ativ = StatusAtiv.find(params[:id])\n\n respond_to do |format|\n if @status_ativ.update_attributes(params[:status_ativ])\n format.html { redirect_to @status_ativ, notice: 'Status ativ was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @status_ativ.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @comentario = current_user.comentarios.find(params[:comentario])\n\n respond_to do |format|\n if @comentario.update_attributes(params[:id])\n format.html { redirect_to @comentario, notice: 'Comentario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comentario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @accesorio = Accesorio.find(params[:id])\n\n respond_to do |format|\n if @accesorio.update_attributes(params[:accesorio])\n format.html { redirect_to @accesorio, notice: 'Accesorio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render \"edit\" }\n format.json { render json: @accesorio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cargo_eleicao = CargoEleicao.find(params[:id])\n\n respond_to do |format|\n if @cargo_eleicao.update_attributes(params[:cargo_eleicao])\n format.html { redirect_to @cargo_eleicao, notice: 'Cargo eleicao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cargo_eleicao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ingresso.update(ingresso_params)\n format.html { redirect_to @ingresso, notice: 'Ingresso was successfully updated.' }\n format.json { render :show, status: :ok, location: @ingresso }\n else\n format.html { render :edit }\n format.json { render json: @ingresso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @prioridade_adocao = PrioridadeAdocao.find(params[:id])\n\n respond_to do |format|\n if @prioridade_adocao.update_attributes(params[:prioridade_adocao])\n format.html { redirect_to @prioridade_adocao, notice: 'Prioridade adocao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prioridade_adocao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @status_confirmacao_adotando = StatusConfirmacaoAdotando.find(params[:id])\n\n respond_to do |format|\n if @status_confirmacao_adotando.update_attributes(params[:status_confirmacao_adotando])\n format.html { redirect_to @status_confirmacao_adotando, notice: 'Status confirmacao adotando was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @status_confirmacao_adotando.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contador.update(contador_params)\n format.html { redirect_to @contador, notice: 'Contador was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contador.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #parametros_autocomplete!(params[:estudiante][:persona])\n @estudiante = Estudiante.find(params[:id])\n \n begin\n @estudiante.persona_id = params[:persona][:id]\n rescue\n end\n\n respond_to do |format|\n if @estudiante.update_attributes(params[:estudiante])\n format.html { redirect_to @estudiante, notice: 'Estudiante actualizado' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @estudiante.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @inventario.update(inventario_params)\n format.html { redirect_to @inventario, notice: 'Inventario was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventario }\n else\n format.html { render :edit }\n format.json { render json: @inventario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @inventario.update(inventario_params)\n format.html { redirect_to @inventario, notice: 'Inventario was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventario }\n else\n format.html { render :edit }\n format.json { render json: @inventario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @caballo = Caballo.find(params[:id])\n\n respond_to do |format|\n if @caballo.update_attributes(params[:caballo])\n format.html { redirect_to @caballo, notice: 'Caballo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @caballo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recurso = Recurso.find(params[:id])\n\n respond_to do |format|\n if @recurso.update_attributes(params[:recurso])\n format.html { redirect_to @recurso, notice: 'O recurso de auto de infração foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recurso.errors, status: :unprocessable_entity }\n end\n end\n end", "def activo_update\n respond_to do |format|\n activo = params[:presentacion][:activo]\n id = params[:id]\n Presentacion.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end", "def update\n respond_to do |format|\n if @responsible.update(responsible_params)\n format.html { redirect_to @responsible, notice: 'Responsavel editado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @responsible.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @aluno.update(aluno_params)\n format.html { redirect_to @aluno, notice: 'Edição do Aluno realizada com sucesso.' }\n format.json { render :show, status: :ok, location: @aluno }\n else\n format.html { render :edit }\n format.json { render json: @aluno.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @adocao_animal = AdocaoAnimal.find(params[:id])\n\n respond_to do |format|\n if @adocao_animal.update_attributes(params[:adocao_animal])\n format.html { redirect_to @adocao_animal, notice: 'Adocao animal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @adocao_animal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lista_contato = ListaContato.find(params[:id])\n\n respond_to do |format|\n if @lista_contato.update_attributes(params[:lista_contato])\n format.html { redirect_to @lista_contato, notice: 'Lista contato was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lista_contato.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ocat = Ocat.find(params[:id])\n\n respond_to do |format|\n if @ocat.update_attributes(params[:ocat])\n format.html { redirect_to @ocat, notice: 'Ocat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ocat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @calificacion_servicio = CalificacionServicio.find(params[:id])\n\n respond_to do |format|\n if @calificacion_servicio.update_attributes(params[:calificacion_servicio])\n format.html { redirect_to @calificacion_servicio, notice: 'Calificacion servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @calificacion_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @anio.update(anio_params)\n format.html { redirect_to @anio, notice: 'Anio was successfully updated.' }\n format.json { render :show, status: :ok, location: @anio }\n else\n format.html { render :edit }\n format.json { render json: @anio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @calificacion = Calificacion.find(params[:id])\n\n respond_to do |format|\n if @calificacion.update_attributes(params[:calificacion])\n format.html { redirect_to @calificacion, notice: 'Calificacion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @calificacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @calificacion = Calificacion.find(params[:id])\n\n respond_to do |format|\n if @calificacion.update_attributes(params[:calificacion])\n format.html { redirect_to @calificacion, notice: 'Calificacion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @calificacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @datoscontacto = Datoscontacto.find(params[:id])\n\n respond_to do |format|\n if @datoscontacto.update_attributes(params[:datoscontacto])\n format.html { redirect_to @datoscontacto, notice: 'Datoscontacto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @datoscontacto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n if @paciente.update_attributes(params[:paciente])\n format.html { redirect_to \"/administrador/pacientes\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @habito.update(habito_params)\n format.html { redirect_to index_habito_path(params[:habito][:paciente_id]), notice: 'Datos actualizados correctamente' }\n format.json { render :show, status: :ok, location: @habito }\n else\n format.html { render :edit }\n format.json { render json: @habito.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @safra_verdoso = SafraVerdoso.find(params[:id])\n\n respond_to do |format|\n if @safra_verdoso.update_attributes(params[:safra_verdoso])\n format.html { redirect_to \"/safra_produtos/#{@safra_verdoso.safra_produto_id}/descontos\"}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @safra_verdoso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expediente = Expediente.find(params[:id])\n\n respond_to do |format|\n if @expediente.update_attributes(params[:expediente])\n format.html { redirect_to @expediente, notice: 'Expediente was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @expediente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @trein_consul_comercial.update(trein_consul_comercial_params)\n format.html { redirect_to @trein_consul_comercial, notice: 'Trein consul comercial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trein_consul_comercial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @admission_type = AdmissionType.find(params[:id])\n\n respond_to do |format|\n if @admission_type.update_attributes(params[:admission_type])\n format.html { redirect_to @admission_type, :notice => 'Tipo de Ingressso atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @admission_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @atividade.update(atividade_params)\n format.html { redirect_to @atividade, notice: 'Atividade was successfully updated.' }\n format.json { render :show, status: :ok, location: @atividade }\n else\n format.html { render :edit }\n format.json { render json: @atividade.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @inscrito = Inscrito.find(params[:id])\n\n respond_to do |format|\n if @inscrito.update_attributes(params[:inscrito])\n format.html { redirect_to @inscrito, notice: 'Inscrito was successfully updated. #{undo_link}' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inscrito.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @apoio.update(apoio_params)\n format.html { redirect_to @apoio, notice: 'Apoio was successfully updated.' }\n format.json { render :show, status: :ok, location: @apoio }\n else\n format.html { render :edit }\n format.json { render json: @apoio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n if @cliente.update_attributes(params[:cliente])\n format.html { redirect_to @cliente, notice: 'Cliente atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @opinion = Opinion.find(params[:id])\n\n respond_to do |format|\n if @opinion.update_attributes(params[:opinion])\n format.html { redirect_to @opinion, notice: 'Opinion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @opinion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contato.update(contato_params)\n format.html { redirect_to @contato, flash: { success: 'Contato was successfully updated.' } }\n format.json { render :show, status: :ok, location: @contato }\n else\n format.html { render :edit }\n format.json { render json: @contato.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end", "def update\n @advogados_escritorio = AdvogadosEscritorio.find(params[:id])\n\n respond_to do |format|\n if @advogados_escritorio.update_attributes(params[:advogados_escritorio])\n flash[:notice] = t('general.messages.update_success', model_name: t('activerecord.models.advogados_escritorio'))\n format.html { redirect_to edit_advogados_escritorio_path(@advogados_escritorio) }\n format.json { head :no_content }\n format.js { render action: 'save.js.erb' }\n else\n flash.now[:error] = t('general.messages.update_error', model_name: t('activerecord.models.advogados_escritorio'))\n format.html { render action: \"edit\" }\n format.json { render json: @advogados_escritorio.errors, status: :unprocessable_entity }\n format.js { render action: 'save.js.erb' }\n end\n end\n end", "def update\n respond_to do |format|\n if @solicitacao_tipo.update(solicitacao_tipo_params)\n format.html { redirect_to @solicitacao_tipo, notice: 'Solicitacao tipo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @solicitacao_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_with Expense.update(params[:id], expense_params), status: 204\n end", "def update\n @contacter = Contacter.find(params[:id])\n\n respond_to do |format|\n if @contacter.update_attributes(params[:contacter])\n format.html { redirect_to @contacter, notice: 'Contacter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contacter.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n\n respond_to do |format|\n if @solicitud_servicio.update_attributes(params[:solicitud_servicio])\n format.html { redirect_to @solicitud_servicio, notice: 'Solicitud servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @solicitud_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @articulo = Articulo.find(params[:id])\n\n respond_to do |format|\n if @articulo.update_attributes(params[:articulo])\n format.html { redirect_to @articulo, notice: 'Articulo se ha actualizado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @articulo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @appeal.update_attributes(params[:appeal])\n format.html { redirect_to [@conference, @appeal], notice: 'Appeal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @appeal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ano = Ano.find(params[:id])\n\n respond_to do |format|\n if @ano.update_attributes(params[:ano])\n format.html { redirect_to @ano, notice: 'Ano was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ano.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.68740344", "0.6508011", "0.6374225", "0.634008", "0.6299347", "0.6268326", "0.62560046", "0.6252494", "0.6252113", "0.6248781", "0.6247315", "0.62207776", "0.6206411", "0.6186919", "0.61850315", "0.617283", "0.6169775", "0.6152704", "0.6147492", "0.6146387", "0.61308557", "0.6121827", "0.6112182", "0.61100394", "0.61093396", "0.6105705", "0.6104398", "0.6098775", "0.6097312", "0.60757655", "0.6060998", "0.6058577", "0.6058287", "0.604788", "0.60439426", "0.6043486", "0.60418767", "0.60371166", "0.6022802", "0.6015246", "0.6013732", "0.60128534", "0.6010139", "0.6005667", "0.6004867", "0.60017496", "0.6001385", "0.5999847", "0.59948146", "0.5993804", "0.59855545", "0.59848493", "0.59835684", "0.59807086", "0.59759855", "0.5969316", "0.5961427", "0.5960754", "0.59552056", "0.5953328", "0.5952045", "0.59519064", "0.5951356", "0.5947666", "0.59407204", "0.59407204", "0.593926", "0.5932979", "0.5932109", "0.5931745", "0.5930749", "0.59298676", "0.5926591", "0.5923705", "0.5922816", "0.5919739", "0.59158534", "0.59158534", "0.59126204", "0.59078926", "0.59068656", "0.59042895", "0.5902304", "0.5901103", "0.59003055", "0.5898958", "0.58908343", "0.5890619", "0.5887878", "0.5883283", "0.588158", "0.58813286", "0.58805925", "0.5879877", "0.5879455", "0.5879263", "0.5878958", "0.5878392", "0.58770615", "0.58768165" ]
0.6687972
1
DELETE /descuento_adicionals/1 DELETE /descuento_adicionals/1.json
def destroy @descuento_adicional.destroy respond_to do |format| format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional fue eliminado exitosamente.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item_adicional.destroy\n respond_to do |format|\n format.html { redirect_to item_adicionals_url, notice: 'Item adicional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @descuento = Descuento.find(params[:id])\n @descuento.destroy\n\n respond_to do |format|\n format.html { redirect_to descuentos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @indicacao = Indicacao.find(params[:id])\n @indicacao.destroy\n\n respond_to do |format|\n format.html { redirect_to indicacoes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aactio = Aactio.find(params[:id])\n @aactio.destroy\n\n respond_to do |format|\n format.html { redirect_to aactios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @serv_adicionale = ServAdicionale.find(params[:id])\n @serv_adicionale.destroy\n\n respond_to do |format|\n format.html { redirect_to serv_adicionales_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @explaination = Explaination.find(params[:id])\n @explaination.destroy\n\n respond_to do |format|\n format.html { redirect_to explainations_url }\n format.json { head :no_content }\n end\n end", "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 @dis_generic_alcohol_interaction.destroy\n respond_to do |format|\n format.html { redirect_to dis_generic_alcohol_interactions_url, notice: 'Dis generic alcohol interaction was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @apologetic.destroy\n respond_to do |format|\n format.html { redirect_to apologetics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @apuesta_detail = ApuestaDetail.find(params[:id])\n @apuesta_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to apuesta_details_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @apoio_educacioanl.destroy\n respond_to do |format|\n format.html { redirect_to apoio_educacioanls_url, notice: 'Apoio educacioanal foi excluído com Sucesso !' }\n format.json { head :no_content }\n end\n end", "def destroy\n @indicativo = Indicativo.find(params[:id])\n @indicativo.destroy\n\n respond_to do |format|\n format.html { redirect_to indicativos_url }\n format.json { head :no_content }\n end\n end", "def delete\n unless possui_acesso?()\n return\n end\n @aviso = Aviso.find(params[:id])\n @aviso.destroy\n\n respond_to do |format|\n format.html { redirect_to avisos_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\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 @retroalimentacion = Retroalimentacion.find(params[:id])\n @retroalimentacion.destroy\n\n respond_to do |format|\n format.html { redirect_to retroalimentacions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n# redirect_to activacionclientets_path # ted esto para evitar que borren por la web. ok. Que valla al index. provisional ok.\n \n #@activacionclientet.destroy\n respond_to do |format|\n format.html { redirect_to activacionclientets_url, notice: 'Activacionclientes no se puede eliminar por esta via. Contacte el administrador.' } # ted esto para evitar que borren por la web\n format.json { head :no_content }\n end\n end", "def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dis_alcohol_interaction.destroy\n respond_to do |format|\n format.html { redirect_to dis_alcohol_interactions_url, notice: 'Dis alcohol interaction was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @adopcion.destroy\n respond_to do |format|\n format.html { redirect_to adopcions_url, notice: 'Adopcion Eliminada.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @accident_item.destroy\n respond_to do |format|\n format.html { redirect_to accident_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @adicional_desconto = AdicionalDesconto.find(params[:id])\n @adicional_desconto.destroy\n\n respond_to do |format|\n flash[:notice] = 'Adicional / Desconto excluído com sucesso.'\n #format.html { redirect_to(adicional_descontos_url) }\n format.html { redirect_to(adicional_descontos_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n # @observation = Observation.find(params[:id])\n # @observation.destroy\n\n @coral = Coral.find(params[:coral_id])\n @observation = @coral.observations.find(params[:id])\n @observation.destroy\n # redirect_to coral_path(@coral)\n \n respond_to do |format|\n format.html { redirect_to coral_path(@coral) }\n format.json { head :no_content }\n end\n end", "def destroy\n @status_ativ = StatusAtiv.find(params[:id])\n @status_ativ.destroy\n\n respond_to do |format|\n format.html { redirect_to status_ativs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @especialidad.destroy\n respond_to do |format|\n format.html { redirect_to especialidads_url, notice: 'Servicio eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @comentario = Comentario.find(params[:id])\n @avaliacao_id = @comentario.avaliacao_id\n @comentario.destroy\n\n respond_to do |format|\n format.html { redirect_to avaliacao_path(@avaliacao_id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @occasion = Occasion.find(params[:id])\n @occasion.destroy\n\n respond_to do |format|\n format.html { redirect_to occasions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asociado = Asociado.find(params[:id])\n @asociado.destroy\n\n respond_to do |format|\n format.html { redirect_to asociados_url }\n format.json { head :ok }\n end\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n head :no_content\n end", "def destroy\n @analise.destroy\n respond_to do |format|\n format.html { redirect_to analises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @solicitud.destroy\n respond_to do |format|\n format.html { redirect_to solicitudes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @asiento = Asiento.find(params[:id])\n @asiento.destroy\n\n respond_to do |format|\n format.html { redirect_to asientos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @historial_odt = HistorialOdt.find(params[:id])\n @historial_odt.destroy\n\n respond_to do |format|\n format.html { redirect_to historial_odts_url }\n format.json { head :no_content }\n end\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 delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @historial = Historial.find(params[:id])\n @historial.destroy\n\n respond_to do |format|\n format.html { redirect_to historials_url }\n format.json { head :ok }\n end\n end", "def destroy\n @sivic_discipulo.destroy\n respond_to do |format|\n format.html { redirect_to sivic_discipulos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @notificaciones_admin_actualouse = NotificacionesAdminActualouse.find(params[:id])\n @notificaciones_admin_actualouse.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :ok }\n end\n end", "def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ativo_outro = AtivoOutro.find(params[:id])\n @ativo_outro.destroy\n\n respond_to do |format|\n format.html { redirect_to ativo_outros_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @entrada_inventario = EntradaInventario.find(params[:id])\n @entrada_inventario.destroy\n\n respond_to do |format|\n format.html { redirect_to entrada_inventarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @addimition = Addimition.find(params[:id])\n @addimition.destroy\n\n respond_to do |format|\n format.html { redirect_to addimitions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @humanidades2 = Humanidades2.find(params[:id])\n @humanidades2.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades2s_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 @atividades_extra.destroy\n respond_to do |format|\n format.html { redirect_to atividades_extras_url, notice: 'Atividades extra was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @adocao_animal = AdocaoAnimal.find(params[:id])\n @adocao_animal.destroy\n\n respond_to do |format|\n format.html { redirect_to adocao_animals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @capacidad = Capacidad.find(params[:id])\n @capacidad.destroy\n\n respond_to do |format|\n format.html { redirect_to capacidades_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prioridade_adocao = PrioridadeAdocao.find(params[:id])\n @prioridade_adocao.destroy\n\n respond_to do |format|\n format.html { redirect_to prioridade_adocoes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @equipe = Equipe.find(params[:equipe_id])\n @adversaire = Adversaire.find(params[:id])\n @adversaire.destroy\n\n respond_to do |format|\n format.html { redirect_to @equipe }\n format.json { head :no_content }\n end\n end", "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 @intention = Intention.find(params[:id])\n @intention.destroy\n\n respond_to do |format|\n format.html { redirect_to intentions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @puestos_entidad = PuestosEntidad.find(params[:id])\n @puestos_entidad.destroy\n\n respond_to do |format|\n format.html { redirect_to puestos_entidads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @inspiration.destroy\n render json: @inspiration\n end", "def destroy\n @atracao = Atracao.find(params[:id])\n @atracao.destroy\n\n respond_to do |format|\n format.html { redirect_to atracaos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @respuestum.destroy\n respond_to do |format|\n format.html { redirect_to comentarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @atencion.destroy\n respond_to do |format|\n format.html { redirect_to atencions_url, notice: 'Atencion eliminada satisfactoriamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @indication_for_meal.destroy\n respond_to do |format|\n format.html { redirect_to indication_for_meals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @habito.destroy\n respond_to do |format|\n format.html { redirect_to index_habito_path(params[:paciente_id]), notice: 'Se elimino el registro' }\n format.json { head :no_content }\n end\n end", "def destroy\n @advocacy = Advocacy.find(params[:id])\n @advocacy.destroy\n\n respond_to do |format|\n format.html { redirect_to advocacies_url }\n format.json { head :ok }\n end\n end", "def destroy\n @candidato = Candidato.find(params[:id])\n @candidato.destroy\n\n respond_to do |format|\n format.html { redirect_to candidatos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidato = Candidato.find(params[:id])\n @candidato.destroy\n\n respond_to do |format|\n format.html { redirect_to candidatos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dental = Dental.find(params[:id])\n @dental.destroy\n\n respond_to do |format|\n format.html { redirect_to dentals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @unidad.destroy\n respond_to do |format|\n format.html { redirect_to unidades_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @sivic_contabanco.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_contabancos_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @actividad = Actividad.find(params[:id])\n @actividad.destroy\n\n respond_to do |format|\n format.html { redirect_to actividads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @institucional = Institucional.find(params[:id])\n @institucional.destroy\n\n respond_to do |format|\n format.html { redirect_to institucionals_url }\n format.json { head :ok }\n end\n end", "def destroy\n @accesorio = Accesorio.find(params[:id])\n @accesorio.destroy\n\n respond_to do |format|\n format.html { redirect_to accesorios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @antropo.destroy\n respond_to do |format|\n format.html { redirect_to antropos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aluno.destroy\n respond_to do |format|\n format.html { redirect_to alunos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @observacao_vocacionada = ObservacaoVocacionada.find(params[:id])\n @observacao_vocacionada.destroy\n\n respond_to do |format|\n format.html { redirect_to observacao_vocacionadas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aucrecord.destroy\n respond_to do |format|\n format.html { redirect_to aucrecords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @annex = Annex.find(params[:id])\n @annex.destroy\n\n respond_to do |format|\n format.html { redirect_to annexes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datoscontacto = Datoscontacto.find(params[:id])\n @datoscontacto.destroy\n\n respond_to do |format|\n format.html { redirect_to datoscontactos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @colegio = Colegio.find(params[:id])\n @colegio.destroy\n\n respond_to do |format|\n format.html { redirect_to colegios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @odontologia1 = Odontologia1.find(params[:id])\n @odontologia1.destroy\n\n respond_to do |format|\n format.html { redirect_to odontologia1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asistencia_domingo.destroy\n respond_to do |format|\n format.html { redirect_to asistencia_domingos_url, notice: 'Asistencia domingo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @representante_athlete = Representante::Athlete.find(params[:id])\n @representante_athlete.destroy\n\n respond_to do |format|\n format.html { redirect_to representante_athletes_url, notice: 'Atleta apagado com sucesso' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cargo_eleicao = CargoEleicao.find(params[:id])\n @cargo_eleicao.destroy\n\n respond_to do |format|\n format.html { redirect_to cargo_eleicaos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @anuncio = current_user.anuncios.find(params[:id])\n @anuncio.destroy\n \n respond_to do |format|\n format.html { redirect_to anuncios_url, notice: 'Anuncio excluido.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @adquisicione.destroy\n respond_to do |format|\n format.html { redirect_to adquisiciones_url, notice: 'Adquisicione was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @competency_pertenece_asignatura = CompetencyPerteneceAsignatura.find(params[:id])\n @competency_pertenece_asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to competency_pertenece_asignaturas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @atencion.destroy\n respond_to do |format|\n format.html { redirect_to atenciones_url, notice: 'Atencion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @occasion.destroy\n respond_to do |format|\n format.html { redirect_to occasions_url, notice: 'Occasion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evento = Evento.find(params[:id])\n @comentarios = Comentario.where(:comentavel_id => @evento.id).order('created_at DESC')\n\n if @comentarios\n @comentarios.delete_all\n end\n @evento.destroy\n\n respond_to do |format|\n format.html { redirect_to eventos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @anio.destroy\n respond_to do |format|\n format.html { redirect_to anios_url, notice: 'Anio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignacion_familiar.destroy\n respond_to do |format|\n format.html { redirect_to asignacion_familiars_url, notice: 'Asignacion familiar eliminada exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @accidente.destroy\n respond_to do |format|\n format.html { redirect_to accidentes_url, notice: 'Accidente was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expediente = Expediente.find(params[:id])\n @expediente.destroy\n\n respond_to do |format|\n format.html { redirect_to expedientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @inventario_cosa.destroy\n respond_to do |format|\n format.html { redirect_to inventario_cosas_url, notice: 'Inventario cosa was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @sivic_alunoaula.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_alunoaulas_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n if @diet.destroy\n head :no_content, status: 200\n else\n render json: @diet.errors, status: 405\n end\n end", "def destroy\n @dis_alcohol_interaction.destroy\n respond_to do |format|\n format.html { redirect_to dis_alcohol_interactions_url, notice: 'Combination dose was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @capacitacion = Capacitacion.find(params[:id])\n @capacitacion.destroy\n\n respond_to do |format|\n format.html { redirect_to capacitacions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n \n @lancamentorapido = Lancamentorapido.find(params[:id])\n @lancamentorapido.destroy \n\n respond_to do |format|\n format.html { redirect_to lancamentorapidos_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @sindicato.destroy\n respond_to do |format|\n format.html { redirect_to sindicatos_url, notice: 'Sindicato fue eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @adotando_animal = AdotandoAnimal.find(params[:id])\n @adotando_animal.destroy\n\n respond_to do |format|\n format.html { redirect_to adotando_animais_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7584859", "0.7107488", "0.69920623", "0.6938006", "0.68970776", "0.68573004", "0.68464035", "0.68457973", "0.6844119", "0.6829674", "0.6827674", "0.6827197", "0.68189293", "0.68072635", "0.67916226", "0.67914766", "0.6785067", "0.67733", "0.67674804", "0.67585856", "0.6753205", "0.6750718", "0.67452824", "0.67389894", "0.6733627", "0.6721717", "0.6718493", "0.67176646", "0.67151606", "0.67123", "0.6708942", "0.6699174", "0.6694238", "0.66920936", "0.6689442", "0.66890395", "0.6685133", "0.6672903", "0.6662886", "0.6662036", "0.6649901", "0.664903", "0.66481644", "0.6644288", "0.66430646", "0.6642756", "0.66341364", "0.66341364", "0.6632432", "0.6632135", "0.6631192", "0.6628646", "0.6627874", "0.6626199", "0.66167974", "0.66162616", "0.6615405", "0.6614439", "0.6613837", "0.6605919", "0.66057044", "0.6605324", "0.6603787", "0.6599838", "0.6599838", "0.6599163", "0.6598213", "0.6598143", "0.659741", "0.6587683", "0.65853024", "0.6583846", "0.6580617", "0.6580102", "0.6579495", "0.6579228", "0.65761447", "0.65741366", "0.6572736", "0.6571609", "0.6570174", "0.6569422", "0.6569399", "0.6569252", "0.6567125", "0.65669256", "0.65666425", "0.6564406", "0.65630907", "0.65620065", "0.65601724", "0.6559721", "0.6558934", "0.65579987", "0.6555308", "0.65505177", "0.65494514", "0.65493435", "0.6548713", "0.65474135" ]
0.7483473
1
Use callbacks to share common setup or constraints between actions.
def set_descuento_adicional @descuento_adicional = DescuentoAdicional.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def descuento_adicional_params params.require(:descuento_adicional).permit(:descuento_adicional, :detalle) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def filtering_params\n params.permit(:email)\n end", "def active_code_params\n params[:active_code].permit\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def filter_parameters; end", "def filter_parameters; end", "def list_params\n params.permit(:name)\n end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.6981606", "0.6784227", "0.6746523", "0.67439264", "0.67361516", "0.6593381", "0.6506166", "0.64994407", "0.6483518", "0.64797056", "0.64578557", "0.6441216", "0.63811713", "0.63773805", "0.6366333", "0.63217646", "0.6301816", "0.63009787", "0.6294436", "0.62940663", "0.6292164", "0.62917984", "0.62836355", "0.6242686", "0.6241917", "0.62210834", "0.6214862", "0.62125784", "0.619428", "0.617912", "0.617705", "0.61735916", "0.6163706", "0.61532795", "0.6152666", "0.6148062", "0.6123372", "0.61180484", "0.61088324", "0.6106139", "0.60925204", "0.608326", "0.60711503", "0.606551", "0.60216546", "0.6018924", "0.6015004", "0.60106766", "0.6008301", "0.6008301", "0.60028726", "0.60020626", "0.5999236", "0.59931505", "0.5993037", "0.59917194", "0.5982164", "0.5968051", "0.5960277", "0.5960268", "0.5960012", "0.59594494", "0.5954652", "0.5954304", "0.59440255", "0.59404963", "0.59404963", "0.59401006", "0.593522", "0.5932182", "0.5925528", "0.5924541", "0.5918796", "0.59123147", "0.5910144", "0.5909186", "0.5907257", "0.5899382", "0.5897783", "0.58972496", "0.58958495", "0.58948576", "0.5892734", "0.5888056", "0.58843875", "0.58818483", "0.5873746", "0.58700997", "0.5870056", "0.5869255", "0.58668107", "0.58662325", "0.5865003", "0.5862908", "0.5862406", "0.58614665", "0.5859661", "0.585562", "0.5855185", "0.58523446", "0.58504915" ]
0.0
-1
this will be useful if we want to `puts params` in the server log
def to_s @params.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def output_debug(params)\n Rails.logger.debug(\"\\n\\n\\n\\n------------------------------------------------\\n\")\n Rails.logger.debug(params.inspect)\n Rails.logger.debug(\"\\n------------------------------------------------\\n\\n\\n\\n\")\n end", "def log_request\n logger.info \"HTTP request received => #{request.fullpath} , params => #{params} \"\n end", "def p(params)\n MyLogger.info params\nend", "def collectd\n logger.info(params.inspect)\n end", "def log_params\n params[:log]\n end", "def log_request\n # REQUEST_LOG.info( {\n # time: Time.now.to_s,\n # ip: request.remote_ip,\n # path: request.path,\n # site: request.host,\n # user_agent: request.user_agent,\n # params: (request.request_parameters.blank? ? request.query_parameters : request.request_parameters),\n # device: sub_group_type,\n # referer_header: referer,\n # current_page_header: current_page,\n # landing_url_header: land_url,\n # visitor_id_header: request.env['HTTP_VISITOR_ID'],\n # session_id_header: request.env['HTTP_SESSION_ID'],\n # visitor_id: visitor_id,\n # session_id: session_id,\n # params: params\n # } )\n end", "def request_log(request); end", "def log_params()\n lparms = @parameters.clone if @parameters\n lparms = {} unless lparms\n lparms[:cur_host] = @host\n lparms[:cur_port] = @port\n lparms[:cur_login] = @login\n lparms[:cur_passcode] = @passcode\n lparms[:cur_ssl] = @ssl\n lparms[:cur_recondelay] = @reconnect_delay\n lparms[:cur_parseto] = @parse_timeout\n lparms[:cur_conattempts] = @connection_attempts\n lparms[:cur_failure] = @failure # To assist in debugging\n lparms[:openstat] = open?\n #\n lparms\n end", "def log_request(req)\n message = [req.remote_ip, req.command, req.args.join(' ')].join(' ')\n log.info(message)\n end", "def printparams\r\n return if @@params.empty?\r\n @@params.each {|key, value| puts \"#{key} : #{value}\" }\r\n end", "def log_event(params)\n puts \"Log Details:\"\n puts \"<====================>\"\n puts \"Event Type: #{params['event']}\"\n puts \"Recepient: #{params['recipient']}\"\n puts \"City: #{params['city']}\"\n puts \"Country: #{params['country']}\"\n puts \"Client Type: #{params['client-type']}\"\n puts \"Client Name: #{params['client-name']}\"\n puts \"Device Type: #{params['device-type']}\"\n puts \"Client OS: #{params['client-os']}\"\n puts \"Url Clicked: #{params['url']}\" if params['event'] == \"clicked\"\n puts \"Logged at: #{Time.at(params['timestamp'].to_i).utc.to_datetime}\"\n puts \"<====================>\"\n end", "def log_params\n params.require(:log).permit(:class_name, :method_name, :hash_parms)\n end", "def __log(method, path, params, body, url, response, json, took, duration)\n logger.info \"#{method.to_s.upcase} #{url} \" +\n \"[status:#{response.status}, request:#{sprintf('%.3fs', duration)}, query:#{took}]\"\n logger.debug \"> #{__convert_to_json(body)}\" if body\n logger.debug \"< #{response.body}\"\n end", "def log _args\n \"log _args;\" \n end", "def print_parameters()\n @params.each do |clave, valor|\n #$LOG.debug \"The Parameter #{clave} have the value \" +valor.to_s\n puts \"#{clave} = #{valor} \"\n end\n end", "def log_request_info(env, req_id)\n query_string = \"?#{env.url.query}\" if env.url.query\n size = env.body.respond_to?(:size) ? env.body.size : env.request_headers['Content-Length']\n info { \"{#{req_id}} [OUT] #{env.method} #{env.url.path}#{query_string} (#{size || 0})\" }\n end", "def history_log_params\n end", "def log(msg, meta = {})\n puts \"#{msg} --- #{meta}\"\nend", "def log_event(event, params)\n end", "def log_params\n params.permit(:macaddress, :secret_key, :log_file, :page)\n end", "def debugLog _args\n \"debugLog _args;\" \n end", "def log(*args); end", "def append_info_to_payload(payload)\n super\n request_logging_context_data.each do |key, value|\n payload[key] = BlackSquareLoggingRails.format_value(value)\n end\n\n # Add request parameters to lograge output when the logger is in DEBUG mode\n if BlackSquareLoggingRails.enable_request_parameter_logging\n parameters = request.filtered_parameters.except(*ActionController::LogSubscriber::INTERNAL_PARAMS)\n payload[:request_params] = BlackSquareLoggingRails.format_value(parameters) if parameters.any?\n end\n end", "def error_log_params\n params[:error_log]\n end", "def zt_log *args\n if args.length == 0\n File.open(ZT_LOG_FILE, 'a') { |file_log| file_log.puts \"#{zt_timestamp} #{params[:controller]}##{params[:action]} - no arguments\"}\n else\n file_log = File.open(ZT_LOG_FILE, 'a') # Opens file\n file_log.puts \"#{zt_timestamp} #{params[:controller]}##{params[:action]}:\" # Writes controller#action\n\n # Writes all arguments to ...\n args.each_with_index do |arg, index|\n file_log.puts \"arg[#{index}]: #{arg.inspect}\" # ... zt.log\n puts \"arg[#{index}]: #{arg.inspect}\" # ... console\n# logger.debug \"arg[#{index}]: #{arg.inspect}\" # ... console & development.log\n end\n file_log.close #Closes file\n end\n end", "def log(type, msg, meta=nil)\n post type, msg, meta\n end", "def debug\n \tputs \"session is:\" + session.inspect\n\tputs \"params are:\" + params.inspect\n end", "def log_params\n params.require(:log).permit(:msg)\n end", "def log (msg, **kwargs) Log.write(msg, :info, kwargs) end", "def log(params_hash = {})\n begin\n raise_error_unless_params_is_a_hash(params_hash)\n request.method = :get\n request.uri = \"_log#{querystring(params_hash)}\"\n Couchdbtools.execute(request)\n rescue Exception => exception\n exception.message\n end\n end", "def print_parameters()\n @h.each do |clave, valor|\n \n $LOG.debug \"The Parameter #{clave} have the value \" +valor.to_s\n end\n end", "def log(msg)\n Serv::Log.info(Time.now.to_s+': '+msg+\"\\n\")\n end", "def log_request\n \"#{request.ip} - #{session[:login] ? session[:login].name : '-'} [#{Time.now.strftime('%d/%m/%Y:%H:%M:%S %z')}] \\\"#{request.request_method} #{request.path} HTTP\\\" #{response.status} #{response.content_length} #{timer.stop(request.object_id).round(3)}\"\n 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 log(path)\n case path\n when *Global.boring\n else\n Log.info(\"Dynamic request from #{request.ip}: #{request.request_uri}\")\n end\n end", "def log(*args)\n\t\t\trouter.log(*args)\n\t\tend", "def log_request_debug(env, req_id)\n debug { \"{#{req_id}} [OUT] #{env.body}\" }\n end", "def user_log_params\n params[:user_log]\n end", "def log_sql(query, params = {})\n if @debug\n message = \"#{colorize(\"[#{@name}]\", :cyan)} #{query.gsub(/\\s+/, \" \").strip}\"\n message = \"#{message} #{params.inspect}\" if params.any?\n log message\n end\n end", "def log_params\n params.fetch(:log, {}).permit(\n :cat_id, :feed_id, :fed_at\n )\n end", "def log(*args)\nend", "def log(*args)\n puts *args\n end", "def log(msg)\n puts msg if @verbose\n end", "def log(msg)\n puts msg if @verbose\n end", "def log(type='Log', text)\n puts \"[#{type}] #{text}\"\n submit_log(LOG_HOST, LOG_PORT, type, text)\nend", "def log(arg1, arg2, *rest); end", "def info(msg) log(6, msg); end", "def grid_rest_log(method, url, rparams = {}, emsg = \"\")\n if current_namespace\n return unless GridRest.grid_config.namespaces[current_namespace]['logging']\n else\n return unless GridRest.grid_config['logging']\n end\n grid_rest_log_message(rparams.any? ? \"#{Time.now.to_s(:db)} #{method.to_s.upcase} #{url} with #{rparams.inspect} #{emsg}\" : \"#{Time.now.to_s(:db)} #{method.to_s.upcase} #{url} #{emsg}\")\n end", "def log_params\n params.require(:log).permit(:date_of_session, :time_of_sesion, :details, :reference_code, :client_code, :iname)\n end", "def log(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"log \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end", "def append_info_to_payload(payload)\n super\n payload[\"params\"] = request.params\n end", "def append_info_to_payload(payload)\n super\n payload[\"params\"] = request.params\n end", "def log(msg)\n puts msg\n end", "def log(*_args)\n end", "def log\n end", "def debug_params\n params.require(:debug).permit(:log, :user)\n end", "def access_logger\n Rails.application.config.another_logger.info(\"#{request.method} '#{request.path}' #{request.version} from: #{request.remote_ip}\")\n end", "def debug_log( arg )\r\n print('DEBUG: ')\r\n puts (arg)\r\nend", "def info_msg(msg)\n @log.puts(msg)\n puts msg\nend", "def log_request\n ServerRequestLog.create! default_log_hash\n end", "def log_request_begin(logger, env)\n # Assuming remote addresses are IPv4, make them all align to the same width\n remote_addr = env['HTTP_X_FORWARDED_FOR'] || env[\"REMOTE_ADDR\"] || \"-\"\n remote_addr = remote_addr.ljust(15)\n\n # Log the fact that a query string was present, but do not log its contents\n # because it may have sensitive data.\n if (query = env[\"QUERY_STRING\"]) && !query.empty?\n query_info = '?...'\n else\n query_info = ''\n end\n\n # Session\n if env['global_session']\n cookie = env['global_session']\n info = [ env['global_session'].id,\n cookie.keys.map{|k| %{\"#{k}\"=>\"#{cookie[k]}\"} }.join(', ') ]\n sess = %Q{Session ID: %s Session Data: {%s}} % info\n else\n sess = \"\"\n end\n\n shard_info = 'Shard: ' + (env['HTTP_X_SHARD'] || 'default').to_s + ';'\n\n params = [\n env[\"REQUEST_METHOD\"],\n env[\"PATH_INFO\"],\n query_info,\n remote_addr,\n sess,\n shard_info,\n env[\"rack.request_uuid\"] || ''\n ]\n\n logger.info %Q{Processing %s \"%s%s\" (for %s) %s %s Request ID: %s} % params\n end", "def log(msg)\n puts\n puts msg\nend", "def params() request.params end", "def log_http_call(payload); end", "def log_http_call(payload); end", "def logger_info\n {\n :url => url,\n :body => body.inspect\n }\n end", "def create_log(param); end", "def log_requests(which = T.unsafe(nil)); end", "def log_params\n params.require(:log).permit(:uniqid, :contact_id, :log_type, :time, :duration, :device_id, :device_imei, :contact_number)\n end", "def debug(message) ; @log.debug(message) ; end", "def log(message)\n puts message\n end", "def debug_begin_request\n str = <<END\n ~ Start: #{Time.now}\n ~ Params: #{params.inspect}\n ~ Session: #{session.instance_variable_get(:@data).inspect}\nEND\n @__start_action_time = Time.now\n puts str\n 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 log_params\n params.require(:log).permit(:user_id, :action, :content)\n end", "def log_http_request(request)\n log :info, \"Starting request: #{request.method} #{request.path}\"\n\n return unless log_debug?\n\n log :debug, \" body : #{request.body}\"\n log :debug, \" headers :\"\n request.each_header do |name, value|\n log :debug, \" #{name}: #{value}\"\n end\n end", "def info_request(*args)\n info args.join(' ')\n end", "def debug(msg) log(7, msg); end", "def verbosity(conn, method, *args)\n return unless noop || verbose\n log format('uri: %s %s', method.upcase, conn.url_prefix)\n\n return unless args.last && !args.last.empty?\n\n log method == :get ? \"params: #{args.last}\" : \"body: #{args.last}\"\n end", "def logs\n\n end", "def p(arg)\n NSLog arg.inspect\n end", "def write( message )\n\t\t\tApache.request.server.log_debug( message )\n\t\tend", "def log_params\n p = params.require(:log).permit(:type, :team_id, :time, :user_id, :client, :log_type, :deleted, :point, :data, :gen)\n if !p.has_key?(:type)\n # add the type if not present; this can be from an old app\n p.merge!({ type: 'TeamLog' })\n else\n p\n end\n end", "def log(message); logger.info(message); end", "def info(msg); @logger.info(msg); end", "def _roda_after_90__common_logger(result)\n return unless result && result[0] && result[1]\n\n env = @_request.env\n\n qs = env[\"QUERY_STRING\"]\n query_string = \"?#{ qs }\" unless qs.empty?\n\n length = result[1][\"Content-Length\"]\n length = \"\" if length == \"0\"\n\n LOGGER.request \"#{ env['HTTP_X_FORWARDED_FOR'] || env['REMOTE_ADDR'] || '-' } - \\\"#{ env['REQUEST_METHOD'] } #{ env['SCRIPT_NAME'] }#{ env['PATH_INFO'] }#{ query_string } #{ env['HTTP_VERSION'] }\\\" #{ result[0] } #{ length }\\n\"\n end", "def log_metric_params\n params.fetch(:log_metric, {})\n end", "def encode_params(log_msg)\n params_patterns = \"(#{ENCODE_PARAMS.join('|')})=\\\\w+\"\n log_msg.gsub(Regexp.new(params_patterns)) { |match| hide_value(match).to_s }\n end", "def action_log_params\n params.require(:action_log).permit(:user_id, :target_user, :do_user, :infomation, :log_type, :description)\n end", "def echo(params)\n params\n end", "def log(s)\n puts \"[Debug]: #{s}\"\nend", "def log(s)\n puts \"[Debug]: #{s}\"\nend", "def logs\n end", "def params\n '(%s)' % @format\n end", "def log_load_time_params\n params.fetch(:log_load_time, {})\n end" ]
[ "0.75409245", "0.75017816", "0.72487843", "0.70113087", "0.7004724", "0.67856485", "0.676497", "0.6665338", "0.66461235", "0.6624847", "0.65805256", "0.6577461", "0.6563905", "0.65606695", "0.6515263", "0.64926493", "0.64505297", "0.6413419", "0.640959", "0.6376653", "0.63758934", "0.6346325", "0.6340058", "0.6332078", "0.63309187", "0.63211846", "0.63164324", "0.62600124", "0.6250525", "0.6243115", "0.62337255", "0.62154835", "0.6200924", "0.61955726", "0.61955726", "0.61955726", "0.61955726", "0.61955726", "0.61955726", "0.61955726", "0.61955726", "0.61947876", "0.6193437", "0.6168386", "0.6157407", "0.6150694", "0.61494994", "0.6136107", "0.6128231", "0.61231583", "0.61231583", "0.6117024", "0.61051506", "0.61008334", "0.60936314", "0.60927707", "0.6090387", "0.6076926", "0.6076926", "0.60669476", "0.6029178", "0.6027946", "0.6027546", "0.6026945", "0.6024351", "0.60199916", "0.6013365", "0.59884745", "0.5988038", "0.5984001", "0.5979553", "0.5979553", "0.5978907", "0.597211", "0.59672195", "0.59536606", "0.59142554", "0.5912448", "0.59058535", "0.58969104", "0.5895576", "0.58952904", "0.58943325", "0.58934045", "0.5890534", "0.58904827", "0.589016", "0.5876904", "0.58754194", "0.5865014", "0.58635575", "0.58625066", "0.58500403", "0.58500093", "0.5847491", "0.5841121", "0.58410686", "0.58410686", "0.5806374", "0.57996416", "0.57994926" ]
0.0
-1
this should return an array user[address][street] should return ['user', 'address', 'street']
def parse_key(key) key.gsub(/(\[|\])/, " ").split(/\s+/) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_user_data(users, username)\n user_array = []\n users.each do |user|\n if user['username'] == username\n user_array << user['name']\n user_array << user['username']\n user_array << user['password']\n user_array << user['admin']\n end\n end\n return user_array\nend", "def extract_user_emails(user_fields, client)\n user_emails = []\n user_fields.each_index do |row|\n user_emails.push(user_fields[row][0])\n end\n user_emails\nend", "def user_keys\n all_keys = params[:user].keys\n all_keys.collect do |key|\n next if key == \"addresses_attributes\"\n key\n end\n end", "def address_keys\n address_attr = params[:user][\"addresses_attributes\"].values\n address_attr[0].keys\n end", "def addresses(tenantArr)\n tenantArr.each do |tenant|\n #puts tenant[:name]\n end\n end", "def get_name_and_location\n @top_ten.each do |user|\n user_details = self.class.get(\"/users/#{user[0]}\").parsed_response\n user << user_details[\"name\"]\n user << user_details[\"location\"]\n end\n end", "def addresses(aptArr)\n aptArr.each do |apt|\n #puts apt[:address]\n end\n end", "def getTaxAddress property\n\t\tarr = []\n\t\taddray = property[:taxAddr].split\n\t\tarr << (addray[0...-3].join \" \")\n\t\tarr << addray[-3]\n\t\tarr << addray[-2]\n\t\tarr << addray[-1]\n\t\tarr << property[:owns]\n\t\tarr << property[:owner]\n\t\tarr\n\tend", "def find_user (map)\n user = []\n for i in 0..map.length-1\n for j in 0..map.length-1\n if map[i][j] == \" U \"\n user = [i,j]\n end\n end\n end\n user\n end", "def users\n @users.each_key.to_a\n end", "def get_users_a\n\n return [] if self.users.nil? or self.users.empty?\n\n array = self.users.split('|')\n array.compact!\n array.delete('')\n\n return array\n end", "def get_biz_names_addresses_coordinates\n @request_businesses.shift(2).map{|business|{name: business[\"name\"], address: business[\"vicinity\"], latitude: business[\"geometry\"][\"location\"][\"lat\"], longitude: business[\"geometry\"][\"location\"][\"lng\"]}}\n end", "def get_users\n username_array = []\n con = get_connection()\n usernames = con.exec \"SELECT username FROM hashes\"\n usernames.each do |name|\n username_array[username_array.length] = name['username']\n end\n return username_array\nend", "def return_this(user_id)\n return_this = []\n converts_result_hash_into_array(user_id).each do |i|\n return_this << (i[0] + \" -- \" + i[1])\n end\nreturn return_this\nend", "def users\n result_hash['usr']\n end", "def get_array(element, path='.')\n return unless element\n \n result = element/path\n if (result.is_a? Nokogiri::XML::NodeSet) || (result.is_a? Array)\n result.collect { |item| self.get(item) }\n else\n [self.get(result)]\n end\n end", "def build_hash(emails, first_names, last_names)\n deputies_array = []\n\n emails.each_with_index do |email, index|\n deputy_hash = {}\n deputy_hash['first_name'] = first_names[index]\n deputy_hash['last_name'] = last_names[index]\n deputy_hash['email'] = email\n deputies_array << deputy_hash\n end\n\n deputies_array\nend", "def keys(key)\n Array(@nesting) + Array(key)\n end", "def extract_user_object_attributes(users)\n arr = users.inject([]) do |a, user|\n u = HashWithIndifferentAccess.new(user)\n a << u.slice(*USER_ATTRIBUTES)\n end\n\n return arr\n end", "def user_ids \n @user_ids ||= input[\"users\"].map{|user| user[\"id\"]}\nend", "def get_user_bracket(url)\n\n\nend", "def dot_key_array\n return ['label', 'label and hint','message','message error', 'message info','message success','message warning','model','model and menu','action', 'lookup']\n end", "def get_users input\n\t\t@users[input]\n\tend", "def user_data_as_array(key)\n val = ec2_user_data(key)\n if !val || val.empty?\n val = []\n elsif !val.is_a?(Array)\n val = [val]\n end\n\n val\n end", "def show_address_fields(user, company)\n\n all_fields = [ { name: 'street_address', label: 'street', method: nil },\n { name: 'post_code', label: 'post_code', method: nil },\n { name: 'city', label: 'city', method: nil },\n { name: 'kommun', label: 'kommun', method: 'name' },\n { name: 'region', label: 'region', method: 'name' } ]\n\n if user.admin? || user.is_in_company_numbered?(company.company_number)\n return all_fields, true\n else\n start_index = all_fields.find_index do |field|\n field[:name] == company.address_visibility\n end\n\n if start_index\n return all_fields[start_index..4], false\n else\n return nil, false\n end\n end\n end", "def profile_info_items(user)\n occupation = [\"Occupation\", user.occupation]\n company = [\"Company\", user.company]\n location = [\"Location\", user.location]\n birthday = [\"Birthday\", user.birthday? ? user.birthday.strftime(\"%m/%d/%Y\") : nil]\n [ occupation, company, location, birthday ]\n end", "def users\n recipes.map {|recipe| recipe.user}\n end", "def retrieveaddressnameskey(fileonedata)\n arr = Array.new\n fileonedata.each_line.with_index do |single_line, index|\n arr.push(single_line.split[0]) if (single_line.split[5] && index>20)\n end\n return arr\n end", "def users\n return @users_array\n \tend", "def address_ret(res_name)\n # id = res_name[:id]\n separate\n name = res_name[:name]\n address1 = res_name[:location][:city]\n address2 = res_name[:location][:state]\n return \"The location of #{name} is #{address1}, #{address2}\"\nend", "def get_names(instructors)\n instructors.map do |instructor|\n instructor[:name]\n end\nend", "def full_address_array\n [name, address1, address2, city_state_zip].compact\n end", "def full_address_array\n [name, address1, address2, city_state_zip].compact\n end", "def users\n @circle.keySet.to_a\n end", "def get_names(instructors)\n # map will return a new array with the same number of elements\n instructors.map do |instructor_hash|\n # we want to return JUST the name\n instructor_hash[:name]\n end\nend", "def parse_user_info(node)\n return nil if node.nil?\n {}.tap do |hash|\n node.children.each do |e|\n unless e.kind_of?(Nokogiri::XML::Text) || e.name == 'proxies'\n # There are no child elements\n if e.element_children.count == 0\n if hash.has_key?(e.name)\n hash[e.name] = [hash[e.name]] if hash[e.name].is_a? String\n hash[e.name] << e.content\n else\n hash[e.name] = e.content\n end\n elsif e.element_children.count\n # JASIG style extra attributes\n if e.name == 'attributes'\n hash.merge!(parse_user_info(e))\n else\n hash[e.name] = [] if hash[e.name].nil?\n hash[e.name] = [hash[e.name]] if hash[e.name].is_a? String\n hash[e.name].push(parse_user_info(e))\n end\n end\n end\n end\n end\n end", "def get_nicknames_and_names(users)\n list = []\n users.each do |user|\n list.push({ :nickname => get_nickname(user), :name => get_name(user) })\n end\n \n return list\n end", "def _get_array(sp, key)\n return self[key] if sp.length == 0\n\n if key.is_a?(Range)\n res = []\n self[key].each do |k|\n next unless k.structured?\n res << k.rh_get(sp) if k.rh_exist?(sp)\n end\n res\n else\n self[key].rh_get(sp) if self[key].structured?\n end\n end", "def readinformation student\n [student[:firstname], student[:lastname], student[:course]]\nend", "def hash_flatten prefix, value\n if value.is_a? Hash\n value.flat_map do |k, v|\n key = prefix.empty? ? k : [prefix, k].join('.')\n hash_flatten(key, v)\n end\n else\n [[prefix, value]]\n end\nend", "def build_addresses(v)\n # only create on address\n if v.kind_of? Hash\n return [Address.new(v)]\n # create multiple addresses\n elsif v.kind_of? Array\n # todo: multiple addresses\n end\n end", "def context_customer_emails(context)\n context = JSON.parse(context)\n customer_emails = context['context']['environment']['customer']['emailAddresses']\n customer_emails = customer_emails.map {|x| x[\"value\"]}\nend", "def get_townhall_email(townhall_url)\r\n page = get_page(townhall_url)\r\n email = page.xpath('//*[contains(text(), \"@\")]').text\r\n town_name = page.xpath('//*[contains(text(), \"Adresse mairie de\")]').text.split #nom de ville\r\n email_array_one_hash = [{town_name[3] => email}] #nom\r\n return email_array_one_hash\r\nend", "def all_users\n return [] if @json_data['users'].nil?\n @json_data['users'].collect { |user| [user['first'], user['last']].join(' ') }\n end", "def names_mails\n mail_array = depute_mail\n names_array = names\n a = []\n\n names_array.each_with_index do |x, y|\n a << {x => (mail_array) [y]}\n end\n \n puts a\n return a\nend", "def team_names\n # team_array = []\n # team_array.push(game_hash[:home][:team_name])\n # team_array.push(game_hash[:away][:team_name])\n # team_array\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def address_array(visibility_limit = visibility)\n return [] if visibility_limit == self.class.no_visibility\n\n start_index = self.class.visibility_items.index { |viz_item| viz_item == visibility_limit }\n return [] unless start_index\n\n viz_items_length = self.class.visibility_items.length\n\n # Create the array with the actual values of the address.\n # Add in the kommun name if there is one for the address.\n if kommun\n ary = [street_address, post_code, city, kommun.name,\n sverige_if_nil][start_index..viz_items_length]\n else\n ary = [street_address, post_code, city,\n sverige_if_nil][start_index..(viz_items_length - 1)]\n end\n ary.delete_if { |f| f.blank? }\n end", "def user\n {\n id: object.user.id,\n email: object.user.email,\n birthday: object.user.birthday,\n first_name: object.user.first_name,\n middle_name: object.user.middle_name,\n last_name: object.user.last_name,\n phone: object.user.phone,\n gender: object.user.gender,\n neighborships: object.user.neighborships\n }\n end", "def get_contact_info_array\n rtn = []\n rtn << get_attr(:name)\n rtn << [:provided_by, self.provider.name] # Special case, as the symbol doesn't match the attribute\n rtn << get_attr(:phone)\n rtn << get_attr(:email)\n rtn << get_attr(:url)\n end", "def get_user_collection_fields(username)\n query_and_build \"users/#{username}/collection/fields\"\n end", "def users\n self.triples.map(&:first)\n end", "def index\n @user_addresses = current_user.user_addresses\n end", "def getHash(restid)\n # get all ordered items of users who ordered in restaurant \"restid\"\n userItems=OrderMng.getAllUsersItemsByRestID(restid)\n # userItems=Hash[userItems.map.with_index { |value, index| [index, value] }]\n return userItems\nend", "def joinData(arr)\n return data = {\"rusr\" => arr[0][1..-1].split(\"!\")[0], \"raddress\" => arr[0].split(\"!\")[1], \"type\" => arr[1], \"where\" => arr[2][1..-1]}\n end", "def get_target_users\n\n users = []\n\n self.get_orders.each do |user_hash|\n\n user_ids = user_hash.keys\n\n users = users + user_ids unless user_ids.nil?\n end\n\n users.compact!\n\n return users\n end", "def usernames\n @attributes[:usernames]\n end", "def usernames\n @attributes[:usernames]\n end", "def curator_list\n users.map(&:email)\n end", "def [](user_name)\n all[user_name]\n end", "def user_data_from_results(res, username, key)\n users = res['users']\n users.each do |user|\n return user[key] if user['name'] == username\n end\n nil\n end", "def parse_user search\n Hash[*search.split(',').map{|pair| pair.split('=').values_at(0..1)}.flatten]['uid']\n end", "def index\n @users_and_address = {}\n @users.each do |user|\n @users_and_address[user] = user.has_role?(:doctor) ? Address.business_for(user) : Address.home_for(user)\n end\n end", "def players\n # players_array = []\n # iterating through game hash and returning a list of all my players\n game_hash.map do |key, value|\n value[:players]\n end.flatten\n\nend", "def get_key_from(field)\n return [] if Chef::Config[:solo] && !chef_solo_search_installed?\n return [] unless Chef::DataBag.list.key?('users')\n search('users', \"#{field}:*\").map do |v| # ~FC003 ignore footcritic violation\n Chef::Log.info \"ssh_server: installing ssh-keys for root access of user #{v['id']}\"\n v[field]\n end.flatten\nend", "def addresses(tenantArr)\n tenantArr.each do |tenant|\n if tenant[:age] > 44\n #puts tenant[:age]\n end\n end\n end", "def email_addresses_with_details(only_validated = false)\n\t\t# {'email@address'=>{:name=>'member name'},...}\n\t\t{}\n\tend", "def get_people(detail_page)\n first_table = detail_page.search('div#ctl00_MainBodyContent_group_17 table.ContentPanel')\n people_array = [] \n if first_table\n list_tr = first_table.search('tr')\n for i in 1..list_tr.length-1\n list_td = list_tr[i].search('td')\n people_obj = {}\n people_obj[:role] = clean_whitespace(list_td[0].inner_text)\n people_obj[:name] = clean_whitespace(list_td[1].inner_text)\n people_obj[:address] = clean_whitespace(list_td[2].inner_text)\n \n people_array << people_obj\n end\n else\n return \"\"\n end\n return people_array\nend", "def get_people(detail_page)\n first_table = detail_page.search('div#ctl00_MainBodyContent_group_17 table.ContentPanel')\n people_array = [] \n if first_table\n list_tr = first_table.search('tr')\n for i in 1..list_tr.length-1\n list_td = list_tr[i].search('td')\n people_obj = {}\n people_obj[:role] = clean_whitespace(list_td[0].inner_text)\n people_obj[:name] = clean_whitespace(list_td[1].inner_text)\n people_obj[:address] = clean_whitespace(list_td[2].inner_text)\n \n people_array << people_obj\n end\n else\n return \"\"\n end\n return people_array\nend", "def users\n user_arr = []\n accounts.each do |s|\n user_arr << User.find(s.user.id)\n end\n user_arr\n end", "def get_townhall_email(townhall_url)\n\tpage = Nokogiri::HTML(open(townhall_url)) \n\temail_array = []\n\n\temail = page.xpath('//*[contains(text(), \"@\")]').text\n town = page.xpath('//*[contains(text(), \"Adresse mairie de\")]').text.split \n# On divise la string pour pouvoir récupérer uniquement le nom de la ville\n\n email_array << {town[3] => email} \n# On indique la position du nom de la ville dans la string pour la récupérer\n\tputs email_array\n\treturn email_array\nend", "def filtered_user(raw_user)\n if raw_user['checkins'] && raw_user. checkins.items.count > 0\n recentCheckin = raw_user.checkins.items.first.venue.location\n else\n recentCheckin = {'lat' => nil, 'lng' => nil}\n end\n result = {\n 'id' => raw_user['id'],\n 'firstName' => (raw_user['firstName'] || \"\").gsub(/[^\\u0000-\\uFFFF]/, ''),\n 'lastName' => (raw_user['lastName'] || \"\").gsub(/[^\\u0000-\\uFFFF]/, ''),\n 'photo' => raw_user['photo'].to_hash,\n 'homeCity' => (raw_user['homeCity'] || \"\").gsub(/[^\\u0000-\\uFFFF]/, ''),\n 'superuser' => raw_user['superuser'],\n 'checkins' => {\n 'items' => [\n {\n 'venue' => {\n 'location' => {\n 'lat' => recentCheckin['lat'],\n 'lng' => recentCheckin['lng']\n }\n }\n }\n ]\n }\n }\n end", "def allergens\n users.map do |user_ob|\n #binding.pry\n user_ob.allergens.each do |allergen_ob|\n #binding.pry\n allergen_ob\n end\n end.flatten\nend", "def movies(user)\n\t\treturn @user_info[user].keys\t\n\tend", "def extract_name(students)\n student_names = []\n students.each do |student|\n student_names.push(student[:name])\n end\n return student_names\nend", "def get_recursive_array_from_params(params)\n return params if !params.kind_of?(Hash)\n resp = []\n params.each do |k, v|\n rec_ar = get_recursive_array_from_params(v)\n if rec_ar.kind_of?(Array)\n rec_ar.each do |r|\n if (r =~ /\\]/).nil?\n resp << \"#{k}[#{r.gsub('=', ']=')}\"\n else\n temp_string = r[(r =~ /\\[/) + 1, r.length]\n resp << \"#{k}[#{r[0, (r =~ /\\[/)]}][#{temp_string}\"\n end\n end\n else\n resp << \"#{k}=#{rec_ar}\"\n end\n end\n resp\n end", "def registered_usr\n name_arry =[ \"david\", \"haggai\", \"mark\"]\n return name_arry\n end", "def passwords\n @users.each_value.to_a\n end", "def expect_user_addresses(user)\n user.reload\n expect_selected(user.bill_address, :user, :bill)\n expect_selected(user.ship_address, :user, :ship)\n\n expect_list_addresses(user.addresses)\n end", "def value\n expand( address ).map { |ar| ar.map { |addr| data[ addr ] } }\n end", "def keys\n [:name, :username, :email, ]\n end", "def list_of_directors(source)\nrow_index = 0\narray =[]\nwhile row_index < source.length\n array << source[row_index][:name]\n row_index += 1\nend\narray\nend", "def getSlices\n broker_url = APP_CONFIG['broker_ip'] + ':' + APP_CONFIG['broker_port'].to_s\n result = HTTParty.get(broker_url + \"/resources/users?name=\"+current_user.name, :verify => false)\n user_slices = []\n if result.header.code == '200'\n temp = JSON.parse(result.body) \n user_data = temp[\"resource_response\"][\"resources\"]\n user_data.each do |element|\n element[\"projects\"].each do |slice|\n user_slices << slice[\"account\"][\"name\"]\n end\n end \n else\n temp = JSON.parse(result.body)\n if temp[\"exception\"][\"reason\"] == \"No resources matching the request.\"\n flash[:danger] = \"No resources matching the request. Please create a slice\"\n else\n flash[:danger] = \"Something went wrong !\"\n end\n end\n\n return user_slices\n end", "def user_array(user_data, game_data, index)\n\t\tis_button = game_data['state']['button'] == index\n\t\tis_active = game_data['state']['acting_player']['id'] == user_data['id']\n\t\tin_hand = game_data['state']['players_in_hand'].include?(user_data['id'])\n\t\tbet = game_data['state']['player_bets'][user_data['id'].to_s]\n\t\tall_in = user_data['bankroll'] == 0\n\t\tar = []\n\t\tar << \"#######\"\n\t\tar << \"##{user_data['name'][0,5].center(5)}#\"\n\t\tar << (is_button ? \"# B #\" : \"# #\")\n\t\tar << (all_in ? \"#ALLIN#\" : (is_active ? \"# Act #\" : \"#######\"))\n\t\tar << \"# Bet #\"\n\t\tar << (in_hand ? \"##{bet.to_s.center(5)}#\" : \"# Fold#\")\n\t\tar << \"#Stack#\"\n\t\tar << \"##{user_data['bankroll'].to_i.to_s.center(5)}#\"\n\t\tar << \"#######\"\n\tend", "def student_data_hash\n\n # turn data into 2 Dim array containing arrays of eles where delimiter is colon :\n clean_user_account_data = ruby_class_user_accounts.map { |x| x.split(/:/) }\n\n # turn data into a hash using 2 arrays for keys and values\n keys = %w[user_name password uid gid gcos_field home_directory login_shell]\n final_array_of_hashes = []\n\n clean_user_account_data.each do |account_data|\n hash = Hash.new\n keys.each_with_index { |item, index| hash[item] = account_data[index] }\n final_array_of_hashes << hash\n end\n final_array_of_hashes\n end", "def get_city_name(city_name)\n city_name.keys\nend", "def addresses\n Array(@addresses)\n end", "def generate_user_fields(user_params)\n return {:name => \"#{user_params[:firstname]} #{user_params[:lastname]}\",\n :email => user_params[:email],\n :password => user_params[:password],\n :college_id => College.find_by_name(user_params[:college]).id,\n :pending_school_id => user_params[:school],\n :pending_semester => user_params[:semester],\n :pending => 0,\n :profile => \"ambassador\" }\n end", "def get_values_from_locations_and_prices_hash(user_id)\n process_search(user_id).values\nend", "def complete_name_list\n #User.select(:name).map{|user_record| user_record.name}\n end", "def addresses(tenantArr)\n tenantArr.each do |tenant|\n if tenant[:apartment_id] == 1\n #puts tenant[:apartment_id]\n end\n end\n end", "def to_array\n [@name, @city]\n end", "def transform_users_json_to_array(users, queue)\n users.each do |user|\n begin\n ident = user[\"identities\"].select { |identity|\n identity[\"provider\"] == \"auth0\"\n }.first\n row = [\n user[\"email\"],\n user[\"email_verified\"],\n user[\"given_name\"],\n user[\"family_name\"],\n (ident[\"user_id\"] if ident)\n ]\n queue << row\n rescue StandardError => ex\n @logger.warn ex\n end\n end\n end", "def get_followers_from_tasks(tasks, array) #tasks == an array, array == an array\n tasks.each do |task|\n task[\"followers\"].each do |follower|\n #get user name based on user id\n user = JSON.parse(Typhoeus::Request.get(\"https://app.asana.com/api/1.0/users/\" + follower[\"id\"].to_s, userpwd: \"4tuQrdX.5djpapCXlKooicNrUgx0zbeY:\").body)\n array.push(user[\"data\"][\"name\"])\n end\n end\nend", "def to_array_form(external_ref_path)\n # TODO: use regexp disjunction\n external_ref_path.gsub(/^node\\[/, '').gsub(/^service\\[/, '').gsub(/\\]$/, '').split('][')\n end", "def get_array(key, values, level)\n content = ''\n content << \"#{key.to_s}[]=\"\n if values[0].is_a?(::Numeric)\n content << '{'\n values.each { |v|\n content << \"#{get_numeric(v)},\"\n }\n content.chomp!(',')\n content << \"};\\r\\n\"\n else\n content << \"\\r\\n\"\n level.times { content << \"\\t\"}\n content << \"{\\r\\n\"\n values.each { |v|\n (level + 1).times {content << \"\\t\"}\n content << \"\\\"#{v.to_s}\\\",\\r\\n\"\n }\n content.chomp!(\",\\r\\n\")\n content << \"\\r\\n\"\n level.times { content << \"\\t\"}\n content << \"};\\r\\n\"\n end\n content\n end", "def loners(people)\n lonely_array = []\n for person in people\n if person[:friends] == []\n lonely_array.push(person[:name])\n end\n end\n return lonely_array\nend", "def name_and_role\n instructors.map do |instructors_hash|\n {instructors_hash[:name] => instructors_hash[:role]}\n end\nend", "def nickservData(arr)\n return data = {\"rusr\" => arr[0][1..-1].split(\"!\")[0], \"raddress\" => arr[0].split(\"!\")[1], \"to\" => arr[2], \"usr\" => arr[3][1..-1], \"status\" => arr[5]}\n end", "def getUserGroups(userName)\n\n if(userName == nil)\n return nil\n end\n user = loadUser(userName)\n at = 0\n groupsV = []\n while user[\"group#{at}\"] != nil do\n groupsV <= user[\"group#{at}\"]\n at = at.next\n end\n return groupsV\n\n end", "def string_to_nested_array(str)\n arr1 = str.split(',')\n arr2 = []\n for i in 0..arr1.size - 1\n arr2[i] = arr1[i].split(':')\n end\n return arr2\nend", "def getEmailList\n\t\tdata = index()\n\t\temailList = []\n\t\tdata.each do |person|\n\t\t\temailList.push(\"#{person[\"email_address\"]}\")\n\t\tend\n\t\treturn emailList\n\tend" ]
[ "0.60554117", "0.5764049", "0.5719801", "0.56254435", "0.55866015", "0.5446294", "0.54349995", "0.54079497", "0.53280914", "0.52007", "0.51558053", "0.51461625", "0.50951827", "0.50842553", "0.5081877", "0.50778097", "0.5074795", "0.50687027", "0.5064698", "0.5058538", "0.5058056", "0.5052311", "0.5043789", "0.5021578", "0.5009146", "0.49859416", "0.49786934", "0.49747914", "0.49466497", "0.4940841", "0.49286312", "0.4924721", "0.4924721", "0.49228838", "0.49101606", "0.49083167", "0.49063748", "0.4899551", "0.48837772", "0.4864384", "0.4863197", "0.48627526", "0.48520952", "0.48463356", "0.48405597", "0.48395312", "0.48307484", "0.4822498", "0.481516", "0.48131612", "0.48055276", "0.47998902", "0.479346", "0.4792464", "0.47860897", "0.47742668", "0.47742668", "0.4771796", "0.47601342", "0.4753241", "0.47513875", "0.47358912", "0.47353178", "0.47323352", "0.4721077", "0.47192487", "0.47187677", "0.47187677", "0.4712672", "0.4712413", "0.47070333", "0.47040454", "0.47005886", "0.46980223", "0.46961758", "0.46917135", "0.46910536", "0.4687328", "0.46851563", "0.46839452", "0.46831638", "0.46802747", "0.46758208", "0.46738476", "0.46679404", "0.46637636", "0.46487454", "0.46476898", "0.4643378", "0.46421185", "0.46381953", "0.4617004", "0.46166444", "0.46148223", "0.46052682", "0.4598204", "0.45976678", "0.45930883", "0.45910096", "0.45897245", "0.4587617" ]
0.0
-1
Creates a pipeline on AWS Elastic Transcoder
def create_pipeline name, input_bucket, output_bucket, role begin @elastictranscoder.create_pipeline( name: name, input_bucket: input_bucket, output_bucket: output_bucket, role: role ) rescue #Raise informative exception end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_pipeline(**args)\n params = parameters(args) do\n optional_params :name, :deal_probability, :order_nr, :active\n end\n request(:post, 'pipelines', params)\n end", "def pipeline(name)\n return PipelineT.new(name)\n end", "def to_pipeline\n p = Pipeline.new([ self ])\n p.stdin!(self.stdin)\n p.stdout!(self.stdout)\n p.stderr!(self.stderr)\n end", "def create_pipeline(options = {})\n options[:accept] = 'application/vnd.go.cd.v1+json'\n post 'admin/pipelines', options\n end", "def create(json_file)\n pipeline_json = File.read(json_file)\n @http.pipelines.post pipeline_json\n rescue StandardError => e\n puts \"Error creating pipeline: #{e}\"\n Process.exit(1)\n end", "def pipeline(uri)\n builder = PipelineBuilder.new(context())\n builder.uri = uri\n __builders.push(builder)\n return builder\n end", "def create\n @pipeline = Pipeline.new(pipeline_params)\n\n respond_to do |format|\n if @pipeline.save\n format.html { redirect_to @pipeline, notice: 'Pipeline was successfully created.' }\n format.json { render :show, status: :created, location: @pipeline }\n else\n format.html { render :new }\n format.json { render json: @pipeline.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_pipeline(pipeline_name, pipeline_path, repository, system_config)\n cmdline = Schott::AzureCLI::Commandlines.create_pipeline(pipeline_name, pipeline_path, repository)\n cmd = run_command(\"Create #{pipeline_name}\", cmdline, system_config)\n return cmd.success?\n end", "def initialize(name)\n # Check and set the name\n @name = name.to_sym\n\n # Initialize the internals of the pipeline.\n\n\n # Initialize the environment for building the pipeline\n\n # The stages\n @stages = []\n\n # The event synchronizing the pipeline\n @mk_ev = proc { $clk.posedge }\n\n # The reset\n @mk_rst = proc { $rst }\n\n # Creates the namespace to execute the pipeline block in.\n @namespace = Namespace.new(self)\n\n # Generates the function for setting up the pipeline.\n obj = self # For using the right self within the proc\n HDLRuby::High.space_reg(@name) do |&ruby_block|\n if ruby_block then\n # Builds the pipeline.\n obj.build(&ruby_block)\n else\n # Return the pipeline as is.\n return obj\n end\n end\n\n end", "def transcoder\n @transcoder ||= Aws::ElasticTranscoder::Client.new(\n region: Rails.application.secrets.aws_region\n )\n end", "def pipeline\n Offer.pipeline(self)\n end", "def create(pipeline_name)\n validation_errors = []\n \n validation_errors.push('invalid_pipeline_name') unless Util::CommonValidator.is_string?(pipeline_name)\n \n return validation_error(\n 'l_t_pd_pl_1',\n 'something_went_wrong',\n validation_errors,\n GlobalConstant::ErrorAction.default\n ) if validation_errors.present?\n \n url_path = create_request_path(@pipelines_endpoint)\n custom_params = {\n name: pipeline_name\n }\n \n r = send_request_of_type('post', url_path, custom_params)\n return r unless r.success?\n \n success_with_data(\n {\n pipeline_id: r[:data]['id']\n })\n end", "def create\n @rnaseq_pipeline = RnaseqPipeline.new(params[:rnaseq_pipeline])\n @rnaseq_pipeline.email=current_user.email\n respond_to do |format|\n if @rnaseq_pipeline.save\n flash[:notice] = 'RnaseqPipeline was successfully created.'\n format.html { redirect_to(@rnaseq_pipeline) }\n format.xml { render :xml => @rnaseq_pipeline, :status => :created, :location => @rnaseq_pipeline }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @rnaseq_pipeline.errors, :status => :unprocessable_entity }\n end\n end\n end", "def pipeline(enterprise: 'default', organization: nil, project: nil, pipeline: nil)\n arr = []\n @api.pipeline(enterprise: enterprise, organization: organization, project: project, pipeline: pipeline).each do |o|\n arr << OpenStruct.new(o)\n end\n arr\n end", "def pipelines(enterprise: 'default', organization: nil, project: nil)\n @api.pipelines(enterprise: enterprise, organization: organization, project: project)\n end", "def input(*inputs, &block)\n project.build_pipeline(*inputs, &block)\n end", "def build(&ruby_block)\n # Use local variable for accessing the attribute since they will\n # be hidden when opening the sytem.\n name = @name\n stages = @stages\n namespace = @namespace\n this = self\n mk_ev = @mk_ev\n mk_rst = @mk_rst\n scope = HDLRuby::High.cur_system.scope\n\n return_value = nil\n\n # Enters the current system\n HDLRuby::High.cur_system.open do\n sub do\n HDLRuby::High.space_push(namespace)\n # Execute the instantiation block\n return_value =HDLRuby::High.top_user.instance_exec(&ruby_block)\n HDLRuby::High.space_pop\n\n # Create the pipeline code.\n \n # Declare and register the pipeline registers generators.\n prs = []\n stages.each do |st|\n st.each do |rn|\n r = PipeSignal.new(name.to_s+\"::\"+rn.to_s,scope)\n prs << r\n namespace.add_method(rn) { r }\n end\n end\n\n # Build the pipeline structure.\n return_value = par(mk_ev.call) do\n hif(mk_rst.call == 0) do\n # No reset, pipeline handling.\n stages.each do |st|\n # Generate the code for the stage.\n HDLRuby::High.space_push(namespace)\n HDLRuby::High.top_user.instance_exec(&st.code)\n HDLRuby::High.space_pop\n end\n end\n helse do\n prs.each { |r| r <= 0 }\n end\n end\n end\n end\n\n return return_value\n end", "def initialize(pipelines)\n pipelines.with_indifferent_access.each do |key, pipeline|\n create_instance_method(key) { Item.new(pipeline) }\n self.pipelines << key\n end\n end", "def setup\n self.pipeline_requires = []\n self.on_readies = []\n\n self.pipeline 'jquery'\n self.pipeline 'jquery_ujs'\n self.pipeline 'init'\n end", "def create_attachment_pipeline pipeline, field\n uri = URI(\"http://#{@host}:#{@port_s}/_ingest/pipeline/#{pipeline}\")\n req = Net::HTTP::Put.new(uri)\n req.body = {\n description: \"Extract attachment information\",\n processors: [\n {\n attachment: {\n field: field,\n indexed_chars: -1\n }\n },\n {\n remove: {\n field: field\n }\n }\n ]\n }.to_json\n run(uri, req)\n end", "def pipeline_stack\n @pipeline_stack ||= []\n end", "def transform()\n @stages.each do |stage|\n# Pry::ColorPrinter.pp stage\n @ead = stage.transform(@ead)\n#Rails.logger.debug(\"#{@ead.to_s.pretty_inspect}\")\n end\n @ead.to_s\n end", "def blogparser_pipeline(factory)\n new_site = factory.new\n new_site.main\n puts \"created a new #{new_site.class} with a factory\"\nend", "def blogparser_pipeline(factory)\n new_site = factory.new\n new_site.main\n puts \"created a new #{new_site.class} with a factory\"\nend", "def set_pipeline\n @pipeline = Pipeline.find(params[:id])\n end", "def handle_pipeline(object, &block)\n object.is_a?(Redis::Future) ? object.add_transformation(&block) : block.call(object)\n end", "def convert(pipeline, format)\n pipeline.convert!(format)\n end", "def process_resource(resource, pipeline)\n TrajectTransformJob.perform_later(resource, pipeline)\n end", "def build_yield\n TransformationYield.new((params[:transformation_yield] || {}).merge(:transformation => Transformation.new))\n end", "def create_pipeline\n @pipeline = Gst::Pipeline.new\n @pipeline.add(*self.pipeline_elements)\n\n @input_device >> @raw_audio_parse >> @eq >> @audioconvert >> @audioresample >> @sink\n\n # Listen to playback events\n @pipeline.bus.add_watch do |bus, message|\n p [bus, message.type]\n # XXX need to be able to handle error\n # XXX is there such thing as EOF/EOS with /dev/sound ??\n true\n end\n end", "def initialize(pipeline, children = {})\n @children = children\n\n # the pipeline tells you which pipeline it belongs to without having\n # to query the class itself. I know it is only useful for tests but\n # worth it\n @pipeline = pipeline\n\n children.each do |key, child|\n if child.instance_of?(ActiveSupport::HashWithIndifferentAccess)\n next if respond_to?(key)\n\n child_item = Item.new(pipeline, child)\n define_singleton_method(key) { child_item }\n else\n define_singleton_method(key) { child }\n end\n end\n end", "def input(*inputs, &block)\n # Allow pipelines without a specified block. This is possible\n # if before and after filters are all that are needed for a\n # given input.\n block = proc {} unless block_given?\n project.build_pipeline(*inputs, &block)\n end", "def transform! &block\n @transformer||=[]\n @transformer << block if block_given?\n self\n end", "def filter_pipeline\n @filter_pipeline ||= HTML::Pipeline.new([TypogrubyFilter])\n end", "def transform(transform)\n end", "def initialize_pipetree!\n heritage.record :initialize_pipetree!\n\n self[\"pipetree\"] = Railway.new\n\n strut = ->(last, input, options) { [last, Instantiate.(input, options)] } # first step in pipe.\n self[\"pipetree\"].add(Railway::Right, strut, name: \"operation.new\") # DISCUSS: using pipe API directly here. clever?\n end", "def use_transform_producer(*spec, &block)\n Orocos::RobyPlugin::Engine.create_instanciated_component(nil, nil, self).use_transform_producer(*spec, &block)\n end", "def transformer\n @transformer ||= Transformer.new self\n end", "def create_tag_stage\n self.tag_stages.create\n end", "def create\n transformation_yield.valid?\n respond_with(transformation_yield)\n end", "def stage(*regs, &ruby_block)\n # Create the resulting state\n result = Stage.new\n # Test and set the registers.\n regs.each do |reg|\n # Ensure it is a symbol.\n reg = reg.to_sym\n # Add it.\n result << reg\n end\n # Sets the generation code.\n result.code = ruby_block\n # Add it to the list of states.\n @stages << result\n # Return it.\n return result\n end", "def add_pipeline(m, *args)\n raise IOError.new(\"pipelining not enabled\") unless @in_pipeline\n return add_sync_pipeline(m, *args) if @synchronous_pipeline\n\n input = (@active_pipelines.empty? ? $stdin : @active_pipelines.last.reader)\n @active_pipelines << Pipeline.new\n output = @active_pipelines.last.writer\n error = ($stderr == $stdout ? output : $stderr)\n pid = fork do # might not be necessary, spawn might cover it. Not risking it before testing\n system_command(m, *args, out: output, input: input, err: error, except: true)\n output.close\n exit!(true)\n end\n output.close\n @active_pipelines.last.link_process(pid)\n end", "def transform\n Transform.new(handle: @handle, apikey: @apikey, security: @security)\n end", "def build_pipeline(elements)\n pipeline = Gst::Pipeline.new('raspi-stream')\n vars = {}\n\n prev = nil\n elements.each do |el|\n element = if el.kind_of?(String)\n Gst::ElementFactory.make(el)\n else\n opts = el.select { |s| s.kind_of?(Hash) }[0]\n sym = el.select { |s| s.kind_of?(Symbol) }[0]\n o = Gst::ElementFactory.make(el[0])\n\n opts.each_pair { |k, v| o.set_property(k.to_s, v) } if not opts.nil?\n vars[sym] = o if not sym.nil?\n o\n end\n pipeline.add(element)\n prev >> element if not prev.nil?\n prev = element\n\n end\n [pipeline, vars]\nend", "def pipe(other)\n Pipeline.new(@pipes + [other])\n end", "def pipeline_params\n params.require(:pipeline).permit(:name, :repo, :triggers, :domain)\n end", "def create_attachment_array_pipeline pipeline, field\n uri = URI(\"http://#{@host}:#{@port_s}/_ingest/pipeline/#{pipeline}\")\n req = Net::HTTP::Put.new(uri)\n req.body = {\n description: \"Extract attachment information from arrays\",\n processors: [\n {\n foreach: {\n field: field,\n processor: {\n attachment: {\n target_field: \"_ingest._value.attachment\",\n field: \"_ingest._value.data\",\n indexed_chars: -1\n }\n }\n }\n },\n foreach: {\n field: field,\n processor: {\n remove: {\n field: \"_ingest._value.data\"\n }\n }\n }\n ]\n }.to_json\n run(uri,req)\n end", "def initialize elastic, name\n @elastic = elastic\n @name = name.downcase\n @dirname = File.dirname(__FILE__)\n @logstashdir = File.expand_path(File.join(@dirname, \"..\", \"..\", \"logstash\"))\n create_output\n end", "def transform\n end", "def execute(agent, pipelines)\n pipeline = LogStash::Pipeline.new(@pipeline_config.config_string, @pipeline_config.settings, @metric, agent)\n \n status = pipeline.start # block until the pipeline is correctly started or crashed\n\n if status\n pipelines[pipeline_id] = pipeline # The pipeline is successfully started we can add it to the hash\n end\n\n LogStash::ConvergeResult::ActionResult.create(self, status)\n end", "def initialize(*_)\n super\n SfnAws.load!\n @translators = Smash.new\n end", "def run_and_transform; end", "def new\n @rnaseq_pipeline = RnaseqPipeline.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rnaseq_pipeline }\n end\n end", "def initialize\n fail InstanceError, 'Pipes are not supposed to be instantiated'\n end", "def to_pipeline\n pipeline = []\n pipeline.push({ \"$skip\" => skip }) if skip\n pipeline.push({ \"$limit\" => limit }) if limit\n pipeline.push({ \"$sort\" => sort }) if sort\n pipeline\n end", "def create\n with_error_handling do\n record = Lark::Transactions::CreateAuthority\n .new(event_stream: event_stream)\n .call(attributes: parsed_body(format: ctype))\n .value!\n\n [201, response_headers, [serialize(record: record, format: ctype)]]\n end\n end", "def transform(transformation)\n end", "def client\n @client ||= Aws::ElasticTranscoder::Client.new\n end", "def initialize(pipe)\r\n @pipe = pipe\r\n\r\n @element_stack = []\r\n end", "def transforms; end", "def initialize_pipetree!\n heritage.record :initialize_pipetree!\n self[\"pipetree\"] = ::Pipetree::Flow.new\n end", "def create_named_pipe_pivot(opts)\n request = Packet.create_request(COMMAND_ID_CORE_PIVOT_ADD)\n request.add_tlv(TLV_TYPE_PIVOT_NAMED_PIPE_NAME, opts[:pipe_name])\n\n\n c = Class.new(::Msf::Payload)\n c.include(::Msf::Payload::Stager)\n c.include(::Msf::Payload::TransportConfig)\n\n # Include the appropriate reflective dll injection module for the target process architecture...\n if opts[:arch] == ARCH_X86\n c.include(::Msf::Payload::Windows::MeterpreterLoader)\n elsif opts[:arch] == ARCH_X64\n c.include(::Msf::Payload::Windows::MeterpreterLoader_x64)\n end\n\n stage_opts = {\n force_write_handle: true,\n datastore: {\n 'PIPEHOST' => opts[:pipe_host],\n 'PIPENAME' => opts[:pipe_name]\n }\n }\n\n stager = c.new()\n\n stage_opts[:transport_config] = [stager.transport_config_reverse_named_pipe(stage_opts)]\n stage = stager.stage_payload(stage_opts)\n\n request.add_tlv(TLV_TYPE_PIVOT_STAGE_DATA, stage)\n\n self.client.send_request(request)\n end", "def create_stage_for_test stage_data\n cli.create_stage(stage_data)\nrescue\nend", "def create\n @video = Video.where(video_params).first\n #@profesor_selected = @video.personas.first.id\n @profesor_selected = params[:profesor_id]\n saved = @video.save\n puts 'entro cuando cargue un video'\n if saved\n pipeline_id = '1439848270326-bs22oc'\n input_key = URI(@video.attach.url).path\n input_key = input_key[1..input_key.length]\n region = 'us-west-1'\n transcoder_client = AWS::ElasticTranscoder::Client.new(region: region)\n Funciones.get_options pipeline_id, input_key\n job = transcoder_client.create_job(options)\n job_id = job[:job][:id]\n @video.transcoder_job_id = job_id\n @video.save\n p job\n end\n respond_to do |format|\n if saved\n generar_evaluaciones(@video.profesor.id, @video.id)\n format.html { redirect_to video_path(@video.id), notice: 'Video fue creado con éxito.' }\n format.json { render :show, status: :created, location: @video }\n else\n #format.html { render :new }\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @transform = Transform.new(transform_params)\n\n respond_to do |format|\n if @transform.save\n format.html { redirect_to @transform, notice: 'Transform was successfully created.' }\n format.json { render action: 'show', status: :created, location: @transform }\n else\n format.html { render action: 'new' }\n format.json { render json: @transform.errors, status: :unprocessable_entity }\n end\n end\n end", "def client\n @client ||= Aws::ElasticTranscoder::Client.new\n end", "def new\n respond_with(transformation_yield)\n end", "def pipeline(id:, **args)\n params = parameters(args) do\n optional_params :totals_convert_currency\n end\n request(:get, \"pipelines/#{id}\", params)\n end", "def new\n @encoding_job = EncodingJob.new\n end", "def perform(release_id, pipeline_id = nil)\n release = Release.find_by_id(release_id)\n return unless release\n\n pipeline = Ci::Pipeline.find_by_id(pipeline_id)\n\n ::Releases::CreateEvidenceService.new(release, pipeline: pipeline).execute\n end", "def consumer(uri)\n builder = PipelineConsumerBuilder.new(context())\n builder.uri = uri\n __builders.push(builder)\n return builder\n end", "def initialize(&block)\n block.call(@msms_pipeline_analysis=MsmsPipelineAnalysis.new) if block\n end", "def create_ingestion_workflow(params={})\n payload=create_ingestion_workflow_payload(params)\n create_workflow(payload)\n end", "def transformation\n end", "def create_stages_from_serialized_content!(serialized_content_array, actions, opts = {})\n serialized_content_array.each do |serialized_content|\n #serialized_content[:nodenodeob] = opts[:nodes]{cat node id?}\n #if nodes = opts[:nodes] add_node_ids(serialized_content_array, nodes)\n if nodes = opts[:nodes] \n add_node_object_info!(serialized_content, nodes)\n end\n if stage = Stage::InterNode.parse_and_reify?(serialized_content, actions, opts)\n stage.attempts = opts[:attempts]\n stage.retry = opts[:retry]\n stage.add_to_template_content!(self, serialized_content, just_parse: opts[:just_parse])\n end\n end\n end", "def initialize(transformers:)\n super()\n @params = {}\n @transformers = transformers\n end", "def pipe(input, env = environment)\n self.environment = env\n self.datasets = input\n self\n end", "def pipeline_id\n respond_to?(:execution_context) && !execution_context.nil? ? execution_context.pipeline_id : \"main\"\n end", "def create_logs_pipeline_with_http_info(body, opts = {})\n\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: LogsPipelinesAPI.create_logs_pipeline ...'\n end\n # verify the required parameter 'body' is set\n if @api_client.config.client_side_validation && body.nil?\n fail ArgumentError, \"Missing the required parameter 'body' when calling LogsPipelinesAPI.create_logs_pipeline\"\n end\n # resource path\n local_var_path = '/api/v1/logs/config/pipelines'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(body)\n\n # return_type\n return_type = opts[:debug_return_type] || 'LogsPipeline'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]\n\n new_options = opts.merge(\n :operation => :create_logs_pipeline,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type,\n :api_version => \"V1\"\n )\n\n data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: LogsPipelinesAPI#create_logs_pipeline\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def transform; end", "def execute_pipeline\n PipelineJob.perform_async(id)\n end", "def stage(&block)\n idx = self.staging\n rv = yield idx\n idx.build\n rv\n end", "def create(_state)\n workflow do\n run_apply\n end\n end", "def build(name, provider = :aws, &block)\n provider = Bogo::Utility.snake(provider).to_sym\n rs = Creator::RuleSet.new(provider)\n rs.instance_exec(&block)\n self.new(name, provider, rs.items)\n end", "def add_tier\n begin\n with_transaction do\n Tier.create!(\n name: params[:name],\n stage: params[:stage],\n pipeline_id: @pipeline.id\n )\n\n render json: tiers_for_pipeline_view\n end\n rescue Exception => e\n error = \"#{ConfluxErrors::TierCreationFailed} - #{e}\"\n logger.error { error }\n render json: { message: error }, status: 500\n end\n end", "def transformations; end", "def pipeline(context_name=nil, &block)\n if block\n options = context.fetch\n current_options = context.fetch(context_name)\n options.merge!(current_options) unless context_name.nil?\n ssh_options = _ssh_options(options.ssh_options)\n sshkit_wrapper(options, ssh_options).instance_exec(&block)\n end\n end", "def create_process 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_create_process_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::DataCatalog::Lineage::V1::Process.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def on_transform(&blk)\n @transform_handler = blk\n self\n end", "def pipelined\n yield\n end", "def create\n # JSONファイルから文字列を抽出する\n file = params['stage']['file']# Upされたファイルにアクセス\n \n p(\"file params:\")\n\n @jsonstring = file.read\n p(@jsonstring)\n @stage = Stage.new(:scene_data => @jsonstring, :title => params[:stage][:title])\n p(\"stage.scene_data:\")\n p(@stage.scene_data)\n #p(@stage.nothing)\n \n if params[:stage][:texture] != nil\n @textures = Texture.new(:data => params[:stage][:texture]['data'])\n @stage.textures << @textures\n end\n\n respond_to do |format|\n if @stage.save!\n format.html { redirect_to @stage, notice: 'Stage was successfully created.' }\n format.json { render action: 'show', status: :created, location: @stage }\n else\n format.html { render action: 'new' }\n format.json { render json: @stage.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_crawler(name, role_arn, db_name, db_prefix, s3_target)\n @glue_client.create_crawler(\n name: name,\n role: role_arn,\n database_name: db_name,\n targets: {\n s3_targets: [\n {\n path: s3_target\n }\n ]\n }\n )\n rescue Aws::Glue::Errors::GlueException => e\n @logger.error(\"Glue could not create crawler: \\n#{e.message}\")\n raise\n end", "def create_sequence(context)\n return RightScale::ExecutableSequenceProxy.new(context)\n end", "def add_transformation_to_yield(transformation_yield)\n transformation_yield.transformation = self\n end", "def addTransformer(transformer)\n @transformer.add(transformer)\n self\n end", "def prepare_publish\n workload = []\n\n source_category = \"stage\"\n destination_category = \"pool\"\n\n Component.dataset(source_category).each do |entry|\n source = Component.new(entry[:component], entry[:suitename], source_category)\n source.files.each do |fullname|\n package = Package.new(fullname, entry[:suitename], entry[:component])\n destination = Architecture.new(package.architecture, entry[:component], entry[:suitename], destination_category)\n\n workload << {\n :source_fullname => fullname,\n :destination_fullname => File.join(destination.directory, package.newbasename),\n :component => entry[:component],\n :suitename => entry[:suitename],\n :architecture => package.architecture\n }\n end\n end\n \n workload\n end", "def initialize(env, processors, &block)\n @env, @processors = env, []\n chain(processors)\n instance_eval(&block) if block\n end", "def pipe!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 79 )\n\n type = PIPE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 200:8: '|'\n match( 0x7c )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 79 )\n\n end", "def create\n @transformer = Transformer.new(transformer_params)\n\n respond_to do |format|\n if @transformer.save\n format.html { redirect_to @transformer, notice: 'Transformer was successfully created.' }\n format.json { render :show, status: :created, location: @transformer }\n else\n format.html { render :new }\n format.json { render json: @transformer.errors, status: :unprocessable_entity }\n end\n end\n end", "def lazy(&block)\n callable = nil\n Pipeline.new(@pipes + [lambda do |e|\n callable ||= block.call\n callable.call(e)\n end])\n end" ]
[ "0.652446", "0.64508605", "0.6340263", "0.63075244", "0.62349594", "0.621768", "0.6021814", "0.58086044", "0.5745947", "0.5608509", "0.5604101", "0.5568337", "0.5525445", "0.55089235", "0.5487428", "0.546316", "0.5413003", "0.53632617", "0.5357884", "0.53394645", "0.53355235", "0.527307", "0.5265946", "0.5265946", "0.5247125", "0.5242571", "0.51878494", "0.51834005", "0.51204205", "0.51004463", "0.508298", "0.5063207", "0.5056094", "0.50507206", "0.50326717", "0.5027376", "0.50087225", "0.4973526", "0.49632004", "0.496147", "0.49550197", "0.49507433", "0.4922335", "0.49200222", "0.49120992", "0.4904421", "0.49024874", "0.48959503", "0.489506", "0.48839322", "0.48707452", "0.48693988", "0.4850378", "0.48411256", "0.48386848", "0.4833568", "0.481405", "0.4790872", "0.4769297", "0.47686595", "0.47571167", "0.47525108", "0.47429174", "0.47302777", "0.47253877", "0.47061834", "0.47018352", "0.46940896", "0.46933648", "0.46889883", "0.46740177", "0.46720016", "0.46552345", "0.46529627", "0.46435666", "0.46280488", "0.46267176", "0.46232972", "0.46113065", "0.4590894", "0.45823222", "0.45810002", "0.45800436", "0.45643547", "0.4553742", "0.45349836", "0.45279396", "0.4522209", "0.4518721", "0.45146874", "0.45145908", "0.45044622", "0.44873342", "0.44792178", "0.44758138", "0.44691712", "0.44630343", "0.44535828", "0.44414738", "0.44348472" ]
0.74993247
0
Deletes a pipeline on AWS Elastic Transcoder given an id
def delete_pipeline id begin @elastictranscoder.delete_pipeline(id: id) rescue #Raise informative exception end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_pipeline(id:, **args)\n params = parameters(args) do\n optional_params\n end\n request(:delete, \"pipelines/#{id}\", params)\n end", "def delete_pipeline(id)\n delete(\"dealGroups/#{id}\")\n end", "def delete_pipeline(id, opts = {})\n data, status_code, headers = delete_pipeline_with_http_info(id, opts)\n return data\n end", "def delete(app, pipeline_name)\n @http.pipelines[URI.escape(\"#{app}/#{pipeline_name}\")].delete\n rescue StandardError => e\n puts \"Error deleting pipeline: #{e}\"\n Process.exit(1)\n end", "def destroy\n @rnaseq_pipeline = RnaseqPipeline.find(params[:id])\n @rnaseq_pipeline.destroy\n\n respond_to do |format|\n format.html { redirect_to(rnaseq_pipelines_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @pipeline.destroy\n respond_to do |format|\n format.html { redirect_to pipelines_url, notice: 'Pipeline was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_pipeline_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ProjectsApi#delete_pipeline ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling delete_pipeline\" if id.nil?\n \n # resource path\n path = \"/Projects/{id}/Pipeline\".sub('{format}','json').sub('{' + 'id' + '}', 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 _header_accept = ['application/json', 'text/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:DELETE, 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 => 'APIProject')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectsApi#delete_pipeline\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def pipelines_id_delete(id, opts = {})\n pipelines_id_delete_with_http_info(id, opts)\n end", "def delete_pipeline_schedule(project, pipeline_schedule_id)\n delete(\"/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}\")\n end", "def delete_logs_pipeline_with_http_info(pipeline_id, opts = {})\n\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: LogsPipelinesAPI.delete_logs_pipeline ...'\n end\n # verify the required parameter 'pipeline_id' is set\n if @api_client.config.client_side_validation && pipeline_id.nil?\n fail ArgumentError, \"Missing the required parameter 'pipeline_id' when calling LogsPipelinesAPI.delete_logs_pipeline\"\n end\n # resource path\n local_var_path = '/api/v1/logs/config/pipelines/{pipeline_id}'.sub('{pipeline_id}', CGI.escape(pipeline_id.to_s).gsub('%2F', '/'))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type]\n\n # auth_names\n auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]\n\n new_options = opts.merge(\n :operation => :delete_logs_pipeline,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type,\n :api_version => \"V1\"\n )\n\n data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: LogsPipelinesAPI#delete_logs_pipeline\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def destroy\n @kf_pipe = Kf::Pipe.find(params[:id])\n @kf_pipe.destroy\n\n respond_to do |format|\n format.html { redirect_to kf_pipes_url }\n format.json { head :no_content }\n end\n end", "def remove_asset_from_stage\n @stage = Stage.find(params[:id])\n params[:asset_ids].each { |asset|\n @stage.assets.delete(Asset.find(asset)) }\n if @stage.save\n redirect_to :back, :notice =>\"Successfully deleted from stage.\"\n else\n redirect_to :back, :notice => \"An error occured\"\n end\n end", "def pipelines_id_delete_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PipelinesApi.pipelines_id_delete ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling PipelinesApi.pipelines_id_delete\"\n end\n # resource path\n local_var_path = \"/pipelines/{id}\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = [ 'access_token' ]\n response = @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: PipelinesApi#pipelines_id_delete\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return response\n end", "def destroy(id)\n if id.is_a?(Array)\n id.map {|one_id| destroy(one_id)}\n else\n find(id).destroy\n end\n end", "def delete(id)\n StoredProcedures.delete(as_id(id))\n end", "def destroy\n @stage = Stage.find(params[:id])\n @stage.destroy\n\n head :no_content\n end", "def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end", "def delete_stage(api_id, env)\r\n @client.delete_stage(rest_api_id: api_id, stage_name: env)\r\n puts 'Deleted API gateway stage ' + env\r\n rescue Aws::APIGateway::Errors::NotFoundException\r\n puts 'API Gateway stage ' + env + ' does not exist. Nothing to delete.'\r\n end", "def set_pipeline\n @pipeline = Pipeline.find(params[:id])\n end", "def perform(id)\n Post.find(id).delete\n end", "def delete(id)\n @chunks.delete(id).delete if @chunks.has_key? id\n end", "def delete_workflow_step(id)\n @client.raw('delete', \"/crm/steps/#{id}\")\n end", "def delete_stage_for_test stage_data\n cli.delete_stage stage_data\nrescue\nend", "def destroy\n @stage = Stage.find(params[:id])\n @stage.destroy\n\n respond_to do |format|\n format.html { redirect_to(stages_url) }\n end\n end", "def deletePublisher( publisher_id)\n params = Hash.new\n params['publisher_id'] = publisher_id\n return doCurl(\"delete\",\"/publisher\",params)\n end", "def destroy\n @stage.destroy\n render json: {message: 'Etapa Excluida'}, status: :ok\n end", "def delete(id)\n @app.client.input_delete id if id.is_a? String\n @app.client.inputs_delete id if id.is_a? Array\n end", "def delete_workflow_step(id)\n return @client.raw(\"delete\", \"/crm/steps/#{id}\")\n end", "def destroy\r\n @stage = Stage.find(params[:id])\r\n @stage.destroy\r\n\r\n respond_to do |format|\r\n format.html {redirect_to stages_url}\r\n format.json {head :no_content}\r\n end\r\n end", "def destroy\n @transform.destroy\n respond_to do |format|\n format.html { redirect_to transforms_url }\n format.json { head :no_content }\n end\n end", "def asr_delete_router(router_id)\n elektron_networking.delete(\"/asr1k/routers/#{router_id}\").body\n end", "def destroy\n @stage.destroy\n respond_to do |format|\n format.html { redirect_to stages_url }\n format.json { head :no_content }\n end\n end", "def update_pipeline(id:, **args)\n params = parameters(args) do\n optional_params :name, :deal_probability, :order_nr, :active\n end\n request(:put, \"pipelines/#{id}\", params)\n end", "def destroy\n @stage = Stage.find(params[:id])\n @stage.destroy\n session[:stage_id] = nil\n\n respond_to do |format|\n format.html { redirect_to(asset_manager_stages_url) }\n format.xml { head :ok }\n end\n end", "def remove_by_id(id)\n @jobs.delete { |job| job.id == id }\n end", "def delete_component\n @structure_component = StructureComponent.find(params[:id])\n @structure_component.destroy\n @existing_structure = StructureComponent.find_all_by_assessment_id(@structure_component.assessment_id, :order => \"id\")\n redirect_to(\"/structure_components/create_structure/#{@structure_component.assessment_id}\")\n end", "def delete(id)\n connection.delete do |req|\n req.url \"job/#{id}\"\n end\n end", "def delete(id)\n assert_exists(id)\n\n persister.delete(id)\n end", "def delete(id)\n path(id).delete\n clean(id) if clean?\n end", "def stop\n @pipeline.stop\n end", "def destroy!(entity_set, id)\n query = service[entity_set].query\n url_chunk = query.find(id).to_s\n api_delete url_chunk\n true\n end", "def destroy\n @assembler = Assembler.find(params[:id])\n @assembler.destroy\n\n respond_to do |format|\n format.html { redirect_to(assemblers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @main_stage = MainStage.find(params[:id])\r\n @main_stage.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to main_stages_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def delete(id)\n call(:delete, path(id))\n end", "def destroy\n Job.destroy(params[:id])\n end", "def delete(id)\n collection.remove(id)\n end", "def destroy\n @transformer.destroy\n respond_to do |format|\n format.html { redirect_to transformers_url, notice: 'Transformer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @assign_stage.destroy\n end", "def destroy\n @event= Event.find(params[:id])\n stage = @event.stage\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to(stage_path stage) }\n format.xml { head :ok }\n end\n end", "def delete_by_id(id)\n delete_product_by_id(id)\n end", "def destroy\n @current_stage.destroy\n\n respond_to do |format|\n format.html { redirect_to stages_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n self.stage { |idx| idx.delete(path) }\n end", "def delete_asset_id=(asset_id)\n if asset = installed_assets.detect {|asset| asset.g_u_i_d == asset_id }\n hist = asset.asset_on_segment_history\n hist.uninstall(asset)\n AssetObserver.remove(asset, hist)\n asset.asset_on_segment_history_id = nil\n assets_to_save << asset \n end\n end", "def destroy(id = nil)\n new(__record_id: id).destroy\n end", "def delete(id)\n _params = {:id => id}\n return @master.call 'webhooks/delete', _params\n end", "def destroy\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to physical_racks_url }\n format.json { head :ok }\n end\n end", "def destroy\n Generator.where(id: params[:id] ).first.destroy\n respond_to do |format|\n format.html { redirect_to generators_url }\n format.json { head :no_content }\n end\n end", "def delete_transcoding(transcoding_id)\n response = self.class.resource.delete(\"#{id}/transcodings/#{transcoding_id}\")\n reload\n response.code.to_i == 200\n end", "def delete(id)\n @conn.execute(*@builder.delete(id))\n end", "def execute_pipeline\n PipelineJob.perform_async(id)\n end", "def destroy\n fail \"No id; can't delete #{self.inspect}!\" unless id\n Connection.delete(create_route(:delete))\n end", "def pipeline_id\n respond_to?(:execution_context) && !execution_context.nil? ? execution_context.pipeline_id : \"main\"\n end", "def destroy\n params[:id].each{|id| \n s = Scriptlet.find(id.to_i)\n s.destroy\n remove_scriptlet(s.name)\n } if params[:id]\n\n respond_to do |format|\n format.html { redirect_to(scriptlets_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @stage.destroy\n respond_to do |format|\n format.html { redirect_to stages_url, notice: 'Stage was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(id)\n FileUtils.rm_r File.join(DOTDIR, id)\n end", "def destroy\n @go_slim_sequence = GoSlimSequence.find(params[:id])\n @go_slim_sequence.destroy\n\n respond_to do |format|\n format.html { redirect_to go_slim_sequences_url }\n format.json { head :no_content }\n end\n end", "def destroy_existing(id, params={})\n request(params.merge(:_method => :delete, :_path => build_request_path(params.merge(primary_key => id)))) do |parsed_data, response|\n new(parse(parsed_data[:data]).merge(:_destroyed => true))\n end\n end", "def destroy\n @szene = Szene.find(params[:id])\n @szene.destroy\n\n respond_to do |format|\n format.html { redirect_to(script_video_path(:id => @szene.sequence.video.id)) }\n format.xml { head :ok }\n end\n end", "def delete(id)\n read_or_die(id)\n\n sql, vals = sql_delete(id_fld => id)\n execute sql_subst(sql, *vals.map{|v| quote v})\n\n self\n\n rescue => e\n handle_error(e)\n end", "def destroy(id)\n multiple_ids = if composite_primary_key?\n id.first.is_a?(Array)\n else\n id.is_a?(Array)\n end\n\n if multiple_ids\n find(id).each(&:destroy)\n else\n find(id).destroy\n end\n end", "def _delete_reference_to_id(id)\n @data.delete_if do |v|\n v && v.respond_to?(:is_poxreference?) && v.id == id\n end\n @store.cache.cache_write(self)\n end", "def destroy(params = {})\n validate_id(params)\n submit(id_url(params.delete(:id)), :delete)\n end", "def delete_id(id)\n redis.srem(key, id)\n end", "def delete(id)\n collection.remove({ _id: id })\n end", "def delete_statement_pipe(statement_pipe_id, opts = {})\n delete_statement_pipe_with_http_info(statement_pipe_id, opts)\n nil\n end", "def delete_layer(id)\n if layer = layers.find {|layer| layer.id == id}\n layer.destroy\n end\n end", "def remove_trigger(id)\n\t transmit(:remove_trigger, id)\n\t triggers.delete(id)\n\tend", "def delete_program_by_id(item_id)\n item = get_program_by_id(item_id)\n item.destroy\n end", "def delete(id)\n # TODO: Implement this for Stripe webhooks\n end", "def delete(id)\n CSVFileTransaction.new(@path).write do |existing_data|\n generate(existing_data.reject { |task| task[:id] == id })\n end\n end", "def delete_importer(id)\n return @client.raw(\"delete\", \"/config/importers/#{id}\")\n end", "def delete_workflow(workflow_id:)\n delete(url: \"#{@url}workflows/#{workflow_id}\")\n end", "def destroy_deploy_groups_stages\n DeployGroupsStage.where(stage_id: id).delete_all\n end", "def delete_project(id)\n elektron_identity.delete(\"projects/#{id}\")\n end", "def destroy\n @custom_search_engine = CustomSearchEngine.find(params[:id])\n if @custom_search_engine.present?\n if (parent = @custom_search_engine.parent).present?\n parent.children_ids.delete(@custom_search_engine.id)\n parent.save\n end\n @custom_search_engine.destroy\n end\n\n respond_to do |format|\n format.html { redirect_to cses_path }\n format.json { head :no_content }\n end\n end", "def delete(id)\n @hashes.delete(id)\n end", "def destroy\n self.class.collection.delete_one(:_id => BSON::ObjectId.from_string(@id))\n end", "def remove_vertex(id)\n # YOUR WORK HERE\n end", "def destroy\n @flat_stage.destroy\n respond_to do |format|\n format.html { redirect_to flat_stages_url, notice: 'Stage was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n \n @sequence = Sequence.first(:seq_id=>params[:id].to_i) #current_user.sequences.first(:seq_id=>params[:id].to_i)#Sequence.get(params[:id])\n debugger\n @sequence.destroy!\n\n respond_to do |format|\n format.html { redirect_to(sequences_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @stage = @segment.stage\n @segment.destroy\n\n @segments = Segment.where(stage_id: @stage.id).order(:name)\n respond_to do |format|\n format.html { redirect_to stage_segments_url(@stage), notice: \"Segment was successfully destroyed.\" }\n format.json { head :no_content }\n flash.now[:now] = \"Segment was successfully destroyed.\"\n format.turbo_stream { render \"shared/destroy\", locals: { object: Segment.new } }\n end\n end", "def delete(id)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\"\n return HTTParty.delete(url, :timeout => 4)\n end\n end", "def delete(id)\n self.find(id).delete_\n end", "def destroy\n @group = Group.find_by_param(params[:id])\n @group.tuners.clear\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end", "def delete(id=nil)\n if id.class == String && block_given?\n return @j_del.java_method(:delete, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(id,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))\n end\n raise ArgumentError, \"Invalid arguments when calling delete(id)\"\n end", "def destroy_tag(tag_id)\n tag_id = DomainEnumerated.is_an_integer(tag_id)\n raise \"Unknown tag tag_id=#{tag_id}\" unless tag_id and tag_ids.include?(tag_id)\n descriptor[:tag_ids].delete(tag_id)\n update_attribute(:descriptor, descriptor)\n begin\n dtag = Dtag.find(tag_id)\n rescue\n \n else\n dtag.destroy\n end\n\n end", "def destroy\n @asset = Asset.find(params[:asset_id])\n @tag = @asset.tags.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(asset_manager_asset_tags_path(@asset)) }\n format.xml { head :ok }\n end\n end", "def destroy\n Seances::UseCases::Delete.new.call(id: params[:id])\n end", "def delete(id)\n Mailgun.submit :delete, webhook_url(id)\n end", "def delete_composer\n logger.debug \"**** DELETE COMPOSER ****\"\n @composer = Role.find(params[:id])\n if params[:work_id]\n @composers = session[(\"composers_\" + params[:work_id]).to_sym]\n else\n @composers = session[:composers]\n end\n @composers.delete(@composer)\n if params[:work_id]\n session[(\"composers_\" + params[:work_id]).to_sym] = @composers\n else\n session[:composers] = @composers\n end\n \n @dom_id = generate_id(@composer)\n \n logger.debug \"Dom id is #{@dom_id}\"\n end" ]
[ "0.831177", "0.80013835", "0.72955346", "0.7219937", "0.70177466", "0.6564606", "0.62814873", "0.626145", "0.5979849", "0.58549", "0.57210433", "0.57043666", "0.56821215", "0.56635123", "0.56628966", "0.5651034", "0.5632525", "0.5617103", "0.55874884", "0.5555457", "0.55437565", "0.5540626", "0.5529264", "0.5497546", "0.5485384", "0.54703856", "0.54633784", "0.5456575", "0.5456265", "0.54508233", "0.5436639", "0.54352564", "0.5414861", "0.54071474", "0.53910387", "0.5376461", "0.53675747", "0.53411734", "0.5325736", "0.53156805", "0.5313478", "0.5299951", "0.52937746", "0.5281237", "0.52579594", "0.52554107", "0.52272767", "0.5223385", "0.5218831", "0.5218351", "0.5211904", "0.5205168", "0.51863664", "0.51834285", "0.51814455", "0.5172784", "0.5167278", "0.5166958", "0.5163496", "0.51629615", "0.5157396", "0.5154361", "0.51534086", "0.51486206", "0.51468676", "0.5127087", "0.51268125", "0.5125731", "0.51230925", "0.51224697", "0.51173985", "0.51164544", "0.5115675", "0.51007897", "0.51000655", "0.5098921", "0.5098086", "0.5092124", "0.50850546", "0.5082419", "0.50765514", "0.5072664", "0.5072597", "0.50725955", "0.5061331", "0.5058867", "0.50470626", "0.50375366", "0.50370085", "0.5034817", "0.50298625", "0.5028212", "0.50258064", "0.5012899", "0.50108624", "0.5008663", "0.50081086", "0.500669", "0.50063485", "0.5003652" ]
0.9011064
0
To verify data integrity, its a good idea to easily check headers and how many unique elements there are on the last column of the CSV
def preview_output path puts `head #{path}` last_columns = [] open(path) do |csv| csv.each_line do |line| last_columns.push(line.split(',').last.strip) end end p Hash[last_columns.sort.group_by {|x| x}.map {|k,v| [k,v.count]}] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_number_of_rows\n row_array = []\n CSV.foreach('testdata.csv', {headers: true}) {|row| row_array << row[1]} \n row_array.uniq.size\nend", "def check_duplicate_csv_headers(table)\n if table.headers.size != table.headers.uniq.size\n dups = table.headers.select{|e| table.headers.count(e) > 1 }\n Squib.logger.warn \"CSV duplicated the following column keys: #{dups.join(',')}\"\n end\n end", "def find_number_of_columns\n column_array = []\n CSV.foreach('testdata.csv', {headers: true}) {|row| column_array << row[0]}\n column_array.uniq.size\nend", "def check_for_duplicates(csv_data, column_name)\n data = csv_data.select{|item| !item[column_name].nil? }\n value = data.map{|i| i[column_name]}\n duplicates = value.filter{ |e| value.count(e) > 1 }.sort.uniq\n naughty_values = duplicates.map{|i| \" 👉 \\\"#{i}\\\"\" }.join(\"\\n\")\n if value.uniq.length != value.length\n puts \"🔴 Found some services with the same #{column_name} \\n\\n#{naughty_values}\\n\\n\"\n return true\n else\n return false\n end\n end", "def process_csv_file(filename, no_of_unique,delimiter)\n @arr_unique = Array.new{hash.new}\n @arr_details = Array.new(@no_of_columns){{\"int\" => 0, \"float\" => 0, \"date\" => 0, \"datetime\" => 0, \"string\" => 0, \"max_value\" => 0, \"min_value\" => 0}}\n total_chunks = SmarterCSV.process(filename, {:col_sep => delimiter, :chunk_size => 200, :remove_empty_values => false, :remove_zero_values => false}) do |chunk|\n for i in 0..@headers.length-1\n arr = chunk.map{|x| x[@headers[i].to_sym]}\n if(@arr_unique[i].to_a.empty?)\n @arr_unique[i] = arr.uniq\n elsif(@arr_unique[i].size < no_of_unique.to_i+2)\n @arr_unique[i] |= arr.uniq\n elsif (arr.uniq.include?(nil) && !@arr_unique[i].include?(nil))\n @arr_unique[i].push(nil)\n elsif (arr.uniq.include?(\"NULL\") && !@arr_unique[i].include?(\"NULL\"))\n @arr_unique[i].push(\"NULL\")\n elsif (arr.uniq.include?(\"\\N\") && !@arr_unique[i].include?(\"\\N\"))\n @arr_unique[i].push(\"\\N\") \n elsif (arr.uniq.include?(\"\") && !@arr_unique[i].include?(\"\"))\n @arr_unique[i].push(\"\")\n elsif (arr.uniq.include?(\" \") && !@arr_unique[i].include?(\" \"))\n @arr_unique[i].push(\" \")\n end \n arr.each do |field|\n field_type = get_datatype(field)\n count = @arr_details[i][field_type]\n @arr_details[i][field_type] = count+1\n if(field != nil)\n begin\n if(@header_datatype[i] == \"int\" || @header_datatype[i] == \"float\") \n if(@arr_details[i][\"max_value\"] < field)\n @arr_details[i][\"max_value\"] = field\n end\n if(@arr_details[i][\"min_value\"] > field || @arr_details[i][\"min_value\"] == 0)\n @arr_details[i][\"min_value\"] = field\n end\n else\n if(@arr_details[i][\"max_value\"] < field.to_s.length)\n @arr_details[i][\"max_value\"] = field.to_s.length\n end\n if(@arr_details[i][\"min_value\"] > field.to_s.length || @arr_details[i][\"min_value\"] == 0)\n @arr_details[i][\"min_value\"] = field.to_s.length\n end\n end\n rescue Exception => e\n end\n end\n end\n end\n end\n end", "def check_required_field_exists(csv_data, column_name)\n data = csv_data.select{|item| !item[column_name].nil? }\n if data.length < csv_data.length\n puts \"🔴 Some rows contain empty #{column_name}\"\n return true\n else \n return false\n end\n end", "def columnheaders_unique?\r\n columnheaders_raw.length == columnheaders_raw.uniq.length\r\n end", "def valid_headers?(row)\n (required_csv_headers - row.keys).empty?\n end", "def problems_csv_has_been_read\n return $label_to_num.keys.length>0\nend", "def valid_header?(header)\n return false if header.empty?\n length = -1\n header.each do |row|\n return false if row.empty?\n length = row.size if length == -1\n return false if row.size != length\n end\n true\n end", "def mark_duplicate_rows(csv_data)\n # Grouping on first name, last name, email & phone - two different people with the same name shouldn't be counted as one, and if a person has moved they won't be counted as two (people are likely to keep the same email and phone number)\n grouped_data = csv_data.group_by { |row| [row[:first_name], row[:last_name], row[:email], row[:phone]] }\n\n # Add validation errors\n grouped_data.each do |k,rows|\n # Sort by date and reverse first to make sure we don't add the errors to the wrong row\n rows.sort_by! { |row| row[:date_added]}.reverse!\n rows[1..].each do |row|\n row[:validation_errors].append(:duplicate)\n end\n end\n\n grouped_data.transform_values(&:count).count { |k,v| v > 1 }\n end", "def validate_books\r\n csv_text = open(file.url)\r\n csv = CSV.parse(csv_text, :headers => true)\r\n csv.each do |row|\r\n book_hash = Book.new\r\n book_hash.title = row[\"Book title\"]\r\n book_hash.author = Author.find_or_create_by(name: row[\"Book author\"])\r\n book_hash.published_at = Date.parse(row[\"Date published\"])\r\n book_hash.uuid = row[\"Unique identifier for the book\"]\r\n book_hash.publisher_name = row[\"Publisher name\"]\r\n book_hash.user_id = user_id\r\n unless book_hash.valid?\r\n self.errors[:base] << \"UUID Already exist for #{row[\"Unique identifier for the book\"]}\"\r\n end\r\n end\r\n end", "def check_csv(db,tbl)\n csv = \"/opt/tucdocs/MDB/#{db}_#{tbl}.csv\"\n puts \"csv: #{csv}\"\n num_csv = %x! wc -l #{csv} !.chomp.to_s.to_i\nend", "def validate!\n\n reset = \"\\r\\e[0K\"\n\n @check_users = true\n line = reset_line\n\n add_check_all(validate_csv_header :user, @check_users)\n user_bar = ProgressBar.new(\"Users...\", csv_size(:user)) if @verbose\n csv_for_each :user do |row|\n user = true\n row.each do |col, value|\n user &= value.present?\n end\n\n print_error :err_missing, :user, line unless user\n\n @check_users &= user\n # cache user id\n user_ids[row[\"id\"]] = true\n user_bar.inc if @verbose\n line += 1\n break unless user\n end\n user_bar.finish if @verbose\n add_check_all(@check_users)\n\n @check_groups = true\n\n add_check_all(validate_csv_header :group, @check_groups)\n line = reset_line\n # This function will change the header\n # due to a very common typo on csv\n fix_csv_elp_name\n group_bar = ProgressBar.new(\"Groups...\", csv_size(:group)) if @verbose\n csv_for_each :group do |row|\n group = true\n row.each do |col, value|\n group &= value.present?\n end\n print_error :err_missing, :group, line unless group\n\n group &= row[\"privacy\"].downcase == \"public\" || row[\"privacy\"].downcase == \"private\"\n print_error :err_validity, :group, line, \"privacy\", \"Privacy\", row[\"privacy\"] unless group\n\n group &= !row[\"privacy\"].downcase!\n print_error :err_lowercase, :group, line, \"privacy\", \"Privacy\", row[\"privacy\"] unless group\n\n @check_groups &= group\n # cache group id\n groups[row[\"id\"]] = true\n group_bar.inc if @verbose\n line += 1\n break unless group\n end\n group_bar.finish if @verbose\n\n add_check_all(@check_groups)\n\n @check_memberships = true\n line = reset_line\n add_check_all(validate_csv_header :membership, @check_memberships)\n member_bar = ProgressBar.new(\"Memberships\", csv_size(:membership)) if @verbose\n csv_for_each :membership do |row|\n membership = true\n row.each do |col, value|\n membership &= value.present? unless col==\"creator_id\"\n end\n print_error :err_missing, :membership, line unless membership\n\n membership &= groups[row[\"group_id\"]] if membership\n print_error :err_foreign, :membership, line, \"group_id\" unless membership\n\n if row[\"creator_id\"].present?\n membership &= user_ids[row[\"creator_id\"]]\n print_error :err_foreign, :membership, line, \"creator_id\" unless membership\n end\n\n membership &= row[\"level\"].downcase == \"admin\" || row[\"level\"].downcase == \"member\"\n print_error :err_validity, :membership, line, \"level\", \"Access Level\", row[\"level\"] unless membership\n\n membership &= !row[\"level\"].downcase!\n print_error :err_lowercase, :membership, line, \"level\", \"Access Level\", row[\"level\"] unless membership\n\n @check_memberships &= membership\n line += 1\n member_bar.inc if @verbose\n\n break unless membership\n end\n member_bar.finish if @verbose\n add_check_all(@check_memberships)\n\n @check_lings = true\n line = reset_line\n add_check_all(validate_csv_header :ling, @check_lings)\n ling_bar = ProgressBar.new(\"Lings\", csv_size(:ling)) if @verbose\n csv_for_each :ling do |row|\n ling = true\n row.each do |col, value|\n ling &= value.present? unless col==\"creator_id\" || col==\"parent_id\"\n end\n print_error :err_missing, :ling, line unless ling\n\n ling &= groups[row[\"group_id\"]] if ling\n print_error :err_foreign, :ling, line, \"group_id\" unless ling\n\n if row[\"creator_id\"].present?\n ling &= user_ids[row[\"creator_id\"]] if ling\n print_error :err_foreign, :ling, line, \"creator_id\" unless ling\n end\n\n @check_lings &= ling\n # cache ling id\n ling_ids[row[\"id\"]] = row[\"group_id\"]\n\n line += 1\n ling_bar.inc if @verbose\n break unless ling\n end\n ling_bar.finish if @verbose\n add_check_all(@check_lings)\n line = reset_line\n @check_parents = true\n ling_ass_bar = ProgressBar.new(\"Lings Associations\", csv_size(:ling)) if @verbose\n csv_for_each :ling do |row|\n if row[\"parent_id\"].blank?\n ling_ass_bar.inc if @verbose\n next\n end\n\n parent = ling_ids[row[\"parent_id\"]].present?\n print_error :err_foreign, :ling, line, \"parent_id\" unless parent\n\n parent &= ling_ids[row[\"parent_id\"]] == row[\"group_id\"]\n print_error :err_foreign, :ling, line, \"group_id\" unless parent\n\n print_to_console \"\\n=> Should be '#{ling_ids[row[\"parent_id\"]]}' instead of '#{row[\"group_id\"]}'\" unless parent\n @check_parents &= parent\n\n line += 1\n ling_ass_bar.inc if @verbose\n break unless parent\n end\n ling_ass_bar.finish if @verbose\n add_check_all(@check_parents)\n\n @check_categories = true\n line = reset_line\n add_check_all(validate_csv_header :category, @check_categories)\n cat_bar = ProgressBar.new(\"Category\", csv_size(:category)) if @verbose\n csv_for_each :category do |row|\n category = true\n row.each do |col, value|\n category &= value.present? unless col==\"creator_id\" || col==\"description\"\n end\n print_error :err_missing, :category, line unless category\n\n category &= groups[row[\"group_id\"]] if category\n print_error :err_foreign, :category, line, \"group_id\" unless category\n\n if row[\"creator_id\"].present?\n category &= user_ids[row[\"creator_id\"]] if category\n print_error :err_foreign, :category, line, \"creator_id\" unless category\n end\n\n @check_categories &= category\n\n # cache category id\n category_ids[row[\"id\"]] = true\n\n line += 1\n cat_bar.inc if @verbose\n break unless category\n end\n cat_bar.finish if @verbose\n add_check_all(@check_categories)\n\n @check_properties = true\n line = reset_line\n add_check_all(validate_csv_header :property, @check_properties)\n prop_bar = ProgressBar.new(\"Property\", csv_size(:property)) if @verbose\n csv_for_each :property do |row|\n property = true\n row.each do |col, value|\n property &= value.present? unless col==\"creator_id\" || col==\"description\"\n end\n\n print_error :err_missing, :property, line unless property\n\n property &= groups[row[\"group_id\"]] if property\n print_error :err_foreign, :property, line, \"group_id\" unless property\n\n property &= category_ids[row[\"category_id\"]] if property\n print_error :err_foreign, :property, line, \"category_id\" unless property\n\n if row[\"creator_id\"].present?\n property &= user_ids[row[\"creator_id\"]] if property\n print_error :err_foreign, :property, line, \"creator_id\" unless property\n end\n\n @check_properties &= property\n # cache property id\n property_ids[row[\"id\"]] = true\n\n line += 1\n prop_bar.inc if @verbose\n break unless property\n end\n prop_bar.finish if @verbose\n add_check_all(@check_properties)\n\n @check_examples = true\n line = reset_line\n add_check_all(validate_csv_header :example, @check_examples)\n ex_bar = ProgressBar.new(\"Examples\", csv_size(:example)) if @verbose\n csv_for_each :example do |row|\n example = true\n row.each do |col, value|\n example &= value.present? unless col==\"creator_id\"\n end\n\n print_error :err_missing, :example, line unless example\n\n example &= groups[row[\"group_id\"]] if example\n print_error :err_foreign, :example, line, \"group_id\" unless example\n\n example &= ling_ids[row[\"ling_id\"]] if example\n print_error :err_foreign, :example, line, \"ling_id\" unless example\n\n if row[\"creator_id\"].present?\n example &= user_ids[row[\"creator_id\"]] if example\n print_error :err_foreign, :example, line, \"creator_id\" unless example\n end\n\n @check_examples &= example\n # cache example id\n example_ids[row[\"id\"]] = true\n\n line += 1\n ex_bar.inc if @verbose\n break unless example\n end\n ex_bar.finish if @verbose\n add_check_all(@check_examples)\n\n @check_lings_properties = true\n line = reset_line\n add_check_all(validate_csv_header :lings_property, @check_lings_properties)\n lp_bar = ProgressBar.new(\"Lings Properties\", csv_size(:lings_property)) if @verbose\n csv_for_each :lings_property do |row|\n lp = true\n row.each do |col, value|\n lp &= value.present? unless col==\"creator_id\"\n end\n\n print_error :err_missing, :lings_property, line unless lp\n\n lp &= groups[row[\"group_id\"]] if lp\n print_error :err_foreign, :lings_property, line, \"group_id\" unless lp\n\n lp &= ling_ids[row[\"ling_id\"]] if lp\n print_error :err_foreign, :lings_property, line, \"ling_id\" unless lp\n\n if row[\"creator_id\"].present?\n lp &= user_ids[row[\"creator_id\"]] if lp\n print_error :err_foreign, :lings_property, line, \"creator_id\" unless lp\n end\n\n @check_lings_properties &= lp\n lp_bar.inc if @verbose\n # cache lings_property id\n lings_property_ids[row[\"id\"]] = true\n\n break unless lp\n end\n lp_bar.finish if @verbose\n add_check_all(@check_lings_properties)\n\n @check_examples_lp = true\n line = reset_line\n add_check_all(validate_csv_header :examples_lings_property, @check_examples_lp)\n elp_bar = ProgressBar.new(\"Examples Lings Properties\", csv_size(:examples_lings_property)) if @verbose\n csv_for_each :examples_lings_property do |row|\n elp = true\n row.each do |col, value|\n elp &= value.present? unless col==\"creator_id\"\n end\n\n print_error :err_missing, :examples_lings_property, line unless elp\n\n elp &= groups[row[\"group_id\"]] if elp\n print_error :err_foreign, :examples_lings_property, line, \"group_id\" unless elp\n\n elp &= lings_property_ids[row[\"lings_property_id\"]] if elp\n print_error :err_foreign, :examples_lings_property, line, \"lings_property_id\" unless elp\n\n elp &= example_ids[row[\"example_id\"]] if elp\n print_error :err_foreign, :examples_lings_property, line, \"example_id\" unless elp\n\n if row[\"creator_id\"].present?\n elp &= user_ids[row[\"creator_id\"]] if elp\n print_error :err_foreign, :examples_lings_property, line, \"example_id\" unless elp\n end\n\n @check_examples_lp &= elp\n elp_bar.inc if @verbose\n line += 1\n break unless elp\n end\n elp_bar.finish if @verbose\n\n add_check_all(@check_examples_lp)\n\n @check_stored_values = true\n line = reset_line\n add_check_all(validate_csv_header :stored_value, @check_stored_values)\n sv_bar = ProgressBar.new(\"Stored Values\", csv_size(:stored_value)) if @verbose\n csv_for_each :stored_value do |row|\n stored_value = true\n row.each do |col, value|\n stored_value &= value.present?\n end\n\n print_error :err_missing, :stored_value, line unless stored_value\n\n stored_value &= groups[row[\"group_id\"]] if stored_value\n print_error :err_foreign, :stored_value, line, \"group_id\" unless stored_value\n\n stored_value &= example_ids[row[\"storable_id\"]] if stored_value\n print_error :err_foreign, :stored_value, line, \"storable_id\" unless stored_value\n\n @check_stored_values &= stored_value\n\n line += 1\n sv_bar.inc if @verbose\n break unless stored_value\n end\n sv_bar.finish if @verbose\n add_check_all(@check_stored_values)\n @check_all\n end", "def valid_learners_excel_upload(csv_row)\n #if any of the fields are blank then dont allow. return false\n if (!csv_row[0].nil? or !csv_row[0].blank?) and (!csv_row[1].nil? or !csv_row[1].blank?) then\n #check the lengths of name and email are in limits else return false\n if csv_row[0].length <=40 and csv_row[1].length <=255 then\n #remove spaces in email_id\n csv_row[1] = csv_row[1].gsub(\" \",\"\")\n #validate_email() method validates the email id with the regular expression\n if validate_email(csv_row[1])\n fill_learners_table(csv_row)\n return true\n else\n return false\n end\n else\n return false\n end\n else\n return false\n end\n end", "def validate_csv_format\n\tfile = params[:file]\n\theaders = CSV.open(file.path, 'r') { |csv| csv.first }\n\tunless (EXPECTED_HEADER - headers).empty?\n\t\tremoved_columns = EXPECTED_HEADER - headers\n\t\tadded_columns = headers - EXPECTED_HEADER\n\t\tresponse = {msg: \"You have added or removed columns\"}\n\t\t# response = {msg: \"You have removed some columns\"}\n\t\tresponse[:added_column] = added_columns unless added_columns.nil?\n\t\t# response[:removed_columns] = removed_columns unless removed_columns.nil?\n\t\tresponse[:removed_columns] = removed_columns\n\t\trender json: response.to_json, status: \"422\"\n\tend\nend", "def validate_header(header)\n import_failed(0, t(:header_invalid)) if self.class.csv_header != header\n end", "def has_valid_metadata?\n @row_count = 0\n all_valid = true\n metadata_file_path = FileLocations.metadata_file_path(@source_dir)\n ::CSV.foreach(metadata_file_path, headers: true).each do |csv_row|\n next if csv_row.blank?\n # Each row of metadata listed in DESCRIPTION.csv should be valid\n row = strip_csv_row(csv_row)\n @row_count += 1\n all_valid = all_valid && has_valid_metadata_row?(row, @row_count)\n end\n # Should have 1 or more rows\n unless @row_count > 0\n @errors << \"Metadata file #{metadata_file_path} has no rows\"\n all_valid = false\n end\n all_valid\n end", "def collect_row_headers\n @row_headers = []\n CSV.foreach('testdata.csv') {|row| @row_headers << row[1].to_i}\n @row_headers = @row_headers.uniq.sort[0..-1] # ==> [0, 734638, 734639, 734640, 734641, 734642, 734643, 734644, 734645, 734646]\nend", "def validate_header_pairs(row)\n errors = []\n row.each_with_index do |header, i|\n next if header == 'resource_type'\n next unless header.match(type_header_pattern)\n next_header = row[i + 1]\n field_name = header.gsub('_type', '')\n if next_header != field_name\n errors << \"Invalid headers: '#{header}' column must be immediately followed by '#{field_name}' column.\"\n end\n end\n raise errors.join(', ') if errors.present?\n end", "def check_name_import_id(csv_data)\n # import_id !import_id_reference\n data = csv_data.select{|item| item['import_id'].present? && item['import_id_reference'].nil? && item['name'].nil?}\n if data.length > 0\n puts \"🔴 Import id requires a name field\"\n puts data.map{|i| \" 👉 \\\"#{i[\"import_id\"]}\\\"\" }.join(\"\\n\")\n return true\n else \n return false\n end\n end", "def process(csv_data)\n unless csv_data.headers == SOA_CSV_STRUCTURE\n LOGGER.error(\"Structure of #{csv_filename} does not match:\\nExpected: #{SOA_CSV_STRUCTURE.inspect}.\\nActual: #{csv_data.headers.inspect}.\\nContent: #{csv_file}\")\n abort('ABORTED!')\n end\n\n index = 0\n csv_data.delete_if do |row|\n index += 1\n retval = row[:buchungstag].nil? || row[:wertstellung].nil? || row[:umsatzart].nil?\n LOGGER.info(\"- Record nbr. #{index} not processed due to empty field(s): #{row.inspect}\") if retval\n retval\n end\n\n csv_data.sort_by { |row| DateTime.parse(row[:buchungstag]) }\n end", "def excel_columns_equal?(content)\n contents = CSV.parse(content)\n fields_arr = contents[0].map do |field|\n field.strip unless field.nil?\n end.compact\n saved_fields_arr = JSON.parse(self.fields_str).map{|f| f['name']}\n #saved_fields_arr = JSON.parse(self.fields_str).reduce({}, :merge).collect{|k,v| k}.concat(JSON.parse(self.ignored_str))\n return fields_arr.uniq.sort == saved_fields_arr.uniq.sort \n end", "def record_count\n return nil unless @parsed_csv.size\n rows_with_values = @parsed_csv.reject { |row| row.to_hash.values.all?(&:nil?) }\n rows_with_values.count\n end", "def collect_column_headers\n @column_headers = []\n CSV.foreach('testdata.csv') {|row| @column_headers << row[0].to_i}\n @column_headers = @column_headers.uniq.sort[1..-1] # ==> [102231711, 103244134, 103285344, 103293593]\nend", "def verify_in_file\n STDERR.puts \"\\nRM input-CSV filename: #{@in_file}\"\n unless File.file?(@in_file) && File.readable?(@in_file)\n STDERR.puts \"CSV file '#{@in_file}' is not found or is not readable.\"\n exit 6\n end\n\n end", "def modelo_register(name,password)\n count=0\n CSV.foreach($clientes,headers:true) do |row|\n if row['name']==name then count += 1 end\n end\n if count == 0\n CSV.open($clientes, \"a+\") do |csv|\n csv << [name,password,0]\n end \n end\n count == 0\nend", "def row_count \r\n assert_exists\r\n return rows.length\r\n end", "def check_uniqueness_of_header(header_array)\n uniqueness = Array.new\n duplicates = Array.new\n\n header_array.each do |header|\n if uniqueness.include? header\n duplicates << header\n else\n uniqueness << header\n end\n end\n\n return duplicates.uniq\n\n end", "def initial_data_type(filename,chunk,delimiter)\n @headers = Array.new\n @header_datatype = Array.new\n get_keys = false\n @arr_unique = Array.new{hash.new}\n #hash_datatype = {\"int\" => 0, \"float\" => 0, \"date\" => 0, \"string\" => 0}\n @arr_details = Array.new(@no_of_columns){{\"int\" => 0, \"float\" => 0, \"date\" => 0, \"datetime\" => 0, \"string\" => 0}}\n total_chunks = SmarterCSV.process(filename, {:col_sep => delimiter, :chunk_size => chunk, :remove_empty_values => false, :remove_zero_values => false}) do |chunk|\n if(get_keys == false)\n chunk.each do |row| \n @headers = row.keys\n #puts headers[0].to_sym\n get_keys = true\n break\n end\n end\n for i in 0..@headers.length-1\n arr = chunk.map{|x| x[@headers[i].to_sym]}\n if(@arr_unique[i].to_a.empty?)\n @arr_unique[i] = arr\n arr.each do |field|\n field_type = get_datatype(field)\n count = @arr_details[i][field_type]\n @arr_details[i][field_type] = count+1\n\n end\n else\n @arr_unique[i] |= arr\n arr.each do |field|\n field_type = get_datatype(field)\n count = @arr_details[i][field_type]\n @arr_details[i][field_type] = count+1\n end\n end\n end\n break\n end\n #To prepare hash with datatypes of every column to decide on the intial datatypes\n #puts @arr_details.inspect\n @arr_details.each do |hash|\n max_value = 0\n max_value_key = String.new\n hash.each do |key, value|\n if(max_value <= value)\n max_value = value\n max_value_key = key\n end\n end\n if max_value_key == \"int\"\n if hash[\"float\"] != 0\n max_value_key = \"float\"\n end\n end\n max_value_key = \"string\" if hash[\"string\"] != 0\n @header_datatype.push(max_value_key)\n end\n #puts @header_datatype.inspect\n end", "def compute_csv_data\n row_count = 0\n csv_row_number = 0\n csv_data = []\n CSV.foreach(self.file.path, headers: true) do |row|\n # Transform row to hash\n row = row.to_hash\n # Normalize it\n row = normalize_row(row)\n # Increment row number\n csv_row_number += 1\n\n # PRECOMPUTE\n row = precompute_row(row, csv_row_number) # row[:csv_row_number] = csv_row_number AND initialize errors and array fields as arrays\n\n # store the valid_row result\n valid_row = valid_row?(row)\n\n # tranform raw row hash into a intermediate (more concise) information OR put in rejected data\n if valid_row\n csv_data << compute_row(row)\n else\n @rejected_user_data << row\n end\n if !self.limit.zero? && valid_row\n row_count += 1\n if row_count >= self.limit\n break\n end\n end\n end\n # Save original CSV data for post-processing report\n @original_csv_data = csv_data\n end", "def valid_row?(index)\n row_values = row(index).compact\n row_values == row_values.uniq\n end", "def check_taxon_headers\n headers = @csvfile.headers()\n if headers.nil?\n @validation_results[:issues] << {:issue_description => 'Unable to read headers from CSV'}\n return\n end\n # Require at least one taxon header\n found_taxon_headers = (@config.taxonomy_columns.values) & headers\n if found_taxon_headers.empty?\n # No taxon headers found\n @validation_results[:issues] << {\n :issue_description => 'Missing taxon headers',\n :suggested_solution => \"Make sure CSV file has headers for taxa '#{@config.taxonomy_columns.values.join(',')}'.\"\n }\n else\n # Found at least one taxon header in the CSV file that is described by the template\n # Need to reverse the hash so that we can look up an internal group name (e.g. 'htg')\n # based on the value that appears in the CSV file (e.g. 'Higher Taxonomic Group')\n # Also, only store mappings for values that were found in the CSV, since our template\n # may reference extra fields\n\n @taxon_header_map = @config.taxonomy_columns.reject{|k,v| !found_taxon_headers.include? v }.invert\n @validation_results[:info] << {:info => 'Taxon headers are valid'}\n end\n end", "def test_csv_table_match(subject)\n # Compare the fields\n if !subject.empty?\n subject_fields = subject[0].keys\n master_fields = @golden_master.headers\n\n if subject_fields.count != master_fields.count\n throw_no_match \"Expected #{master_fields.count} field(s), got #{subject_fields.count}\"\n end\n\n master_fields.each_with_index do |column, index|\n if column != subject_fields[index]\n throw_no_match \"Expected field \\\"#{column}\\\", got field \\\"#{subject_fields[index]}\\\"\"\n end\n end\n end\n\n # Compare the number of records\n subject_record_count = subject.count\n master_record_count = @golden_master.inject(0){|count| count += 1}\n if subject_record_count != master_record_count\n throw_no_match \"Expected #{master_record_count} record(s), got #{subject_record_count}\"\n end\n\n # Compare the values of the golden master with the subject\n current_row = 0\n @golden_master.each do |row|\n row.each do |field, master_string|\n subject_value = subject[current_row][field]\n if !match_values?(master_string, subject_value)\n throw_no_match \"Field \\\"#{field}\\\", Record #{current_row + 1}: Expected value #{master_string.nil? ? '<NULL>' : \"\\\"#{master_string}\\\"\"}, got #{subject_value.nil? ? '<NULL>' : \"\\\"#{subject_value}\\\"\"}\"\n end\n end\n current_row += 1\n end\n end", "def filter_data_columns_csv(iterator)\n retval = []\n\n if iterator == nil\n return []\n end\n\n csv = CSV.parse(iterator, :headers => true, :skip_blanks => true)\n \n headers = csv.headers() \n #check for duplicate field names\n #dup_head = headers.detect {|e| headers.rindex(e) != headers.index(e)}\n dup_head = headers.detect do |e|\n if (!e.empty?) #For empty (e == \"\") header fields\n headers.rindex(e) != headers.index(e)\n end\n end\n \n if (headers.empty?)\n message = \"#### Error: header filtering failed.\\n\"\n return [message, nil]\n end\n \n if (dup_head != nil)\n message = \"### Error: document may contain duplicate column names.\\n\"\n message << \"# Source: \" << dup_head << \"\\n\"\n return [message, nil]\n end\n \n csv.each do |row|\n row_hash = (row.to_hash)\n retval << row_hash\n end\n\n return [message, retval]\n end", "def validUploadRow?(locale, row)\n missing_count = 0\n row.each do |key, val|\n shortKey = Upload.get_short(locale, key)\n if shortKey.present? && Upload::SHORT_REQ[shortKey.to_sym] && val.blank?\n puts \"invalid upload row: #{shortKey} - #{row.inspect}\"\n missing_count += 1\n end\n end\n return (missing_count > 2 ? false : true)\n end", "def laneBarcodeValidInSamplesCSV?(lane)\n sampleSheet = \"SampleSheet.csv\"\n laneFoundInCSV = false\n barcodeFoundInCSV = false\n\n if !@isFCMuxed\n return true\n end\n\n if !File::exist?(@baseCallsDir + \"/\" + sampleSheet)\n raise \"Error : Did not find Sample Sheet : \" + sampleSheet + \" in \" + @baseCallsDir\n end\n\n laneNumber = lane.slice(0).chr.to_s\n lines = IO.readlines(@baseCallsDir + \"/\" + sampleSheet) \n \n lines.each do |line|\n tokens = line.split(\",\")\n if tokens[1].to_s.eql?(laneNumber.to_s)\n laneFoundInCSV = true\n end\n if @barcodeSeq != nil && !@barcodeSeq.empty?() && tokens[4].to_s.eql?(@barcodeSeq)\n barcodeFoundInCSV = true\n end\n end\n\n if laneFoundInCSV && !barcodeFoundInCSV\n puts \"Error : Invalid Lane barcode \" + lane\n puts \" Lane Number present in CSV but barcode \" + @barcodeSeq + \" is absent from CSV\"\n return false\n elsif barcodeFoundInCSV && !laneFoundInCSV\n puts \"Error : Lane \" + laneNumber.to_s + \" is not multiplexed as per CSV\"\n return false\n else\n return true\n end\n end", "def test_read_csv_file\n assert oldsize = Redirection.count\n Redirection.read_google_csv(File.open(@test_data_dir + \"google_not_found.csv\"))\n assert_equal 4, Redirection.count - oldsize\n assert Redirection.find_by_uri(\"/computing/cvinfo\")\n assert Redirection.find_by_uri(\"/computing/cvinfo.html\")\n assert_equal 1, Redirection.find_all_by_uri(\"/index\").size\n end", "def validate\n # valid if list of headers identical to list of drills and data items combined\n # except that there may be dummy units, algorithm columns\n headers.each do |header|\n if !(definition.drill.keys+definition.data.keys+['units','algorithm','default']).include?(header)\n raise \"Header missing from itemdef: #{header}, itemdef has: #{(definition.drill.keys+definition.data.keys+['units','algorithm','default']).join(',')}\"\n end\n end\n (definition.drill.keys+definition.data.keys+['units']).each do |key|\n raise \"Header missing from data table: #{key}\" if !headers.include?(key)\n end\n end", "def _row_contains_data(row)\n if row.length > 1 then\n row[1..-1].each do |value|\n if value && value.length > 0 then\n return true\n end\n end\n end\n return false\n end", "def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true)\n # Iterate over the table object's rows\n csv.each do |row|\n # Create a hash for each row\n row_hash = row.to_hash\n # Convert each row_hash to an Entry by using add_entry method\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n\n # Get the number of items parsed by calling the count method\n return csv.count\n end", "def verify_header_names(key, models_columns, header)\n normalized_header = []\n\n got_error = false\n header.each_with_index do |h, i|\n logger.debug \"verify header: #{h}\"\n if h == \"id\"\n error(cur_sheet_name, 1, \"Header column #{h} not allowed, update not supported yet\")\n next\n end\n\n if h.nil?\t# ignore empty header\n normalized_header[i] = nil\n next\n else\n normalized_header[i] = normalize_header(h)\n end\n\n # see if heading is an attribute name, pseudo attribute,\n # fk_finder, refrerence id or reference to one\n # if so, put it in the models_columns :headers hash with header index\n header_is_known = false\n show_header_in_results = true\n models_columns.each_with_index do |mc, ci|\n\n # check for ambiguous header name\n if mc[:dups].has_key?(normalized_header[i])\nlogger.debug \"verify_header: ci: #{ci} found ambiguous header: #{normalized_header[i]}\"\n dup_index = mc[:dups][normalized_header[i]]\nlogger.debug \"verify_header: ci: #{ci} dup_index: #{dup_index}\"\n next if dup_index.nil?\n if dup_index == i\n header_is_known = true\n mc[:headers] << [normalized_header[i], i] # 0 based index\nlogger.debug \"header #{h} i: #{i} ci: #{ci} is_ambiguous_model_column mc[:headers]: #{mc[:headers]}\"\n break\n end\n next\n end\n\n if mc[:allowed_cols].include?(normalized_header[i])\n header_is_known = true\n mc[:headers] << [normalized_header[i], i] # 0 based index\nlogger.debug \"header #{h} is_model_column mc[:headers]: #{mc[:headers]}\"\n break\n end\n\n if is_pseudo_attr(mc[:model], normalized_header[i])\n header_is_known = true\n mc[:headers] << [normalized_header[i], i]\nlogger.debug \"header #{h} is_model_pseudo_attr mc[:headers]: #{mc[:headers]}\"\n break\n end\n\n if is_fk_finder_header(normalized_header[i], mc)\n header_is_known = true\n mc[:headers] << [normalized_header[i], i]\nlogger.debug \"header #{h} is_fk_finder mc[:headers]: #{mc[:headers]}\"\n break\n end\n\n if is_ref_def_header(normalized_header[i], mc[:model])\n header_is_known = true\n show_header_in_results = false\n @sheet_results[key][:_refs][(mc[:model]).name] = normalized_header[i]\n @sheet_results[key][:_ref_ids][normalized_header[i]] = {}\n mc[:headers] << [normalized_header[i], i]\nlogger.debug \"header #{h} is_ref_def mc[:headers]: #{mc[:headers]}\"\n break\n end\n\n if is_ref_ref_header(normalized_header[i], mc)\n header_is_known = true\n mc[:headers] << [normalized_header[i], i]\nlogger.debug \"header #{h} is_ref_ref mc[:headers]: #{mc[:headers]}\"\n break\n end\n end\n if !show_header_in_results\n normalized_header.delete_at(i)\n end\n next if header_is_known\n\n # error if not recognized, but continue to gather all errors\n got_error = true\n error(cur_sheet_name, 1, \"Header name '#{h}' is not recognized for model(s) #{model_column_names(models_columns)}\")\n end\n return false if got_error\n\n#logger.debug \"mc[0][:headers]: #{models_columns[0][:headers]}\"\n#logger.debug \"mc[1][:headers]: #{models_columns[1][:headers]}\"\n\n @sheet_results[key][:header] = [\"id\"] + normalized_header.compact\n logger.debug \"Normalized header: key: #{key} #{@sheet_results[key][:header]}\"\n return true\nend", "def verify_table_length(records)\n records.size == TestRecord.count\n end", "def validate()\n cs = checksum()\n return cs == @header[LENGTH - 1]\n end", "def check_is_numeric(csv_data, column_name)\n data = csv_data.select{|item| !item[column_name].nil? }\n non_numeric_values = data.filter{|i| !CSV::Converters[:integer].call(i[column_name]).is_a?(Numeric) }\n naughty_values = non_numeric_values.map{|i| \" 👉 \\\"#{i[column_name]}\\\"\" }.join(\"\\n\")\n if non_numeric_values.length > 0\n puts \"🔴 Found non numeric data in #{column_name} \\n\\n#{naughty_values}\\n\\n\"\n return true \n else \n return false\n end\n end", "def seriously_dude?(response)\n response.split(\"\\n\").map do |row|\n begin\n row.parse_csv.map(&:downcase!).compact\n rescue\n nil\n end\n end.select{|r| r.present? && (r.length > 1)}.uniq\n end", "def verify_dispatch_tables(h)\n\n h.each{|k,h|\n\n field = h['field']\n tbl = h['table']\n\n numrows = tbl.size\n numcols = tbl[0].size\n\n rowctr = 0\n\n tbl.each{|r|\n\n if (r.size != numcols)\n raise \"error: tbl #{k} error row #{rowctr}\"\n end\n\n rowctr += 1\n }\n }\nend", "def valid_row?(row)\n required_csv_fields.all? do |required_field|\n valid_field = row[required_field].present?\n row[:errors] << \"The field #{I18n.t(required_field).titleize} is required!\" unless valid_field\n valid_field\n end\n end", "def has_listed_files?\n file_count = 0\n all_valid = true\n files_file_path = FileLocations.files_file_path(@source_dir)\n ::CSV.foreach(files_file_path, headers: true).each do |csv_row|\n next if csv_row.blank?\n # Each file listed in FILES.csv should be valid\n row = strip_csv_row(csv_row)\n file_count += 1\n all_valid = all_valid && has_valid_file?(row, file_count)\n end\n # FILES.csv should have atleast 1 row\n unless file_count > 0\n @errors << \"Metadata file #{files_file_path} has no rows\"\n all_valid = false\n end\n # There should be no unverified files\n all_valid\n end", "def check_duplicate(line)\n return line.uniq.length == line.length\nend", "def check_eof( row )\n @eof = !row.has_key?( :row )\n end", "def csv_file_headers\n # Open file\n CSV.foreach(self.file.path, headers: true) do |row|\n # Transform row to hash\n row = row.to_hash\n # Normalize it\n row = normalize_row(row)\n errors.add(:file, \"Invalid CSV headers, please check if #{required_csv_headers.join(', ')} are present.\") unless valid_headers?(row)\n break\n end\n end", "def solr_metadata_not_in_csv(csv_metadata, solr_metadata)\n not_in_csv = solr_metadata.reject { |s| csv_metadata.any? { |c| c.casecmp(s.strip).zero? } }\n log(\"ERROR: Found solr metadata that wasn't in the CSV, appending to the end of the list during migration => #{not_in_csv.join('; ')}\") unless not_in_csv.empty?\n not_in_csv\n end", "def csv_file_header_array\n\t\tScreeningDatumUpdate.expected_column_names\n\tend", "def find_errors(data)\n keys = Hash.new(0)\n columns = [data.chron_column, data.dimension_columns].flatten.compact\n allkeys = columns.map{|col| col.values}.transpose\n allkeys.each {|keylist| keys[keylist] += 1}\n duplicates = []\n keys.each_pair do |key, count|\n duplicates << key if count > 1\n end\n duplicates.each do |dup|\n @errors << \"Duplicate entry in source for (#{dup.map {|key| key.to_s}.join(', ')})\"\n end\n end", "def has_valid_file?(row, row_index)\n # Ignore FILES.csv\n filepath = get_data_path(row.fetch('path'))\n return false if filepath.nil?\n return true if filepath.end_with?(FileLocations.files_file_name)\n # the file exists on disk\n return false unless has_file?(filepath, row_index)\n # The file size matches\n has_size = has_required_size?(filepath, row, row_index)\n # The hash matches\n has_hash = has_required_hash?(filepath, row, row_index)\n # Files ias added to list of cheked files\n @checked_files_in_file << filepath\n has_size && has_hash\n end", "def verify_data_positions(hash)\n items = hash.values\n\n positions=Array.new\n for thing in items\n positions << thing[:position]\n end\n \n all_unique = true\n\n for value in positions\n if positions.count(value)>1\n print \"Position \" + value.to_s + \" is not unique!\"\n all_unique=false \n end\n\n end\n \n return all_unique\n\nend", "def is_valid?(line)\n words = line.split(/\\s+/)\n words.length == words.uniq.length\nend", "def scanFirstRowOfIndividualLogFile(row)\n @csvColumnLabelList = [] ;\n @csvColumnIndex = {} ;\n row.each{|val|\n index = @csvColumnLabelList.length ;\n @csvColumnIndex[val] = index ;\n self.instance_variable_set(\"@index_\" + val.to_s, index) ;\n @csvColumnLabelList.push(val) ;\n }\n RequiredColumnName.each{|colName|\n if(!@csvColumnIndex.has_key?(colName)) then\n p [:missingColumn, colName] ;\n raise(\"log CSV file should have the column: \" + colName) ;\n end\n }\n end", "def findCsvRowError (row)\n error = nil\n\n if row.size != 4\n error = 'Row does not have 4 entries'\n elsif !row.key?('object_id') || row['object_id'] == '' || !isPositiveInteger?(row['object_id'])\n error = 'Row object_id does not correspond to a valid integer'\n elsif !row.key?('object_type') || row['object_type'] == ''\n error = 'Row object_type does not correspond to a non-empty string'\n elsif !row.key?('timestamp') || row['timestamp'] == '' || !isPositiveInteger?(row['timestamp'])\n error = 'Row timestamp does not correspond to a valid integer'\n elsif !row.key?('object_changes')\n error = 'Row object_changes is not a valid json structure'\n else\n begin\n JSON.parse(row['object_changes'])\n rescue JSON::ParserError => e\n error = 'Row object_changes is not a valid json structure'\n end\n end\n\n return error\n end", "def validate_rows(errors, rows)\n errors = errors\n titles = {}\n title = rows.each_with_index do |row, index|\n titles[row.title] = titles[row.title].to_i + 1\n errors << { \"Row #{index + 2}\": \"title must be unique. Duplicate value: #{row.title}\" } if titles[row.title] > 1\n end\n # Resort the errors which got appeneded. The format of the errors requires conversion from a symbol to integer\n errors.sort_by { |hsh| hsh.keys[0].to_s.sub(\"Row \",\"\").to_i }\n end", "def parse_all(filename, vio, rac, sex, age)\n count = 0\n CSV.foreach(filename, headers: true, converters: %i[numeric date]) do |row|\n vio[row[\"violation\"]] += 1\n rac[row[\"subject_race\"]] += 1\n sex[row[\"subject_sex\"]] += 1\n age.push(row[\"subject_age\"])\n count += 1\n end\n count\nend", "def csv?(csv)\n valid = csv.include?(';')\n valid |= csv.include?(',')\n valid &= csv.include?(\"\\n\")\n valid\n end", "def process\n lines = clean_lines\n\n # Peek ahead to get the headers\n unless @file_content.blank?\n CSV.parse(@file_content, {:headers => true, :skip_blanks => true}) do |row|\n @rows_exist = true\n @headers = row.headers\n break\n end\n end\n\n @rows_exist = @rows_exist and !@headers.blank?\n end", "def verify_column_headers\n \n unless (headers = get_spreadsheet.headers)\n # log an error if we can't get the metadata headers\n @verification_errors << BulkOps::Error.new({type: :bad_header, field: column_name}) \n end\n\n headers.each do |column_name|\n next if column_name.blank?\n column_name_redux = column_name.downcase.parameterize.gsub(/[_\\s-]/,\"\")\n # Ignore everything marked as a label\n next if column_name_redux.ends_with? \"label\"\n # Ignore any column names with special meaning in hyrax\n next if BulkOps::SPECIAL_COLUMNS.any?{|col| col.downcase.parameterize.gsub(/[_\\s-]/,\"\") == column_name_redux }\n # Ignore any columns speficied to be ignored in the configuration\n ignored = options[\"ignored headers\"] || []\n next if ignored.any?{|col| col.downcase.parameterize.gsub(/[_\\s-]/,\"\") == column_name_redux }\n # Column names corresponding to work attributes are legit\n next if Work.attribute_names.any?{|col| col.downcase.parameterize.gsub(/[_\\s-]/,\"\") == column_name_redux }\n @verification_errors << BulkOps::Error.new({type: :bad_header, field: column_name})\n end\n end", "def test_s_parseAndCreate\n colSize = 8\n csvStr = \"foo,!!!foo!!!,!foo,bar!,!!!!!!,!!,,!\\r!,!\\r\\n!\\nNaHi,!!!Na!!!,!Na,Hi!,!\\r.\\n!,!\\r\\n\\n!,!!!!,!\\n!,!\\r\\n!\".gsub!('!', '\"')\n csvStrTerminated = csvStr + \"\\n\"\n\n myStr = csvStr.dup\n res1 = []; res2 = []\n idx = 0\n col, idx = CSV::parse_row(myStr, 0, res1)\n col, idx = CSV::parse_row(myStr, idx, res2)\n\n buf = ''\n col = CSV::generate_row(res1, colSize, buf)\n col = CSV::generate_row(res2, colSize, buf)\n assert_equal(csvStrTerminated, buf)\n\n parsed = []\n CSV::Reader.parse(csvStrTerminated) do |row|\n parsed << row\n end\n\n buf = ''\n CSV::Writer.generate(buf) do |writer|\n parsed.each do |row|\n\twriter.add_row(row)\n end\n end\n assert_equal(csvStrTerminated, buf)\n\n buf = ''\n CSV::Writer.generate(buf) do |writer|\n parsed.each do |row|\n\twriter << row\n end\n end\n assert_equal(csvStrTerminated, buf)\n end", "def valid?(board_array)\n board_array.each { |row| return false if row.length != row.uniq.length }\n return true\nend", "def scanCsv(csvFile)\n CSV.foreach(csvFile){|row|\n if(@colList.nil?) then\n scanCsvHeader(row) ;\n else\n scanCsvEntry(row) ;\n end\n }\n end", "def check_length_of_columns_vs_lines\n longest = 0\n self.line_items.each {|line| longest = line.body_array.length if line.body_array.length > longest }\n set_error_message(\"Column lengths do not match\") unless self.fields.length == longest\n end", "def unique_date?\n if config['BATCH']['date']\n date_index = config['BATCH']['date'][0]\n dates = csv.collect{|row| row[date_index]}.compact\n dates.uniq.length == 1\n else\n true\n end\n end", "def unique_record_check(record,row)\n #recupero tutte le info necessarie per memorizzare la chiave primaria\n plot_id = Plot.find(:first,:conditions => [\"numero_plot = ? AND deleted = false\",record.cod_plot]).id\n active_campaign_id = Campagne.find(:first,:conditions => [\"active = true\"]).id\n file = ImportFile.find(session[:file_id])\n #cerco la chiave primaria\n pk = Copl.find(:first,:conditions => [\"campagne_id = ? AND plot_id = ? AND subplot = ? AND in_out = ? AND priest = ? AND file_name_id = ? AND import_num = ?\", active_campaign_id, plot_id, record.subplot, record.in_out, record.priest, file.id, file.import_num])\n #se già è presente\n if pk\n #salvo l'errore\n save_error(record,\"Duplicate row\",row)\n #segnalo che c'è stato un errore sulla riga\n session[:row_error] = true\n #e segnalo l'errore sul file\n session[:file_error] = true\n end\n end", "def test_first_table_has_correct_length\n assert_equal( 1, @result.values.first.size )\n end", "def _find_number_of_data_rows(rows, col=0)\n puts \"Finding number of data rows. rows.length is returning: #{rows.length.to_s}\"\n cnt_data_rows = 0\n\n rows.each do |row|\n if row.cells.length > 0\n if row.cells[col].present?\n cnt_data_rows = cnt_data_rows + 1\n end # if row.cells[col].present?\n end # if row.cells.length > 0\n end if rows.present? # rows.each do |row|\n\n puts \"We found #{ (cnt_data_rows-1).to_s }\"\n\n # Subtract 1 for header row.\n return cnt_data_rows-1\n end", "def test_parse_headers\n tmpdbfile = Tempfile.new('tmp.db')\n args = [\"--header\", \n \"--source\", \"header_test.csv\", \n \"--save-to\", tmpdbfile.path, \n \"--ifs=\" \",\",\n \"--table-name\",\"header_test\"]\n Csvql.run(args)\n\n db = SQLite3::Database.new tmpdbfile.path\n headers_from_db = db.execute2('select * from header_test;')[0]\n headers_from_file = File.open('header_test.csv').each_line.first.gsub(/\\n/,'').split(',')\n\n #binding.pry\n assert_equal headers_from_db, headers_from_file\n end", "def csv_func\n write_file = File.open(\"output_isbn_file.csv\", \"w\" , { :col_sep => \"\\n\" , :row_sep => \"\\n\"} )\n\n CSV.foreach('input_isbn_file.csv') do |row|\n if isbn_check(row[1]).to_s== \"true\"\n row << (\"valid\")\n else\n row << (\"invalid\")\n\n end\n \n write_file.puts row[0] + \",\" + row[1] + \",\" + row[2]\n\n end\n write_file.close\nend", "def check_correspondence(header)\n\t\terr = \"\"\n\t\tif(header.length > @map.length)\n\t\t\traise \"inconsistent between header and mapping\"\n\t\tend\n\t\t\n\t\tidx = 0\n\t\t@map.each_key do |key|\n\t\t\tif(idx == header.length-1) \n\t\t\t\tbreak\n\t\t\telsif(header[idx].eql?(key))\n\t\t\t\tidx+=1\n\t\t\tend\n\t\tend\n\t\tif(idx < header.length - 1)\n\t\t\traise \"inconsistent between header and mapping_\"\n\t\tend\n\t\t\n\t#\tputs header\n\t#\tputs @map\n\t#\tputs \"IDX=\"+idx.to_s\t\n\tend", "def clean_up_data(rows)\n rows.delete_if { |row| row.any? { |value| value.length < 3 } }\n # Remove headers and trailing header\n rows.delete_at(0)\n rows.delete_at(-1)\n rows\nend", "def column_count\r\n assert_exists\r\n arr_rows = rows\r\n return arr_rows[0].column_count\r\n end", "def process_data(data, header)\n i = 2\n if data.present?\n data.each do |row|\n obj = Transport.new(:academic_year_id => academic_year_id)\n header.each do |name|\n method_n = header_to_method(name)\n send(method_n, obj, row[name].try(:strip)) if row[name].present? or method_n == \"fare\"\n end\n val = obj.save\n log_error(i, obj.errors.full_messages) unless val\n i += 1\n end\n else\n import_failed(1, t(:no_data_present_in_csv))\n end\n end", "def validate_values(header_name, valid_values_method)\n column_number = @transformed_headers.find_index(header_name)\n return unless column_number\n\n @rows.each_with_index do |row, i|\n next if i.zero? # Skip the header row\n next unless row[column_number]\n\n values = row[column_number].split(delimiter)\n valid_values = method(valid_values_method).call\n invalid_values = values.select { |value| !valid_values.include?(value) }\n\n invalid_values.each do |value|\n @errors << \"Invalid #{header_name.titleize} in row #{i + 1}: #{value}\"\n end\n end\n end", "def test_inserts_single_csv_address\n cma.populate_csv(\"./test/data/address.csv\")\n assert_equal 1, cma.count\n end", "def fail_unless_header_complete(column_mappings)\n return unless header_lines > 0 && !header_valid?\n\n expected_names = column_names(column_mappings)\n received_names = @header_best_guess || []\n\n unexpected = received_names - expected_names\n missing = expected_names - received_names\n\n fail header_message_for(missing, unexpected)\n end", "def process_CSV_file(file, _total_lines = 0, charset = 'bom|utf-8')\n start_time = Time.now.to_i # setting up time keeping\n ActiveRecord::Base.transaction do\n SmarterCSV.process(file, chunk_size: 10, verbose: true, file_encoding: charset.to_s) do |file_chunk|\n file_chunk.each do |record_row|\n sanitized_row = sanitize_row(record_row)\n process_record_row(sanitized_row, {})\n @counter << sanitized_row # appends in latest record to allow error to report where import failed\n ### CallingActorInUpdater feeding it the this (the current) actor.\n @updater_actor.run(Celluloid::Actor.current) unless @updater_actor.nil?\n @counter\n end\n end\n # finishing up time keeping and reporting:\n total_count = @counter.size\n end_time = Time.now.to_i\n total_count_hash = { total_lines: total_count, time: ((end_time - start_time) / 60).round(2) }\n puts \"\\033[32m#{total_count_hash}\\033[0m\\n\" # green\n @exit_status = 0\n @result = total_count_hash\n end\n ensure\n # on CSV::MalformedCSVError # something gets said\n @updater_actor.terminate unless @updater_actor.nil?\n end", "def unique?\n if @data.fetch(:Index_type) == \"UNIQUE\" || @data.fetch(:Non_unique).to_i == 0\n return true\n else\n return false\n end\n end", "def recommendation_csv_inputs csv_path\n valid_inputs = []\n\n CSV.foreach(csv_path, {headers: true, header_converters: :symbol}) do |row|\n row = row.to_h\n valid_inputs << row if valid_recommendation_hash?(row)\n end\n\n valid_inputs\n\n rescue => e\n valid_inputs\n end", "def product_import_initial_values\n if @temp_file.blank?\n errors.add(:file_missing, \"file missing\")\n return false\n end\n\n begin\n file_content = read_import_csv(@temp_file)\n rescue Exception => e\n errors.add(:encoding_failed, \"<br />#{e.backtrace.join('<br />')}\")\n return false\n end\n\n begin\n data = CSV.parse(file_content)\n rescue Exception => e\n errors.add(:invalid_csv, \"<br />#{e.backtrace.join('<br />')}\")\n return false\n end\n\n if has_header?\n header_row = parse_header(data.first)\n errors.add(:has_header) unless valid_header?(header_row, import_kind)\n end\n end", "def victory_row?(row_values)\n unique_values = row_values.uniq\n one_unique_value?(unique_values)\nend", "def required_csv_headers\n [:email, :name]\n end", "def importable_class_headers_ok?\n extra_headers = importable_columns - headers\n if extra_headers.empty?\n @columns_not_found = nil\n return true\n else\n @columns_not_found = extra_headers.join(', ')\n return false\n end\n end", "def validate_unique *colnames\n\t\t\tcolnames.each { |colname|\n\t\t\t\tds = self.class.where colname => send(colname)\n\t\t\t\tds.filter!(~{primary_key => send(primary_key)}) unless new?\n\t\t\t\tif ds.count > 0\n\t\t\t\t\terrors.add(colname, 'must be unique.')\n\t\t\t\tend\n\t\t\t}\n\t\tend", "def validate_row(row_hash)\n row_validation_errors(row_hash).empty?\n end", "def parse_header(filename, header)\n result = Hash.new(0)\n CSV.foreach(filename, headers: true, converters: %i[numeric date]) do |row|\n result[row[header]] += 1\n end \n result \nend", "def validate_values(header_name, valid_values_method, case_insensitive = false)\n @parsed_csv.each_with_index do |row, index|\n next if row.to_hash.values.all?(&:nil?) # Skip blank rows\n next unless row[header_name]\n values = row[header_name].split(delimiter)\n valid_values = method(valid_values_method).call\n invalid_values = invalid_values(values, valid_values, case_insensitive)\n\n invalid_values.each do |value|\n @errors << \"Invalid #{header_name.to_s.titleize} in row #{index + 2}: #{value}\"\n end\n end\n end", "def valid_data?\n not_blank = (params[:upload_file] != \"\")\n is_csv = (params[:upload_file].content_type == \"text/csv\")\n\n not_blank && is_csv\n end", "def make_testdata_reworked_csv_file\n create_column_headers_index_hash \n create_row_headers_index_hash \n clear_testdata_reworked_file\n CSV.open('testdata_reworked.csv', \"wb\") do |csv|\n CSV.foreach('testdata.csv', {headers: true}) do |row| \n row[0] = @column_hash.key(row[0].to_i)\n row[1] = @row_hash.key(row[1].to_i)\n csv << row\n end\n end\nend", "def validate_headers\n raise UnknownDataField, unknown_headers.join(',') if unknown_headers.present?\n end", "def prefilter_csv_data(raw_csv_data)\n # De-dup emails absolutely\n csv_data = raw_csv_data.uniq{|row| row[:email]}\n\n # Remove data with duplicate names scoped in company and address (parameterized)\n #csv_data.uniq{|row| \"#{row[:first_name]} #{row[:last_name]} #{row[:company]} #{row[:address]}\".try(:parameterize)}\n end", "def uniqeErrorLines data\n\tset = Set.new\n\tfor row in data do\n\t\tset.add row[\"Line\"].to_s\n\tend\n\t@lines = \"\";\n\tfor e in set do\n\t\t@lines += e + \",\"\n\tend\n\treturn @lines[0..-2]\nend", "def number_of_columns\n return rows.first.length unless rows.empty?\n raise Error, 'your table needs some rows'\n end", "def load_data\n path = ENV[\"path\"]\n if !path.blank? && FileTest.exists?(path)\n File.open(path + \".error_rpt\",\"w+\") do |f|\n f.write(\"Errors While inserting to db\")\n end \n rowcount = 0\n FCSV.foreach(path, :headers=>true) do |row|\n rowhash = row.to_hash\n rowcount = rowcount + 1\n rowhash[\"slno\"] = rowcount\n yield rowhash \n end \n else\n puts \"Error please provide a valid file: \" \n end\nend" ]
[ "0.72180647", "0.7186385", "0.7156484", "0.6971711", "0.6933744", "0.69251376", "0.69096893", "0.6859789", "0.6753944", "0.6720358", "0.6642854", "0.6543956", "0.64059967", "0.640305", "0.6380496", "0.63673365", "0.6366493", "0.62796265", "0.62711096", "0.6256302", "0.6122794", "0.60947543", "0.60774", "0.60722315", "0.60527414", "0.6030218", "0.59938014", "0.5966097", "0.59558874", "0.59417367", "0.5886794", "0.587988", "0.58750343", "0.5873837", "0.58543134", "0.5852204", "0.5825217", "0.58225393", "0.5817807", "0.5814696", "0.5803319", "0.5800789", "0.57995135", "0.5728121", "0.57017577", "0.5694608", "0.56919926", "0.5674688", "0.5627975", "0.56270444", "0.56098264", "0.5607622", "0.5603145", "0.5600439", "0.5586721", "0.55787015", "0.55759823", "0.55724686", "0.556961", "0.5548877", "0.55341715", "0.5524701", "0.55242133", "0.5515357", "0.55143434", "0.5507639", "0.55064976", "0.5505808", "0.5498727", "0.54880726", "0.5478402", "0.5472387", "0.5466175", "0.54587495", "0.5449149", "0.5440136", "0.5415452", "0.5408731", "0.54000205", "0.53966624", "0.5380853", "0.5372315", "0.5369457", "0.5366528", "0.5361615", "0.5351936", "0.5350966", "0.5347523", "0.5345207", "0.53434676", "0.5338218", "0.53334194", "0.5332861", "0.5330644", "0.5318228", "0.5298285", "0.52967507", "0.52935004", "0.528549", "0.52794975" ]
0.5400881
78
Following methods use select instead of where to force retrieving prices even if they are not persisted
def book_tickets prices.select{ |p| p.type == 'Price::BookTicket' }.reject(&:blank?).sort_by(&:number) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prices(id, where)\n Price.find(:all, :conditions=>\"dish_id=#{id} and freezer='#{where}'\")\n end", "def active_prices\n prices.where('active = 1')\n end", "def all_prices\n request :public, :get, :price\n end", "def prices\n Excursion.all.each do |excursion|\n excursion.price \n end\n end", "def find_price_by_currency(currency)\n self.prices.find_by_currency(currency)\n end", "def fetch\n Abacos.prices_available.map do |s|\n {\n id: s[:codigo_produto],\n code_abacos: s[:codigo_produto_pai],\n price: s[:preco_tabela],\n promotional_price: s[:preco_promocional],\n protocolo_preco: s[:protocolo_preco]\n }\n end\n end", "def set_price\n @price = Price.find(params[:id])\n @prices = Price.order('position Asc')\n #@price.strain_id = Strain.find(params[:id]).id\n #@price.region_id = Region.find(params[:id]).id\n end", "def price_in(currency)\n get_price_in(currency) || prices.first || Spree::Price.new(:variant_id => self.id, :currency => currency)\n end", "def set_prices\n @price = Price.find(params[:id])\n end", "def request_raw_prices\n Ds::Pim::Api.get_product_offering_prices @offering_id # Array\n end", "def special_prices\n prices\n end", "def index\n @prices = @prices.includes(:good).paginate( :page => params[:page])\n end", "def get_products2()\n products = Product.find_by_sql(['Select products.*,\n stocks.quantity \n from products \n INNER JOIN stocks ON products.id = stocks.product_id order by products.code '])\n return products\n end", "def new_prices\n # Since everything is relative to USD, we don't need to fetch it.\n commodities\n .reject { |c| c == \"USD\" }\n .reduce(existing_prices) do |db, c|\n # `|` is a shortcut for merge\n db | prices_for_symbol(c, start_date: start_date, end_date: end_date)\n .map { |x| price_string_from_result(x, symbol: c) }\n end\n end", "def price\n raise 'Redefine this method in your billing model.'\n end", "def price\n raise 'Redefine this method in your billing model.'\n end", "def special_prices\n customized_special_prices || prices\n end", "def search_by_price(database, price)\n\tsearch_result = database.execute(<<-SQL \n\t\t\tSELECT * FROM restaurants WHERE price<= \"#{price}\" ORDER BY price\n\t\tSQL\n\t\t) \n\tprint(search_result, \"price\")\nend", "def price\n (read_attribute(:sale_price) if on_sale?) || read_attribute(:price)\n end", "def price\n @price\n end", "def price\n @price\n end", "def price_fluc\n # return nil when current price is unavailable\n return nil if kindle_price == -1\n\n price_changes = prices(:order => [:retrieved_at.desc])\n\n # defensive code, this case is incorrect\n return nil if price_changes.empty?\n\n if price_changes.length == 1 # only 1 price, no fluc\n []\n else\n [price_changes[1], price_changes[0]]\n end\n end", "def set_price\n\t\tif persisted?\n\t\t\tself[:price]\n\t\telse\n\t\t\tproduct.price\n\t\tend\n\tend", "def execute(input_set = nil)\n resp = super(input_set)\n results = GetPriceResultSet.new(resp)\n return results\n end", "def index\n @prices = Price.all\n end", "def index\n @prices = Price.all\n end", "def stock\n sql = \"SELECT * FROM cars\n WHERE shop_id = $1\"\n value = [@id]\n cars = SqlRunner.run(sql, value)\n result = cars.map{|car| Car.new(car)}\n return result\n end", "def get_prices(timestamp, duration = 31.minutes)\n price_class = \"::#{exchange_name.capitalize}Price\".constantize\n execute_query(\n price_class.where('timestamp > ?', (timestamp - duration.to_i)).to_sql\n )\n end", "def original_price\n self.read_attribute(:price)\n end", "def original_price\n read_attribute(:price)\n end", "def price\n \n end", "def last_price\n logger.info 'LAST PRICE LOAD BEGIN.'\n instruments = Instrument.select(:id, :symbol).joins(positions: :portfolio).where(portfolios: { user_id: current_user.id }).order(:symbol).distinct # Get instrument list. Added .order for WebMock testing.\n trades = DataCache.price_values(instruments, params.key?('livePrices'))\n logger.info 'LAST PRICE LOAD END.'\n render json: trades, each_serializer: TradeSerializer\n end", "def index\r\n @base_prices = BasePrice.all\r\n end", "def price_in_cents\n read_attribute(:price) \n end", "def price\n self.default_variant ? self.default_variant.price : read_attribute(:price)\n end", "def index\n @admin_prices = Price.all\n end", "def selected_price_model\n \t@selected_price_model\n \tend", "def price\n return 0 unless self.persisted?\n\n return product.master.price if with_master_price?\n\n default_price.price\n end", "def price_document\n self.carrier_product_price.try(:price_document)\n end", "def price_as_price\n @price_as_price ||= Price.new(price, price_includes_tax?, tax_rate)\n end", "def find_price(price_id)\n prices.select { |e| e.id.to_s == price_id.to_s }.first\n end", "def get_price_by_currency(currency_code)\n currency_id = Currency.find_by_code(currency_code).id\n product_prices.find_by_currency_id(currency_id)\n end", "def get_price\n item_prc_1\n end", "def price()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Price::PriceRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def price_for(price_options)\n variant.currently_valid_prices.detect do |price|\n ( price.country_iso == price_options.desired_attributes[:country_iso] ||\n price.country_iso.nil?\n ) && price.currency == price_options.desired_attributes[:currency]\n end.try!(:money)\n end", "def price\n on_sale? ? sale_price : original_price\n end", "def price\n return eval_shop_condition(@price_formula) unless @price_formula.empty?\n return item.price if @price_type == 0\n return @price\n end", "def list_price\n support_product_number = type == 'hw' ? 'HA104A' : 'HA107A'\n year1 = PricingDbHpPrice.option_price(:product_number => support_product_number, :year => 1, :option_number => option_number)\n year3 = PricingDbHpPrice.option_price(:product_number => support_product_number, :year => 3, :option_number => option_number)\n year4 = PricingDbHpPrice.option_price(:product_number => support_product_number, :year => 4, :option_number => option_number)\n @list_price = [(year4 - year3)/BigDecimal(\"12.0\"), (year3 - year1)/BigDecimal(\"24.0\")].max\n end", "def index\n @product_prices = ProductPrice.where(user_id: current_user.user_id).search(params[:search]).paginate(page: params[:page], per_page: 50).order('updated_at DESC')\n end", "def index\n # @prices = Price.where(name:['木瓜(元/公斤)','蘿蔔(元/公斤)','香菇(太空包)乾(元/公斤)']).order(:name)\n @prices = Price.order(:name)\n #get_json\n end", "def set_price\n @price = Price.find(params[:id])\n end", "def fetch_market_prices(ids)\n rescue_metrics_down_with({}, stat_timeout) do\n scatter_gather_batch(ids) do |ids_slice|\n raw = JSON.parse(resource['product_stats'].post(:ids => ids_slice))\n # Preserve misses, which are a nil stat\n hashmap(raw) {|stat| stat && MarketPrice.new(stat)}\n end\n end\n end", "def original_price\n @price || item.price\n end", "def price # getter for rent in cents\n\t\tread_attribute(:price_in_cents)\n\tend", "def index\n is_logged_in\n @prices = Price.last\n if @prices.nil? \n @prices = Price.new\n end\n end", "def price_with_tax\n price_as_price.with_tax\n end", "def get_supplier_payments0(fecha1,fecha2)\n @vouchers = SupplierPayment.where([\" company_id = ? AND fecha1 >= ? and fecha1<= ? \", self.id, \"#{fecha1} 00:00:00\",\"#{fecha2} 23:59:59\" ]).order(:id)\n return @vouchers \nend", "def get_supplier_payments0(fecha1,fecha2)\n @vouchers = SupplierPayment.where([\" company_id = ? AND fecha1 >= ? and fecha1<= ? \", self.id, \"#{fecha1} 00:00:00\",\"#{fecha2} 23:59:59\" ]).order(:id)\n return @vouchers \nend", "def get_supplier_payments0(fecha1,fecha2)\n @vouchers = SupplierPayment.where([\" company_id = ? AND fecha1 >= ? and fecha1<= ? \", self.id, \"#{fecha1} 00:00:00\",\"#{fecha2} 23:59:59\" ]).order(:id)\n return @vouchers \nend", "def find_price_by_product_id(product_id, products = Products)\n products[\"prices\"].each do |product|\n return product[\"price\"] if product[\"product_id\"]== product_id\n end\n end", "def create_price \n Price.create_from_item(self)\n end", "def price(date)\n if self.show_prices().any? {|price| price[\"date\"] == date}\n selected_price = @prices.map {|price| return price[\"val\"] if price[\"date\"] == date}\n else\n return false\n end\n end", "def set_price\n @price = Price.find(params[:id])\n end", "def set_price\n @price = Price.find(params[:id])\n end", "def set_price\n @price = Price.find(params[:id])\n end", "def set_price\n @price = Price.find(params[:id])\n end", "def set_price\n @price = Price.find(params[:id])\n end", "def set_price\n @price = Price.find(params[:id])\n end", "def set_price\n @price = Price.find(params[:id])\n end", "def set_price\n @price = Price.find(params[:id])\n end", "def index\n @list_prices = ListPrice.all\n end", "def fixed_price\n data.fixed_price\n end", "def get_value_of_shelf\n value = DATABASE.execute(\"SELECT price, quantity FROM products WHERE shelf_id = #{@id}\")\n \n value.each do |x|\n shelf_value += x[:quantity] * x[:price]\n end\n shelf_value\n end", "def set_price\n @price = Price.find(params[:id])\n end", "def prices\n return @prices unless @prices.nil?\n\n base_price = @random.int(90..110)\n formula = Formula.create(@pattern, base_price, @random)\n @prices = formula.exec\n end", "def prices (currency='TWD')\n get '/prices/' + currency\n end", "def price(_currency)\n raise Sibit::NotSupportedError, 'price() doesn\\'t work here'\n end", "def call_centre_commission\n # .where.not('PRODUCT_VARIANTS.product_sell_type_id = ?', 10000).each do |ord| upsell_products << \" #{ord.product_variant.extproductcode}\n ext_prod_code = self.product_variant.extproductcode\n if ProductVariant.where(extproductcode: ext_prod_code ).where(\"product_sell_type_id != ?\", 10000).present?\n\n product_cost = ProductCostMaster.where('prod = ?', self.product_variant.extproductcode)\n #.pluck(:value)\n if product_cost.present?\n return product_cost.first.call_centre_commission\n else\n return 0\n end\n else\n return 0\n end\nend", "def set_prices\n @prices = Campground.find(params[:campground_id]).seasons.find(params[:season_id]).prices.where(rental_category_id: params[:rental_category_id])\n end", "def unit_price\n return self[:unit_price] if persisted?\n product.price\n end", "def get_oil_price_obj(date)\n oil_price_obj = OilPrice.where('date <= ?', date).order(date: :desc).limit(1)[0]\n if oil_price_obj == nil\n oil_price_obj = OilPrice.order(date: :asc).limit(1)[0]\n end\n return oil_price_obj\n end", "def get_product_prices(page_html, selector = { price: nil, old_price: nil }) #, saving: ''\n product_data = { price: nil, old_price: nil } #, saving: nil\n\n selector.each { |key, value| product_data[key] = get_float(page_html.css(value).last) }\n\n product_data\n end", "def get_city_on_price(db,price)\n rows = db.execute(\"SELECT cities.city_name, cities.city_coutery_location FROM \n cities WHERE cities.city_prices ='#{price}'\")\n puts \"City Name Country\"\n puts \"--------- -------\"\n\n rows.each do |row|\n puts \"#{row['city_name']} -- #{row['city_coutery_location']}\"\n end\nend", "def sell_price\r\n price\r\n end", "def set_pln_invoice\n @pln_invoice = PlnInvoice.find(params[:id])\n @pln_invoice_items = @pln_invoice.pln_invoice_items\n @prices = @pln_invoice_items.where.not(price_netto: nil).first\n end", "def price_like_shiny_mouse_sub\n # There are multiple 'Shiny Mouse' toys that all have different prices.\n # Your goal is to list all names and prices of the toys with the same prices \n # as the different 'Shiny Mouse' toys. \n\n # Exclude the 'Shiny Mouse' toy from your results.\n # Order your alphabetically by toy name.\n\n # USE A SUBQUERY\n execute(<<-SQL) \n SELECT DISTINCT toys.name, toys.price\n FROM cattoys\n JOIN cats ON cat_id = cats.id\n JOIN toys ON toy_id = toys.id\n WHERE toys.price IN (\n SELECT price\n FROM toys\n WHERE toys.name = 'Shiny Mouse')\n AND toys.name != 'Shiny Mouse'\n ORDER BY toys.name ASC\n SQL\nend", "def select(*args)\n Criteria.new(self).select(*args)\n end", "def insurance_prices(params = {})\n scope 'default'\n get('prices/insurance', params)\n end", "def fetch_default_price_points\n @price_points = CacheManagement::OstPricePointsDefault.new.fetch\n\n success\n end", "def pricing\n request('pricing', :get)\n end", "def currency_filter(selection)\n\t\t\tif selection == 'any'\n\t\t\t\tself.all\n\t\t\telse\n\t\t\t\tself.where(name_of_class + '.currency = ?', selection)\n\t\t\tend\n\t\tend", "def getters_return_physical_quantities\n @getters_return_physical_quantities = true\n end", "def average_price\n populate_price_data unless @average_price\n @average_price\n end", "def price\n b = read_attribute(:price)\n user = User.current.blank? ? User.where(id: 0).first : User.current\n b.to_d * user.currency.exchange_rate.to_d\n end", "def price(options)\n request :public, :get, :price, options\n end", "def set_price\n self.product = Product.find(orderable_id)\n self.unit_price = product.price\n end", "def price\n basic = Spree::Currency.basic.char_code\n price = prices.where(currency: basic).limit(1)[0]\n if price\n amount = price.amount\n else\n amount = read_attribute(:price) || 0\n end\n Spree::Currency.conversion_to_current(amount)\n end", "def details(skip: 0, take: nil, **opts)\n take_now = (take && take <= MAX_PER_REQUEST) ? take : MAX_PER_REQUEST\n take_later = take - take_now if take\n skip_later = skip + take_now\n\n items = Operations::Prices.new(settings)\n .call(skip: skip, take: take_now, **opts)\n\n return items if (items.count < take_now) || take_later&.zero?\n items + details(skip: skip_later, take: take_later, **opts)\n end", "def index\n @event_prices = EventPrice.all\n end", "def select\n execute_only(:select)\n end", "def unit_price\n if persisted?\n self[:unit_price]\n else\n product.price\n end\n end" ]
[ "0.6748442", "0.6546701", "0.63549113", "0.6162604", "0.6039596", "0.60256654", "0.5946158", "0.5929014", "0.59220076", "0.5901812", "0.58832526", "0.58200175", "0.57957953", "0.5780098", "0.57524323", "0.57524323", "0.5746339", "0.5687618", "0.56817746", "0.56791365", "0.56791365", "0.5673421", "0.5660766", "0.5646412", "0.5623319", "0.5623319", "0.55992967", "0.5574027", "0.5572911", "0.5543267", "0.5543117", "0.554024", "0.5529909", "0.5526318", "0.5515665", "0.54993165", "0.5491109", "0.5476307", "0.5469706", "0.545758", "0.545433", "0.544299", "0.54407924", "0.5439221", "0.5434021", "0.5433595", "0.543287", "0.54200083", "0.54124737", "0.54019845", "0.5401102", "0.53942686", "0.5384386", "0.5384362", "0.53832763", "0.5375937", "0.5374644", "0.5374644", "0.5374644", "0.5371661", "0.53565454", "0.5355682", "0.5355267", "0.5355267", "0.5355267", "0.5355267", "0.5355267", "0.5355267", "0.5355267", "0.5355267", "0.5352141", "0.5351468", "0.53494453", "0.5347385", "0.5344608", "0.53136545", "0.5313102", "0.5306613", "0.5305615", "0.53042614", "0.529998", "0.5296418", "0.5289672", "0.52828103", "0.5279762", "0.5270349", "0.52653766", "0.5257545", "0.525546", "0.5254192", "0.52480286", "0.52393156", "0.52303976", "0.5228672", "0.52192223", "0.5215211", "0.5214435", "0.52024215", "0.5199911", "0.5198614", "0.5198596" ]
0.0
-1
Tells if a free trial is defined in the price group
def has_free_trial? return (trial and trial.free?) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trial?\n (plan_type == 'free_trial')\n end", "def free?\n cost == 0.0 || payment_not_required\n end", "def premium?\n \t! free?\n end", "def trial?\n price_is_zero = price_amount_micros == 0\n price_is_zero && payment_received?\n end", "def has_chosen_free_item_from_expense_group(expense_group)\n registrant_expense_items.each do |rei|\n next unless rei.free\n if rei.expense_item.expense_group == expense_group\n return true\n end\n end\n paid_details.each do |pei|\n next unless pei.free\n if pei.expense_item.expense_group == expense_group\n return true\n end\n end\n\n false\n end", "def free?\n self.setupFee == 0 && self.laborFee == 0 && self.oneTimeFee == 0 && self.recurringFee == 0 && self.hourlyRecurringFee == 0\n end", "def free?\n price.blank? || price.zero?\n end", "def active?\n !self.trial_over? or self.paid?\n end", "def check_free_venue\n if @total >= 20\n return true\n end\n end", "def valid_test_taking()\n if current_user.tenant.pricing_plan.plan_group == \"assessment_only_plan\" then\n if current_user.tenant.remaining_learner_credit > 0 then\n return true\n else\n return false\n end\n else\n return true\n end\n end", "def free?\n\t\t\t\tnot(fee?)\n\t\t\tend", "def available?\n if tenant == false && @units != @number\n return true\n else \n return false\n end\n end", "def trial_period?\n !is_trial_period.nil? && is_trial_period\n end", "def trial?\n @receipts.first.is_trial_period\n end", "def doing_trial?\n active_subscription && active_subscription.trial?\n end", "def paid_subscriptions?\r\n !self.subscriptions.map { |sub| sub.periods.paid }.flatten.empty?\r\n end", "def paid_subscriptions?\r\n !self.subscriptions.map { |sub| sub.periods.paid }.flatten.empty?\r\n end", "def trial?\n @receipts.last.is_trial_period\n end", "def payment_possible_for?(listing)\n listing.price && listing.price > 0 && payments_in_use?\n end", "def payment_possible_for?(listing)\n listing.price && listing.price > 0 && stripe_in_use?\n end", "def trial?\n params['period1'] || params['period2'] ? true : false\n end", "def reg_paid?\n return true if spectator?\n Rails.cache.fetch(\"/registrant/#{id}-#{updated_at}/reg_paid\") do\n registration_cost_items = RegistrationCost.all_registration_expense_items\n paid_expense_items.any? { |item| registration_cost_items.include?(item) }\n end\n end", "def technically_paid?\n unconfirmed_value_paid >= value_needed\n end", "def pending_financials?\n shop && shop.pending_products.any?\n end", "def is_premium\n premium_tier > 0\n end", "def free?\n cost.zero?\n end", "def check_for_eligible_of_free_shipping(order)\n order.each do |key, price|\n if price > 100\n return true\n else\n return false\n end \n end\nend", "def available?\n self.active == true and self.quantity_available > 0\n end", "def can_buy_drug?(price, qty)\n wallet > (price * qty) \n end", "def fully_paid?\n amount_owed <= 0\n end", "def provides_price?\n false\n end", "def active_trial?\n trial_end_date > Time.now ? true : false\n end", "def allow_free_trial\n result = Spreedly.post(\"/subscribers/#{id}/allow_free_trial.xml\")\n\n case result.code.to_s\n when /2../\n else\n raise \"Could not allow subscriber to another trial: result code #{result.code}.\"\n end\n end", "def paid?\n rate.present? && rate.cents > 0\n end", "def shipping_free?(price)\n return price >= 50\nend", "def check_for_eligible_of_free_shipping(order)\n if order > 100\n return true\n else\n return false\n end\nend", "def premium?\n product == \"premium\"\n end", "def premium?\n premium\n end", "def price_is_gross?\n true\n end", "def ticket_count_and_tall_enough?\n ticket_count && tall_enough?\n end", "def free?\n \tcost.zero?\n end", "def not_paid_at_all\n\t\tget_cart_pending_balance == get_cart_price\n\tend", "def enable?(item)\n return (item.price > 0)\n end", "def expensive?\n base_price = an_order.base_price\n base_price > 1000\nend", "def enable?(item)\n item && item.price > 0\n end", "def price_consented?\n price_consent_status == 1\n end", "def fulfilled?\n user.donations.active.count >= quantity\n end", "def free_plan?(service_id, plans = nil)\n @free_plans ||= {}\n return @free_plans[service_id] if @free_plans.key?(service_id)\n plans ||= load_plans(service_id)\n @free_plans[service_id] = plans.any? { |plan| (plan[:price][:cents]).zero? }\n @free_plans[service_id]\n end", "def payment_required?\n billing_total.to_f > 0.0\n end", "def price_is_gross?\n !price_is_net?\n end", "def purchasing?\n auction.buy_it_now_price == amount\n end", "def gta_travel_support_single_rate_multiplier?\n if is_channel_gta_travel? and self.gta_travel_rate_basis <= 1 and self.gta_travel_max_occupancy >= 1\n return true\n else\n false\n end\n end", "def bought?\n # paym\n end", "def paid_enough(hash, price)\n temp_paid = cash_converters(hash)\n if temp_paid >= price then true else false end\n end", "def to_be_performed?\n self.research_billing_qty > 0\n end", "def is_free?\n ppn_used == 0\n end", "def plans?\n true\n end", "def is_available?\n count_available > 0\n end", "def check_price\n end", "def fixed_price?\n !auction?\n end", "def group?\n !self.DiscountGrpCustNo.zero?\n end", "def on_over_trial_days?\n result = false\n if self.last_grade and self.grades.length >= self.trial_days_total\n result = true\n end\n return result\n end", "def hasEnoughFunds?\n available = @mturk.availableFunds\n puts \"Got account balance: %.2f\" % available\n return available > 0.055\nend", "def can_buy_depot_train?(entity)\n entity.cash >= @depot.upcoming.first.price\n end", "def is_available?\n stock > 0\n end", "def money_enough?\n remaining_sum > 0\n end", "def never_billed?\n self[:paid_until].blank?\n end", "def has_srdc_submit?\n patron?(tier: 4) || subscriptions.tier3.active.any? || admin? || self.class.stay_insideathon?\n end", "def paid?\n unless self.last_paid_at.blank?\n return Time.now - 365.days < self.last_paid_at\n else\n return false\n end\n end", "def paid?\n status == 'paid'\n end", "def has_enough_money(item)\r\n if(self.credits>= item.get_price)\r\n return true\r\n else\r\n puts('get money')\r\n return false\r\n end\r\n end", "def is_pledge_payment?\n payable_type == 'UserGroup' && goal == 'pledge'\n end", "def can_supply?\n payment_received? || payment_on_account?\n end", "def recurring\n !on_trial && !cancelled\n end", "def paid?\n status == PAID\n end", "def paid_in_full?\n !payment_outstanding?\n end", "def has_tickets?\n (!tickets_remaining.blank?) && (tickets_remaining.to_i > 0)\n end", "def has_resources_for?(price)\r\n return true if @organisation.limit.nil? || @organisation.is_admin?(@user)\r\n\r\n resources = @organisation.limit - (@spend + price)\r\n resources > 0\r\n end", "def charges?\n true\n end", "def paid?\n !!paid_at\n end", "def may_purchase?(_company)\n false\n end", "def has_shopped?\n self.points_entries.purchases.count > 0\n end", "def gta_travel_support_triple_rate_multiplier?\n if is_channel_gta_travel? and self.gta_travel_rate_basis <= 3 and self.gta_travel_max_occupancy >= 3\n return true\n else\n false\n end\n end", "def ballot_registered?\n @ballot_registered\n end", "def can_rent_truck?\n !license.expired? && age >= 60 && license.to_drive_truck?\n end", "def can_charge_subscription?\n # * cannot charge subscription until trial period is running\n # * can only charge with a valid shipped_at or panic event\n !order.blank? && !subscription_deferred? && ( senior.any_panic_received? || !shipped_at.blank?)\n end", "def paid?\n status == 'paid'\n end", "def gta_travel_support_double_rate_multiplier?\n if is_channel_gta_travel? and self.gta_travel_rate_basis <= 2 and self.gta_travel_max_occupancy >= 2\n return true\n else\n false\n end\n end", "def money_approved?\n true\n end", "def available_works?\n if prev.valid_tracking?\n prev.done > done\n else\n product_line_quantity > done\n end\n end", "def subscription_deferred?\n # * trial period will end one day less than trial-period-span-months-window\n # _defer = if (order.cc_months_advance.blank? && order.cc_months_trial.blank?)\n # order.product_cost.recurring_delay.to_i\n # else\n # order.cc_months_advance.to_i + order.cc_months_trial.to_i\n # end\n # \n # Fri May 27 21:59:53 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4504\n # * when user intake is created directly, this failed on order == nil\n _defer = ( order.blank? ? 0 : ( order.cc_months_advance.to_i + order.cc_months_trial.to_i ))\n !order.blank? && (Date.today < (order.created_at.to_date >> _defer))\n # !order.blank? && !order.product_cost.blank? && (Date.today < (order.created_at.to_date + order.product_cost.recurring_delay.months))\n end", "def in_billing_retry_period?\n is_in_billing_retry_period == 1\n end", "def postpaid?\n postpaid.to_i == 1\n end", "def hasEnoughFunds?\n \t puts \"Checking for available MTurk balance...\"\n \t available = @mturk.availableFunds\n \t puts \"Got account balance: %.2f\" % available\n \t return available > 0.055\n \tend", "def billing_yearly?\n numbering_period == 'yearly'\n end", "def available?\n Holdings::Status::Available.new(@callnumber).available?\n end", "def enable?(item)\n return false if item.nil?\n return false if $game_party.gold < item.dismantle_gold_fee \n return item.dismantlable?\n end", "def can_subscribe_to?(plan)\n return false if !doing_trial? && active_subscription && active_subscription.plan == plan\n return false if debtor?\n return true\n end", "def collect_payment?\n true\n end", "def evaluate_group(grp)\n true\n end" ]
[ "0.7206481", "0.6949126", "0.6887819", "0.6801576", "0.67869574", "0.67436624", "0.6724147", "0.6675729", "0.6661419", "0.6626156", "0.6622098", "0.65532976", "0.65111524", "0.6496665", "0.6491064", "0.6484405", "0.6484405", "0.64556193", "0.6430888", "0.64216447", "0.6409723", "0.63975614", "0.63923085", "0.63614553", "0.63010377", "0.6295662", "0.6282515", "0.6266907", "0.6265046", "0.6251482", "0.62307954", "0.6229756", "0.6226121", "0.6216898", "0.6196534", "0.61944383", "0.61752015", "0.6172965", "0.6150578", "0.61338127", "0.6131825", "0.60881674", "0.6086155", "0.60521054", "0.6048886", "0.6032933", "0.60283136", "0.60187685", "0.6017934", "0.6008162", "0.5999515", "0.5989295", "0.59814173", "0.5978797", "0.5942464", "0.59421146", "0.5941992", "0.59376097", "0.5935159", "0.593488", "0.5931493", "0.5905189", "0.5897846", "0.5889087", "0.5888553", "0.58810204", "0.58779436", "0.5862239", "0.585531", "0.58467716", "0.5845511", "0.58420587", "0.58335584", "0.5833288", "0.5829673", "0.582417", "0.5816619", "0.58120894", "0.5810655", "0.580949", "0.58061385", "0.580482", "0.5801941", "0.5801157", "0.5784819", "0.5780485", "0.57769364", "0.5774885", "0.57695717", "0.5755118", "0.57488316", "0.57447356", "0.5729335", "0.572924", "0.572576", "0.5718843", "0.5711454", "0.57097197", "0.57055753", "0.5705553" ]
0.74790967
0
Method for accepts_nested_attributes_for :prices Tells if the price is valid regarding attributes passed Check if the price is valid by checking its valid? method
def reject_price attributes exists = attributes[:id].present? _price = Price.new(attributes.merge(price_group: self)) price_has_to_be_rejected = _price.has_to_be_rejected? || attributes[:delete_price].present? # Destroy if price exists and amount is nil attributes.merge!({:_destroy => 1}) if exists and price_has_to_be_rejected # Reject if price does't not exist yet and amount is nil return (!exists and price_has_to_be_rejected) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_attributes?\n true\n end", "def check_price\n return unless self.price.nil?\n if product && product.master_price\n self.price = product.master_price\n else\n errors.add_to_base(\"Must supply price for variant or master_price for product.\")\n return false\n end\n end", "def check_price\n return unless self.price.nil?\n if product && product.master_price\n self.price = product.master_price\n else\n errors.add_to_base(\"Must supply price for variant or master_price for product.\")\n return false\n end\n end", "def check_if_can_be_set_to_visible_against_price\n return true if visibility_changed? && !visible\n unless self.price && self.price > 0\n errors.add(\"Can't update the product visibility because the price is not set\") \n false\n end\n end", "def validates_price\n if price.zero?\n errors.add(:display_price, \"cannot be zero\")\n end\n\n nil\n end", "def valid_for_nested_creation?\n\t\tself.operator.present? && self.logic_type.present? && self.system_option_id.present?\n\tend", "def validations_on_update\n check_if_can_be_set_to_visible_against_price if Validations.on_update('product','not_visible_if_price_lower_than_zero')\n check_if_can_be_set_to_visible_against_images if Validations.on_update('product','not_visible_if_no_images')\n end", "def price_validate\n\t\tif (self.pay_mode == \"free\") || (self.pay_mode == \"FREE\") || (self.pay_mode == \"Free\")\n\t\t\tunless self.price == nil \n\t\t\t\t errors.add(:price, \"price should be nil\")\n\t\t\tend\t\n\t\telsif (self.pay_mode == \"paid\") || (self.pay_mode == \"PAID\") || (self.pay_mode == \"Paid\")\n\t\t\tunless self.price > 0 \n\t\t\t\t errors.add(:price, \"price should have a value not either nil nor 0\")\n\t\t\tend\n\t\telsif (self.pay_mode == \"donation\") || (self.pay_mode == \"DONATION\") || (self.pay_mode == \"Donation\")\n\t\t\tunless self.price == nil \n\t\t\t\t errors.add(:price, \"price should be nil\")\n\t\t\tend\t\t\t\t\t\t\t\n\t\tend\n\tend", "def price_validation_before_cast\n return unless price\n errors.add(:price, 'is invalid') unless price_before_type_cast.to_s.match?(VALID_PRICE_REGEX)\n errors.add(:price, 'must be greater than 0') unless price_before_type_cast.to_f.positive?\n end", "def valid?\n return false if @pricing_component_type.nil?\n pricing_component_type_validator = EnumAttributeValidator.new('String', [\"setup\", \"subscription\", \"arrears\", \"usage\"])\n return false unless pricing_component_type_validator.valid?(@pricing_component_type)\n return false if @charge_type.nil?\n charge_type_validator = EnumAttributeValidator.new('String', [\"Credit\", \"Debit\"])\n return false unless charge_type_validator.valid?(@charge_type)\n return false if @period_start.nil?\n return false if @period_end.nil?\n return false if @invoice_id.nil?\n return false if @organization_id.nil?\n return false if @name.nil?\n return false if @description.nil?\n return false if @calculation.nil?\n return false if @cost.nil?\n return false if @tax.nil?\n return false if @component_value.nil?\n return false if @pricing_component_id.nil?\n return false if @public_pricing_component_name.nil?\n return false if @pricing_component_name.nil?\n return false if @subscription_charge_id.nil?\n return false if @child_invoice_id.nil?\n return false if @type.nil?\n type_validator = EnumAttributeValidator.new('String', [\"PricingComponent\", \"Coupon\", \"Migration\", \"AggregatedInvoice\"])\n return false unless type_validator.valid?(@type)\n return true\n end", "def valid?\n return false if @quantity.nil?\n return false if @unit_price.nil?\n true\n end", "def validate #:doc:\n errors.add(:price, \"should be positive\") unless price.nil? || price >= 0.01\n end", "def validate_consumption_and_production_prices\n %i[marginal_costs max_consumption_price].each do |price_attribute|\n value = public_send(price_attribute)\n\n next if value.nil?\n\n if merit_order&.type != :flex\n errors.add(price_attribute, 'is only allowed when the merit_order type is \"flex\"')\n next\n end\n\n errors.add(price_attribute, 'must not be less than zero') if value.negative?\n end\n end", "def check_price\n if self.price.blank?\n raise \"Must supply price for variant or master.price for product.\" if self.is_master\n self.price = calculate_price\n end\n end", "def check_price\n if price.nil?\n raise 'Must supply price for variant or master.price for product.' if self == product.master\n self.price = product.price\n end\n end", "def valid?\n return false if @currency_code.nil?\n return false if @description.nil?\n return false if @original_price.nil?\n return false if @sku.nil?\n return true\n end", "def valid_attributes\n { :free => false,\n :details => nil,\n :expense_item_id => @exp.id\n }\n end", "def check_price\n if self.price.nil?\n raise 'Must supply price for variant or master.price for product.' if self == product.master\n self.price = product.master.price\n end\n end", "def valid?\n return false if @id.nil?\n return false if @ordertext.nil?\n return false if @amount.nil?\n return false if @vat.nil?\n return false if @quantity.nil?\n return false if @quantity < 1\n return false if @origin.nil?\n origin_validator = EnumAttributeValidator.new('String', [\"plan\", \"add_on\", \"ondemand\", \"additional_cost\", \"credit\", \"discount\", \"setup_fee\"])\n return false unless origin_validator.valid?(@origin)\n return false if @timestamp.nil?\n return false if @amount_vat.nil?\n return false if @amount_ex_vat.nil?\n return false if @unit_amount.nil?\n return false if @unit_amount_vat.nil?\n return false if @unit_amount_ex_vat.nil?\n return false if @amount_defined_incl_vat.nil?\n return true\n end", "def valid?\n @specification.check_tag(self) && @attributes.all? { | _k, v | v.valid? }\n end", "def positive_price\n errors.add(:price, \"should be positive\") unless price.nil? || price >= 0.01\n end", "def valid_attributes?\n attribute_errors.empty?\n end", "def valid_attributes\n @vendor.attributes\n end", "def valid_create?\n param! :sku_id, Integer, blank: false\n param! :price, Float, blank: false\n param! :discount, Float, blank: false\n end", "def valid_attributes\r\n {\r\n :item_id => 2,\r\n :seller_id => 1,\r\n :bid_amount => 100,\r\n :highest_bidder => 2,\r\n :state => 1,\r\n :end_time => Time.now\r\n }\r\n end", "def valid?\n return false if @product_rate_plan.nil?\n return false if @invoicing_type.nil?\n invoicing_type_validator = EnumAttributeValidator.new('String', [\"Immediate\", \"Aggregated\"])\n return false unless invoicing_type_validator.valid?(@invoicing_type)\n return false if @pricing_behaviour.nil?\n pricing_behaviour_validator = EnumAttributeValidator.new('String', [\"None\", \"Full\", \"Difference\", \"DifferenceProRated\", \"ProRated\"])\n return false unless pricing_behaviour_validator.valid?(@pricing_behaviour)\n return true\n end", "def validate(rid, price, item)\n flag = false\n flag = true if rid > 0 && price > 0.0 && !item.nil? && !item.empty?\n end", "def valid?\n each_field_with_value do |_, field, value|\n return false unless field.valid?(value)\n end\n true\n end", "def check_price\n self.price = self.price.to_f\n end", "def check_new_price\n begin\n new_price = Float(params[:item][:new_price])\n add_price_error if new_price < 0\n rescue\n add_price_error\n end\n end", "def valid_attributes\n { }\n end", "def accepts_nested_attributes_for(*attr_names)\n options = attr_names.extract_options!\n options[:reject_if] = PARA_REJECT_ALL_BLANK_PROC if options[:reject_if] == :all_blank\n super(*attr_names, options)\n end", "def validate_attributes!\n raise TrainNumberValidationError unless valid_number?\n raise TrainTypeValidationError if type.nil? || type.empty?\n end", "def valid_attributes\n { }\n end", "def valid_attributes\n { }\n end", "def valid?\n return false if !@channel_partner_item_id.nil? && @channel_partner_item_id.to_s.length > 30\n return false if !@country_code_of_origin.nil? && @country_code_of_origin.to_s.length > 2\n return false if !@description.nil? && @description.to_s.length > 2000\n return false if !@merchant_item_id.nil? && @merchant_item_id.to_s.length > 20\n return false if !@parent_merchant_item_id.nil? && @parent_merchant_item_id.to_s.length > 20\n return false if !@perishable_class.nil? && @perishable_class.to_s.length > 50\n return false if !@quickbooks_class.nil? && @quickbooks_class.to_s.length > 31\n tax_product_type_validator = EnumAttributeValidator.new('String', ['', 'digital', 'physical', 'service'])\n return false unless tax_product_type_validator.valid?(@tax_product_type)\n true\n end", "def core_attributes_valid\n core_attributes = [@rateable, @rater, @ratee, @rating_type]\n return if core_attributes.all? { |atr| atr.present? && atr.valid? }\n errors.add('message', 'Not all core attributes present and valid.')\n end", "def your_attributes_valid\n do_validate_attributes('your')\n end", "def valid?\n return false if @ir.nil?\n return false if @loi.nil?\n return false if @approval_id.nil?\n return false if @calculated_max_price.nil?\n return false if @completes.nil?\n return false if @event_id.nil?\n return false if @id.nil?\n return false if @new_estimated_cost.nil?\n return false if @original_cpi.nil?\n return false if @original_estimated_cost.nil?\n return false if @project_id.nil?\n return false if @quota_group_id.nil?\n return false if @reason.nil?\n return false if @request_new_price.nil?\n return false if @required_completes.nil?\n true\n end", "def input_valid?\n could_refund = @order.total_price - @order.refund_price\n @params[:refund_price].to_f.positive? && @params[:refund_price].to_f <= could_refund\n end", "def valid_attributes\n {:hp_id => valid_id?(@valid_id1)}\n end", "def check_price\n if price.nil? && Spree::Config[:require_master_price]\n raise 'No master variant found to infer price' unless product && product.master\n raise 'No master variant found to infer price' unless greeting && greeting.master\n raise 'Must supply price for variant or master.price for product.' if self == product.master\n self.price = product.master.price\n raise 'Must supply price for variant or master.price for greeting.' if self == greeting.master\n self.price = greeting.master.price\n end\n if price.present? && currency.nil?\n self.currency = Spree::Config[:currency]\n end\n end", "def taxes_valid?\n errors.add(:taxes, :one_must_be_chosen) if taxes.compact_blank.size != 1\n end", "def valid?\n _errors_before = self.errors.dup\n _s = super\n validate_attributes\n _errors_before.each { |e| append_error(_errors_before,e) }\n self.errors.empty?\n end", "def build_prices_for_conference_items\n return false if conference.blank?\n\n conference.conference_items.each do |item|\n prices << item.prices.build(:discount_key => discount_key)\n end\n true\n end", "def valid?\n validate_survivors and validate_items && validate_records\n end", "def valid_attributes\n {\n translations_attributes: {\n \"1\" => {\n locale: \"en\",\n name: \"Small T-Shirt\",\n details_label: nil\n }\n },\n cost: 15.00,\n has_details: false,\n position: 1,\n tax: 0,\n maximum_available: nil\n }\n end", "def valid_attributes\n {}\n end", "def valid_attributes\n {}\n end", "def valid_attributes\n {}\n end", "def valid_attributes\n {}\n end", "def valid_attributes\n {}\n end", "def valid_attributes\n {}\n end", "def valid_attributes\n {}\n end", "def valid_attributes\n {}\n end", "def valid?\n return false if @property_code.nil?\n return false if @property_name.nil?\n return false if @location.nil?\n return false if @total_price.nil?\n return false if @min_daily_rate.nil?\n return true\n end", "def valid?\n p = build_payment\n p.valid?\n end", "def valid?\n if valid_symbol_setting_exist?\n valid_price? && valid_amount?\n else\n valid_symbol? && valid_side?\n end\n end", "def set_prices!\n return if @course_prices_attributes.nil?\n if @course_prices_attributes.keys.include?('0')\n @course_prices_attributes = @course_prices_attributes.map { |_, v| v }\n @course_prices_attributes.reject! { |p| p[\"amount\"].blank? or p[\"amount\"].nil? }\n else\n @course_prices_attributes = [@course_prices_attributes].flatten.compact\n end\n end", "def valid?\n return false if @id.nil?\n return false if @account_id.nil?\n return false if @organization_id.nil?\n return false if @product_id.nil?\n return false if @product_rate_plan_id.nil?\n return false if @name.nil?\n type_validator = EnumAttributeValidator.new('String', [\"Subscription\", \"FixedTerm\", \"Trial\"])\n return false unless type_validator.valid?(@type)\n return false if @state.nil?\n state_validator = EnumAttributeValidator.new('String', [\"Trial\", \"Provisioned\", \"Paid\", \"AwaitingPayment\", \"Cancelled\", \"Failed\", \"Expired\"])\n return false unless state_validator.valid?(@state)\n return false if @initial_period_start.nil?\n return false if @trial_end.nil?\n managed_by_validator = EnumAttributeValidator.new('String', [\"BillForward\", \"Stripe\"])\n return false unless managed_by_validator.valid?(@managed_by)\n return false if @version_start.nil?\n return false if @version_number.nil?\n return false if @current_time.nil?\n failed_payment_behaviour_validator = EnumAttributeValidator.new('String', [\"CancelSubscription\", \"None\"])\n return false unless failed_payment_behaviour_validator.valid?(@failed_payment_behaviour)\n return true\n end", "def child_valid?(context, model, attribute)\n filtered_context = filter_attributes(context, model.send(:attribute_list))\n return true if send(attribute).nil? || filtered_context.nil? || filtered_context.empty?\n\n send(attribute).valid?(filtered_context)\n end", "def valid_save?\n valid = true\n\n if self.name.nil? || self.name == \"\"\n valid = false\n end\n\n if self.general_info.nil? || self.general_info == \"\"\n valid = false\n end\n\n if self.technical_specs.nil? || self.technical_specs == \"\"\n valid = false\n end\n\n if self.where_to_buy.nil? || self.where_to_buy == \"\"\n valid = false\n end\n\n return valid\n end", "def product_params\n params.require(:product).permit(:name, :description, :company_id, :branch_id, :storage_id, :family_id, :subfamily_id, prices_attributes: [:price, :description, :company_id, :branch_id, :product_id, :client_type_id, :measurement_unit_id])\n end", "def validate\n validate_root\n validate_associated\n valid?\n end", "def valid?\n self.valid\n end", "def valid?\n has_children? and children.inject(true) { |result, el| result and el.valid? }\n end", "def valid?\n # TODO validate nested objects\n output = super\n errors.empty? && output\n end", "def valid?\n return false if @additional_details.nil?\n return false if @blockchain.nil?\n blockchain_validator = EnumAttributeValidator.new('String', [\"bitcoin\", \"bitcoin-cash\", \"litecoin\", \"dogecoin\", \"dash\", \"ethereum\", \"ethereum-classic\", \"xrp\", \"zcash\"])\n return false unless blockchain_validator.valid?(@blockchain)\n return false if @fee_priority.nil?\n fee_priority_validator = EnumAttributeValidator.new('String', [\"slow\", \"standard\", \"fast\"])\n return false unless fee_priority_validator.valid?(@fee_priority)\n return false if @network.nil?\n network_validator = EnumAttributeValidator.new('String', [\"mainnet\", \"testnet\", \"ropsten\", \"mordor\"])\n return false unless network_validator.valid?(@network)\n return false if @recipients.nil?\n return false if @total_transaction_amount.nil?\n return false if @transaction_request_status.nil?\n transaction_request_status_validator = EnumAttributeValidator.new('String', [\"created\", \"await-approval\", \"pending\", \"prepared\", \"signed\", \"broadcasted\", \"success\", \"failed\", \"rejected\", \"mined\"])\n return false unless transaction_request_status_validator.valid?(@transaction_request_status)\n return false if @transaction_type.nil?\n transaction_type_validator = EnumAttributeValidator.new('String', [\"coin\", \"token\"])\n return false unless transaction_type_validator.valid?(@transaction_type)\n return false if @unit.nil?\n return false if @wallet_id.nil?\n true\n end", "def valid?(values = {})\n assign(values) unless values.empty?\n validator.valid?(attributes)\n end", "def valid?\n return false if @beez_up_order_item_id.nil?\n return false if @order_item_order_item_type.nil?\n return true\n end", "def apply_validations_for_decimal\n apply_validations_for_float\n end", "def valid?\n return false if @name.nil?\n return false if @name.to_s.length > 50\n return false if @prefix_suffix_option.nil?\n prefix_suffix_option_validator = EnumAttributeValidator.new('String', [\"Prefix\", \"Suffix\"])\n return false unless prefix_suffix_option_validator.valid?(@prefix_suffix_option)\n return false if !@invoice_pre_suffix.nil? && @invoice_pre_suffix.to_s.length > 5\n application_units_validator = EnumAttributeValidator.new('String', [\"Amount\", \"Hours\", \"Incidents\"])\n return false unless application_units_validator.valid?(@application_units)\n application_cycle_validator = EnumAttributeValidator.new('String', [\"Contract2Weeks\", \"Contract4Weeks\", \"ContractYear\", \"CalendarMonth\", \"CalendarQuarter\", \"CalendarWeek\", \"ContractQuarter\", \"CalendarYear\"])\n return false unless application_cycle_validator.valid?(@application_cycle)\n return false if @employee_comp_rate.nil?\n employee_comp_rate_validator = EnumAttributeValidator.new('String', [\"Actual\", \"Hourly\"])\n return false unless employee_comp_rate_validator.valid?(@employee_comp_rate)\n return false if @employee_comp_not_exceed.nil?\n employee_comp_not_exceed_validator = EnumAttributeValidator.new('String', [\"Billing\", \"Percent\", \"Amount\"])\n return false unless employee_comp_not_exceed_validator.valid?(@employee_comp_not_exceed)\n return false if @invoicing_cycle.nil?\n invoicing_cycle_validator = EnumAttributeValidator.new('String', [\"CalendarYear\", \"ContractYear\"])\n return false unless invoicing_cycle_validator.valid?(@invoicing_cycle)\n return false if !@invoice_description.nil? && @invoice_description.to_s.length > 4000\n return false if @bill_time.nil?\n bill_time_validator = EnumAttributeValidator.new('String', [\"Billable\", \"DoNotBill\", \"NoCharge\", \"NoDefault\"])\n return false unless bill_time_validator.valid?(@bill_time)\n return false if @bill_expenses.nil?\n bill_expenses_validator = EnumAttributeValidator.new('String', [\"Billable\", \"DoNotBill\", \"NoCharge\", \"NoDefault\"])\n return false unless bill_expenses_validator.valid?(@bill_expenses)\n return false if @bill_products.nil?\n bill_products_validator = EnumAttributeValidator.new('String', [\"Billable\", \"DoNotBill\", \"NoCharge\", \"NoDefault\"])\n return false unless bill_products_validator.valid?(@bill_products)\n return true\n end", "def save_valid\n if self.valid?\n self.save\n else\n false\n end\n end", "def define_and_validate(options={})\n @model = define_model :product, :price => :integer, :size => :integer do\n validates_numericality_of :price, options\n end\n\n validate_numericality_of(:price)\n end", "def check_price\n end", "def valid\n\t\tself.validate unless self.validated?\n\n\t\tself.log.debug \"Building valid fields hash from raw data: %p\" % [ @valid ]\n\t\tunless @parsed_params\n\t\t\t@parsed_params = {}\n\t\t\tfor key, value in @valid\n\t\t\t\tself.log.debug \" adding %s: %p\" % [ key, value ]\n\t\t\t\tvalue = [ value ] if key.to_s.end_with?( '[]' )\n\t\t\t\tif key.to_s.include?( '[' )\n\t\t\t\t\tbuild_deep_hash( value, @parsed_params, get_levels(key.to_s) )\n\t\t\t\telse\n\t\t\t\t\t@parsed_params[ key ] = value\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\treturn @parsed_params\n\tend", "def valid?\n return false if @name.nil?\n return false if @name.to_s.length < 1\n return false if @timezone.nil?\n return false if @timezone.to_s.length < 1\n return false if @currency.nil?\n return false if @currency.to_s.length < 1\n case_sensitivity_validator = EnumAttributeValidator.new('String', [\"sensitive\", \"insensitive-uppercase\", \"insensitive-lowercase\"])\n return false unless case_sensitivity_validator.valid?(@case_sensitivity)\n campaign_priority_validator = EnumAttributeValidator.new('String', [\"universal\", \"stackable\", \"exclusive\"])\n return false unless campaign_priority_validator.valid?(@campaign_priority)\n exclusive_campaigns_strategy_validator = EnumAttributeValidator.new('String', [\"listOrder\", \"lowestDiscount\", \"highestDiscount\"])\n return false unless exclusive_campaigns_strategy_validator.valid?(@exclusive_campaigns_strategy)\n default_discount_scope_validator = EnumAttributeValidator.new('String', [\"sessionTotal\", \"cartItems\", \"additionalCosts\"])\n return false unless default_discount_scope_validator.valid?(@default_discount_scope)\n default_discount_additional_cost_per_item_scope_validator = EnumAttributeValidator.new('String', [\"price\", \"itemTotal\", \"additionalCosts\"])\n return false unless default_discount_additional_cost_per_item_scope_validator.valid?(@default_discount_additional_cost_per_item_scope)\n true\n end", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:vessel_code => self.vessel_code}],self)\n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_vessel\n\t end\nend", "def product_attributes_must_not_be_empty\n\n\t\t# Instance\n\t\tproduct = Product.new\n\n\t\tassert product.invalid?\n\t\tassert product.errors[:title].any?\n\t\tassert product.errors[:description].any?\n\t\tassert product.errors[:price].any?\n\t\tassert product.errors[:image_url].any?\n\tend", "def valid_attributes\n { \"amount\"=>1245.to_s, 'book_id'=>@od.to_param,\n \"narration\"=>'Premier virement', \"date\"=>Date.today.to_formatted_s('%d-%m-%Y'),\n :compta_lines_attributes=>{'0'=>{account_id:@ba.to_param}, '1'=>{account_id:@bb.to_param}}\n }\n end", "def valid_tree?\n true\n end", "def valid?\n @errors = [] \n validate_field_types\n \n if integer?(\"point_adjustment\")\n if point_adjustment < 1\n @errors << {message: \"Point adjustment must be greater than 0.\", variable: \"point_adjustment\"}\n end\n end\n\n @errors.empty?\n end", "def valid?\n return false if @income_type.nil?\n return false if @tax_rate.nil?\n return false if @tax_amount.nil?\n return false if @tax_amount_no_vat.nil?\n return false if @withheld.nil?\n return false if @vat_type.nil?\n true\n end", "def alternate_price_params\n params.require(:alternate_price).permit(\n :group_id, :price\n )\n end", "def validate(order)\n raise \"Total price is incorrect!\" if calculate_price != expected_price\n end", "def patch_valid?\n validate(false).empty?\n end", "def valid?\n return @_valid unless @_valid.nil?\n @_valid = super\n end", "def valid_attributes\n { :val_1 => 1.1,\n :val_2 => 2.2,\n :val_3 => 3.3,\n :val_4 => 4.4,\n :notes => \"hi\"\n }\n end", "def valid?\n all? {|e| e.respond_to?(:valid?) ? e.valid? : true}\n end", "def fee_for_additional_materials_is_valid?\n return ((self.fee_for_additional_materials != nil) and (self.fee_for_additional_materials >= 0))\n end", "def valid_attributes\n {\n company_id: company.id\n }\n end", "def validAsProduct(aItemId, aPrice, aMinimumBatchQuantity, aBatchPrice)\r\n validAsProductID(aItemId)\r\n raise \"Duplicate products are not allowed in the store.\" if find_product?(aItemId)\r\n\r\n validAsRetailPrice(aPrice)\r\n validAsBatchQuantity(aMinimumBatchQuantity)\r\n validAsBatchPrice(aBatchPrice)\r\n validate_sensible_discount(aBatchPrice, aMinimumBatchQuantity)\r\n end", "def valid?\n return false if @name.nil?\n return false if @slug.nil?\n return false if @status.nil?\n status_validator = EnumAttributeValidator.new('String', ['enabled', 'disabled'])\n return false unless status_validator.valid?(@status)\n return false if @type.nil?\n type_validator = EnumAttributeValidator.new('String', ['digital', 'physical'])\n return false unless type_validator.valid?(@type)\n return false if @sku.nil?\n return false if @price.nil?\n availability_validator = EnumAttributeValidator.new('String', ['available', 'comingSoon', 'retired'])\n return false unless availability_validator.valid?(@availability)\n stock_status_validator = EnumAttributeValidator.new('String', ['available', 'alert', 'unavailable'])\n return false unless stock_status_validator.valid?(@stock_status)\n return false if @categories.nil?\n true\n end", "def valid?\n return false if @value.nil?\n change_mode_validator = EnumAttributeValidator.new('String', [\"immediate\", \"delayed\"])\n return false unless change_mode_validator.valid?(@change_mode)\n invoicing_type_validator = EnumAttributeValidator.new('String', [\"Immediate\", \"Aggregated\"])\n return false unless invoicing_type_validator.valid?(@invoicing_type)\n return true\n end", "def valid?\n true\n end", "def valid?\n valid = true\n\n if self.name.nil? || self.name == \"\"\n valid = false\n end\n\n if self.general_info.nil? || self.general_info == \"\"\n valid = false\n end\n\n if self.technical_specs.nil? || self.technical_specs == \"\"\n valid = false\n end\n\n if self.where_to_buy.nil? || self.where_to_buy == \"\"\n valid = false\n end\n\n product_to_find = DATABASE.execute(\"SELECT name FROM products;\")\n\n product_to_find.each do |names|\n if names[\"name\"] == @name\n valid = false\n end\n end\n\n return valid\n end", "def valid_attributes\n { :customer_paypal_id => '1234' }\n end", "def valid_tree?\n true\n end", "def valid_tree?\n true\n end", "def valid?\n return false if @class_id.nil?\n class_id_validator = EnumAttributeValidator.new('String', [\"license.LicenseInfo\"])\n return false unless class_id_validator.valid?(@class_id)\n return false if @object_type.nil?\n object_type_validator = EnumAttributeValidator.new('String', [\"license.LicenseInfo\"])\n return false unless object_type_validator.valid?(@object_type)\n license_state_validator = EnumAttributeValidator.new('String', [\"NotLicensed\", \"GraceExpired\", \"TrialPeriod\", \"OutOfCompliance\", \"Compliance\", \"TrialExpired\"])\n return false unless license_state_validator.valid?(@license_state)\n license_type_validator = EnumAttributeValidator.new('String', [\"Base\", \"Essential\", \"Standard\", \"Advantage\", \"Premier\", \"IWO-Essential\", \"IWO-Advantage\", \"IWO-Premier\"])\n return false unless license_type_validator.valid?(@license_type)\n true && super\n end" ]
[ "0.6346616", "0.63246816", "0.6321266", "0.6204721", "0.6191313", "0.6106032", "0.6104835", "0.6088375", "0.60619634", "0.6026781", "0.60256666", "0.597858", "0.59772426", "0.5912503", "0.5895036", "0.5890304", "0.58326656", "0.58111614", "0.5795945", "0.5716297", "0.56999934", "0.56825733", "0.5676363", "0.56317997", "0.5620154", "0.56190705", "0.56110424", "0.55924565", "0.5585642", "0.55838835", "0.5583735", "0.55809057", "0.5573358", "0.5551487", "0.5551487", "0.55413955", "0.5536115", "0.5532199", "0.55193603", "0.5516241", "0.5512887", "0.55099195", "0.5503414", "0.54878384", "0.5482848", "0.5479556", "0.5466428", "0.5464606", "0.5464606", "0.5464606", "0.5464606", "0.5464606", "0.5464606", "0.5464606", "0.5464606", "0.54510754", "0.5447238", "0.5439753", "0.5437108", "0.54359543", "0.5419326", "0.5409595", "0.54023886", "0.53923535", "0.53856415", "0.5372386", "0.53685516", "0.5360915", "0.5353943", "0.5353873", "0.53459895", "0.5344313", "0.5344076", "0.5332561", "0.5328227", "0.53269607", "0.5323082", "0.53215736", "0.53195864", "0.53156376", "0.5315284", "0.5304731", "0.5303365", "0.5301586", "0.5300256", "0.52957463", "0.52946657", "0.5292906", "0.52874285", "0.52710795", "0.5264807", "0.52638376", "0.52566856", "0.5254855", "0.52434295", "0.52281004", "0.5227054", "0.52224684", "0.52224684", "0.5221723" ]
0.6107574
5
def update card = AnswerCard.find(params[:id]) card.update(answer_card_params) render json: card end def destroy AnswerCard.find(params[:id]).destroy head :no_content end
def answer_card_params params.require(:answer_card).permit(:user_id, :answer_text, :question_card_id, :expiration_date) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n # @card = Card.find(params[:id])\n # @card.update(card_params)\n # render json: @card\n end", "def update\n @card = Card.find(params[:id])\n\n if @card.update(card_params)\n head :no_content\n else\n render json: @card.errors, status: :unprocessable_entity\n end\n end", "def update\n if @card.update(card_params)\n render json: @card, status: :created\n else\n render json: @card.errors, status: :unprocessable_entity\n end\n end", "def update\n @card.update(card_params)\n if @card.errors.any?\n render json: @card.errors, status: :unprocessable_entity\n else\n render json: @card, status: 201\n end\n end", "def update\n respond_to do |format|\n if @card.update(card_params)\n format.json { render json: {}, status: :ok }\n else\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #@card = Card.find(params[:id])\n\n respond_to do |format|\n if @card.update_attributes(params[:card])\n format.html { redirect_to cards_url, :notice => 'Card was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @card.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @card = Card.find(params[:id])\n\n respond_to do |format|\n if @card.update_attributes(card_params)\n format.html { redirect_to action: :index }\n format.json { head :no_content }\n flash[:notice] = 'Card was successfully updated.'\n else\n format.html { render action: \"edit\" }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @card = Card.find(params[:id])\n respond_to do |format|\n if @card.save\n format.html { redirect_to @card, flash: { success: \"Updated the card!\" } }\n format.json { render json: @card, status: :ok }\n else\n format.html {\n flash[:danger] = \"Error : Failed to update card.\"\n render :edit\n }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card.update(card_params)\n format.html { redirect_to cards_path, notice: t(\".successfully_updated\") }\n format.json { render :show, status: :ok, location: @card }\n else\n format.html { render :edit }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card.update(card_params)\n format.html { redirect_to @card, notice: 'Card was successfully updated.' }\n format.json { render :show, status: :ok, location: @card }\n else\n format.html { render :edit }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card.update(card_params)\n format.html { redirect_to @card, notice: 'Card was successfully updated.' }\n format.json { render :show, status: :ok, location: @card }\n else\n format.html { render :edit }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card.update(card_params)\n format.html { redirect_to @card, notice: 'Card was successfully updated.' }\n format.json { render :show, status: :ok, location: @card }\n else\n format.html { render :edit }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card.update(card_params)\n format.html { redirect_to @card, notice: 'Card was successfully updated.' }\n format.json { render :show, status: :ok, location: @card }\n else\n format.html { render :edit }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card.update(card_params)\n format.html { redirect_to @card, notice: 'Card was successfully updated.' }\n format.json { render :show, status: :ok, location: @card }\n else\n format.html { render :edit }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card.update(card_params)\n format.html { redirect_to @card, notice: 'Card was successfully updated.' }\n format.json { render :show, status: :ok, location: @card }\n else\n format.html { render :edit }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @entry_card.update(entry_card_params)\n format.html { redirect_to @entry_card, notice: 'Entry card was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @entry_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card_detail.update(card_detail_params)\n format.html { redirect_to @card_detail, notice: 'Card detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @card_detail }\n else\n format.html { render :edit }\n format.json { render json: @card_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card.update(card_params)\n format.html { redirect_to deck_cards_path(@deck, @card), notice: 'Card was successfully updated.' }\n format.json { render :show, status: :ok, location: @card }\n else\n format.html { render :edit }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @card = Card.find(params[:id])\n\n respond_to do |format|\n if @card.update_attributes(params[:card])\n format.html { redirect_to @card, notice: 'Card was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @card = Card.find(params[:id])\n\n respond_to do |format|\n if @card.update_attributes(params[:card])\n format.html { redirect_to @card, notice: 'Card was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @card = Card.find(params[:id])\n\n respond_to do |format|\n if @card.update_attributes(params[:card])\n format.html { redirect_to @card, notice: 'Card was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @answer = Answer.find(params[:id])\n\n if @answer.update(answer_params)\n head :no_content\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end", "def update\n @card = @deck.cards.find(params[:id])\n respond_to do |format|\n if @card.update_attributes(card_params)\n format.html { redirect_to deck_path(@deck), notice: 'Card was successfully updated.' }\n format.json { render :show, status: :ok, location: deck_card_path(@deck, @card) }\n else\n format.html { render :edit }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vote_card.update(vote_card_params)\n format.html { redirect_to @vote_card, notice: 'VoteCard was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vote_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @deck_of_card.update(deck_of_card_params)\n format.html { redirect_to @deck_of_card, notice: 'Deck of card was successfully updated.' }\n format.json { render :show, status: :ok, location: @deck_of_card }\n else\n format.html { render :edit }\n format.json { render json: @deck_of_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n # @card = Card.destroy(params[:id])\n # render json: 200\n end", "def update\n respond_to do |format|\n if @card.update(card_params)\n format.html { redirect_to @card, notice: 'Cartão atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @inden_card.update(inden_card_params)\n format.html { redirect_to @inden_card, notice: (t 'inden_cards.title2')+(t 'actions.updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @inden_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card.update(card_params)\n format.html { redirect_to @card, notice: 'Tarjeta Actualizada Satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @card }\n else\n format.html { render :edit }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @card = Card.find(params[:id])\n\n respond_to do |format|\n if @card.update_attributes(params[:card])\n notify_admin(\"Card Updated (#{@card.last_three_digits})\", @card.as_json)\n format.html { redirect_to @card, notice: 'Card was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @quiz = Quiz.find(params[:id])\n @quiz.update_attributes(private_card_params)\n @quiz = Quiz.all\n respond_to do |page|\n page.js\n end\n end", "def update\n respond_to do |format|\n if @poker_card.update(poker_card_params)\n format.html { redirect_to @poker_card, notice: 'Poker card was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @poker_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @m_card.update(m_card_params)\n format.html { redirect_to @m_card, notice: 'M card was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @m_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card.update(card_params)\n format.html { redirect_to plan_path(@plan), notice: 'Card was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card.update(card_params)\n format.html { redirect_to tarot_cards_path(@tarot), notice: 'Card was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n puts \"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\"\n puts card_params\n if @card.update(card_params)\n format.html { redirect_to @card, notice: 'Card was successfully updated.' }\n format.json { render :show, status: :ok, location: @card }\n else\n format.html { render :edit }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @deck_card.update(deck_card_params)\n flash[:success] = \"Deck card was successfully updated.\"\n redirect_to @deck_card.deck\n format.json { render :show, status: :ok, location: @deck_card }\n else\n format.html { render :edit }\n format.json { render json: @deck_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n #@card = Card.find(params[:id])\n @card.destroy\n\n respond_to do |format|\n format.html { redirect_to cards_url, :notice => 'Card successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @eno_card.update(eno_card_params)\n format.html { redirect_to @eno_card, notice: 'Eno card was successfully updated.' }\n format.json { render :show, status: :ok, location: @eno_card }\n else\n format.html { render :edit }\n format.json { render json: @eno_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @side_card.update(side_card_params)\n format.html { redirect_to @side_card, notice: 'Side card was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @side_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @wallet.update_card(params[:id], card_params)\n format.html { redirect_to wallet_path, notice: 'Card was successfully updated.' }\n format.json { render json: @wallet, status: :ok, location: wallet_path }\n else\n @card = @wallet.find_card(params[:id])\n format.html { render :edit }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @card = Card.find(params[:id])\n @card.destroy\n\n respond_to do |format|\n format.html { redirect_to cards_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @card = Card.find(params[:id])\n @card.destroy\n\n respond_to do |format|\n format.html { redirect_to cards_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @card = Card.find(params[:id])\n @card.destroy\n\n respond_to do |format|\n format.html { redirect_to cards_url }\n format.json { head :no_content }\n end\n end", "def update\n @cards_question = Cards::Question.find(params[:id])\n\n respond_to do |format|\n if @cards_question.update_attributes(params[:cards_question])\n format.html { redirect_to @cards_question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cards_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n card = Card.find( params[:id] )\n card.destroy\n respond_to do |format|\n format.html { redirect_to cards_url, notice: 'Card was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @note_card.update(note_card_params)\n format.html { redirect_to @note_card, notice: 'Note card was successfully updated.' }\n format.json { render :show, status: :ok, location: @note_card }\n else\n format.html { render :edit }\n format.json { render json: @note_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @card.delete\n render json: {messsage: \"Movie/Series Card was successfully deleted.\"}, status: 204\n end", "def update\n respond_to do |format|\n if @excuse_card.update(excuse_card_params)\n format.html { redirect_to @excuse_card, notice: 'Excuse card was successfully updated.' }\n format.json { render :show, status: :ok, location: @excuse_card }\n else\n format.html { render :edit }\n format.json { render json: @excuse_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @card = @deck.cards.find(params[:id])\n @card.destroy\n respond_to do |format|\n format.html { redirect_to deck_path(@deck), notice: 'Card was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @entry_card.destroy\n respond_to do |format|\n format.html { redirect_to entry_cards_url }\n format.json { head :no_content }\n end\n end", "def update\n if !(params[:id].nil?)\n if(CompanyCard.exists?(params[:id]))\n card = CompanyCard.find(params[:id])\n card.update(card_params)\n render status: 200, json:{\n message: \"Successfully updated\",\n company_cards: card\n }.to_json\n else\n render status: 422, json:{\n message: \"Unable to process your request of the server.\"\n }.to_json\n end\n else\n render status: 422, json:{\n message: \"Unable to process your request of the server.\"\n }.to_json\n end\n end", "def destroy\n @card.destroy\n respond_to do |format|\n format.html { redirect_to cards_url, notice: 'Card was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @card.destroy\n respond_to do |format|\n format.html { redirect_to cards_url }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @card = Card.find(params[:id])\n respond_to do |format|\n if @card.update_attributes(params[:card])\n flash[:notice] = 'Card was successfully updated.'\n format.html { redirect_to(deck_card_url(@deck, @card)) }\n format.xml { head :ok }\n else\n @decks = Deck.find(:all, :order => 'title')\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @card.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @deck.update(deck_params)\n format.js\n else\n format.js { render :edit }\n end\n end\n end", "def destroy\n @card.destroy\n respond_to do |format|\n format.html { redirect_to cards_url, notice: 'Card was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @card.destroy\n respond_to do |format|\n format.html { redirect_to cards_url, notice: 'Card was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @card.destroy\n respond_to do |format|\n format.html { redirect_to cards_url, notice: 'Card was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @card.destroy\n respond_to do |format|\n format.html { redirect_to cards_url, notice: 'Card was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @card.destroy\n respond_to do |format|\n format.html { redirect_to cards_url, notice: 'Card was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @card.destroy\n respond_to do |format|\n format.html { redirect_to cards_url, notice: 'Card was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @card.destroy\n respond_to do |format|\n format.html { redirect_to cards_url, notice: 'Card was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @card_detail.destroy\n respond_to do |format|\n format.html { redirect_to card_details_url, notice: 'Card detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @answer.post.update(embedded_post_params)\n format.js { head :no_content }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @inden_card.destroy\n respond_to do |format|\n format.html { redirect_to inden_cards_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pk_card.destroy\n respond_to do |format|\n format.html { redirect_to pk_cards_url, notice: 'Pk card was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @card.destroy\n \n respond_to do |format|\n format.html { redirect_to cards_url, notice: 'Card was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @card_instance.update(card_instance_params)\n format.html { redirect_to @card_instance, notice: 'Card instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @card_instance }\n else\n format.html { render :edit }\n format.json { render json: @card_instance.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @card_instance.update(card_instance_params)\n format.html { redirect_to @card_instance, notice: 'Card owner was successfully updated.' }\n format.json { render :show, status: :ok, location: @card_instance }\n else\n format.html { render :edit }\n format.json { render json: @card_instance.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @cards_question = Cards::Question.find(params[:id])\n @cards_question.destroy\n\n respond_to do |format|\n format.html { redirect_to cards_questions_url }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @vehicle_card.update(vehicle_card_params)\n format.html { redirect_to @vehicle_card, notice: (t 'vehicle_cards.title')+(t 'actions.updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vehicle_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @company_card.update(company_card_params)\n format.html { redirect_to @company_card, notice: 'Company card was successfully updated.' }\n format.json { render :show, status: :ok, location: @company_card }\n else\n format.html { render :edit }\n format.json { render json: @company_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @card.destroy\n respond_to do |format|\n format.html { redirect_to cards_url, notice: t(\".successfully_destroyed\") }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @keycard.update(keycard_params)\n format.html { redirect_to keycards_path, notice: 'keycard ' + @keycard.id.to_s + ' was successfully updated.' }\n format.json { render :show, status: :ok, location: @keycard }\n else\n format.html { render :edit }\n format.json { render json: @keycard.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n if(params.has_key?(:card_id))\n @Point3Card = Point3Card.find_by_card_id(params[:card_id])\n @Point3Card.destroy\n elsif(params.has_key?(:id))\n @Point3Card = Point3Card.find_by_card_id(params[:id])\n @Point3Card.destroy\n else\n Point3Card.delete_all\n end\n render json: {}, status: :no_content\n end", "def destroy\n answer = Answer.find(params[:answer_id])\n answer.destroy\n \n render json: {success: true}\n end", "def destroy\n @card.destroy\n respond_to do |format|\n format.html { redirect_to deck_cards_path(@deck, @card), notice: 'Card was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if(params.has_key?(:card_id))\n @Point2Card = Point2Card.find_by_card_id(params[:card_id])\n @Point2Card.destroy\n elsif(params.has_key?(:id))\n @Point2Card = Point2Card.find_by_card_id(params[:id])\n @Point2Card.destroy\n else\n Point2Card.delete_all\n end\n render json: {}, status: :no_content\n end", "def update\n @flash_card = FlashCard.find(params[:id])\n\n respond_to do |format|\n if @flash_card.update_attributes(params[:flash_card])\n format.html { redirect_to(@flash_card, :notice => 'Flash card was successfully updated.') }\n format.json { render :json => [] }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @flash_card.errors, :status => :unprocessable_entity }\n format.xml { render :xml => @flash_card.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fate_card.update(fate_card_params)\n format.html { redirect_to @fate_card, notice: 'Fate card was successfully updated.' }\n format.json { render :show, status: :ok, location: @fate_card }\n else\n format.html { render :edit }\n format.json { render json: @fate_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n if !(params[:id].nil?)\n if (CompanyCard.exists?(params[:id]))\n card = CompanyCard.find(params[:id])\n card.destroy\n render status: 200, json:{\n message: \"Successfully deleted that card.\"\n }.to_json\n else\n render status: 422, json:{\n message: \"Unable to process your request of the server.\"\n }.to_json \n end\n else\n render status: 422, json:{\n message: \"Unable to process your request of the server.\"\n }.to_json \n end\n end", "def destroy\n set_m_card\n @m_card.destroy\n respond_to do |format|\n format.html { redirect_to m_cards_url }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @deck.update(deck_params)\n format.html { redirect_to @deck, notice: 'Deck was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @deck.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @card = Card.find(params[:id])\n\n respond_to do |format|\n if @card.update_attributes(params[:card])\n flash[:notice] = 'Card was successfully updated.'\n format.html { redirect_to(@card) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xmll => @card.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @card.destroy\n respond_to do |format|\n format.html { redirect_to request.referer, notice: 'Card was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @debit_card.update(debit_card_params)\n format.html { redirect_to @debit_card, notice: 'Debit card was successfully updated.' }\n format.json { render :show, status: :ok, location: @debit_card }\n else\n format.html { render :edit }\n format.json { render json: @debit_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @card = Card.find(params[:id])\n\n @current_user = User.find_by_id(session[:user_id])\n\n unless @current_user.admin?\n flash[:error] = \"You do not have permission to update a card\"\n redirect_to cards_path(@cards)\n return\n end\n\n @card.destroy\n\n respond_to do |format|\n format.html { redirect_to cards_url }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @deck.update(deck_params)\n score_update(deck_params, @deck.id)\n format.html { redirect_to @deck, notice: '更新されました' }\n format.json { render :show, status: :ok, location: @deck }\n else\n format.html { render :edit }\n format.json { render json: @deck.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @greeting_card.update(greeting_card_params)\n format.html { redirect_to @greeting_card, notice: 'Greeting card was successfully updated.' }\n format.json { render :show, status: :ok, location: @greeting_card }\n else\n format.html { render :edit }\n format.json { render json: @greeting_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user_card.update(user_card_params)\n format.html { redirect_to @user_card, notice: 'User card was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_card }\n else\n format.html { render :edit }\n format.json { render json: @user_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @name_card.update(name_card_params)\n format.html { redirect_to @name_card, notice: 'Name card was successfully updated.' }\n format.json { render :show, status: :ok, location: @name_card }\n else\n format.html { render :edit }\n format.json { render json: @name_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @flashcard = Flashcard.find(params[:id])\n\n respond_to do |format|\n if @flashcard.update_attributes(params[:flashcard])\n format.html { redirect_to @flashcard, notice: 'Flashcard was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @flashcard.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @report_card.update(report_card_params)\n format.html { redirect_to @report_card, notice: 'Report card was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @report_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n answer = Answer.find(params[:answer_id])\n if answer.update(content: params[:content])\n render json: {answer: answer, success: true} \n else\n render json: @answer.errors, success: false \n end\n end", "def destroy\n @vote_card.destroy\n respond_to do |format|\n format.html { redirect_to vote_cards_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.8172313", "0.8014409", "0.78973067", "0.7871751", "0.78175044", "0.766368", "0.7563084", "0.7562726", "0.7543309", "0.75148106", "0.75148106", "0.75148106", "0.75148106", "0.75148106", "0.75148106", "0.751174", "0.7504278", "0.7477327", "0.7468358", "0.7468358", "0.7468358", "0.74650604", "0.7463647", "0.7456036", "0.74365807", "0.7426448", "0.7410352", "0.7392434", "0.7381603", "0.73581785", "0.735338", "0.7352982", "0.7352978", "0.7338903", "0.7335446", "0.7328366", "0.73239493", "0.7296613", "0.7264329", "0.7263055", "0.72355235", "0.72270536", "0.72270536", "0.72270536", "0.7220272", "0.71945673", "0.71685445", "0.71648073", "0.71543336", "0.7145347", "0.71435004", "0.71389633", "0.7127546", "0.7112829", "0.7104823", "0.70964676", "0.70896167", "0.7070036", "0.7070036", "0.7070036", "0.7070036", "0.7070036", "0.7070036", "0.7070036", "0.7066846", "0.70616186", "0.70488", "0.70467156", "0.704517", "0.704076", "0.70315826", "0.7028885", "0.7028134", "0.70116895", "0.7008105", "0.7004475", "0.70044196", "0.70044", "0.7000828", "0.69896257", "0.6986227", "0.6985744", "0.698083", "0.6977562", "0.69771355", "0.69654185", "0.696346", "0.69613236", "0.69585615", "0.6957097", "0.6956344", "0.695397", "0.695397", "0.695397", "0.6953593", "0.6951789", "0.6949788", "0.69441634", "0.6942744", "0.69389045", "0.69375795" ]
0.0
-1
pascal implementation of euclid program euclid(input.output); var x.y: integer; function gcd(u.v: integer):integer; var t: integer; begin repeat if uy) and (y>0) then writeln(x,y.gcd(x.y)) end; end. 2.3 reduction of fraction to lowest terms recursively if u > v then gcd u,v == gcd v, uv
def gcd (v,u) if (u==v) return v elsif (u>v) u-=v gcd(v,u) else gcd(u,v) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gcd(p0) end", "def gcd(x, y) # finds greatest common factor of x,y\n while y != 0\n t = y\n y = x % y\n x = t\n end\n x\nend", "def gcd_ex(x, y)\n s1 = t0 = 0\n s0 = t1 = 1\n until y.zero?\n x, (q, y) = y, divmod(x, y)\n s0, s1 = s1, s0 - q*s1\n t0, t1 = t1, t0 - q*t1\n # puts \"x=#{x} y=#{y} s0=#{s0} s1=#{s1} t0=#{t0} t1=#{t1} q=#{q}\"\n end\n return x, s0, t0, t1, s1\n end", "def gcd(x, y)\n until y.zero?\n # puts \"#{x} #{y}\"\n x, y = y, mod(x, y)\n end\n x\n end", "def gcd(x, y)\n if (y == 0)\n return x\n else\n gcd(y, x%y)\n end\nend", "def gcd x, y\n r = x % y # r - remainder\n if r == 0\n y\n else\n gcd(y, r)\n end\nend", "def gcd(x, y)\n x == 0 ? y : gcd(y % x, x)\nend", "def gcd a,b\n if a<b\n gcd b,a\n elsif b==0\n a\n else\n gcd b,a%b\n end\nend", "def xgcd_rec(x, y)\n if y == 0\n [x, 1, 0]\n else\n gcd, a, b = xgcd_rec(y, x%y)\n [gcd, b, a-x/y*b]\n end\nend", "def gcd(u,v)\n u, v = u.abs, v.abs\n while v > 0\n u, v = v, u % v\n end\n u\nend", "def egcd(a, b)\n # let A, B = a, b \n s, t, u, v = 1, 0, 0, 1\n while 0 < b\n # loop invariant: a = sA + tB and b = uA + vB and gcd(a,b) = gcd(A,B)\n q = a/b\n a, b, s, t, u, v = b, (a%b), u, v, (s-u*q), (t-v*q) \n end \nreturn [a, s, t] \nend", "def euclidean_gcd(up, down)\n return up if down.zero?\n euclidean_gcd(down, up % down)\nend", "def gcd2 a,b\n if a<b\n d,s,r = gcd2 b,a\n [d,r,s]\n elsif b==0\n [a,1,0]\n else\n x=a/b\n y=a%b\n d,r,s = gcd2 b,y\n # here we know that d = r*b+s*y, and a=x*b+y, so y=a-x*b\n # thus d=r*b+s*(a-x*b) = (r-s*x)*b + s*a\n # so we return [d,s,r-s*x]\n # uncomment the following three lines to see this work out\n # puts \"#{a}=#{x}*#{b}+#{y}\"\n # puts \"#{d}=#{s}*#{a} + #{(r-s*x)}*#{b}\"\n [d,s,(r-s*x)]\n end\nend", "def gcd(a, b)\r\n if b == 0\r\n return a\r\n else\r\n return gcd(b, a % b)\r\n end\r\nend", "def gcd( a, b )\n return a if b.zero?\n gcd b, a % b\nend", "def gcd3 (v,u,w)\n if (u==v)\n return gcd(v,w)\n elsif (u>v)\n u-=v\n gcd(gcd(v,u),w)\n else\n gcd(gcd(u,v),w)\n end\nend", "def gcd(a, b)\n if a == b\n a\n elsif a < b\n gcd1(b, a)\n else\n gcd1(a, b)\n end\nend", "def gcd(a,b)\n if (b==0)\n a\n else\n gcd(b,a%b)\n end\nend", "def euclid(a, b)\n\treturn a if b == 0\n\teuclid(b, a % b)\nend", "def gcd(a, b)\n if a % b == 0\n b\n else\n gcd(b, a % b)\n end\nend", "def gcd(a, b)\n if (b == 0) then a\n else gcd(b, a % b)\n end\nend", "def gcd(a, b)\n # Everything divides 0\n return b if a == 0\n\n return a if b == 0\n\n # base case\n return a if a == b\n\n # a is greater\n return gcd(a - b, b) if a > b\n\n gcd(a, b - a)\nend", "def gcd(a, b)\n if b == 0\n return a\n else\n return gcd(b, a%b)\n end\nend", "def gcd(a,b)\n return b if a % b == 0\n return gcd(b, a % b)\nend", "def gcd(a, b)\n return a if b == 0\n\n remiander = a % b\n return gcd(b, remiander)\nend", "def gcd(a, b)\n return a if b == 0\n div = a % b\n gcd(b, div)\nend", "def gcd(a,b)\n # base case: everything divides zero\n if b == 0\n return a\n else\n remainder = a%b\n end\n return gcd(b, remainder)\nend", "def gcd(a,b)\n\treturn a if b === 0\n\treturn gcd(b, a % b)\nend", "def gcd(a,b)\n while a != b\n if a > b\n return gcd(a - b,b)\n else\n return gcd(a , b - a)\n end\n end\n return a\nend", "def xgcd_iter(x, y)\n a, next_a = 1, 0\n b, next_b = 0, 1\n while y != 0\n a, next_a = next_a, a-x/y*next_a\n b, next_b = next_b, b-x/y*next_b\n x, y = y, x%y\n end\n [x, a, b]\nend", "def gcd(a,b)\n return gcd(b, a) if a > b\n return b if a == 0\n gcd(b % a, a)\nend", "def main()\n puts \"Please enter a single integer: \"\n num1 = gets.to_i\n puts \"Please enter a second integer: \"\n num2 = gets.to_i\n \n res1 = gcdI(num1, num2)\n puts \"This is the interative gcd function: \" + res1.to_s\n \n res2 = gcdR(num1, num2)\n puts \"This is the recursive gcd function: \" + res2.to_s\nend", "def gcdI(i, j)\n while i != j\n if i > j\n i = i - j\n else\n j = j - i\n end\n end\n return i\nend", "def extended_lehmer_gcd(a, b)\r\n\t\td0 = a\r\n\t\tu0 = 1\t# d0 = a * u0 + b * v0\r\n\t\td1 = b\r\n\t\tu1 = 0\t# d1 = a * u1 + b * v1\r\n\r\n\t\tloop do\r\n\t\t\tif d1.instance_of?(Fixnum)\r\n\t\t\t\t_u, _v, d = extended_gcd(d0, d1)\r\n\r\n\t\t\t\t# here\r\n\t\t\t\t# d == _u * d0 + _v * d1\r\n\t\t\t\t# d0 == u0 * a + v0 * b\r\n\t\t\t\t# d1 == u1 * a + v1 * b\r\n\r\n\t\t\t\tu = _u * u0 + _v * u1\r\n\t\t\t\tv = (d - u * a) / b\r\n\r\n\t\t\t\treturn u, v, d\r\n\t\t\tend\r\n\r\n\t\t\t# Get most significant digits of d0 and d1\r\n\t\t\tshift_size = (d0 < d1 ? d1 : d0).bit_size - FIXNUM_BIT_SIZE\r\n\t\t\ta_ = d0 >> shift_size\r\n\t\t\tb_ = d1 >> shift_size\r\n\r\n\t\t\t# Initialize (Here a_ and b_ are next value of d0, d1)\r\n\t\t\t_A = 1\r\n\t\t\t_B = 0\t# a_ == msd(d0) * _A + msd(d1) * _B\r\n\t\t\t_C = 0\r\n\t\t\t_D = 1\t# b_ == msd(d0) * _C + msd(d1) * _D\r\n\r\n\t\t\t# Test Quotient\r\n\t\t\tuntil 0 == b_ + _C or 0 == b_ + _D\r\n\t\t\t\tq1 = (a_ + _B) / (b_ + _D)\r\n\t\t\t\tq2 = (a_ + _A) / (b_ + _C)\r\n\t\t\t\tbreak if q1 != q2\r\n\r\n\t\t\t\t# Euclidean step\r\n\t\t\t\t_A, _C = _C, _A - q1 * _C\r\n\t\t\t\t_B, _D = _D, _B - q1 * _D\r\n\t\t\t\ta_, b_ = b_, a_ - q1 * b_\r\n\t\t\tend\r\n\r\n\t\t\t# Multi-precision step\r\n\t\t\tif 0 == _B\r\n\t\t\t\tq, r = d0.divmod(d1)\r\n\t\t\t\td0, d1 = d1, r\r\n\t\t\t\tu0, u1 = u1, u0 - q * u1\r\n\t\t\telse\r\n\t\t\t\td0, d1 = d0 * _A + d1 * _B, d0 * _C + d1 * _D\r\n\t\t\t\tu0, u1 =u0 * _A + u1 * _B, u0 * _C + u1 * _D\r\n\t\t\tend\r\n\t\tend\r\n\tend", "def gcd(a, b)\n # always consider that a > b\n b.downto(1) do |num|\n if b % num == 0\n return num if a % num == 0\n end\n end\nend", "def gcd(n1, n2)\n if n1.abs < n2.abs\n n1, n2 = n2, n1\n end\n return n1 if n2 == 0\n gcd(n2, n1 % n2)\nend", "def gcd(a, b)\n return b if a == 0\n return a if b == 0\n a, b = b, a if a < b\n a % b == 0 ? b : gcd(b, a % b)\nend", "def gcd (a, b) # O(log b)\n if b != 0\n self.gcd(b, a % b)\n else\n return a\n end\n end", "def gcd( a, b )\r\n\t\t\treturn (b*(a%b))/lcm(b,a%b)\r\n\t\tend", "def gcd(a, b)\n b == 0 ? a : gcd(b, a % b)\nend", "def euclidean_algorithm(x, y)\n smaller, larger = [x, y].sort\n quotient = larger / smaller\n remainder = larger % smaller\n puts \"#{remainder} = #{larger} - #{quotient} * #{smaller}\"\n case remainder\n when 0 then puts 'No solutions'\n when 1 then return\n else euclidean_algorithm smaller, remainder\n end\n end", "def gcd_euclides(a, b)\n while b != 0\n t = b\n b = a % b\n a = t\n end\n a\nend", "def gcdR(i, j)\n if j != 0\n return gcdR(j, i%j)\n else\n return i\n end\nend", "def GCD(a, b)\n \n a, b = a.abs, b.abs\n\n # Always b => a\n if (a < b)\n a,b = b, a\n end\n while not (a == 0 or b == 0)\n a, b = b, a % b\n end\n\n if a == 0\n return b\n elsif b == 0\n return a\n end\n \nend", "def ext_euclid(a, b)\n if (a%b).zero?\n return [0, 1]\n else\n x, y = ext_euclid(b, a%b)\n return [y, x-y*(a/b)]\n end\nend", "def extended_gcd(a, b)\r\n\t\tu0 = a.class.one\r\n\t\tu1 = a.class.zero\r\n\r\n\t\treturn u0, u1, a if b.zero?\r\n\r\n\t\td0 = a\t# d0 = a * u0 + b * v0\r\n\t\td1 = b\t# d1 = a * u1 + b * v1\r\n\r\n\t\tloop do\r\n\t\t\tq, r = d0.divmod(d1)\r\n\r\n\t\t\treturn u1, (d1 - a * u1) / b, d1 if r.zero?\r\n\r\n\t\t\td0, d1 = d1, r\r\n\t\t\tu0, u1 = u1, u0 - q * u1\r\n\t\tend\r\n\tend", "def extended_gcd(a, b)\n\n # trivial case first: gcd(a, 0) == 1*a + 0*0 \n return 1, 0 if b == 0\n\n # recurse: a = q*b + r\n q, r = a.divmod b\n s, t = extended_gcd(b, r)\n\n # compute and return coefficients:\n # gcd(a, b) == gcd(b, r) == s*b + t*r == s*b + t*(a - q*b)\n return t, s - q * t\nend", "def gcdI(i, j)\n\twhile i != j\n\t\tif i > j\n\t\t\ti = i - j\n\t\telse\n\t\t\tj = j - i\n\t\tend\n\tend\n\treturn i\nend", "def gcd(num1,num2)\n\tif num1 < num2\n\t\ttemp = num1\n\t\tnum1 = num2\n\t\tnum2 = temp\n\tend\n\n\tif num1 % num2 == 0\n\t\treturn num2\n\tend\n\n\tremainder = num1 % num2 \n\tgcd(num2, remainder)\nend", "def gcd(num1, num2)\n\n loop do\n remainder = num1 % num2\n break if remainder == 0\n num1 = num2\n num2 = remainder\n end\n\n num2\nend", "def gcd2test a,b\n d,r,s = gcd2 a,b\n z = r*a+s*b\n return z==d\nend", "def get_d(p,q,e)\n phi = (p-1)*(q-1)\n x,y = extended_gcd(e,phi)\n x += phi if x<0 # Have to add the modulus if it returns negative\n x\nend", "def extended_gcd(a, b)\n return [0,1] if a % b == 0\n x,y = extended_gcd(b, a % b)\n [y, x-y*(a / b)]\nend", "def recursive_gcd(numerator, denominator)\n if d != 0\n return n\n else\n return recursive_gcd(denominator, numerator % denominator)\n end\nend", "def factor_gcd(n, g)\n m = 0\n while((m = gcd(n, g)) != 1) do\n n /= m\n end\n n\nend", "def extended_gcd(a, b)\n last_remainder = a.abs\n remainder = b.abs\n x = 0\n last_x = 1\n y = 1\n last_y = 0\n\n while remainder != 0\n last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)\n x, last_x = last_x - quotient * x, x\n y, last_y = last_y - quotient * y, y\n end\n\n [last_remainder, last_x * (a.negative? ? -1 : 1)]\nend", "def GCD_verbose(a, b)\n \n a, b = a.abs, b.abs\n\n # Always b => a\n if (a < b)\n a,b = b, a\n end\n puts \"(A,B) = \" + a.to_s() + \", \" + b.to_s()\n count = 1\n while not (a == 0 or b == 0)\n puts \"*\" * 10\n print \"Step #{count}:\\n\"\n tmp = a \n a, b, division = b, a % b, a / b\n print \"#{tmp} = #{a} * #{division} + #{b}\\n\"\n print \"(A,B) = #{a}, #{b}\\n\"\n puts \"*\" * 10\n count += 1\n end\n\n if a == 0\n return b\n elsif b == 0\n return a\n end\n return a, b\nend", "def extended_euclid(a, b)\n if a < b\n swap_values = true\n end\n\n if swap_values\n a, b = b, a\n end\n\n remainders = []\n quotients = []\n a_tmp, b_tmp = a, b\n while a_tmp % b_tmp > 0\n remainders.push(a_tmp % b_tmp)\n quotients.push(a_tmp / b_tmp)\n\n a_tmp, b_tmp = b_tmp, a_tmp % b_tmp\n end\n\n x_tmp, y_tmp = 1, -quotients[-1]\n quotients.take(quotients.size - 1).reverse.each do |quotient|\n x_tmp, y_tmp = y_tmp, x_tmp - y_tmp * quotient\n end\n\n unless x_tmp*a + y_tmp*b == remainders[-1]\n raise 'Failed to compute Bezout coefficients'\n end\n\n if swap_values\n x_tmp, y_tmp = y_tmp, x_tmp\n end\n\n return x_tmp, y_tmp\nend", "def gcd(num1, num2)\n if num2 > num1\n num1, num2 = num2, num1\n end\n r = nil\n r1 = num1\n r2 = num2\n until r == 0\n r = r1 % r2\n r1 = r2\n r2 = r\n end\n r1\n end", "def extended_gcd(a, b)\n last_remainder, remainder = a.abs, b.abs\n x, last_x, y, last_y = 0, 1, 1, 0\n while remainder != 0\n last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)\n x, last_x = last_x - quotient*x, x\n y, last_y = last_y - quotient*y, y\n end\n\n return last_remainder, last_x * (a < 0 ? -1 : 1)\nend", "def extended_gcd(a, b)\n last_remainder, remainder = a.abs, b.abs\n x, last_x, y, last_y = 0, 1, 1, 0\n while remainder != 0\n last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)\n x, last_x = last_x - quotient*x, x\n y, last_y = last_y - quotient*y, y\n end\n\n return last_remainder, last_x * (a < 0 ? -1 : 1)\nend", "def extended_gcd(a, b)\n last_remainder, remainder = a.abs, b.abs\n x, last_x, y, last_y = 0, 1, 1, 0\n while remainder != 0\n last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)\n x, last_x = last_x - quotient*x, x\n y, last_y = last_y - quotient*y, y\n end\n\n return last_remainder, last_x * (a < 0 ? -1 : 1)\nend", "def extended_gcd(a, b)\n last_remainder, remainder = a.abs, b.abs\n x, last_x, y, last_y = 0, 1, 1, 0\n while remainder != 0\n last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)\n x, last_x = last_x - quotient * x, x\n y, last_y = last_y - quotient * y, y\n end\n return last_remainder, last_x * (a.negative? ? -1 : 1)\nend", "def gcd(*nums)\r\n\t\treturn nums.inject do |a, b|\r\n\t\t\ta, b = b, a % b until b.zero?\r\n\t\t\tnext a\r\n\t\tend\r\n\tend", "def extended_binary_gcd(a, b)\r\n\t\tif a < b\r\n\t\t\ta, b = b, a\r\n\t\t\texchange_flag_1 = true\r\n\t\tend\r\n\r\n\t\tif 0 == b\r\n\t\t\treturn 0, 1, a if exchange_flag_1\r\n\t\t\treturn 1, 0, a\r\n\t\tend\r\n\r\n\t\t# Reduce size once\r\n\t\t_Q, r = a.divmod(b)\r\n\t\tif 0 == r\r\n\t\t\treturn 1, 0, b if exchange_flag_1\r\n\t\t\treturn 0, 1, b\r\n\t\tend\r\n\t\ta, b = b, r\r\n\r\n\t\t# Compute power of 2\r\n\t\t_K = 0\r\n\t\t_K += 1 while 0 == a[_K] and 0 == b[_K]\r\n\t\tif 0 < _K\r\n\t\t\ta >>= _K\r\n\t\t\tb >>= _K\r\n\t\tend\r\n\r\n\t\tif b.even?\r\n\t\t\ta, b = b, a\r\n\t\t\texchange_flag_2 = true\r\n\t\tend\r\n\r\n\t\t# Initialize\r\n\t\tu = 1\r\n\t\td = a\t# d == a * u + b * v, (v = 0)\r\n\t\tu_ = 0\r\n\t\td_ = b\t# d_ == a * u_ + b * v_, (v_ = 1)\r\n\r\n\t\t# Remove intial power of 2\r\n\t\twhile d.even?\r\n\t\t\td >>= 1\r\n\t\t\tu += b if u.odd?\r\n\t\t\tu >>= 1\r\n\t\tend\r\n\r\n\t\tloop do\r\n\t\t\t# Substract\r\n\t\t\tnext_u = u - u_\r\n\t\t\tnext_d = d - d_\t\t# next_d == a * next_u + b * next_v\r\n\t\t\tnext_u += b if next_u < 0\r\n\r\n\t\t\tbreak if 0 == next_d\r\n\r\n\t\t\t# Remove powers of 2\r\n\t\t\twhile next_d.even?\r\n\t\t\t\tnext_d >>= 1\r\n\t\t\t\tnext_u += b if next_u.odd?\r\n\t\t\t\tnext_u >>= 1\r\n\t\t\tend\r\n\r\n\t\t\tif 0 < next_d\r\n\t\t\t\tu = next_u\r\n\t\t\t\td = next_d\r\n\t\t\telse\r\n\t\t\t\tu_ = b - next_u\r\n\t\t\t\td_ = -next_d\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\tv = (d - a * u) / b\r\n\r\n\t\tu, v = v, u if exchange_flag_2\r\n\t\td <<= _K\r\n\t\tu, v = v, u - v * _Q\r\n\t\tu, v = v, u if exchange_flag_1\r\n\r\n\t\treturn u, v, d\r\n\tend", "def find_gcd(nums)\n nums.max.gcd(nums.min)\nend", "def ext_gcd(other)\n\t\tif @bits == 0\n\t\t\treturn F2_poly.new(other.bits), F2_poly.new(0), F2_poly.new(1)\n\t\tend\n\t\tif other.bits == 0\n\t\t\treturn F2_poly.new(@bits), F2_poly.new(1), F2_poly.new(0)\n\t\tend\n\n\t\tsprime = 1\n\t\tt = 1\n\t\ts = 0\n\t\ttprime = 0\n\t\tc = @bits\n\t\td = other.bits\n\n\t\twhile true\n\t\t\tq, r = F2_poly.iquot_and_rem(c, d)\n\t\t\tif r == 0\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tc = d\n\t\t\td = r\n\t\t\tsprime, s = s, sprime ^ F2_poly.bit_mul(q, s)\n\t\t\ttprime, t = t, tprime ^ F2_poly.bit_mul(q, t)\n\t\tend\n\t\treturn F2_poly.new(d), F2_poly.new(s), F2_poly.new(t)\n\tend", "def gcf(num1, num2)\n\tx = num1 < num2 ? num1 : num2\n\twhile x > 1 do\n\t\tif num1 % x == 0 && num2 % x == 0\n\t\t\treturn x\n\t\tend\n\t\tx -= 1\n\tend\n\treturn 1\nend", "def gcd_of_last_digits(int_one, int_two)\r\n # your code goes here\r\n last_digit(int_one).gcd(last_digit(int_two))\r\nend", "def lehmer_gcd(a, b)\r\n\t\ta = -a if a < 0\r\n\t\tb = -b if b < 0\r\n\t\ta, b = b, a if a < b\r\n\r\n\t\tuntil 0 == b\r\n\t\t\treturn Abst.gcd(a, b) if b.instance_of?(Fixnum)\r\n\r\n\t\t\t# Get most significant digits of a and b\r\n\t\t\tshift_size = (a < b ? b : a).bit_size - FIXNUM_BIT_SIZE\r\n\t\t\ta_ = a >> shift_size\r\n\t\t\tb_ = b >> shift_size\r\n\r\n\t\t\t_A = 1\r\n\t\t\t_B = 0\t# a_ == msd(a) * _A + msd(b) * _B\r\n\t\t\t_C = 0\r\n\t\t\t_D = 1\t# b_ == msd(a) * _C + msd(b) * _D\r\n\r\n\t\t\t# Always\r\n\t\t\t# a_ + _B <= msd(a * _A + b * _B) < a_ + _A AND\r\n\t\t\t# b_ + _C <= msd(a * _C + b * _D) < a_ + _D\r\n\t\t\t# OR\r\n\t\t\t# a_ + _B > msd(a * _A + b * _B) >= a_ + _A AND\r\n\t\t\t# b_ + _C > msd(a * _C + b * _D) >= a_ + _D\r\n\r\n\t\t\t# Test quotient\r\n\t\t\tuntil 0 == b_ + _C or 0 == b_ + _D\r\n\t\t\t\tq1 = (a_ + _A) / (b_ + _C)\r\n\t\t\t\tq2 = (a_ + _B) / (b_ + _D)\r\n\t\t\t\tbreak if q1 != q2\r\n\r\n\t\t\t\t# Euclidean step\r\n\t\t\t\t_A, _C = _C, _A - q1 * _C\r\n\t\t\t\t_B, _D = _D, _B - q1 * _D\r\n\t\t\t\ta_, b_ = b_, a_ - q1 * b_\r\n\t\t\tend\r\n\r\n\t\t\t# Multi-precision step\r\n\t\t\tif 0 == _B\r\n\t\t\t\ta, b = b, a % b\r\n\t\t\telse\r\n\t\t\t\ta, b = a * _A + b * _B, a * _C + b * _D\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\treturn a\r\n\tend", "def greatest_common_factor(number1, number2)\n # get the smaller number\n n = number1 < number2 ? number1 : number2\n\n # check each number i\n # starting from this number n down to 1\n # if it divides both number1 and number2 evenly\n # if so, then this is the gcd\n n.downto(1).each do |i|\n if number1 % i == 0 and number2 % i == 0\n return i\n end\n end\n 1\nend", "def my_gcd(*args)\r\n\targs.inject do |memo, num|\r\n\t\tuntil [memo, num].include?(0)\r\n\t\t\tmod = memo % num\r\n\t\t\tmemo, num = num, mod\r\n\t\tend\r\n\t\t[memo, num].max\r\n\tend\r\nend", "def extended_gcd(a, b)\n last_remainder, remainder = a.abs, b.abs\n x, last_x, y, last_y = 0, 1, 1, 0\n while remainder != 0\n last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)\n x, last_x = last_x - quotient*x, x\n y, last_y = last_y - quotient*y, y\n end\n\n return last_remainder, last_x * (a < 0 ? -1 : 1)\n end", "def greatest_common_divisor(x, y)\n first = [x, y].max\n second = [x, y].min\n return first if second == 0\n rem = first - (first / second) * second\n greatest_common_divisor(second, rem)\nend", "def recursive_gcd_proper_fractions(n)\n return 0 if n == 1\n proper_fractions_found = 0\n\n (1..n-1).each do |i|\n if recursive_gcd(i, n) == 1\n proper_fractions_found += 1\n else\n next\n end\n end\n\n proper_fractions_found\nend", "def gcd_of_last_digits(int_one, int_two)\n # your code goes here\n int_one.gcd(int_two)\n if int_one % 10 < int_two % 10\n return int_one % 10\n else\n return int_two % 10\n end\nend", "def reducir(n, d)\n aux = gcd(n, d)\n n = n / aux\n d = d / aux\n return n, d\n end", "def gcd_of_last_digits(int_one, int_two)\n # your code goes here\n puts (int_one.digits.first).gcd(int_two.digits.first)\nend", "def coprime(a, b)\n gcd(a, b) == 1\nend", "def getGCD(a, b)\n\tif b.zero?\n\t\treturn a\n\telse\n\t\treturn getGCD(b, a%b)\n\tend\nend", "def euclidean(a, b, ctrl)\n rem = a % b\n if !rem.zero? && rem != 1\n euclidean(b, rem, rem)\n elsif rem.zero? && !(b == 1)\n b\n else\n 'Numbers are coprime'\n end\nend", "def find_gcd(nums)\n nums.minmax.reduce(:gcd)\nend", "def gcd(n, m)\n n % m == 0 ? m : gcd(m, n % m)\nend", "def greatest_common_divisor(x, y)\n first, second = [x, y].sort\n (1..first).each_with_object([]) do |num, common_divisors|\n common_divisors << num if first % num == 0 && second % num == 0\n end.max\nend", "def pgdc(a,b)\n\twhile(a != 0 && b !=0)\n\t\tif(a > b)\n\t\t\ta = a%b\n\t\telse\n\t\t\tb = b%a\n\t\tend\n\tend\n\ta==0? b : a\nend", "def greatest_common_divisor(x, y)\n smallest_num = [x, y].min\n smallest_num.downto(1) do |num|\n return num if x % num == 0 && y % num == 0\n end\nend", "def solution(n, m)\n n / gcd(n, m)\nend", "def reduce!\n g = gcd(@numer, @denom)\n @numer /= g\n @denom /= g\n self\n end", "def generalizedGCD(num, arr)\n result = arr.first\n\n arr.each do |num|\n result = result.gcd(num)\n end\n\n result\nend", "def coprime?(a, b)\n 1 == gcd(a, b)\nend", "def solve_identity(d, e, f)\n # First we solve Bezout's identity by using the extended gcd algorithm.\n # See the wikipedia entry in detail.\n g = d.gcd(e)\n return if f % g != 0 # No solution\n d, e, f = d / g, e / g, f / g\n a, b = d, -e\n x0, x1 = 1, 0\n y0, y1 = 0, 1\n while b != 0\n q = a / b\n a, b = b, a % b\n x0, x1 = x1, x0 - x1 * q\n y0, y1 = y1, y0 - y1 * q\n end\n\n # Now we have solution candidates.\n # x = -f * x0 - e * t\n # y = -f * y0 - d * t\n # where t is a free parameter.\n # Then, we consider another constraint: x and y is both printable.\n\n # We must satisfy: 35 <= x <= 126\n # -> ceil((35+f*x0) / e) <= -t <= floor((126+f*x0) / e)\n # -> ceil((35+f*x0) / e) * d - f*y0 <= y <= floor((126+f*x0) / e) * d - f*y0\n ymin = ( 35+f*x0+e+1) / e * d - f*y0\n ymax = (126+f*x0 ) / e * d - f*y0\n\n return if ymax < ymin || ymax < 33 || ymin > 126 # No solution.\n\n ((ymax + f*y0) / -d).upto((ymin + f*y0) / -d) do |t|\n x = -f * x0 - e * t\n y = -f * y0 - d * t\n return [x, y] if printable?(x) && printable?(y) # Solution found.\n end\n\n return # No solution.\nend", "def greatest_common_factor(first_number, second_number)\n x, y = first_number, second_number\n n = x < y ? x : y\n n.downto(1).each do |i|\n if x % i == 0 and y % i == 0\n return i\n end\n end\n 1\nend", "def lcm(u,v)\n (u*v).abs/gcd(u,v)\nend", "def euclid point1, point2\n\treturn Math.sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2)\nend", "def inv_gcd(a, b)\n a %= b\n return [b, 0] if a == 0\n\n s, t = b, a\n m0, m1 = 0, 1\n while t>0 do\n u, s = s.divmod(t)\n m0 -= m1*u\n s, t = t, s\n m0, m1 = m1, m0\n end\n m0 += b/s if m0 < 0\n return [s, m0]\nend", "def solve112(target_proportion)\n bouncy_proportion = 0\n total_bouncy = 0\n num = 0\n while bouncy_proportion < target_proportion\n num += 1\n if bouncy?(num)\n total_bouncy += 1\n bouncy_proportion = 1.0*total_bouncy/num\n end\n end\n puts target_proportion, num\nend", "def solution2(x, y, d)\n if x == y\n counter = 0\n elsif x < y\n if x + d >= y\n counter = 1\n else\n counter = ((y + x)/d).to_f\n end\n end\n counter.round\nend", "def reduce(frac)\n n, d = frac.split('/').map(&:to_i)\n unless (g = gcd(n, d)) == 1\n n /= g; d /= g\n end\n \"#{n}/#{d}\"\nend", "def add_frac(a,b)\nlcm = a[1].lcm(b[1])\nputs a.inspect\nputs b.inspect\nputs lcm\nif lcm == a[1] and b[1] then\n sum2 = a[0] + b[0]\n puts \"Your fraction is #{sum2}/#{lcm}\"\nelse\n sum1 = (a[0]*b[1]) + (b[0]*a[1])\n puts sum1\nputs \"Your fraction is #{sum1}/#{lcm}\"\nend\nend", "def solve_equivalent_fractions\n last = 0\n array = Array.new\n @reduced_row_echelon_form.each do |x|\n array = last.gcdlcm(x.last.denominator)\n last = x.last.denominator\n end\n array.max\n end" ]
[ "0.78156054", "0.7634887", "0.75282645", "0.7428897", "0.7423747", "0.7341764", "0.7283024", "0.7065813", "0.70368975", "0.70364934", "0.7034793", "0.6968274", "0.6870019", "0.6775002", "0.677368", "0.6773565", "0.67295843", "0.67229766", "0.6721197", "0.67091984", "0.66748685", "0.66614074", "0.6646149", "0.66331506", "0.6627369", "0.6624178", "0.6603473", "0.6599791", "0.65938437", "0.6569117", "0.6559858", "0.65561426", "0.65062493", "0.65019834", "0.6493735", "0.6491526", "0.6468245", "0.64574414", "0.6449136", "0.6448601", "0.6445157", "0.64413255", "0.63890046", "0.6364412", "0.6339562", "0.6335099", "0.63286173", "0.62872756", "0.62660056", "0.6250792", "0.62320805", "0.6231617", "0.6221412", "0.6191787", "0.61737144", "0.6150513", "0.6141021", "0.6116577", "0.609269", "0.6079757", "0.6079757", "0.6079757", "0.6067728", "0.60228163", "0.6014183", "0.5992004", "0.5980911", "0.5974603", "0.5967392", "0.5954123", "0.5953656", "0.5948836", "0.5948534", "0.5883771", "0.58824193", "0.58542883", "0.584654", "0.58344746", "0.580651", "0.5805295", "0.58014154", "0.57899696", "0.5766676", "0.57502186", "0.57183415", "0.5716353", "0.56842077", "0.5666903", "0.56470865", "0.56399715", "0.56289464", "0.56132525", "0.55810577", "0.55668473", "0.55493295", "0.5543994", "0.55327314", "0.5525976", "0.5493697", "0.547574" ]
0.7412962
5
2.5 conversion from base ten to binary
def toBinary (x) if (x>1) toBinary(x/2) + (x%2).to_s elsif x==1 return x.to_s end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base2to10(binary)\n\tresult = 0\n digits = binary.chars.reverse\n\n digits.each_with_index do |bit, idx|\n result += bit.to_i * (2**idx)\n end\n\n result\nend", "def to_binary(num)\n num_bin = ''\n current_power_of_2 = 1\n \n loop do\n num_bin.prepend ((num % (current_power_of_2 * 2)) / current_power_of_2).to_s\n \n break if num < current_power_of_2 * 2\n current_power_of_2 *= 2\n end\n \n num_bin.to_i\n end", "def base2to10(binary)\n bin_array = binary.chars.reverse\n i = 0\n sum = 0\n while i < bin_array.length\n sum += bin_array[i].to_i*(2**i)\n i+=1\n end\n sum\nend", "def base2to10(binary)\n base_ten = 0\n binary.split(\"\").reverse.map {|digit| digit.to_i}.each_with_index {|digit, index| base_ten += digit * (2**index)}\n return base_ten\nend", "def decimal_to_binary (decimal)\r\n\t\t# ruby inbuilt method - see other files\r\n\t # divide number by 2 and log remainders?\r\n\r\n\t# get length of number\r\n\t# determine biggest power of 2 that fits into number\r\n\t# see keefer and thom solutions - built with remainders maths\r\n\r\n\r\n\r\nend", "def dec_to_binary(num)\r\n bin = []\r\n quot = Math.floor(num / 2)\r\n bin.push(num % 2)\r\n while (quot > 1) \r\n bin.unshift(quot % 2)\r\n quot = Math.floor(quot / 2)\r\n end\r\n bin.unshift(quot)\r\n return bin.join('')\r\nend", "def int_to_binary_string(number)\n number.to_s(2)\nend", "def binarify(base_ten_num)\n raise 'input must be an integer' if base_ten_num.is_a?(String)\n base_ten_num.to_s(2)\nend", "def base2to10(binary)\n #split to single digits\n digits = binary.split('').map{|str| str.to_i}.reverse\n #loop through multiply by 2 raised to index and add to result\n result = 0\n digits.each_with_index do |num, i|\n result += (num *(2**i))\n end\n result\nend", "def to_bin(number)\n number = Integer(number);\n if(number == 0)\n return 0;\n end\n ret_bin = \"\";\n ## Untill val is zero, convert it into binary format\n while(number != 0)\n ret_bin = String(number % 2) + ret_bin;\n number = number / 2;\n end\n return ret_bin;\n end", "def base_converter(num, b)\n\n return num.to_s if [0, 1].include?(num)\n\n digits = %w(0123456789abcdef)\n base_converter(num/b, b) + digits[num % b]\n\nend", "def base10_to_base2(num)\n base2_ary = []\n\n MAX_POWER_OF_TWO.downto(0).each do |pow|\n if 2 ** pow <= num\n base2_ary << num / 2 ** pow\n num = num % 2 ** pow\n else\n base2_ary << 0\n end\n end\n\n base2_ary.join('').to_i\nend", "def binary\n decimal.to_s(2).rjust(8, '0')\n end", "def decimal_to_binary(number)\n if number == 0\n 0\n else\n number % 2 + 10 * decimal_to_binary(number/2)\n end \nend", "def to_bin(num_string)\n digits = convert_to_base10(num_string)\n digits.map!{|char| to_bits(char)}\n digits.join\n end", "def convert_to_base_8(n)\n n.to_s(8).to_i # replace these two method calls\nend", "def to_bits(base10_num)\n bits = @bit_vals.map do |b|\n if base10_num >= b\n base10_num -= b\n '1'\n else\n '0'\n end\n end\n bits.join\n end", "def convert_to_base_8(n)\n n.to_s(8).to_i\nend", "def convert_to_base_8(n)\n n.to_s(8).to_i\nend", "def base_converter(num, b)\n return num.to_s if [0,1].include?(num)\n\n digits = %w(0 1 2 3 4 5 6 7 8 9 a b c d e f)\n base_converter(num/b, b) + digits[num % b]\nend", "def base_converter(num, b)\n return \"\" if num == 0\n digits = %w(0 1 2 3 4 5 6 7 8 9 a b c d e f)\n\n base_converter(num/b, b) + digits[num%b]\n end", "def binary(digits)\n string(BINARY_DIGITS, digits)\n end", "def symbol_to_bin\n symbol.to_i.to_s(2).rjust(16, '0')\n end", "def symbol_to_bin\n if symbol.to_i.is_a? Integer\n symbol.to_i.to_s(2).rjust(16, '0')\n else\n\n end\n end", "def bin(x)\n x.to_s(16).chars.to_a.map{|d| d.to_i(16).to_s(2).rjust(4, '0')}.join(' ')\nend", "def fake_bin(s)\n s.tr('1-9', '00001')\nend", "def from_bin(num_string)\n bin_vals = num_string.scan(eval(\"/.{#{@bin_rep_length}}/\"))\n base10_vals = bin_vals.map{|bin_val| from_bits(bin_val)}\n convert_from_base10(base10_vals).join\n end", "def binary_to_base_n(binaryarr, base)\n val = 0\n pow = 0\n while !binaryarr.empty?\n val += binaryarr.pop * 2**pow\n pow += 1\n end\n t = []\n num_to_digit_array(val, base).each do |dig|\n if dig > 9\n t << (('a'..'z').to_a[dig-10])\n else\n t << (dig)\n end\n end\n t.join\nend", "def add_binary(a,b)\n #your code here\n binary = a + b\n binary.to_s(2) # Convert um inteiro para string na base 2(base binária)\nend", "def getBinary(number)\n binary = \"\"\n while (number > 0 && binary.size < 16) do\n binary << (number % 2).to_s\n number = number / 2\n end\n # might add condition for case where binary.size < 16, to add extra zero-es\n return binary.reverse\nend", "def base_converter(num, b)\n\nend", "def BinaryConverter(str)\r\n return str.to_i(2)\r\nend", "def to_i(base=10) end", "def decimal_to_binary(decimal)\n binary = 0\n power = 0\n\n if decimal.class == Integer\n until decimal == 0\n binary_digit = decimal % 2\n binary += binary_digit * (10 ** power)\n\n decimal /= 2\n power += 1\n end\n\n return binary\n elsif decimal.class == Float\n decimal_before_dot = decimal - (decimal % 1)\n binary_before_dot = 0\n\n\n until decimal_before_dot == 0\n binary_digit = decimal_before_dot % 2\n binary_before_dot += binary_digit * (10 ** power)\n\n\n decimal_before_dot = (decimal_before_dot / 2)\n decimal_before_dot = decimal_before_dot - (decimal_before_dot % 1)\n\n power += 1\n end\n\n\n decimal_after_dot = (decimal % 1)\n binary_after_dot_string = \"0.\"\n\n until decimal_after_dot == 0\n binary_digit = (decimal_after_dot * 2) - ((decimal_after_dot * 2) % 1)\n\n if binary_digit == 0\n binary_after_dot_string << \"0\"\n elsif binary_digit == 1\n binary_after_dot_string << \"1\"\n end\n\n decimal_after_dot = (decimal_after_dot * 2) % 1\n end\n\n binary_after_dot = binary_after_dot_string.to_f\n\n\n binary = binary_before_dot + binary_after_dot\n\n return binary\n else # if decimal input is not an integer or float\n raise ArgumentError, \"Not a number.\"\n end\n\nend", "def dec2bin(n)\n case n\n when 0 then '0000'\n when 1 then '0001'\n when 2 then '0010'\n when 3 then '0011'\n when 4 then '0100'\n when 5 then '0101'\n when 6 then '0110'\n when 7 then '0111'\n when 8 then '1000'\n when 9 then '1001'\n when 10 then '1010'\n when 11 then '1011'\n when 12 then '1100'\n when 13 then '1101'\n else nil\n end\n end", "def decimal_to_binary(decimal)\n if decimal == 0 || decimal == 1\n return [decimal]\n else\n return decimal_to_binary(decimal/2) + [decimal % 2]\n end\nend", "def binary(digits: 4)\n bin = ''\n digits.times { bin += rand(2).to_s(2) }\n bin\n end", "def base2to10(str_num)\n str = str_num.dup.reverse\n total = 0\n\n str.each_char.with_index do |char, idx|\n total += (char.to_i * (2 ** idx))\n end\n total\nend", "def from_bits(bin_num)\n base10_value = 0\n @bit_vals.each_with_index do |val,i|\n base10_value += val if bin_num[i] == '1'\n end\n base10_value\n end", "def to_s(base = 2)\n case base \n when 2\n inject(\"\") { |a, b| a + \"%0#{@bits}b \" % b }.strip\n when 10\n self.inject(\"\") { |a, b| a + \"%1d \" % b }.strip\n else\n raise(ArgumentError, \"unsupported base\")\n end\n end", "def toBase(n, base)\n return n.to_s(base) if base > 0\n return '0' if n.zero?\n\n digits = []\n while n != 0\n n, remainder = n.divmod(base)\n if remainder < 0\n n += 1\n remainder -= base\n end\n digits << remainder\n end\n digits.join.reverse\nend", "def to_binary_string(min_length = 0)\n BitMapping.number_to_binary_string(number, min_length)\n end", "def decToBin(inputNum, padLen = 4)\n binStr = \"\"\n tempNum = inputNum\n \n while tempNum > 0 do\n binStr.concat((tempNum % 2).to_s)\n tempNum = tempNum / 2 \n end\n \n return binStr.reverse.rjust(padLen, '0')\nend", "def reverse_bits(num, size)\n # To make the input number into binary of 16 or 32 bit format\n binary = \"%0#{size}d\" % num.to_s(2) #convert decimal to string of base 2 number\n puts binary\n puts binary.reverse!\n # puts binary.to_i(2) # convert string of base 2 number to decimal\nend", "def to_decimal\n return @bin.each_char.inject(0) { |sum, digit| sum * 2 + digit.to_i }\n end", "def n_to_binary number\n bin_array = []\n until number == 0\n if number % 2 == 0\n bin_array << 0\n else \n bin_array << 1\n end\n number = number / 2\n end\n bin_array.join\nend", "def convert_to_base_8(n)\r\n #n.method_name.method_name # replace these two method calls\r\n n.to_s(8).to_i\r\nend", "def to_i\n\t\tbits.map(&:to_s).join.to_i(2)\n\tend", "def kidmod10(base); end", "def stringy(num, bit = 1)\n bin_arr = []\n num.times { |n| n.even? ? bin_arr << (0 + bit) : bin_arr << (1 - bit) }\n bin_arr.join\nend", "def stringy number, count = 1\n binary_string = ''\n\n if count == 1\n (number / 2).times {binary_string << '10'}\n binary_string << '1' if number % 2 == 1\n elsif count == 0\n (number / 2).times {binary_string << '01'}\n binary_string << '0' if number % 2 == 1\n end\n\n binary_string\n end", "def to_s(base=2)\n n = Bits.power_of_two(base)\n if n\n digits = (size+n-1)/n\n #{ }\"%0#{digits}d\" % @v.to_s(base)\n Numerals::Format[:fix, base: base].set_leading_zeros(digits).write(@v)\n else\n @v.to_s(base)\n end\n end", "def to_bin(separator='')\n Array.new(factorbase.size){|i| (factors[factorbase[i]] || 0) % 2 }.join(separator)\n end", "def bcd_byte\n [self / 100, (self/10) % 10, self % 10].map{|n| n.chr}.join\n end", "def input_to_bitstring( value )\r\n value\r\n end", "def from_base(base=10)\n n = 0\n chars.reverse_each.with_index do |c, power|\n value = BASE_DIGITS[c]\n n += (base**power) * value\n end\n n\n end", "def binary(integer)\n\nend", "def binary(integer)\n\nend", "def convert_to_binary\n @input.class == String ? @input : @input.to_s(2)\n end", "def test_ber_integers\n assert_equal( \"\\002\\001\\005\", 5.to_ber )\n assert_equal( \"\\002\\002\\001\\364\", 500.to_ber )\n assert_equal( \"\\x02\\x02\\xC3P\", 50000.to_ber )\n assert_equal( \"\\002\\005\\001*\\005\\362\\000\", 5000000000.to_ber )\n end", "def number_to_binary_string(number, min_length = 0)\n assert_non_negative(number)\n binary_string = ''.force_encoding(Encoding::ASCII_8BIT)\n\n while number > 0\n byte_value = number & 0xFF\n binary_string << byte_value\n number >>= 8\n end\n\n binary_string.reverse.rjust(min_length, \"\\x00\")\n end", "def to_bcd(n)\n n.to_s.gsub(/\\d/) {|d| \"%04b \" % d}.strip\nend", "def convert( number, base )\n if(number < base)\n return @digits[number]\n else\n return convert( number / base, base ) + @digits[ number % base ]\n end\n end", "def convert_base(base, integer, target_base)\n x = 0\n result = ''\n\n start_pos = (integer[0] == '-') ? 1 : 0\n\n for i in start_pos..(integer.length - 1)\n x *= base\n x += (integer[i].ord - '0'.ord < 10) ? integer[i].ord - '0'.ord : integer[i].ord - 'A'.ord + 10\n end\n x\n\n\n while (x > 0)\n remainder = x % target_base\n result.prepend (remainder < 10) ? remainder.to_s : ((remainder - 10) + 'A'.ord).chr\n x /= target_base\n end\n\n\n if start_pos == 1\n result.prepend '-'\n end\n\n result\nend", "def base_two(num)\n result = ''\n\n until num.zero?\n rem = num % 2\n num /= 2\n result += rem.to_s\n end\n\n result.reverse\nend", "def bin2dec(bytestring)\n num = 0\n exp = 0\n i = (bytestring.length)-1\n while i >= 0\n num += (bytestring[i].to_i) * 2**exp\n exp += 1\n i -= 1\n end\n return num\n end", "def convert(digits, from_base:, to_base:)\n if from_base > MAX || to_base > MAX || from_base < MIN || to_base < MIN\n raise InvalidRadix,\n \"cannot convert #{digits} from base #{from_base} to base #{to_base}\"\n end\n\n if from_base < 37 && to_base < 37\n return digits.to_s.to_i(from_base).to_s(to_base)\n end\n\n represent(value_of(digits.to_s, in_base: from_base), in_base: to_base)\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 reverse_bits(n)\n bin = n.to_s(2)\n while bin.length < 32\n bin = \"0\" + bin\n end \n bin.reverse.to_i(2)\nend", "def binary(num)\n result = []\n\n until num == 0\n result.unshift(num % 2)\n num /= 2\n end\n\n result.empty? ? \"0\" : result.join\nend", "def hex_to_bin(hex)\nreturn hex.hex.to_s(2).rjust(hex.length * 4, '0')\nend", "def decimal_to_binary(decimal)\n binary_array = []\n num = decimal\n until num == 0\n binary_array.unshift(num % 2)\n num /= 2\n end\n return binary_array\nend", "def fake_bin(s)\ns = s.split(\"\")\ns = s.map {|x| x.to_i }\ns.collect! {|e| (e<5) ? 0 : e || (e>5) ? 1 : e}\ns.join\nend", "def is_binary_base?(num)\n binarify(num).count('1') == 1\nend", "def convert_binary\n end", "def decimal_to_binary(num)\n binary_array = []\n until num == 0\n # prepend will add the new value to the front, instead of the end\n binary_array.prepend(num % 2)\n num /= 2\n end\n return binary_array\nend", "def to_s\n \"%0#{size}b\" % number\n end", "def bin_chr(chr)\n if config.radix\n chr = '0' if chr == config.wildcard\n raise \"invalid character '#{chr}' for radix=#{config.radix}\" if chr.downcase != chr.to_i(config.radix).to_s(config.radix).downcase\n chr.to_i(config.radix)\n else\n if chr == config.wildcard\n 0\n else\n chr.ord\n end\n end.to_s(2).rjust(self.class.bit_density, '0')\n end", "def to_s\r\n @bitstring.reverse.scan(/.{1,8}/).map {|s| s.reverse}.reverse.map {|bin| \"\" << bin.to_i(2)}.join\r\n end", "def int_to_bin(gene)\n gene.to_s(2).split(\"\").map { |s| s.to_i }\nend", "def toBinary(n)\n\ttop = Math.log2(n).to_int\n\tlist = []\n\twhile top >= 0\n\t\tn >= 2 ** top ? (list << 1 and n -= 2 ** top) : (list << 0)\n\t\ttop -= 1\n\tend\n\tlist.join\nend", "def represent(number, in_base:)\n digits = \"\"\n\n while number > 0\n digits = CHARS[number % in_base] + digits\n number = number / in_base\n end\n\n digits\n end", "def bits_to_human_readable(num)\n ['bytes','KB','MB','GB','TB'].each do |x|\n if num < 1024.0\n return \"#{num.to_i} #{x}\"\n else\n num = num/1024.0\n end\n end\n end", "def bits_to_human_readable(num)\n ['bytes','KB','MB','GB','TB'].each do |x|\n if num < 1024.0\n return \"#{num.to_i} #{x}\"\n else\n num = num/1024.0\n end\n end\n end", "def add_binary(a,b)\n total = a+b\n total.to_s(2)\nend", "def stringy(num)\n binary = ''\n loop do\n binary << '1'\n break if binary.length == num\n binary << '0'\n break if binary.length == num\n end\n binary\nend", "def binary(digits: T.unsafe(nil)); end", "def bsb_number; end", "def decimal_to_binary(decimal)\n raise ArgumentError, \"This method only accepts positive decimal values\" if decimal < 0 || !decimal.is_a?(Integer)\n return [0] if decimal == 0\n \n binary = []\n while decimal > 0 \n remainder = decimal%2\n decimal /= 2\n binary << remainder\n end\n \n return binary.reverse! #or would need to implement the swap method to reverse in place\nend", "def real_to_binary(val)\n bdata = Binary.type_bytes(\"2\",3) # 2 is 0010, type indicator for reals\n buff = [val].pack(\"d\")\n return bdata + buff.reverse\n end", "def binary_to_int(n)\n bitset = Array.new()\n while (n > 0) do\n x = largest_power_of_2(n)\n if (x != nil)\n bitset[x] = 1\n n -= BASE ** x\n end\n end\n bitset.map! { |x| \n if (x == nil) \n x = 0\n else\n x = 1\n end\n }\n return bitset\nend", "def num_to_s(num, base)\n raise \"Please give a base greater than 1 and less than 16\" if base <= 1 || base > 16\n\n number_string_hash = {0 =>\"0\", 1 =>\"1\", 2 =>\"2\", 3 =>\"3\", 4 =>\"4\", 5 =>\"5\", 6 =>\"6\",\n 7 =>\"7\", 8 =>\"8\", 9 =>\"9\" }\n \n if base > 10\n num = num.to_i(base)\n base = 10\n end\n \n num_string = \"\"\n num_place = 0\n while num > 0\n current_digit = (num / base**num_place) % base\n num = num - (current_digit * (base**num_place))\n num_string.prepend(number_string_hash[current_digit])\n num_place += 1\n end\n num_string\nend", "def to_binary(input)\n binary = []\n input.each_char do |char|\n result = char.hex.to_s(2).rjust(char.size*4, '0')\n binary << result\n end\n binary.join()\nend", "def binary_array_to_number(arr)\n j = arr.join(\"\").to_i\n temp = j\n dec = 0\n basev = 1\n while temp != 0 do\n ld = temp % 10\n temp = (temp/10).to_i\n dec += (ld * basev)\n basev = basev * 2\n end\n\nputs dec \nend", "def to_byte_val(s)\n val = 0\n s.each_char do |x|\n val *= 2\n val += x.to_i\n end\n return val\nend", "def BinaryConverter(str)\n num = 0\n str.reverse.split(\"\").each_with_index do |value,index|\n num += value.to_i * 2 ** index\n end\n return num\nend", "def bitodec(bi)\n\tbistring = bi.to_s\n\tturnbi = bistring.chars.reverse.map{|i| i.to_i}\n\tfor index in (0...turnbi.length)\n\t\tturnbi[index] = turnbi[index]*(2**index)\n\tend\n\tdec = turnbi.sum\n\treturn dec\nend", "def dec_to_base7(decimal)\r\n result = []\r\n until decimal == 0\r\n result.push(decimal % 7)\r\n decimal = decimal / 7\r\n end\r\n return result.reverse.join.to_i\r\nend", "def stringy(number)\n number_range = (1..number)\n binary = []\n number_range.each do |num|\n if num % 2 == 1\n binary << 1\n elsif num % 2 == 0\n binary << 0\n end\n end\n binary.join(\"\")\nend" ]
[ "0.7847013", "0.78076136", "0.77956134", "0.7770734", "0.7726147", "0.76939833", "0.7551123", "0.7544491", "0.7465557", "0.7461508", "0.74529403", "0.7439611", "0.74303555", "0.74026513", "0.7361329", "0.73552823", "0.7344205", "0.73306334", "0.73306334", "0.73259825", "0.7257705", "0.7181135", "0.71652853", "0.71494615", "0.71290046", "0.71227944", "0.7102726", "0.69909567", "0.69751775", "0.69655627", "0.6959512", "0.69170433", "0.6915529", "0.6912446", "0.68709326", "0.6869933", "0.68584585", "0.68562436", "0.6831681", "0.6775935", "0.6766258", "0.67559946", "0.67532265", "0.6747022", "0.6726918", "0.67071354", "0.6702451", "0.66693974", "0.6664143", "0.66589963", "0.6658258", "0.6634046", "0.65639174", "0.6558197", "0.6522811", "0.6511457", "0.6501396", "0.6501396", "0.6495118", "0.64936936", "0.6485819", "0.6474915", "0.64705473", "0.6470105", "0.645938", "0.6455799", "0.6436369", "0.6420301", "0.6420301", "0.6398162", "0.63860214", "0.63835734", "0.6377725", "0.6375324", "0.63740396", "0.63732946", "0.63682276", "0.63596076", "0.6339445", "0.63374037", "0.63366574", "0.63323164", "0.63309157", "0.63290733", "0.6326807", "0.63171256", "0.62927485", "0.6283171", "0.62810606", "0.62798357", "0.62773025", "0.6269626", "0.6266665", "0.62638354", "0.62634534", "0.6249846", "0.6234161", "0.62237173", "0.6219227", "0.62153023" ]
0.720507
21
2.8 gcd of three ints, calling 2.3
def gcd3 (v,u,w) if (u==v) return gcd(v,w) elsif (u>v) u-=v gcd(gcd(v,u),w) else gcd(gcd(u,v),w) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gcd a,b\n if a<b\n gcd b,a\n elsif b==0\n a\n else\n gcd b,a%b\n end\nend", "def gcd(p0) end", "def gcd( a, b )\n return a if b.zero?\n gcd b, a % b\nend", "def gcd(a, b)\n if a % b == 0\n b\n else\n gcd(b, a % b)\n end\nend", "def gcd(a,b)\n if (b==0)\n a\n else\n gcd(b,a%b)\n end\nend", "def gcd(a, b)\r\n if b == 0\r\n return a\r\n else\r\n return gcd(b, a % b)\r\n end\r\nend", "def gcd(a,b)\n return b if a % b == 0\n return gcd(b, a % b)\nend", "def gcd(a, b)\n return a if b == 0\n\n remiander = a % b\n return gcd(b, remiander)\nend", "def gcd(a, b)\n return a if b == 0\n div = a % b\n gcd(b, div)\nend", "def gcd(a,b)\n\treturn a if b === 0\n\treturn gcd(b, a % b)\nend", "def gcd(a, b)\n if (b == 0) then a\n else gcd(b, a % b)\n end\nend", "def gcd(a, b)\n if a == b\n a\n elsif a < b\n gcd1(b, a)\n else\n gcd1(a, b)\n end\nend", "def gcd(a, b)\n if b == 0\n return a\n else\n return gcd(b, a%b)\n end\nend", "def gcd (v,u)\n if (u==v)\n return v\n elsif (u>v)\n u-=v\n gcd(v,u)\n else\n gcd(u,v)\n end\nend", "def gcd(a,b)\n return gcd(b, a) if a > b\n return b if a == 0\n gcd(b % a, a)\nend", "def gcd(x, y) # finds greatest common factor of x,y\n while y != 0\n t = y\n y = x % y\n x = t\n end\n x\nend", "def gcd(a, b)\n b == 0 ? a : gcd(b, a % b)\nend", "def gcd(a,b)\n # base case: everything divides zero\n if b == 0\n return a\n else\n remainder = a%b\n end\n return gcd(b, remainder)\nend", "def my_gcd(*args)\r\n\targs.inject do |memo, num|\r\n\t\tuntil [memo, num].include?(0)\r\n\t\t\tmod = memo % num\r\n\t\t\tmemo, num = num, mod\r\n\t\tend\r\n\t\t[memo, num].max\r\n\tend\r\nend", "def gcd(a, b)\n return b if a == 0\n return a if b == 0\n a, b = b, a if a < b\n a % b == 0 ? b : gcd(b, a % b)\nend", "def gcd( a, b )\r\n\t\t\treturn (b*(a%b))/lcm(b,a%b)\r\n\t\tend", "def gcd_euclides(a, b)\n while b != 0\n t = b\n b = a % b\n a = t\n end\n a\nend", "def gcd2 a,b\n if a<b\n d,s,r = gcd2 b,a\n [d,r,s]\n elsif b==0\n [a,1,0]\n else\n x=a/b\n y=a%b\n d,r,s = gcd2 b,y\n # here we know that d = r*b+s*y, and a=x*b+y, so y=a-x*b\n # thus d=r*b+s*(a-x*b) = (r-s*x)*b + s*a\n # so we return [d,s,r-s*x]\n # uncomment the following three lines to see this work out\n # puts \"#{a}=#{x}*#{b}+#{y}\"\n # puts \"#{d}=#{s}*#{a} + #{(r-s*x)}*#{b}\"\n [d,s,(r-s*x)]\n end\nend", "def gcd(*nums)\r\n\t\treturn nums.inject do |a, b|\r\n\t\t\ta, b = b, a % b until b.zero?\r\n\t\t\tnext a\r\n\t\tend\r\n\tend", "def gcd x, y\n r = x % y # r - remainder\n if r == 0\n y\n else\n gcd(y, r)\n end\nend", "def gcd(u,v)\n u, v = u.abs, v.abs\n while v > 0\n u, v = v, u % v\n end\n u\nend", "def gcd(a,b)\n while a != b\n if a > b\n return gcd(a - b,b)\n else\n return gcd(a , b - a)\n end\n end\n return a\nend", "def GCD(a, b)\n \n a, b = a.abs, b.abs\n\n # Always b => a\n if (a < b)\n a,b = b, a\n end\n while not (a == 0 or b == 0)\n a, b = b, a % b\n end\n\n if a == 0\n return b\n elsif b == 0\n return a\n end\n \nend", "def gcd(a, b)\n # always consider that a > b\n b.downto(1) do |num|\n if b % num == 0\n return num if a % num == 0\n end\n end\nend", "def gcd(a, b)\n # Everything divides 0\n return b if a == 0\n\n return a if b == 0\n\n # base case\n return a if a == b\n\n # a is greater\n return gcd(a - b, b) if a > b\n\n gcd(a, b - a)\nend", "def gcd(x, y)\n x == 0 ? y : gcd(y % x, x)\nend", "def gcd(n1, n2)\n if n1.abs < n2.abs\n n1, n2 = n2, n1\n end\n return n1 if n2 == 0\n gcd(n2, n1 % n2)\nend", "def gcdI(i, j)\n while i != j\n if i > j\n i = i - j\n else\n j = j - i\n end\n end\n return i\nend", "def gcd(x, y)\n if (y == 0)\n return x\n else\n gcd(y, x%y)\n end\nend", "def gcd_of_last_digits(int_one, int_two)\r\n # your code goes here\r\n last_digit(int_one).gcd(last_digit(int_two))\r\nend", "def gcdR(i, j)\n if j != 0\n return gcdR(j, i%j)\n else\n return i\n end\nend", "def gcd (a, b) # O(log b)\n if b != 0\n self.gcd(b, a % b)\n else\n return a\n end\n end", "def euclidean_gcd(up, down)\n return up if down.zero?\n euclidean_gcd(down, up % down)\nend", "def egcd(a, b)\n # let A, B = a, b \n s, t, u, v = 1, 0, 0, 1\n while 0 < b\n # loop invariant: a = sA + tB and b = uA + vB and gcd(a,b) = gcd(A,B)\n q = a/b\n a, b, s, t, u, v = b, (a%b), u, v, (s-u*q), (t-v*q) \n end \nreturn [a, s, t] \nend", "def gcdI(i, j)\n\twhile i != j\n\t\tif i > j\n\t\t\ti = i - j\n\t\telse\n\t\t\tj = j - i\n\t\tend\n\tend\n\treturn i\nend", "def greatest_common_factor(number1, number2)\n # get the smaller number\n n = number1 < number2 ? number1 : number2\n\n # check each number i\n # starting from this number n down to 1\n # if it divides both number1 and number2 evenly\n # if so, then this is the gcd\n n.downto(1).each do |i|\n if number1 % i == 0 and number2 % i == 0\n return i\n end\n end\n 1\nend", "def find_gcd(nums)\n nums.max.gcd(nums.min)\nend", "def gcd(num1, num2)\n\n loop do\n remainder = num1 % num2\n break if remainder == 0\n num1 = num2\n num2 = remainder\n end\n\n num2\nend", "def gcd(n, m)\n n % m == 0 ? m : gcd(m, n % m)\nend", "def gcd(num1, num2)\n if num2 > num1\n num1, num2 = num2, num1\n end\n r = nil\n r1 = num1\n r2 = num2\n until r == 0\n r = r1 % r2\n r1 = r2\n r2 = r\n end\n r1\n end", "def gcd(x, y)\n until y.zero?\n # puts \"#{x} #{y}\"\n x, y = y, mod(x, y)\n end\n x\n end", "def gcd_of_last_digits(int_one, int_two)\n # your code goes here\n puts (int_one.digits.first).gcd(int_two.digits.first)\nend", "def find_gcd(nums)\n nums.minmax.reduce(:gcd)\nend", "def gcd_of_last_digits(int_one, int_two)\n # your code goes here\n int_one.gcd(int_two)\n if int_one % 10 < int_two % 10\n return int_one % 10\n else\n return int_two % 10\n end\nend", "def extended_lehmer_gcd(a, b)\r\n\t\td0 = a\r\n\t\tu0 = 1\t# d0 = a * u0 + b * v0\r\n\t\td1 = b\r\n\t\tu1 = 0\t# d1 = a * u1 + b * v1\r\n\r\n\t\tloop do\r\n\t\t\tif d1.instance_of?(Fixnum)\r\n\t\t\t\t_u, _v, d = extended_gcd(d0, d1)\r\n\r\n\t\t\t\t# here\r\n\t\t\t\t# d == _u * d0 + _v * d1\r\n\t\t\t\t# d0 == u0 * a + v0 * b\r\n\t\t\t\t# d1 == u1 * a + v1 * b\r\n\r\n\t\t\t\tu = _u * u0 + _v * u1\r\n\t\t\t\tv = (d - u * a) / b\r\n\r\n\t\t\t\treturn u, v, d\r\n\t\t\tend\r\n\r\n\t\t\t# Get most significant digits of d0 and d1\r\n\t\t\tshift_size = (d0 < d1 ? d1 : d0).bit_size - FIXNUM_BIT_SIZE\r\n\t\t\ta_ = d0 >> shift_size\r\n\t\t\tb_ = d1 >> shift_size\r\n\r\n\t\t\t# Initialize (Here a_ and b_ are next value of d0, d1)\r\n\t\t\t_A = 1\r\n\t\t\t_B = 0\t# a_ == msd(d0) * _A + msd(d1) * _B\r\n\t\t\t_C = 0\r\n\t\t\t_D = 1\t# b_ == msd(d0) * _C + msd(d1) * _D\r\n\r\n\t\t\t# Test Quotient\r\n\t\t\tuntil 0 == b_ + _C or 0 == b_ + _D\r\n\t\t\t\tq1 = (a_ + _B) / (b_ + _D)\r\n\t\t\t\tq2 = (a_ + _A) / (b_ + _C)\r\n\t\t\t\tbreak if q1 != q2\r\n\r\n\t\t\t\t# Euclidean step\r\n\t\t\t\t_A, _C = _C, _A - q1 * _C\r\n\t\t\t\t_B, _D = _D, _B - q1 * _D\r\n\t\t\t\ta_, b_ = b_, a_ - q1 * b_\r\n\t\t\tend\r\n\r\n\t\t\t# Multi-precision step\r\n\t\t\tif 0 == _B\r\n\t\t\t\tq, r = d0.divmod(d1)\r\n\t\t\t\td0, d1 = d1, r\r\n\t\t\t\tu0, u1 = u1, u0 - q * u1\r\n\t\t\telse\r\n\t\t\t\td0, d1 = d0 * _A + d1 * _B, d0 * _C + d1 * _D\r\n\t\t\t\tu0, u1 =u0 * _A + u1 * _B, u0 * _C + u1 * _D\r\n\t\t\tend\r\n\t\tend\r\n\tend", "def generalizedGCD(num, arr)\n result = arr.first\n\n arr.each do |num|\n result = result.gcd(num)\n end\n\n result\nend", "def gcd_ex(x, y)\n s1 = t0 = 0\n s0 = t1 = 1\n until y.zero?\n x, (q, y) = y, divmod(x, y)\n s0, s1 = s1, s0 - q*s1\n t0, t1 = t1, t0 - q*t1\n # puts \"x=#{x} y=#{y} s0=#{s0} s1=#{s1} t0=#{t0} t1=#{t1} q=#{q}\"\n end\n return x, s0, t0, t1, s1\n end", "def lehmer_gcd(a, b)\r\n\t\ta = -a if a < 0\r\n\t\tb = -b if b < 0\r\n\t\ta, b = b, a if a < b\r\n\r\n\t\tuntil 0 == b\r\n\t\t\treturn Abst.gcd(a, b) if b.instance_of?(Fixnum)\r\n\r\n\t\t\t# Get most significant digits of a and b\r\n\t\t\tshift_size = (a < b ? b : a).bit_size - FIXNUM_BIT_SIZE\r\n\t\t\ta_ = a >> shift_size\r\n\t\t\tb_ = b >> shift_size\r\n\r\n\t\t\t_A = 1\r\n\t\t\t_B = 0\t# a_ == msd(a) * _A + msd(b) * _B\r\n\t\t\t_C = 0\r\n\t\t\t_D = 1\t# b_ == msd(a) * _C + msd(b) * _D\r\n\r\n\t\t\t# Always\r\n\t\t\t# a_ + _B <= msd(a * _A + b * _B) < a_ + _A AND\r\n\t\t\t# b_ + _C <= msd(a * _C + b * _D) < a_ + _D\r\n\t\t\t# OR\r\n\t\t\t# a_ + _B > msd(a * _A + b * _B) >= a_ + _A AND\r\n\t\t\t# b_ + _C > msd(a * _C + b * _D) >= a_ + _D\r\n\r\n\t\t\t# Test quotient\r\n\t\t\tuntil 0 == b_ + _C or 0 == b_ + _D\r\n\t\t\t\tq1 = (a_ + _A) / (b_ + _C)\r\n\t\t\t\tq2 = (a_ + _B) / (b_ + _D)\r\n\t\t\t\tbreak if q1 != q2\r\n\r\n\t\t\t\t# Euclidean step\r\n\t\t\t\t_A, _C = _C, _A - q1 * _C\r\n\t\t\t\t_B, _D = _D, _B - q1 * _D\r\n\t\t\t\ta_, b_ = b_, a_ - q1 * b_\r\n\t\t\tend\r\n\r\n\t\t\t# Multi-precision step\r\n\t\t\tif 0 == _B\r\n\t\t\t\ta, b = b, a % b\r\n\t\t\telse\r\n\t\t\t\ta, b = a * _A + b * _B, a * _C + b * _D\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\treturn a\r\n\tend", "def solution(n, m)\n n / gcd(n, m)\nend", "def least_common_multiple(num_1, num_2)\n num_1, num_2 = num_2, num_1 if num_1 > num_2\n num_1 * num_2 / getGCD(num_1, num_2)\nend", "def gcd(num1,num2)\n\tif num1 < num2\n\t\ttemp = num1\n\t\tnum1 = num2\n\t\tnum2 = temp\n\tend\n\n\tif num1 % num2 == 0\n\t\treturn num2\n\tend\n\n\tremainder = num1 % num2 \n\tgcd(num2, remainder)\nend", "def euclid(a, b)\n\treturn a if b == 0\n\teuclid(b, a % b)\nend", "def gcf(num1, num2)\n\tx = num1 < num2 ? num1 : num2\n\twhile x > 1 do\n\t\tif num1 % x == 0 && num2 % x == 0\n\t\t\treturn x\n\t\tend\n\t\tx -= 1\n\tend\n\treturn 1\nend", "def common a\n a.reduce :gcd\nend", "def main()\n puts \"Please enter a single integer: \"\n num1 = gets.to_i\n puts \"Please enter a second integer: \"\n num2 = gets.to_i\n \n res1 = gcdI(num1, num2)\n puts \"This is the interative gcd function: \" + res1.to_s\n \n res2 = gcdR(num1, num2)\n puts \"This is the recursive gcd function: \" + res2.to_s\nend", "def extended_gcd(a, b)\r\n\t\tu0 = a.class.one\r\n\t\tu1 = a.class.zero\r\n\r\n\t\treturn u0, u1, a if b.zero?\r\n\r\n\t\td0 = a\t# d0 = a * u0 + b * v0\r\n\t\td1 = b\t# d1 = a * u1 + b * v1\r\n\r\n\t\tloop do\r\n\t\t\tq, r = d0.divmod(d1)\r\n\r\n\t\t\treturn u1, (d1 - a * u1) / b, d1 if r.zero?\r\n\r\n\t\t\td0, d1 = d1, r\r\n\t\t\tu0, u1 = u1, u0 - q * u1\r\n\t\tend\r\n\tend", "def gcd2test a,b\n d,r,s = gcd2 a,b\n z = r*a+s*b\n return z==d\nend", "def factor_gcd(n, g)\n m = 0\n while((m = gcd(n, g)) != 1) do\n n /= m\n end\n n\nend", "def coprime(a, b)\n gcd(a, b) == 1\nend", "def greatest_common_factor(first_number, second_number)\nend", "def extended_gcd(a, b)\n\n # trivial case first: gcd(a, 0) == 1*a + 0*0 \n return 1, 0 if b == 0\n\n # recurse: a = q*b + r\n q, r = a.divmod b\n s, t = extended_gcd(b, r)\n\n # compute and return coefficients:\n # gcd(a, b) == gcd(b, r) == s*b + t*r == s*b + t*(a - q*b)\n return t, s - q * t\nend", "def greatest_common_factor(first_number, second_number)\n \nend", "def greatest_common_factor(first_number, second_number)\n \nend", "def coprime?(a, b)\n 1 == gcd(a, b)\nend", "def extended_gcd(a, b)\n return [0,1] if a % b == 0\n x,y = extended_gcd(b, a % b)\n [y, x-y*(a / b)]\nend", "def greatest_common_factor(number1, number2)\n new = number1.to_i\n number2 = number2.to_i\n while number1 > 0\n if (number1 % new == 0.0) && (number2 % new == 0.0)\n return new\n end\n new -= 1.0\n end\nend", "def greatest_common_factor(first_number, second_number)\n x, y = first_number, second_number\n n = x < y ? x : y\n n.downto(1).each do |i|\n if x % i == 0 and y % i == 0\n return i\n end\n end\n 1\nend", "def greatest_common_factor(num1, num2)\n divisor = 1\n 2.upto([num1.abs, num2.abs].min) do |num|\n if num1 % num == 0 && num2 % num == 0\n divisor = num\n end\n end\n divisor\nend", "def GCD_verbose(a, b)\n \n a, b = a.abs, b.abs\n\n # Always b => a\n if (a < b)\n a,b = b, a\n end\n puts \"(A,B) = \" + a.to_s() + \", \" + b.to_s()\n count = 1\n while not (a == 0 or b == 0)\n puts \"*\" * 10\n print \"Step #{count}:\\n\"\n tmp = a \n a, b, division = b, a % b, a / b\n print \"#{tmp} = #{a} * #{division} + #{b}\\n\"\n print \"(A,B) = #{a}, #{b}\\n\"\n puts \"*\" * 10\n count += 1\n end\n\n if a == 0\n return b\n elsif b == 0\n return a\n end\n return a, b\nend", "def getGCD(a, b)\n\tif b.zero?\n\t\treturn a\n\telse\n\t\treturn getGCD(b, a%b)\n\tend\nend", "def euclidean(a, b, ctrl)\n rem = a % b\n if !rem.zero? && rem != 1\n euclidean(b, rem, rem)\n elsif rem.zero? && !(b == 1)\n b\n else\n 'Numbers are coprime'\n end\nend", "def extended_binary_gcd(a, b)\r\n\t\tif a < b\r\n\t\t\ta, b = b, a\r\n\t\t\texchange_flag_1 = true\r\n\t\tend\r\n\r\n\t\tif 0 == b\r\n\t\t\treturn 0, 1, a if exchange_flag_1\r\n\t\t\treturn 1, 0, a\r\n\t\tend\r\n\r\n\t\t# Reduce size once\r\n\t\t_Q, r = a.divmod(b)\r\n\t\tif 0 == r\r\n\t\t\treturn 1, 0, b if exchange_flag_1\r\n\t\t\treturn 0, 1, b\r\n\t\tend\r\n\t\ta, b = b, r\r\n\r\n\t\t# Compute power of 2\r\n\t\t_K = 0\r\n\t\t_K += 1 while 0 == a[_K] and 0 == b[_K]\r\n\t\tif 0 < _K\r\n\t\t\ta >>= _K\r\n\t\t\tb >>= _K\r\n\t\tend\r\n\r\n\t\tif b.even?\r\n\t\t\ta, b = b, a\r\n\t\t\texchange_flag_2 = true\r\n\t\tend\r\n\r\n\t\t# Initialize\r\n\t\tu = 1\r\n\t\td = a\t# d == a * u + b * v, (v = 0)\r\n\t\tu_ = 0\r\n\t\td_ = b\t# d_ == a * u_ + b * v_, (v_ = 1)\r\n\r\n\t\t# Remove intial power of 2\r\n\t\twhile d.even?\r\n\t\t\td >>= 1\r\n\t\t\tu += b if u.odd?\r\n\t\t\tu >>= 1\r\n\t\tend\r\n\r\n\t\tloop do\r\n\t\t\t# Substract\r\n\t\t\tnext_u = u - u_\r\n\t\t\tnext_d = d - d_\t\t# next_d == a * next_u + b * next_v\r\n\t\t\tnext_u += b if next_u < 0\r\n\r\n\t\t\tbreak if 0 == next_d\r\n\r\n\t\t\t# Remove powers of 2\r\n\t\t\twhile next_d.even?\r\n\t\t\t\tnext_d >>= 1\r\n\t\t\t\tnext_u += b if next_u.odd?\r\n\t\t\t\tnext_u >>= 1\r\n\t\t\tend\r\n\r\n\t\t\tif 0 < next_d\r\n\t\t\t\tu = next_u\r\n\t\t\t\td = next_d\r\n\t\t\telse\r\n\t\t\t\tu_ = b - next_u\r\n\t\t\t\td_ = -next_d\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\tv = (d - a * u) / b\r\n\r\n\t\tu, v = v, u if exchange_flag_2\r\n\t\td <<= _K\r\n\t\tu, v = v, u - v * _Q\r\n\t\tu, v = v, u if exchange_flag_1\r\n\r\n\t\treturn u, v, d\r\n\tend", "def greatest_common_factor(a, b)\n a, b = b, a%b until b == 0\n a\nend", "def extended_gcd(a, b)\n last_remainder, remainder = a.abs, b.abs\n x, last_x, y, last_y = 0, 1, 1, 0\n while remainder != 0\n last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)\n x, last_x = last_x - quotient*x, x\n y, last_y = last_y - quotient*y, y\n end\n\n return last_remainder, last_x * (a < 0 ? -1 : 1)\nend", "def extended_gcd(a, b)\n last_remainder, remainder = a.abs, b.abs\n x, last_x, y, last_y = 0, 1, 1, 0\n while remainder != 0\n last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)\n x, last_x = last_x - quotient*x, x\n y, last_y = last_y - quotient*y, y\n end\n\n return last_remainder, last_x * (a < 0 ? -1 : 1)\nend", "def extended_gcd(a, b)\n last_remainder, remainder = a.abs, b.abs\n x, last_x, y, last_y = 0, 1, 1, 0\n while remainder != 0\n last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)\n x, last_x = last_x - quotient*x, x\n y, last_y = last_y - quotient*y, y\n end\n\n return last_remainder, last_x * (a < 0 ? -1 : 1)\nend", "def xgcd_rec(x, y)\n if y == 0\n [x, 1, 0]\n else\n gcd, a, b = xgcd_rec(y, x%y)\n [gcd, b, a-x/y*b]\n end\nend", "def inv_gcd(a, b)\n a %= b\n return [b, 0] if a == 0\n\n s, t = b, a\n m0, m1 = 0, 1\n while t>0 do\n u, s = s.divmod(t)\n m0 -= m1*u\n s, t = t, s\n m0, m1 = m1, m0\n end\n m0 += b/s if m0 < 0\n return [s, m0]\nend", "def extended_gcd(a, b)\n last_remainder = a.abs\n remainder = b.abs\n x = 0\n last_x = 1\n y = 1\n last_y = 0\n\n while remainder != 0\n last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)\n x, last_x = last_x - quotient * x, x\n y, last_y = last_y - quotient * y, y\n end\n\n [last_remainder, last_x * (a.negative? ? -1 : 1)]\nend", "def extended_gcd(a, b)\n last_remainder, remainder = a.abs, b.abs\n x, last_x, y, last_y = 0, 1, 1, 0\n while remainder != 0\n last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)\n x, last_x = last_x - quotient * x, x\n y, last_y = last_y - quotient * y, y\n end\n return last_remainder, last_x * (a.negative? ? -1 : 1)\nend", "def recursive_gcd(numerator, denominator)\n if d != 0\n return n\n else\n return recursive_gcd(denominator, numerator % denominator)\n end\nend", "def coprime(a,b)\n a.gcd(b) == 1\nend", "def recursive_gcd_proper_fractions(n)\n return 0 if n == 1\n proper_fractions_found = 0\n\n (1..n-1).each do |i|\n if recursive_gcd(i, n) == 1\n proper_fractions_found += 1\n else\n next\n end\n end\n\n proper_fractions_found\nend", "def xgcd_iter(x, y)\n a, next_a = 1, 0\n b, next_b = 0, 1\n while y != 0\n a, next_a = next_a, a-x/y*next_a\n b, next_b = next_b, b-x/y*next_b\n x, y = y, x%y\n end\n [x, a, b]\nend", "def lcm(u,v)\n (u*v).abs/gcd(u,v)\nend", "def greatest_common_factor(number1, number2)\n\n if number1 < number2\n smallest = number1\n largest = number2\n elsif number2 < number1\n smallest = number2\n largest = number1\n else \n puts 'Numbers must de different.'\n end \n\n factor = smallest\n\n while factor > 0\n if largest % factor == 0 && smallest % factor == 0\n puts factor # debug\n return factor\n else\n factor -= 1\n end\n \n end\nend", "def reducir(n, d)\n aux = gcd(n, d)\n n = n / aux\n d = d / aux\n return n, d\n end", "def coprime?( a, b )\n gcd( a, b ) == 1\nend", "def solve(a, b, c)\n v = b ** 2 - 4 * a * c\n if v < 0: raise RangeError end\n s0 = ((-1)*b - Math.sqrt(v))/(2*a)\n s1 = ((-1)*b + Math.sqrt(v))/(2*a)\n return s0, s1\nend", "def LCM(a, b)\n tmp = a.gcd(b)\n return a*b/tmp\nend", "def extended_gcd(a, b)\n last_remainder, remainder = a.abs, b.abs\n x, last_x, y, last_y = 0, 1, 1, 0\n while remainder != 0\n last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)\n x, last_x = last_x - quotient*x, x\n y, last_y = last_y - quotient*y, y\n end\n\n return last_remainder, last_x * (a < 0 ? -1 : 1)\n end", "def smallest_common_multiple(n)\n\n\treturn 0\nend", "def greatest_common_div(a, b)\n return b == 0 ? a : greatest_common_div(b, (a % b))\nend", "def least_common_multiple(num_1, num_2)\n (num_1 * num_2) / greatest_common_denominator(num_1, num_2)\nend", "def greatest_common_divisor(x, y)\n smallest_num = [x, y].min\n smallest_num.downto(1) do |num|\n return num if x % num == 0 && y % num == 0\n end\nend" ]
[ "0.79757494", "0.79428476", "0.7741769", "0.7717525", "0.76527774", "0.76481843", "0.7642725", "0.76075107", "0.7520714", "0.751437", "0.75133854", "0.7512915", "0.74954647", "0.74920386", "0.74825287", "0.7471882", "0.7425406", "0.7421961", "0.7419071", "0.7407413", "0.7402197", "0.7399682", "0.73950404", "0.73893726", "0.7376665", "0.737138", "0.7359541", "0.73543847", "0.7326941", "0.73215246", "0.731599", "0.72992283", "0.7295681", "0.7274095", "0.72653264", "0.7252482", "0.72061", "0.716766", "0.71442705", "0.7121918", "0.71184427", "0.7115038", "0.71110284", "0.7109449", "0.7107664", "0.7107366", "0.7107272", "0.70894676", "0.70714843", "0.7058281", "0.70466954", "0.70104015", "0.7010131", "0.7003541", "0.7000663", "0.6956171", "0.6953325", "0.69364196", "0.6913285", "0.68931574", "0.6870414", "0.68609214", "0.6852788", "0.681096", "0.6780666", "0.67682487", "0.6717232", "0.6717232", "0.6699279", "0.6659221", "0.6647369", "0.66461945", "0.6636951", "0.662918", "0.6578066", "0.6578038", "0.6577913", "0.6560544", "0.6535969", "0.6535969", "0.6535969", "0.6524055", "0.6523212", "0.6522496", "0.6514477", "0.6492433", "0.6482907", "0.6463565", "0.6460734", "0.6451663", "0.6443523", "0.64245", "0.6414238", "0.64087975", "0.63911355", "0.6381117", "0.6348214", "0.6335181", "0.6291715", "0.62620777" ]
0.7881803
2
sieve of eratosthenes page 16 for each i, a[i] true if prime for each i, setting array element corresponding to each multiple of i to false then loop through again, printing them out
def primes arr=Array.new arr[1]=false (2..1000).each {|i| arr[i]=true} (2..1000).each {|i| (i/2).floor (2..1000).each {|j| (j/i).floor arr[i*j] = false }} for i in 1..1000 if arr[i] == true puts i end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def primeArray(number)\n @sieve = Array.new(number)\n \n for count in 2..Math.sqrt(number)\n next if @sieve[count]\n \n for inner_count in 2..number/count\n @sieve[count * inner_count] = true\n end\n end\n @sieve\nend", "def sieve_of_eratosthenes(max)\n list = Array.new(max + 1, true)\n list[0] = false\n list[1] = false\n list.each_with_index do |bool, index|\n if bool\n i = 0\n while (index ** 2 + (index * i)) <= max\n list[index** 2 + (index * i)] = false\n i += 1\n end\n end\n end\n list\nend", "def eratosthenes(n)\r\n array = Array.new((n), true);\r\n index = 2\r\n primes_sum = 0\r\n\r\n until index >= n\r\n j = 0\r\n if array[index]\r\n ((index*2)..(n)).step(index+j) do |j|\r\n array[j] = false;\r\n end\r\n primes_sum += index\r\n end\r\n index += 1\r\n end\r\n primes_sum\r\nend", "def eratosthenes(n)\n a = Array.new(n)\n a.each_index do |i|\n a[i] = {i: i, prime: true}\n end\n (2..Math.sqrt(n)).each do |i|\n if a[i][:prime] == true\n j = i * i\n while j < n\n a[j][:prime] = false\n j += i\n end\n end\n end\n a.select {|h| h[:prime] == true}\nend", "def sieveOfErathosthenes(limit)\n\ta = Array.new(limit, true) \n\tsqLimit = limit ** 0.5\n\t2.upto(sqLimit) do |x|\n\t\tif(a[x]) then\n\t\t\tj = x ** 2\n\t\t\twhile(j < limit)\n\t\t\t\ta[j] = false\n\t\t\t\tj += x\n\t\t\tend\n\t\tend\n\tend\n\ta[0], a[1] = false, false\n\ta\nend", "def primes()\n return [] if @number < 2\n # build Boolean array to use for sieve with buffer to align indices\n sieve_array = Array.new(2, false) + Array.new(@number-1, true)\n # perform Sieve of Eratosthenes eliminations\n (2..Math.sqrt(@number).to_i).each do |i|\n (i**2..@number).step(i) {|j| sieve_array[j] = false} if sieve_array[i] == true\n end\n # return numbers by corresponding index that are still true\n (2..@number).collect {|index| index if sieve_array[index] == true}.compact\n end", "def prime_sieve(limit)\n \n limitn = limit+1\n primes = []\n \n # Fill in prime truth table\n for i in 0..limitn do\n primes[i] = true\n end\n \n primes[0] = false\n primes[1] = false\n \n primes.each_with_index{|prime,i|\n unless i < 2\n range = Range.new(i*i,limitn)\n range.step(i) {|index| primes[index] = false}\n end\n }\n \n true_primes = []\n primes.each_with_index{|value,i|\n true_primes << i if value == true\n }\n \n return true_primes\n \nend", "def prime_numbers(range)\n ar = range.to_a\n ar2 = [nil, nil] + [true] * ar.size\n\n i = 2\n while i <= Math.sqrt(ar.max).to_i\n if ar2[i]\n z = i * i\n while z <= ar.max\n ar2[z] = false\n z += i\n end\n end\n i += 1\n end\n ar.delete_if { |e| ar2[e] == nil || ar2[e] == false }\nend", "def sieve(n) # quickly makes array of all primes from 2 to n\n s = 3.step(n, 2).to_a # make array of odd integers from 3 to n. Skip evens. \n s.each do |p|\n next if p.nil? # go to next element if p has been marked empty\n break if p * p > n # p only needs to go up to sqrt(n)\n\n k, pval = 0, 0\n\n while pval < n\n pval = p * (p + k) # jump forward 2p at a time: p*p, p*p + 2p, p*p + 4p, etc.\n\n # Set all those multiples to nil. i = (pval - 3)/2 translates pvals to index i\n\n s[(pval - 3) / 2] = nil \n k += 2 \n end\n\n end\n s.compact! # removes all nil elements from array\n s.unshift(2).sort # adds 2 as 1st element\nend", "def prime_num_gen( array_size )\n\n # array_size == array.length\n\n array = []\n\n divisors = []\n\n i = 0\n while( array_size != array.length )\n\n # p i\n\n if( i >= 2 ) # 0 and 1 are not prime\n\n if( i == 2 ) # two is a prime\n # p \" 2 is pushed\"\n array.push(i)\n end\n\n if( i % 2 != 0 ) # prime numbers cannot be even\n\n # p \" i #{i}\"\n # p \" divisors #{divisors}\"\n\n # START extra check - if i has more than 2 divisors\n #\n # IMPROVEMENT!!!!\n #\n # Could have simply called is_prime?( i ) --> returns true if prime\n # if is_prime? ? array.push(i) : p \"do nothing\"\n #\n j = 1\n while( i >= j )\n\n #p \" j #{j}\"\n\n if( i % j == 0)\n\n divisors.push(j)\n # p \" divisors #{divisors}\"\n end #if\n\n j += 1\n end # while\n\n if( divisors.length == 2 ) # prime should have 1 and itself as divisors\n array.push(i)\n # p \"#{i} is pushed\"\n end\n\n divisors.clear\n # p divisors\n\n # END of extra check\n #\n # extra check - if i has more than 2 divisors\n\n end # if (prime numbers cannot be even)\n\n end # if outter most\n\n i += 1\n end # while\n\n p array\n return array\n\nend", "def primes(num)\n\twhole_array = (2..num).to_a\n\tprime_array = [whole_array.shift]\n\n\tuntil whole_array == []\n\t\twhole_array.delete_if { |x| x % prime_array.last == 0 }\n\t\tprime_array << whole_array.shift\n\tend\n\tprime_array\nend", "def prime_number(n)\n res = []\n prime = Array.new(n + 1, true)\n (2..n).each do |x|\n num = x * x\n break if num > n\n\n if prime[x]\n (num..n).step(x).each do |multiples|\n prime[multiples] = false\n end\n end\n end\n \n (2..n).each do |primes|\n res << primes if prime[primes]\n end\n res\nend", "def simpleSieve(limit)\n\n i = 2\n\tmark = initArray(limit);\n\tuntil i*i >= limit do\n\n\t\tif mark[i] == false\n\t\t\t# If not marked yet, then its a prime\n\t\t\t$prime.push(i);\n\n\t\t\tj = i;\n\t\t\tuntil j >= limit do\n\n\t\t\t mark[j] = true\n\t\t\t j += i\n\n\t\t\tend\n\t\tend\n\t\ti=1+i\n\n\tend\n\nend", "def sieve(n)\n\tprimes = []\n\ta = Array.new(n, true)\n\t2.step(Math.sqrt(n).to_i) do |i|\n\t\tif a[i]\n\t\t\tprimes.push(i)\n\t\t\t\n\t\t\ti.step(n-1, i) do |k|\n\t\t\t\ta[k] = false\n\t\t\tend\n\t\tend\n\tend\n\n\tMath.sqrt(n).to_i.step(n-1) do |i|\n\t\tif a[i]\n\t\t\tprimes.push(i)\n\t\tend\n\tend\n\n\treturn primes\nend", "def sieve(n)\n table = [false, false] + [true]* (n-1) \n # [0(not prime), 1(not prime), 2 (not sure yet)..]\n for i in (1..n)\n if table[i]\n upto = n/i\n for j in (i..upto)\n table[i*j] = false\n end\n end\n end # I don't like all the end-s written down like this.\n\n # now making a list of primes out of those trues and falses. \n list_of_primes = []\n for i in (1..n)\n if table[i]\n list_of_primes.push(i)\n end\n end \n\n return list_of_primes\nend", "def primes(n)\n result = []\n i = 2\n while i <= n\n j=2\n prime = true\n while j<=i**0.5\n (prime = false) if i%j==0\n j += 1\n end\n (result << i) if prime\n i +=1\n end\n return result\nend", "def sieve2(n)\n\tprimes = []\n\ta = Array.new(n, true)\n\t2.step(n-1) do |i|\n\t\tif a[i]\n\t\t\tprimes.push(i)\n\t\t\t\n\t\t\ti.step(n-1, i) do |k|\n\t\t\t\ta[k] = false\n\t\t\tend\n\t\tend\n\tend\n\n\treturn primes\nend", "def eratosthenes_sieve(max_number)\n numbers = (0..max_number+1).to_a\n bound = Math.sqrt(max_number).to_i\n\n (2..bound+1).each do |current|\n if numbers[current]\n (current+current..max_number+1).step(current).each do |j| numbers[j] = nil end\n end\n end\n\n return numbers.compact![2..-1]\nend", "def sieve_of_eratosthenes(max)\nsieve = []\nfor i in 2 .. max\n sieve[i] = i\nend\n\nfor i in 2 .. Math.sqrt(max)\n next unless sieve[i]\n (i*i).step(max, i) do |j|\n sieve.delete(sieve[j])\n end\nend\n\nend", "def primes_up_to(num)\n\n\tcross_limit = Math.sqrt(num).floor\n\n\t# create a new array with num number of elements, each set as true\n\tprime_bools = Array.new(num, true)\n\n\tprime_bools.each_with_index do |is_prime, i|\n\t\t# we can stop once our steps are at the square root of the limit\n\t\tbreak if i >= cross_limit\n\n\t\t# skip first step (0+0+1 steps over everything) and\n\t\t# non-prime steps, as they're redundant\n\t\tnext if i == 0 || !is_prime\n\n\t\t# set each bool we step over to false, starting at i+i+1, which\n\t\t# ensures we keep the first primes true \n\t\t(i+i+1 .. num).step(i+1) { |i| prime_bools[i] = false }\n\t\t# puts \"removed #{i+1}s #{prime_bools.each_index.select { |i| prime_bools[i] }.map { |j| j+1 }.drop(1)}\"\n\tend\n\n\t# select all the remaining trues from prime_bools\n\tprime_bools = prime_bools.each_index.select { |i| prime_bools[i] }\n\n\t# map the prime_bools to their index/number and drop the 1 (not a prime)\n\tprimes = prime_bools.map { |i| i+1 }.drop(1)\n\nend", "def sieve1(n)\n\tprimes = []\n\ta = Array.new(n, true)\n\t2.step(Math.sqrt(n).to_i) do |i|\n\t\tif a[i]\n\t\t\tprimes.push(i)\n\t\t\t\n\t\t\ti.step(n-1, i) do |k|\n\t\t\t\ta[k] = false\n\t\t\tend\n\t\tend\n\tend\n\n\tMath.sqrt(n).to_i.step(n-1) do |i|\n\t\tif a[i]\n\t\t\tprimes.push(i)\n\t\tend\n\tend\n\n\treturn primes\nend", "def sieve_of_erastothenes2(n)\n primes = (2..n).to_a\n\n (2..n).each do |number|\n if primes[number]\n multiples(number, n).each do |multiple|\n primes.delete(multiple)\n end\n end\n end\n\n primes\nend", "def sieve_of_erastothenes3(n)\n primes = (0..n).to_a\n\n (2..n).each do |number|\n if primes[number]\n multiples(number, n).each do |multiple|\n primes[multiple] = nil\n end\n end\n end\n\n primes.compact.select { |num| num > 1 }\nend", "def sieve_of_e(n)\n a = (0...n).to_a\n a[0] = nil\n a[1] = nil\n (2..Math.sqrt(n)).each do |i|\n if a[i]\n it = 0\n j = i * i\n while j <= n\n a[j] = nil\n it += 1\n j = i * i + i * it\n end\n end\n end\n a.select{|i| i}\nend", "def sieve_eratosthenes(len)\r\n\tprimes = [2]\r\n\tn = 2\r\n\r\n\t# Keep finding primes until requested length is reached\r\n\tuntil primes.length == len\r\n\t\t# Increase next number to test by one\r\n\t\tn += 1 \r\n\r\n\t\t# Test n against all numbers in prime array\r\n\t\t# If n is divisible by a prime, break and get next number to test\r\n\t\tis_prime = true\r\n\t\tprimes.each do |p|\r\n\t\t\tif n%p == 0\r\n\t\t\t\tis_prime = false \r\n\t\t\t\tbreak\r\n\t\t\tend\r\n\t\tend\r\n\t\t# If n is not divisible by previous primes, push to primes array\r\n\t\tprimes << n if is_prime\r\n\tend\r\n\tputs primes.last\r\nend", "def pretentious_primes(arr, num)\n new_arr = []\n if num > 0\n arr.each do |ele|\n i = ele + 1\n count = 0\n while true\n if is_prime?(i)\n count += 1\n end\n if count == num\n new_arr << i\n break\n end\n i += 1\n end\n end\n else\n num = -1 * num\n end\n new_arr\nend", "def prime_numbers(array_input)\n prime_array = (2..(array_input)).to_a\n i = 0\n while (i < prime_array.length)\n prime_array.delete_if do |number|\n (number % prime_array[i] == 0) & (number != prime_array[i])\n end\n i += 1\n end\n prime_array\nend", "def bc_get_prime_numbers(size)\n n = 1\n primes = []\n notprime = Hash.new\n\n until primes.size > size do\n\n n+=1\n\n # if I am known not prime, continue\n if notprime[n] then next end\n\n # check to see if I'm prime (abort instantly on finding divisor)\n (2..Math.sqrt(n)+1).each{|i| print \"Checking #{n} vs #{i}\\n\"; if n%i==0 then notprime[n]=1; print \"NOT A PRIME!\\n\"; next; end}\n\n # I'm prime, so add me to array + mark my multiples as being not\n # prime, but the fewer primes I need to get, the fewer multiples I\n # mark\n\n primes.push(n)\n (2..(size-primes.size())).each{|i| notprime[i*n] = 1}\n end\n primes\nend", "def sieve(n)\n primes = nil\n\n OpenTracing.global_tracer.start_active_span(\"sieve\") do |scope|\n # don't really want the first two, but matching index to value makes it easier\n primes = [*0..n]\n primes[0] = nil\n primes[1] = nil\n\n for x in primes do\n next if x.nil? # already marked as composite, skip to the next one\n\n # find all the composites from this number and make them nil\n (2*x..n).step(x) do |c|\n primes[c] = nil\n end\n end\n\n # remove the nils from the array\n primes = primes.compact\n\n # tag the number of primes found\n scope.span.set_tag(\"primes.count\", primes.count)\n end\n\n primes\nend", "def prime_set(n)\n\t\tprimes_arr =[]\n\t\ti = 1\n\t\t# keep inserting prime numbers into array until its length is equal to 'n'\n\t\tuntil primes_arr.count == n\n\t\t\tif is_prime(i) == true \n\t\t\t\tprimes_arr << i \n\t\t\tend \n\t\t\ti+=1\n\t\tend \n\t\tp primes_arr\n\tend", "def sieve(n)\r\n # Create two arrays (l and empty store)\r\n l = Array.new(n, 1)\r\n store = Array.new\r\n for i in 2 .. n\r\n next unless l[i]\r\n # num.step(limit, step ) {|i| block } => num\r\n # Start at num to limit of step:\r\n # E.g. 4.step(100, 2) = 4, 6, 8\r\n (i**2).step(n, i) {|x| \r\n l[x] = nil \r\n }\r\n store << i \r\n end\r\n store\r\nend", "def compute_primes\n nums = (@max_checked..@max_checked * 2).map { |x| x.odd? ? x : nil }.to_a\n 1.upto(@primes.index { |p| p * p > @max_checked * 2 }) do |i|\n start_idx = -@max_checked % @primes[i] # prime[i]'s 1st multiple's index\n\n (start_idx..nums.size).step(@primes[i]) { |x| nums[x] = nil }\n end\n @max_checked *= 2\n @primes += nums.compact\n end", "def primeSieve(n)\n s = (0..n).to_a\n s[0] = s[1] = nil\n s.each do |p|\n next unless p\n break if p * p > n\n (p*p).step(n, p) { |m| s[m] = nil }\n end\n s.compact\n end", "def pretentious_primes(arr, n)\n arr.map { |num| replace_with_prime(num, n) }\nend", "def getPrimes()\n oldlimit = $primelimit + 1\n $primelimit *= 2\n\n for i in oldlimit...$primelimit\n isPrime = true\n $primes.each do |p|\n if i % p == 0\n isPrime = false\n break\n end\n end\n if isPrime\n $primes << i\n end\n end\n\nend", "def select_primes(array)\n array.delete(1)\n array.select do |num|\n (2...num).to_a.all? {|int| num % int != 0}\n end\nend", "def specific_prime(n)\n\na = (2..n) # list of integers 2 through \nprimes = Array.new\n\nprimes = a.select { |x| (2..Math.sqrt(x)).none? { |d| (x % d).zero? }}\n\nputs primes[10000]\n# answer => 104,743\n\nend", "def prime?(number)\n a = []\n n = (2...number).to_a\n if number == 1 || number == 0 || number.negative?\n false\n else\n n.collect {|x| a << number % x}\n if a.include?(0)\n false\n else\n true\n end\n end\n # (2...number).to_a.each {|x| (number/x).integer? ? false : true}\nend", "def squared_primes(array)\n\n a=[]\n array.each do |x| \n for i in (2..x-1)\n a << x if x % i == 0 \n end\n end\n array -= a\n array.map{ |p| p*p } \n\nend", "def sieve_eratosthenes(biggest_num)\n primes = (0..biggest_num).to_a\n primes[0] = primes[1] = nil\n\n counter = 0\n primes.each do |p|\n next unless p\n\n break if p*p > biggest_num\n counter += 1\n\n (p*p).step(biggest_num,p) { |m| primes[m] = nil }\n end\n primes.compact\nend", "def eratosthenes(n)\n a = Hash.new\n 2.upto(n) do |i|\n a[i] = true\n end\n 2.upto(Math.sqrt(n)) do |i|\n if a[i]\n x = 0\n loop do\n j = i * i + x * i\n break if j > n\n a[j] = false\n x = x + 1\n end\n end\n end\n a.select{|k,v| k if v}.keys\nend", "def squared_primes(array)\n array.find_all{|x| (2..x-1).select(){|i| x % i == 0}.count == 0 && x > 1}.map{|p| p*p}\n\n\n # primes = []\n # array.each do |x|\n # 2.upto(x-1) do |i|\n # if x % i == 0 && x > 2\n # primes << x*x\n # end\n # end\n # end\n # primes\n\n # primes= []\n # array.find_all do |x|\n # if x == 2\n # primes << 2*2\n # end\n\n # if x > 2 && (x % 2 != 0)\n # #(2..x-1).select()\n # # if x % 2 != 0 && x > 1\n # #{|i| x % i == 0}\n # #x.count == 0 && x > 1\n # primes << x * x\n # #end\n # end\n # end\n # # new_array.map{|p| p*p}\n # primes\nend", "def primes_array(options = {})\n limit = options[:limit] || ARRAY_DEFAULT_LIMIT\n field = Array.new(limit+1, true)\n # sieve the number field\n 3.step(field.size / 2, 2) do |k|\n (3 * k).step(field.size, 2 * k) do |n|\n field[n] = false\n end\n end\n \n # collect the field into an array, starting with 3\n primes = [ 2 ]\n 3.step(field.size, 2) do |n|\n primes << n if field[n] \n end\n primes\n end", "def primes (n)\r\n primes = Array.new(n) { |index| index+=1 }\r\n return primes.select { |x| factors(x).length == 2 }\r\nend", "def build_out_prime_list\n new_size = prime_list.size + prime_list.size\n loop_end = Math.sqrt( idx_to_value( new_size ) ).ceil\n\n (prime_list.size..new_size).each { |idx| prime_list[idx] = true }\n\n prime_list.each_with_index do |prime, idx|\n next unless prime\n\n divisor = idx_to_value( idx )\n break if divisor > loop_end\n\n (idx+1..new_size).each { |i| prime_list[i] = false if idx_to_value( i ) % divisor == 0 }\n end\n end", "def primes_up_to(max)\n repository = (0..max).collect{true} #=> Create flag array\n limit = (max ** 0.5) #=> establish search limit\n\n for index in 2..limit #=> search through flag aray\n next if !repository[index]\n num = (index * 2)\n while num <= max #=> unflag multiples of primes\n repository[num] = false\n num += index\n end\n end\n\n # => convert numbers into arrays\n primes = repository.collect.with_index do |flag, value|\n value if flag\n end\n\n # return cleaned array\n primes.shift\n primes.shift\n primes.compact\nend", "def sieve_of_eratosthenes(max)\n if max < 1 || !(max.is_a?(Integer))\n raise TypeError.new \"the number given must be an integer greater than zero\"\n end\n\n root = Integer.sqrt(max)\n primes = Array.new(max + 1) { |i| i.odd? || i == 2 } #every prime number other than 2 is an odd number.\n\n #to find all the prime numbers until max, it will be enough just to perform the sifting only by the prime numbers, which do not exceed the root of max.\n 3.step(root, 2).each do |i|\n next unless primes[i] # next if not initialized as prime\n #i*i, i*i+i, i*i+2i, i*i+3i\n (i * i).step(max, i) do |j|\n primes[j] = false\n end\n end\n\n #Select all prime numbers\n 2.upto(max).select { |i| primes[i] }\nend", "def sieve(n)\n (primes = [*2..n]).each do |k|\n next unless k\n (k*k..n).step(k) { |m| primes[m-2] = nil }\n end\n\n primes.compact\nend", "def prime?(arg)\nreturn false if arg <= 1\nreturn true if arg == 2\n result = true\n (3..arg).to_a.each_with_index{|num, idx|result = false if arg % (idx+1) == 0 && (idx+1) != 1}\n result\nend", "def eratosthenes_sieve(nth_prime)\n top = nth_prime * 10\n # this is really kludgy, you might have to increase 10 if you want\n # nth primes above 10k. It seems to work fine for all numbers under\n # 10k. I need to read up on prime number theory to find out when this fails.\n sieve = []\n (2..top).each { |i| sieve[i] = i }\n for i in 2 .. Math.sqrt(top)\n next unless sieve[i]\n (i*i).step(top, i) do |j|\n sieve[j] = nil\n end\n end\n sieve.compact[nth_prime]\nend", "def eratosthenes_sieve(top)\n sieve = []\n (2..top).each { |i| sieve[i] = i }\n for i in 2 .. Math.sqrt(top)\n next unless sieve[i]\n (i*i).step(top, i) do |j|\n sieve[j] = nil\n end\n end\n sieve.compact\nend", "def sieve_of_atkin(max)\n if max < 1 || !(max.is_a?(Integer))\n raise TypeError.new \"the number given must be an integer greater than zero\"\n end\n\n root = Integer.sqrt(max)\n sieve = Array.new(max){ |i| i == 2 || i == 3 }\n\n for i in 1..root do\n for j in 1..root do\n n = 4 * (i * i) + (j * j)\n # All numbers with modulo-sixty remainder 1, 13, 17, 29, 37, 41, 49, or 53 have a modulo-twelve remainder of 1 or 5.\n if (n <= max) and (n % 12 == 1 || n % 12 == 5)\n sieve[n] = !sieve[n]\n end\n n = 3 * (i * i) + (j * j)\n # All numbers with modulo-sixty remainder 7, 19, 31, or 43 have a modulo-six remainder of 1.\n # These numbers are prime if and only if the number of solutions to 3x^2 + y^2 = n is odd and the number is square free.\n if (n <= max) and (n % 12 == 7)\n sieve[n] = !sieve[n]\n end\n n = 3 * (i * i) - (j * j)\n # All numbers with modulo-sixty remainder 11, 23, 47, or 59 have a modulo-twelve remainder of 11.\n # These numbers are prime if and only if the number of solutions to 3x^2 – y^2 = n is odd and the number is square free.\n if (i > j) and (n <= max) and (n % 12 == 11)\n sieve[n] = !sieve[n]\n end\n end\n end\n\n # If n is prime, omit all multiples of its square\n (5..root).each { |i|\n if sieve[i]\n (i * i).step(max, i * i) do |j|\n sieve[j] = false\n end\n end\n }\n\n #Select all prime numbers\n 2.upto(max).select { |i| sieve[i] }\nend", "def primes(n) \n max = Math::sqrt(n).truncate\n (2..max).each {|val|\n if n % val == 0 then\n p val\n primes(n/val)\n return\n elsif val == max then\n p n\n return\n end\n }\nend", "def primes(max)\n array = []\n i = 2\n while i < max.abs\n if is_prime?(i)\n array << i\n end\n i += 1\n end\n array\nend", "def eratosthenes(limit)\n nlist = [nil, nil, *2..limit]\n (2..Math.sqrt(limit)).each do |x|\n (x ** 2..limit).step(x) { |y| nlist[y] = nil } if nlist[x]\n end\n nlist.compact!\nend", "def pe50v2()\n\ta = sieveOfErathosthenes(3990)\n\tprim,total,count = [], 0, 0\n\ta.each_with_index do |x, index|\n\t\tif x \n\t\t\ttotal += index\n\t\t\tcount += 1 \n\t\t\tprim.push([total,count])\n\t\tend\n\tend\n\t#p prim\n\tmax = 0\n\tthePrime = 0\n\tseq = prim.map {|k| k }.permutation(2).to_a.each {|x| x.flatten!}\n\tseq.each do |a, b, c , d| \n\t\t#printf \"%d %d %d %d\\n\", a, b, c, d\n\t\te = a - c\n\t\tif(Prime.prime?(e)) then\n\t\t\tif(max < b - d) then\n\t\t\t\tmax = b - d\n\t\t\t\tthePrime = e\n\t\t\t\tprintf \"prime %d with max %d\\n\",e,max\n\t\t\tend\n\t\tend\n\tend\n\tprintf \"the prime is %d with a seqence of %d\\n\",thePrime, max\nend", "def primes_below(n)\n a = 2\n output_array = []\n while a < n\n if is_prime?(a)\n output_array.push(a)\n end\n a = a + 1\n end\n return output_array\nend", "def prime?(int)\r\n\r\n arr = [] # empty array to store results\r\n\r\n i = 4 # modulo of 4 for ints 1, 2 and 3 are never zero\r\n while i < int # iteration to check\r\n arr << i if int % i == 0\r\n i += 1\r\n end\r\n\r\n arr.length == 0 # result \"true/false\"\r\nend", "def all_primes(number)\n primes = []\n (2...number).each do |num|\n if prime?(num)\n primes << num \n end\n end\n primes\nend", "def arrayDivisible(n)\n not_factors = []\n numbers_to_check = remove_factors(n)\n\n index1 = 0\n index2 = 1\n\n puts \"index1: #{index1}, index2: #{index2}, array: #{numbers_to_check}\"\n #binding.pry\n\n while index1 <= range_length\n\n while index2 <= range_length\n if numbers_to_check[index2] % numbers_to_check[index1] != 0\n puts \"num1: #{numbers_to_check[index1]}, num2: #{numbers_to_check[index2]}, array: #{numbers_to_check}\"\n not_factors << numbers_to_check[index2]\n puts \"New array: #{not_factors}\"\n puts nil\n end\n index2 += 1\n end\n index1 += 1\n end\n\n not_factors\n\nend", "def solution_3(num)\n starting_time = Time.now\n\n # actual sieve of eratosthenes\n potential_primes = (2..num).to_a\n potential_primes.each_with_index do |val, index|\n if val\n index += val\n while index < num\n potential_primes[index] = nil\n index += val\n end\n else\n next\n end\n end\n\n primes = potential_primes.compact\n\n p \"Sum of first #{num} primes: #{primes.reduce(:+)}\"\n\n p \"In #{Time.now - starting_time} seconds\"\nend", "def problem_77a\n primes = Primes.upto(100)\n\n # off is the offset in the prime array, we can work down :-)\n solve = lambda do |a,off,max|\n n = 0\n while a[off] < max && (a.length-off) >= 2 \n a[off] += a.pop\n n += 1 if (a & primes).length == a.uniq.length\n n += solve.call(a.dup,off+1,a[off]) if a.length - off > 1\n end\n n\n end\n m = 0\n (2..100).each do |num|\n break if (m = solve.call([1] * num,0,num-1)) > 5000\n puts \"#{num} => #{m}\"\n end\n m\nend", "def prime_sieve(n)\n\tarr = (0..n).to_a\n\tfor idx1 in 2..n\n\t\tnext if arr[idx1] == nil\n\t\tidx2 = idx1 ** 2\n\t\twhile idx2 < n\n\t\t\tarr[idx2] = nil\n\t\t\tidx2 += idx1\n\t\tend\n\tend\n\tarr.compact[2..-2]\nend", "def prime_sieve(n)\n\tarr = (0..n).to_a\n\tfor idx1 in 2..n\n\t\tnext if arr[idx1] == nil\n\t\tidx2 = idx1 ** 2\n\t\twhile idx2 < n\n\t\t\tarr[idx2] = nil\n\t\t\tidx2 += idx1\n\t\tend\n\tend\n\tarr.compact[2..-2]\nend", "def print_all_primes(num)\n for i in (2..num)\n is_status = is_prime(i)\n if(is_status)\n puts i\n end\n end\nend", "def test_numbers_with_divisors_are_not_prime\n seed_array = (4..150).step(1).to_a\n seed_array.each do |x|\n x_square = Math.sqrt(x)\n for i in 4..x_square \n if x % i == 0\n assert_equal(false, @primes_container.is_prime?(x), \"#{i} caused failure #{x % i}\")\n end\n end\n end\n end", "def prime?(n)\n return false if n < 2\n\n sieve = (0..n).to_a\n\n (2..n).each do |number|\n if sieve[number]\n multiples(number, n).each do |multiple|\n sieve[multiple] = nil\n end\n end\n end\n\n !!sieve[n]\nend", "def prime_number(n)\n prime_array = []\n count = 1\n until prime_array.length == n\n if count == 1\n prime_array << 2\n count += 2\n elsif is_prime?(count) == true\n prime_array << count\n count += 2\n else\n count += 2\n end\n end\n prime_array.last\nend", "def squared_primes(array)\n# array.find_all {|x| (2..x-1).select(){|i| x % i == 0 }.count == 0 }.map{|p| p*p}\n# Select only primes from array\n\tprime = array.find_all do |x|\n\t\t\t\t \t(2..x-1).select do |i|\n\t\t\t\t \t\tx % i == 0\n\t\t\t\t \tend\n\t\t\t\t \t.count == 0\n\t\t\t\t\tend\n# Square the selected primes and over write the initial array \n return prime.map {|p| p*p}\n \nend", "def solution(a)\n factors = factors_sieve(a)\n n = a.size\n a.map {|num| n - factors[num]}\nend", "def sieve(n)\n # initialize an empty array (this will store all primes between 2 and n)\n prime_array = []\n for i in 2..n\n if(is_prime(i))\n # if 'i' is a prime number, add it to the array\n prime_array.push(i)\n end\n end\n # finally, we'll return our array of prime numbers\n return prime_array\nend", "def divisors(n)\n i=2\n array=[]\n while i <= n/2\n if n % i == 0\n array << i\n end\n i+=1\n end\n if array.count == 0\n \"#{n} is prime\"\n else\n array\n end \nend", "def prime_numbers\n s = (0..self).to_a\n s[0] = s[1] = nil\n s.each do |p|\n next unless p\n break if p * p > self\n (p*p).step(self, p) { |m| s[m] = nil }\n end\n s.compact\n end", "def get_primes num\n primes = []\n for i in 0 ... num do\n if check_prime?(i) == true\n primes.push(i)\n end\n end\n p primes\nend", "def sieve(x)\n s = (0..x.to_i).to_a\n\n s[0] = s[1] = nil\n\n s.each{ |p| # Perform the block for each entry in the array.\n next unless p # Iterate on next array value if entry is nil\n break if p * p > x # Cease iteration if p*p > max_value\n (p*p).step(x, p) { |m| s[m] = nil } # Starting at p*p, set every p-th value to \"nil\" until max_value\n }\n s = s.compact\nend", "def sieve(x)\n s = (0..x.to_i).to_a\n\n s[0] = s[1] = nil\n\n s.each{ |p| # Perform the block for each entry in the array.\n next unless p # Iterate on next array value if entry is nil\n break if p * p > x # Cease iteration if p*p > max_value\n (p*p).step(x, p) { |m| s[m] = nil } # Starting at p*p, set every p-th value to \"nil\" until max_value\n }\n s = s.compact\nend", "def sieve(x)\n s = (0..x.to_i).to_a\n\n s[0] = s[1] = nil\n\n s.each{ |p| # Perform the block for each entry in the array.\n next unless p # Iterate on next array value if entry is nil\n break if p * p > x # Cease iteration if p*p > max_value\n (p*p).step(x, p) { |m| s[m] = nil } # Starting at p*p, set every p-th value to \"nil\" until max_value\n }\n s = s.compact\nend", "def anti_prime?(num)\n max = 0\n sum_i_array = []\n (1..num).each do |n|\n sum_i = 0\n (1..n).each { |i| sum_i += 1 if n % i == 0 }\n sum_i_array << sum_i\n end\n sum_i_array[-1] == sum_i_array.max\nend", "def pretentious_primes(arr, num)\nend", "def find_primes(num,prime_array=[])\n i = 2\n until num % i == 0 \n i += 1\n end\n prime_array << i\n return prime_array if num == i\n find_primes(num/i, prime_array) \nend", "def prime(number)\n primes = (2..number).to_a\n (2..number).each do |int|\n (2..int).each do |n|\n if ( int % n == 0) && n != int\n primes.delete(int)\n break\n end\n end\n end\n primes\nend", "def print_prime\n @n_primes = get_n_primes\n return [] if @n_primes == 0\n p_arr_len = @prime_numbers.length\n return @prime_numbers[0..@n_primes] if p_arr_len >= @n_primes\n (p_arr_len > 1) ? (n = @prime_numbers.last) : (n = 3)\n until @prime_numbers.length == @n_primes do\n @prime_numbers.push(n) if @prime_cache[n]\n (@prime_numbers.push(n) && @prime_cache[n] = true) if is_prime(n)\n n += 1\n end\n @prime_numbers\n end", "def eratosthenes(n)\n\tp_set = (3..n).step(2).to_a\n\tp = 3\n\ti = 0\n\twhile p && p ** 2 <= n \n\t\tD 'set is...'\n\t\tD p_set.inspect\n\n\t\tc = 2\n\n\t\twhile (mul = p * c) <= n \n\t\t\tD \"value is #{mul}, value position #{mul/2-1}\"\n\t\t\tD \"value setting to nil #{p_set[mul/2-1]}\"\n\t\t\tif mul.odd?\n\t\t\t\tp_set[mul/2 - 1] = nil\n\t\t\tend\n\t\t\tc += 1\n\t\tend\n\n\t\tD 'picking next p..'\n\t\ti += 1\n\t\t\n\t\twhile p_set[i].nil? && i < n\n\t\t\ti += 1 \n\t\t\tD \"Start index #{i}\"\n\t\t\tD p_set.inspect\n\t\tend\n\n\t\tif i < n\n\t\t\tp = p_set[i]\n\t\t\tD \"next p is #{p}\"\n\t\telse\n\t\t\tD \"finish\"\n\t\t\tbreak\n\t\tend\n\tend\n\n\tI p_set.compact.join(',')\n\tputs p_set.compact.size\n\t# + 1 because 2 was excluded\nend", "def anti_prime?(num)\n counter = count_divisors(num)\n counters = []\n \n (1...num).each do |i|\n if i.even? #unnecessary to add .even\n counters << count_divisors(i)\n end\n end\n counters.each do |c| \n if c > counter\n return false\n end\n end\n true\nend", "def squared_primes(array)\n prime = array.find_all do |x| \n divisible = (2..x-1).select {|i| x % i == 0 }\n divisible.count == 0\n end\n prime.map{|p| p*p}\nend", "def prime_series\n t = self\n limit = Math.sqrt(t)\n a = (2..t).to_a\n n = 2\n while (n < limit) do\n x = n*2\n begin\n a[x-2]=2\n x+=n\n end until (x > t )\n begin\n n+=1\n end until ( a[n-2] != 2 )\n end\n a.uniq!\n end", "def primes(max)\n yield \"See Primes below: \"\n parray= []\n Prime.each(max) do |p|\n parray << p\n end\n print parray\nend", "def anti_prime? (num)\n # make a helper, that makes an array of all factors of num [1, 2, 3, 4, 5, 6, 8, 12, 24]\n # if I compare the factors array to every array up to it, it's length should be longer.\n # range 0 to num\n\n (1...num).each do |idx|\n if factors(num).length < factors(idx).length\n return false\n end\n end\n true\nend", "def prime?(i)\n if i <= 1\n false\n else\n #(range_of_numbers[i] / 1) == range_of_numbers[i] || 1\n range_of_numbers = (2...i).to_a\n range_of_numbers.all? {|number| i % number != 0}\n end\nend", "def find_prime_numbers(num)\n\tarr =[]\n (2..num).each{|x| arr.push(x)}\n\n i = 0\n p = arr[i]\n\n while p != arr[-1]\n\t arr.delete_if{|n| n%p == 0 && n != p}\n\t i+= 1\n\t p = arr[i]\n end\n return arr\nend", "def sieve_of_eratosthenes(count, sieve_size = 50)\n sieve_of_eratosthenes_delete(count, sieve_size)\n end", "def prime?(integer)\n if integer > 1\n arr = Array.new\n for i in 2..(Math.sqrt(integer).round)\n arr << i\n end\n arr.each do |i|\n return false if integer % i == 0\n end\n return true\n else\n return false\n end\nend", "def prime(n)\r\n\tnumbers = (1..n-1).to_a\r\n\tnumbers.each do |num|\r\n\tif numbers.length == 1\r\n\t\treturn true\r\n\tend\r\n\t\tif n%2 == 0 && n%num == 0 \r\n\r\n\t\t\t\treturn false\r\n\t\telse\r\n\t\t\t\treturn true\r\n\t\tend\t\r\n\tend\r\n\r\n\r\nend", "def pretentious_primes(a, n)\n a.map do |ele|\n if n > 0\n nth_prime_greater_than(ele, n)\n else\n primes = primes_upto(ele-1)\n primes[n]\n end\n end\nend", "def prime(n)\n primes = (0..n).to_a\n primes[0] = nil\n primes[1] = nil\n\n primes.each do |current_num|\n next if current_num.nil?\n break if current_num > Math.sqrt(n)\n (current_num**2).step(n, current_num) { |current_interval| primes[current_interval] = nil }\n end\n\n primes.compact\nend", "def sieve\n @ws.fill(0)\n @ps.zip(@log_ps, @roots) do |p, lp, (s1, s2)|\n ((@m + s1) % p).step(2 * @m, p) {|i| @ws[i] += lp }\n ((@m + s2) % p).step(2 * @m, p) {|j| @ws[j] += lp }\n end\n end", "def solution(n, p, q)\n primes = []\n sieve(n).each_with_index { |v, i| \n primes << i if v\n }\n #puts primes\n \n semiprimes = [false] * (n + 1)\n primes.each { |x|\n primes.each { |y|\n sp = x * y\n break if sp > n\n semiprimes[sp] = true\n }\n }\n #puts semiprimes.inspect\n \n counts = [0]\n (1..n).each { |i|\n counts[i] = counts[i - 1]\n counts[i] += 1 if semiprimes[i]\n }\n #puts counts.inspect\n \n result = []\n p.each_with_index { |a, i| \n b = q[i]\n result << counts[b] - counts[a - 1]\n }\n result\nend", "def collect_primes(number)\n \n sieve = [nil, nil] + (2 .. number).to_a\n \n (2 .. Math.sqrt(number)).each do |n|\n next unless sieve[n]\n (n*n).step(number, n) do |num|\n sieve[num] = nil\n end\n end\n \n primes = []\n sieve.each do |x|\n if x != nil\n primes << x\n end\n end\n return primes\nend", "def primes\n range = (min..max).to_a\n primes = (min..max).to_a\n\n range.each do |mod|\n primes.delete_if do |num| \n composite?(num, mod) unless num == mod\n end\n range = primes\n end\n primes\n end", "def prime?(num)\r\n # your code goes here\r\n prime = []\r\n\r\n for i in 1 .. num\r\n if num % i == 0\r\n prime << i\r\n end\r\n end\r\n prime.length == 2\r\nend" ]
[ "0.7301977", "0.71271074", "0.707012", "0.70455533", "0.6976294", "0.69156003", "0.6885897", "0.6862523", "0.6739983", "0.6675054", "0.6634471", "0.6627764", "0.6622075", "0.66204506", "0.66199076", "0.6608538", "0.65779424", "0.6569534", "0.6550073", "0.6532301", "0.6477396", "0.6448449", "0.64452744", "0.6427806", "0.6422675", "0.64029425", "0.63995105", "0.6394378", "0.6389722", "0.63818455", "0.63694197", "0.63511837", "0.6340972", "0.6304195", "0.63006103", "0.6280268", "0.6277129", "0.6269705", "0.6255754", "0.6254009", "0.6249084", "0.62430894", "0.62411517", "0.6238292", "0.62241095", "0.621213", "0.6195525", "0.61952716", "0.6186809", "0.61834", "0.6182116", "0.6172904", "0.6165504", "0.61626476", "0.6155217", "0.61513126", "0.61242175", "0.61224294", "0.6122026", "0.6118719", "0.6105755", "0.60956216", "0.60950387", "0.60950387", "0.6094947", "0.6094405", "0.6081333", "0.6074682", "0.6066984", "0.6063745", "0.60626507", "0.6062614", "0.605766", "0.60561156", "0.60264385", "0.60264385", "0.60264385", "0.60261166", "0.60173434", "0.601362", "0.6002551", "0.60009974", "0.5995514", "0.59852344", "0.59831727", "0.596727", "0.59665984", "0.59592223", "0.5936113", "0.59356105", "0.59312415", "0.59274477", "0.5925384", "0.5920878", "0.5918473", "0.59111327", "0.59027493", "0.58994305", "0.5899346", "0.58942133" ]
0.78390974
0
3.1 fill in 2d array of bools by setting a[i,j] to true if gcd i,j is 1 and false otherwise uses ruby's built in gcd function
def twoDArray(m,n) arr = Hash.new for m in 0..m for n in 0..n if m.gcd(n) == 1 arr[[m,n]] = true else arr[[m,n]] = false end end end for m in 0..m for n in 0..n if arr[[m,n]] == true puts "#{m} :m and #{n} :n" end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iterate(arr)\n newArr = []\n (0...arr.size).each do |row|\n newArr[row] = []\n (0...arr.size).each do |col|\n num_neighbors = num_neighbors(row,col,arr)\n if arr[row][col]\n if num_neighbors == 2 || num_neighbors == 3\n newArr[row][col] = true\n else\n newArr[row][col] = false\n end\n else\n if num_neighbors == 3\n newArr[row][col] = true\n else\n newArr[row][col] = false\n end\n end\n end\n end\n arr = newArr\nend", "def init_truth(array, width)\r\n row = 0 # used to keep track of which row currently accessing\r\n column = 0 # used to keep track of which column currently accessing\r\n size = width - 1 # used to keep track of how many T/F values to place\r\n height = 2 ** width # used to know when to break inner for loop\r\n while column < width # iterate through one column at a time\r\n iterations = 2** size # used to set number of true values to place in row\r\n second_iteration = 0 # used to set number of false values to place\r\n while row < height # while not at end of column\r\n if iterations > 0 # if iterations less than 0, set to true\r\n array[row][column] = 1 # setting current index to true\r\n iterations = iterations - 1 # decrement number of true values left to place\r\n row = row + 1 # increment row currently in\r\n second_iteration = 2** size if iterations == 0 # if no more trues to place, set how many falses to place\r\n else # set false values\r\n array[row][column] = 0 # setting current index to false\r\n second_iteration = second_iteration - 1 # decrement number of false values left to place\r\n row = row + 1 # increment row currently in\r\n iterations = 2** size if second_iteration == 0 # if no more false values to place, set how many trues to place\r\n end\r\n end # end of inner while loop\r\n column = column + 1 # increment column\r\n size = size - 1 # decrement size to decrement number of t/f's to place in a column\r\n row = 0 # reset row # go back to top row\r\n end # end of outter while loop\r\nend", "def generalizedGCD(num, arr)\n result = arr.first\n\n arr.each do |num|\n result = result.gcd(num)\n end\n\n result\nend", "def gcd_euclides(a, b)\n while b != 0\n t = b\n b = a % b\n a = t\n end\n a\nend", "def solve_array(array)\n check_array = Array.new(9){Array.new(9){Array.new(9){0}}}\n # p array\n for i in 0..8\n for j in 0..8\n if array[i][j] == 0\n p \"for each variable\\n\\n\\n\\n\\n\\n\\n\\n #{i}, #{j}\"\n p \"before_modify #{check_array[i][j]} 1\"\n modify_check_array(array, check_array, i, j)\n p check_array[i][j]\n if count_value(check_array[i][j]) == 1\n p check_array[i][j]\n p \"for ij #{i}, #{j}\"\n array[i][j] = get_value(check_array[i][j])\n end\n end\n end\n end\n end", "def jaccard(a, b)\n a_i = a.map { |i| i > 0 }\n b_i = b.map { |i| i > 0 } \n n = (0 .. (a.size - 1)).map { |i| (a_i[i] && b_i[i]) ? 1 : 0 }.inject(:+)\n u = (0 .. (a.size - 1)).map { |i| (a_i[i] || b_i[i]) ? 1 : 0 }.inject(:+)\n return n.to_f / u\n #b = bray_curtis(a, b)\n #return 2.0*b/(1+b)\n end", "def gcdR(i, j)\n if j != 0\n return gcdR(j, i%j)\n else\n return i\n end\nend", "def gcdI(i, j)\n while i != j\n if i > j\n i = i - j\n else\n j = j - i\n end\n end\n return i\nend", "def gcd(p0) end", "def reciprocal_array?\n true\n end", "def reciprocal_array?\n false\n end", "def reduce_to_all_true(array)\n counter = 0;\n while counter < array.length do\n return false if !array[counter];\n counter += 1;\n end\n return(true);\nend", "def gcd(*nums)\r\n\t\treturn nums.inject do |a, b|\r\n\t\t\ta, b = b, a % b until b.zero?\r\n\t\t\tnext a\r\n\t\tend\r\n\tend", "def reciprocal_array?\n false\n end", "def is_divisible(arr, k)\n n = arr.length\n visited = Array.new(n, 0)\n\n for i in 0...n\n\n for j in 0...n\n\n if visited[i] == 0 && visited[j] == 0 &&\n (arr[i] + arr[j]) % k == 0\n visited[i] = 1\n visited[j] = 1\n break\n end\n\n end \n end\n for i in 0...n\n if visited[i] == 0\n return false\n end \n end\n\n true \nend", "def reciprocal_array?\n true\n end", "def coprime(a, b)\n gcd(a, b) == 1\nend", "def reduce_to_all_true(source_array) \n i = 0\n while i < source_array do\n return false if !source_array[i]\n i += 1\n end\nend", "def coprime?(num_1, num_2)\n # initialize arrays for common\n # determine the minimum between the two nums\n # loop from 1 to minimum using iterator idx\n # push common divisors to array\n # if length is not 1, return false, else true\n minimum = [num_1, num_2].min\n \n (2..minimum).each do |idx|\n return false if num_1 % idx == 0 && num_2 % idx == 0 \n end\n return true\n\nend", "def gcd( a, b )\n return a if b.zero?\n gcd b, a % b\nend", "def primes\n arr=Array.new\n arr[1]=false\n (2..1000).each {|i| arr[i]=true}\n (2..1000).each {|i| (i/2).floor\n (2..1000).each {|j| (j/i).floor\n arr[i*j] = false\n }}\n for i in 1..1000\n if arr[i] == true\n puts i\n end\n end\nend", "def coprime?(a, b)\n 1 == gcd(a, b)\nend", "def gcd(a, b)\n b == 0 ? a : gcd(b, a % b)\nend", "def gcd(a, b)\r\n if b == 0\r\n return a\r\n else\r\n return gcd(b, a % b)\r\n end\r\nend", "def coprime?(a, b)\n (2...a).each { |divisor| return false if (a % divisor == 0 && b & divisor == 0)}\n return true\nend", "def gcd(a,b)\n return b if a % b == 0\n return gcd(b, a % b)\nend", "def arrayDivisible(n)\n not_factors = []\n numbers_to_check = remove_factors(n)\n\n index1 = 0\n index2 = 1\n\n puts \"index1: #{index1}, index2: #{index2}, array: #{numbers_to_check}\"\n #binding.pry\n\n while index1 <= range_length\n\n while index2 <= range_length\n if numbers_to_check[index2] % numbers_to_check[index1] != 0\n puts \"num1: #{numbers_to_check[index1]}, num2: #{numbers_to_check[index2]}, array: #{numbers_to_check}\"\n not_factors << numbers_to_check[index2]\n puts \"New array: #{not_factors}\"\n puts nil\n end\n index2 += 1\n end\n index1 += 1\n end\n\n not_factors\n\nend", "def random_boolean_array(elements)\r\n remaining = elements\r\n arr = []\r\n while remaining > 0\r\n arr.push random_boolean\r\n remaining -= 1\r\n end\r\n return arr\r\n end", "def gcd(a, b)\n if a % b == 0\n b\n else\n gcd(b, a % b)\n end\nend", "def gcdI(i, j)\n\twhile i != j\n\t\tif i > j\n\t\t\ti = i - j\n\t\telse\n\t\t\tj = j - i\n\t\tend\n\tend\n\treturn i\nend", "def check_if_all_combos_tried(row, col, forward)\n \n if @board_indicator[row][col] == 0 && @board[row][col] == 9 && row == @row_of_first_empty_square && col == @col_of_first_empty_square\n return true\n else\n return false\n end\n # if all initial holes are filled with'9', all combos were tried\n # all_combos_tried = true\n # (0..8).each do |k|\n # (0..8).each do |j|\n # if @board_indicator[k][j] == 0 && @board[k][j] < 9\n # all_combos_tried = false\n # #break\n # end\n # end\n # end\n # puts all_combos_tried\n # all_combos_tried\n end", "def coprime?( a, b )\n gcd( a, b ) == 1\nend", "def gcd(a, b)\n if (b == 0) then a\n else gcd(b, a % b)\n end\nend", "def circular_graph?(array)\n\treturn false if array.size.zero?\n\tvisited = array.size.times.map{ |i| false }\n\tvisited[0] = true\n\n\tarray.each do |index|\n\t\tif index > array.size \n\t\t\treturn false\n\t\tend\n\n\t\tif visited[index]\n\t\t\treturn true\n\t\tend\n\n\t\tvisited[index] = true\n\tend\n\tfalse\nend", "def reduce_to_all_true(source_array)\n i = 0\n\n while i < source_array.length do\n if source_array[i] == false\n return false\n end\n i += 1\n end\n \n return true\nend", "def gcd(a,b)\n\treturn a if b === 0\n\treturn gcd(b, a % b)\nend", "def gcd a,b\n if a<b\n gcd b,a\n elsif b==0\n a\n else\n gcd b,a%b\n end\nend", "def reduce_to_all_true(source_array)\n index = 0 \n result = true \n while index < source_array.length do \n if source_array[index]\n result\n else\n result = false\n end\n index += 1 \n end\n result\nend", "def common a\n a.reduce :gcd\nend", "def evenly_divisible_values(array)\n array.permutation(2)\n .select { |a, b| (a % b).zero? }\n .map { |a, b| a / b }\nend", "def gcd(a,b)\n if (b==0)\n a\n else\n gcd(b,a%b)\n end\nend", "def single_cycle_check(array)\n numElementsVisited = 0\n currentIdx = 0\n while numElementsVisited < array.length\n if numElementsVisited > 0 & currentIdx == 0\n return false\n end\n numElementsVisited += 1\n currentIdx = getNextIdx(currentIdx, array)\n end\n return currentIdx == 0\nend", "def gcd(x, y)\n x == 0 ? y : gcd(y % x, x)\nend", "def gcd(x, y) # finds greatest common factor of x,y\n while y != 0\n t = y\n y = x % y\n x = t\n end\n x\nend", "def gcd(a, b)\n if b == 0\n return a\n else\n return gcd(b, a%b)\n end\nend", "def gcd2 a,b\n if a<b\n d,s,r = gcd2 b,a\n [d,r,s]\n elsif b==0\n [a,1,0]\n else\n x=a/b\n y=a%b\n d,r,s = gcd2 b,y\n # here we know that d = r*b+s*y, and a=x*b+y, so y=a-x*b\n # thus d=r*b+s*(a-x*b) = (r-s*x)*b + s*a\n # so we return [d,s,r-s*x]\n # uncomment the following three lines to see this work out\n # puts \"#{a}=#{x}*#{b}+#{y}\"\n # puts \"#{d}=#{s}*#{a} + #{(r-s*x)}*#{b}\"\n [d,s,(r-s*x)]\n end\nend", "def gcd(a,b)\n return gcd(b, a) if a > b\n return b if a == 0\n gcd(b % a, a)\nend", "def reduce_to_all_true(array)\n if array.include? false\n false\n elsif array.each.include? true\n true\n end\nend", "def reduce_to_all_true(source_array)\n i = 0\n while i < source_array.length do\n return false if !source_array[i]\n i += 1\n end\n return true\nend", "def gcd(a, b)\n return b if a == 0\n return a if b == 0\n a, b = b, a if a < b\n a % b == 0 ? b : gcd(b, a % b)\nend", "def extended_gcd(a, b)\n return [0,1] if a % b == 0\n x,y = extended_gcd(b, a % b)\n [y, x-y*(a / b)]\nend", "def gcd(a,b)\n # base case: everything divides zero\n if b == 0\n return a\n else\n remainder = a%b\n end\n return gcd(b, remainder)\nend", "def reduce_to_all_true(source_array)\nend", "def gcd (a, b) # O(log b)\n if b != 0\n self.gcd(b, a % b)\n else\n return a\n end\n end", "def reduce_to_all_true(array)\n i=0 \n while i < array.length do\n if array[i] == false \n #puts \" #{array[i]} is truthy\"\n return false\n end\n #puts \"This is second #{array[i]}\"\n i += 1 \n end\n #puts \"after while #{array[i]}\"\n return true \n \n\nend", "def gcd(a, b)\n return a if b == 0\n\n remiander = a % b\n return gcd(b, remiander)\nend", "def ArrayAdditionI(arr)\n largest = arr.sort!.pop\n\n (2..arr.length).each {|i| arr.combination(i).to_a.each {|x| return true if x.inject(:+) == largest}}\n\n false\nend", "def brute_force_combinations(array)\n results = [[array.first]]\n\n until results.all? { |result| result.last == array.last }\n new_results = []\n results.each do |result|\n val = result.last\n next if val == array.last # This sequence is done\n\n i = array.find_index(val)\n\n valid_next_values = array[(i + 1)..[i + 3, array.last].min].select { |v| v <= val + 3 }\n\n # Always add the first one to the existing sequences\n result << valid_next_values.first\n\n # If we have additional values, create new duplicate sequences for them,\n # changing the final value to create the branch.\n new_results << result.dup.tap { |r| r[-1] = valid_next_values[1] } if valid_next_values.count >= 2\n new_results << result.dup.tap { |r| r[-1] = valid_next_values[2] } if valid_next_values.count == 3\n end\n results += new_results\n end\n results\nend", "def reduce_to_any_true(source_array)\n i = 0 \n while i < source_array.length do\n if source_array[i] == true \n return true\n end\n i += 1 \n end\n return false\nend", "def gcd2test a,b\n d,r,s = gcd2 a,b\n z = r*a+s*b\n return z==d\nend", "def xgcd_iter(x, y)\n a, next_a = 1, 0\n b, next_b = 0, 1\n while y != 0\n a, next_a = next_a, a-x/y*next_a\n b, next_b = next_b, b-x/y*next_b\n x, y = y, x%y\n end\n [x, a, b]\nend", "def gcd(a, b)\n if a == b\n a\n elsif a < b\n gcd1(b, a)\n else\n gcd1(a, b)\n end\nend", "def find_gcd(nums)\n nums.minmax.reduce(:gcd)\nend", "def self_dividing_numbers(left, right)\n result_array = []\n\n (left..right).each do |i|\n arr = array_of_digits(i)\n\n self_dividing = true\n arr.length.times do |digit|\n if arr[digit] == 0\n self_dividing = false\n else\n self_dividing = false if i % arr[digit] != 0\n end\n end\n result_array << i if self_dividing\n end\n\n result_array\nend", "def gc_divisor(ints:[]) \n arr = []\n arr2 = []\n for i in ints \n arr << i \n end\n \n arr.each do |num|\n for i in (1..num)\n if (num % i == 0)\n arr2 << i\n end\n end\n end\n # positive \n #divides numbers without a remainder\n #largetst one of such number\n arr2.each\nend", "def coprime?(num_1, num_2)\n new_arr = []\n i = 1\n while i < num_1 && i < num_2\n if num_1 % i == 0 && num_2 % i == 0\n new_arr << i \n end\n i += 1\n end\n new_arr.length == 1\nend", "def is_full?(i, j)\n end", "def gcd(a, b)\n return a if b == 0\n div = a % b\n gcd(b, div)\nend", "def nine_squares_filled(b)\n empty_square(b) == []\nend", "def divisible_numbers(arr)\n n = arr.size\n (0...n).each do |x|\n a = arr[x]\n ((x+1)...n).each do |y|\n b = arr[y]\n z = [a,b].sort\n return z if z[1] % z[0] == 0\n end\n end\nend", "def my_gcd(*args)\r\n\targs.inject do |memo, num|\r\n\t\tuntil [memo, num].include?(0)\r\n\t\t\tmod = memo % num\r\n\t\t\tmemo, num = num, mod\r\n\t\tend\r\n\t\t[memo, num].max\r\n\tend\r\nend", "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend", "def solution(n)\n number = 1\n stop = false\n while !stop\n results = []\n (1..n).each do |divider| \n if number % divider != 0\n results << false\n else\n results << true\n end\n end\n if results.count {|x| x == false } > 0\n stop = false\n number += 1\n else \n stop = true\n end \n end\n number\nend", "def extended_binary_gcd(a, b)\r\n\t\tif a < b\r\n\t\t\ta, b = b, a\r\n\t\t\texchange_flag_1 = true\r\n\t\tend\r\n\r\n\t\tif 0 == b\r\n\t\t\treturn 0, 1, a if exchange_flag_1\r\n\t\t\treturn 1, 0, a\r\n\t\tend\r\n\r\n\t\t# Reduce size once\r\n\t\t_Q, r = a.divmod(b)\r\n\t\tif 0 == r\r\n\t\t\treturn 1, 0, b if exchange_flag_1\r\n\t\t\treturn 0, 1, b\r\n\t\tend\r\n\t\ta, b = b, r\r\n\r\n\t\t# Compute power of 2\r\n\t\t_K = 0\r\n\t\t_K += 1 while 0 == a[_K] and 0 == b[_K]\r\n\t\tif 0 < _K\r\n\t\t\ta >>= _K\r\n\t\t\tb >>= _K\r\n\t\tend\r\n\r\n\t\tif b.even?\r\n\t\t\ta, b = b, a\r\n\t\t\texchange_flag_2 = true\r\n\t\tend\r\n\r\n\t\t# Initialize\r\n\t\tu = 1\r\n\t\td = a\t# d == a * u + b * v, (v = 0)\r\n\t\tu_ = 0\r\n\t\td_ = b\t# d_ == a * u_ + b * v_, (v_ = 1)\r\n\r\n\t\t# Remove intial power of 2\r\n\t\twhile d.even?\r\n\t\t\td >>= 1\r\n\t\t\tu += b if u.odd?\r\n\t\t\tu >>= 1\r\n\t\tend\r\n\r\n\t\tloop do\r\n\t\t\t# Substract\r\n\t\t\tnext_u = u - u_\r\n\t\t\tnext_d = d - d_\t\t# next_d == a * next_u + b * next_v\r\n\t\t\tnext_u += b if next_u < 0\r\n\r\n\t\t\tbreak if 0 == next_d\r\n\r\n\t\t\t# Remove powers of 2\r\n\t\t\twhile next_d.even?\r\n\t\t\t\tnext_d >>= 1\r\n\t\t\t\tnext_u += b if next_u.odd?\r\n\t\t\t\tnext_u >>= 1\r\n\t\t\tend\r\n\r\n\t\t\tif 0 < next_d\r\n\t\t\t\tu = next_u\r\n\t\t\t\td = next_d\r\n\t\t\telse\r\n\t\t\t\tu_ = b - next_u\r\n\t\t\t\td_ = -next_d\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\tv = (d - a * u) / b\r\n\r\n\t\tu, v = v, u if exchange_flag_2\r\n\t\td <<= _K\r\n\t\tu, v = v, u - v * _Q\r\n\t\tu, v = v, u if exchange_flag_1\r\n\r\n\t\treturn u, v, d\r\n\tend", "def is_magic_three(array)\n # Your code goes here\n if array == [0]\n true\n else\n sumas = array.combination(3).to_a.collect { |item| item.inject(0, :+) }\n\n puts sumas\n check = sumas.collect { |item| true if item == 0 }\n puts check\n check.include? true\n end\nend", "def reduce_to_any_true(source_array)\n counter = -1 \n while counter < source_array.length\n counter += 1\n while source_array[counter]\n if source_array[counter] == true\n return true\n else\n counter += 1\n end\n end\n end\n return false\nend", "def solve!\n c = i = changed = 0\n while i = ((i+1)..(changed+81)).find{|x|!cells[x % 81]}\n NEIGHBOURHOODS[c = i % 81].each do |neighbours|\n pn = neighbours.inject(possibilities[c]){|r, j| (j != c) ? (r &\n~possibilities[j]) : r}\n if v = SINGLEBIT[pn]\n set_cell(changed = i = c, v) \n break \n end\n end\n end\n\n return self if cells.all?\n return nil if possibilities.any?{|p| p.zero?}\n\n p, i = possibilities.zip((0..80).to_a).select{|a, b|numbits(a) > 1}.\n min{|a, b|numbits(a[0]) <=> numbits(b[0])}\n\n eachbit(p){|j| b=clone.set_cell(i, j).solve! and return b}\n return nil\n end", "def gcd(a, b)\n # always consider that a > b\n b.downto(1) do |num|\n if b % num == 0\n return num if a % num == 0\n end\n end\nend", "def gcd(a,b)\n while a != b\n if a > b\n return gcd(a - b,b)\n else\n return gcd(a , b - a)\n end\n end\n return a\nend", "def roots (a, b, c)\n array = Array.new(3)\n if a != 0\n arg = b*b - 4 * a * c\n if arg >= 0\n array[0] = true\n array[1] = (-b + Math.sqrt(arg))/(2*a)\n array[2] = (-b - Math.sqrt(arg))/(2*a)\n else\n print \" roots(): b^2 - 4ac is negative!\"\n array[0] = false\n array[1] = array[2] = 0.0 \n end\n else\n print \" roots(): a is zero!\"\n array[0] = false\n array[1] = array[2] = 0.0\n end\n array\nend", "def array_42(array)\n a = false\n\tarray.each {|i| if i == 42 then a = true end}\n return a \nend", "def got_three? (array)\n arr=[]\n(1..array.length-2).each{|x| arr.push(true) if array[x-1]== array[x] && array[x+1]== array[x] }\narr.include?(true)\nend", "def light_switcher(array, inc)\n counter = 0\n\n while counter < array.length\n array[counter] = !array[counter] if (counter + 1) % inc == 0\n counter += 1\n end\n\n array\nend", "def prime_chars(arr)\n x = 0\n arr.map! {|y| y.length}\n arr.each { |i| x+=i }\n return x\n if x.downto(2).each {|z| return false if x % z == 0}\n true\n end\nend", "def find_duplicates(a)\n len=a.length\n n=len-2\n xor= 0\n x,y=0,0 #variables to store duplicates\n \n #xor of all numbers from 1 to n\n for i in 1..n \n xor^=i\n end\n #xor of all array elements\n for i in 0...len \n xor^=a[i]\n end\n #Rightmost set bit\n set_bit_pos= xor & ~(xor-1)\n #Divinding array in two sets ,one with set bit at set_bit_pos and other with 0.\n for i in 0...len\n if (a[i] & set_bit_pos == 0)\n x^=a[i] # XOR of first-set(with 0 at set_bit_pos) in array\n else\n y^=a[i] # XOR of second-set(with 1 at set_bit_pos) in array\n end\n end\n \n for i in 0..n\n if (i & set_bit_pos == 0)\n x^=i # XOR of first-set(with 0 at set_bit_pos) in range\n else\n y^=i # XOR of second-set(with 1 at set_bit_pos) in range\n end\n end\n print \"#{x} #{y}\"\n\treturn\nend", "def new_array\n\tfull_array.map! {|x| #We call upon the definition from above to create the conditionals for this \n\t\t #function. By defining these arrays (full and new) in separate functions, it \n\t #allows testing to run in increments. \n\t #The block argument (pipes) isolate the element within the array that will be \n\t\t #called upon.\n\t#Using 'map' lays out the array 1-100 (element after element joined together, yet separated by commas).\n\t#Using the exclamation point with map makes sure the array doesn't return back to the \n\t#1-100 array after the changes were made/if there isn't an exclamation point then\n\t#the array would revert back to what it was prior to the changes(conditionals).\n\t\tif x % 3 == 0 && x % 5 == 0 #The double ampersand symbol means 'and' in this case.\n\t\t\t\"mined_minds\" #This is what will replace the current element within the array.\n\t\telsif x % 3 == 0 #The percent sign is a modulo operater in this case--meaning 'if x is divisble \n\t\t\t\"mined\" #by 3 with no remainders' (\"mined\" will replace any element divisible by 3)\n\t\telsif x % 5 == 0 #The percent sign is a modulo operater in this case--meaning 'if x is divisble\n\t\t\t\"minds\" #by 5 with no remainders' (\"minds\" will replace any element divisible by 5)\n\t\telsif x == 11 #The double equals sign means that \"if x 'is the same' as 11\" when the elements \n\t\t\t\"class\" #are cycling through. \n\t\telse\n\t\t\tx #This means that the element within the array must be returned if the element doesn't meet \n\t\t\t #any of the requirements in any of the conditionals listed above.\n\t\tend #Must include 'end' to close out the conditional (lines up with the beginning of 'if' statements)\n\t} #The curly brackets are used when referencing the conditional and replaces the word 'do' in this case.\n\n\t\nend", "def gcd(a, b)\n # Everything divides 0\n return b if a == 0\n\n return a if b == 0\n\n # base case\n return a if a == b\n\n # a is greater\n return gcd(a - b, b) if a > b\n\n gcd(a, b - a)\nend", "def left_rotate_array_optimized(arr, d, n)\n \n gcd = gcd(d, n) - 1\n \n (0..gcd).each do |i|\n temp = arr[i]\n j = i\n while 1\n k = j + d\n k = k - n if k >=n\n break if k == i\n arr[j] = arr[k]\n j = k\n end\n arr[j] = temp\n end\n return arr\nend", "def combinations(arr)\n \tsolution = []\n\tarr.each do |i|\n arr.each do |j|\n if (j > i)\n solution.push([i,j]) \t\n end\n end\n end\n return solution\nend", "def match_maker(a, *b)\n\tarray = (0...b.count).to_a\n\tnew_array = []\n\tanswer = []\n\tarray.each_slice(2){ |i| new_array << i }\n\t\nif a == false\n\tnew_array.each { |i| \n\t\tb[i[0]], b[i[1]] = !!b[i[0]], !!b[i[1]]\n\t\tb[i[0]] == b[i[1]] ? answer << true : answer << false }\n\nelsif a == true\n\tnew_array.each { |i|\t\t\n\t\tb[i[0]], b[i[1]] = !!b[i[0]], !!b[i[1]]\n\t\tb[i[0]] != b[i[1]] ? answer << true : answer << false }\nelse\nend\nanswer\nend", "def calculate_truth_table\r\n false_s = @char_set[0]\r\n truth_s = @char_set[1]\r\n @table_array.each do |x|\r\n trues = x.count(truth_s)\r\n trues == @size ? x.push(truth_s) : x.push(false_s)\r\n trues > 0 ? x.push(truth_s) : x.push(false_s)\r\n trues.odd? ? x.push(truth_s) : x.push(false_s) \r\n end\r\n end", "def solve!\n\n until solved?\n\n\n @cell_array.each do |cell_object|\n cell_object.refresh_possible_values(@cell_array)\n if cell_object.value == 0 && cell_object.possible_values.length == 1\n cell_object.value = cell_object.possible_values[0]\n end\n end\n\n end\n\n board\n\n end", "def gcd( a, b )\r\n\t\t\treturn (b*(a%b))/lcm(b,a%b)\r\n\t\tend", "def reduce_to_any_true(source_array)\n i = 0\n\n while i < source_array.length do\n if source_array[i] == true\n return true\n end\n i += 1\n end\n \n return false\nend", "def gcd(n, m)\n n % m == 0 ? m : gcd(m, n % m)\nend", "def coprime(a,b)\n a.gcd(b) == 1\nend", "def xgcd_rec(x, y)\n if y == 0\n [x, 1, 0]\n else\n gcd, a, b = xgcd_rec(y, x%y)\n [gcd, b, a-x/y*b]\n end\nend", "def gcd(x, y)\n until y.zero?\n # puts \"#{x} #{y}\"\n x, y = y, mod(x, y)\n end\n x\n end", "def squaragonal?(arr)\n left_daig(arr) || right_daig(arr)\nend", "def fill_array rows, cols, num, val\n num = 0 if num < 0\n array = Array.new(rows) { Array.new(cols) { -1 } }\n (0...num).each { |i|\n row = (i / cols).floor\n col = i % cols\n array[row][col] = val\n }\n array\n end" ]
[ "0.5793098", "0.5723635", "0.56556046", "0.5555622", "0.5550151", "0.54802334", "0.5469398", "0.5458594", "0.54552", "0.53868484", "0.53839964", "0.5356436", "0.5348506", "0.53313214", "0.53196746", "0.5301599", "0.5231826", "0.5228158", "0.5216013", "0.5214886", "0.5181425", "0.51696396", "0.5165776", "0.51607186", "0.5156104", "0.5145754", "0.5142497", "0.5142332", "0.51393986", "0.51391715", "0.5135288", "0.5130156", "0.512911", "0.5126842", "0.51206493", "0.51115876", "0.51026374", "0.5098675", "0.5095052", "0.5094006", "0.50912803", "0.50714076", "0.50645536", "0.5062774", "0.50527847", "0.5045654", "0.5039352", "0.5019683", "0.5010268", "0.49797127", "0.4975335", "0.4974133", "0.49710634", "0.4966947", "0.49663365", "0.49619257", "0.496013", "0.49488723", "0.49480593", "0.49480104", "0.4945625", "0.49439946", "0.49402195", "0.4926033", "0.49224493", "0.49112839", "0.4904727", "0.4896234", "0.4893418", "0.48846525", "0.4884276", "0.4882729", "0.48725754", "0.48651215", "0.4864985", "0.4863582", "0.4861239", "0.4859167", "0.48579925", "0.48569497", "0.4854732", "0.48512194", "0.48505065", "0.48426938", "0.4839144", "0.4827441", "0.4821838", "0.48200226", "0.48176438", "0.48072606", "0.48021656", "0.48008052", "0.4798693", "0.4797017", "0.4793961", "0.4783812", "0.4781991", "0.47783345", "0.47780856", "0.4774525" ]
0.60851043
0
3.4 solve the josephus problem with an array N people have decided to commit mass suicide by arranging themselves in a circle and killing the mth person around the circle, closing ranks as each person drops out of the circle. find out the order in which the people die
def josephus(n,m) arr = Array.new order = Array.new for i in 1..n arr[i] = i end arr.compact! for i in 0..n-1 arr= arr.rotate(m-1) order << arr[0] arr[0] = nil arr.compact! end puts "order: #{order.to_s}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def josephus_survivor(n,k)\n # (1..n) people are put into the circle\n items = (1..n).to_a\n Array.new(n){items.rotate!(k-1).shift}.last\nend", "def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n result = (result + k - 1) % i + 1\n end\n \n result\nend", "def josephus(n,m)\n\n while n.size>0\n puts n.rotate!(m-1).shift(1)\n josephus(n,m)\n end\nend", "def josephus_survivor(n,k)\n arr = (1..n).to_a\n\n while arr.length > 1\n idx = k % arr.length\n\n if arr.length > k\n arr = arr.drop(k) + arr.take(k - 1)\n elsif arr.length == k \n arr = arr[0...-1]\n else\n arr = arr.drop(idx) + arr.take(idx - 1)\n end\n end\n \n arr[0]\nend", "def kill_sequence(n, m)\n people = Array.new(n, true) # true = alive\n sequence = []\n index = -1\n\n while sequence.length < n\n # Advance through list until we've landed on the mth alive person\n count = 0\n while count < m\n index = (index + 1) % n\n count += 1 if people[index]\n end\n\n # Kill them\n people[index] = false\n sequence << index\n end\n\n sequence\nend", "def josephus(items,k)\n n = -1\n out = []\n while items.length > 0 do \n n = (n + k) % items.length \n out.push(items.slice!(n))\n n -= 1 \n end\n out\nend", "def josephus(n,k)\n if(n == 1)\n return 0\n end\n\n (josephus(n-1, k) + k) % n\nend", "def solution(a)\n\traise ArgumentError.new(\"a has to be non empty array of max size #{MAX_LEN}\") if !a.is_a? Array or a.empty? or a.length > MAX_LEN\n\tret = 0\n\t#puts a.inspect\n\tmy_h = Hash.new\n\ta.each do |e|\n\t\tif my_h.include? e\n\t\t\tmy_h[e] += 1\n\t\telse\n\t\t\tmy_h[e] = 1\n\t\tend\n\tend\n\n\tmy_h_sort = my_h.sort_by {|k, v| -v}\n\t# -> my_h_sort[value][occurances]\n\treturn 0 if my_h_sort.first[1] < a.size/2\n\tleader_val = my_h_sort.first[0]\n\n\tocc_array = Array.new\n\toccurances = 0\n\ta.each do |e|\n\t\toccurances += 1 if e == leader_val\n\t\tocc_array.push(occurances)\n\tend\n\t#puts occ_array.inspect\n\n\tfor idx in (0...a.length-1) do\n\t\tsum1 = occ_array[idx]\n\t\tsum2 = occ_array.last - occ_array[idx]\n\n\t\t# puts \"#{idx}+1 < #{sum1*2}\"\n\t\t# puts \"#{(a.length - idx -1)} < #{(sum2*2 )} \"\n\n\t\tif (idx+1) < sum1 * 2 && (a.length - idx - 1 ) < sum2 * 2\n\t\t\t## we have a leader\n\t\t\t#puts \"YEAH #{idx}\"\n\t\t\tret += 1\n\t\tend\n\t\t\t#puts \"-------- ret: #{ret}\"\n\tend\n\treturn ret\nend", "def death(arr,pos,m)\n #define an empty result string\n result = \"\"\n #If the array size is 1, just return the first index\n if arr.size == 1\n return arr[0].to_s\n end\n #If the position is bigger than the size of the array\n if pos+m > arr.size\n #Set the pos back into size of the array\n pos = (pos+m)%arr.size\n # append the number in the position to result\n result << arr[pos].to_s\n #delete the number (a.k.a. kill it)\n arr.delete_at(pos)\n #Append to result a recursive call to death\n result += death(arr,pos,m)\n #return the result\n return result\n end\n #If the position is small than the size of the array\n if arr.size > pos+m \n #The next target is updated according to m\n pos = pos + m\n #Append the number in the position to result\n result << arr[pos].to_s\n #delete the number (a.k.a. kill it)\n arr.delete_at(pos)\n #Append the result of a recursive call to death\n result += death(arr,pos,m)\n \n return result\n end\n #if the target is past the end of the array\n if arr.size == pos+m \n #set the position to 0\n pos = 0\n #Append that number\n result << arr[pos].to_s\n #delete it\n arr.delete_at(pos)\n #Append the result of a recursive call to death\n result += death(arr,pos,m)\n #return\n return result\n end\nend", "def find_celebrity(n)\n current = 0\n while true\n next_person = (current + 1) % n\n while next_person != current && !knows(current, next_person)\n next_person = (next_person + 1) % n\n end\n if next_person == current\n 0.upto(n - 1) do |other|\n next if other == current\n return -1 unless knows(other, current)\n end\n return current\n end\n break if current == n - 1\n if next_person > current\n current = next_person \n else\n current += 1\n end \n end\n -1\nend", "def phase_one\r\n # start with empty elimination array\r\n council_elimination = []\r\n # loop 8 times (game mechanics)\r\n 8.times do\r\n # tribe which has lost the challenge\r\n loosing_tribe = @borneo.immunity_challenge\r\n # tribal council for the loosing tribe will eliminate one participants\r\n council_elimination << loosing_tribe.tribal_council\r\n end\r\n # return all eliminations (used for the test szenario)\r\n return council_elimination.length\r\nend", "def problem_108(size = 1001)\n func = lambda do |a|\n if a.length == 1\n a[0]+1\n else\n m = a[0]\n (2*m+1) * func.call(a[1,a.length]) -m\n end\n end\n\n primes = Primes.upto(200)\n prime_number = lambda do |a|\n r = 1\n a.sort.reverse.each_with_index { |m,i| r *= primes[i] ** m }\n r\n end\n\n values = {}\n last = 0\n 1.upto(100).each do |nn|\n nn.groupings do |a|\n sols = func.call a\n ans = prime_number.call a\n# puts \"np=#{nn} sols=#{sols} ans=#{ans} => #{a.inspect}\"\n if values[sols]\n values[sols] = [values[sols],[ans,a]].min\n else\n values[sols] = [ans,a]\n end\n true\n end\n size.upto(size*5/4) do |num|\n if values[num]\n puts \"for np = #{nn} => #{num} => #{values[num].inspect}\"\n if last == values[num]\n puts \"factors = #{values[num][0].factors}\"\n return values[num][0] \n end\n last = values[num]\n break\n end\n end\n #values.sort.each do |k,v|\n # puts \"#{k} => #{v}\"\n #end\n end\n nil\nend", "def phase_one\n eliminated = []\n 8.times do\n elim_tribe = @borneo.immunity_challenge\n index = @borneo.tribes.index(elim_tribe)\n element = elim_tribe.tribal_council\n @borneo.tribes[index].members = @borneo.tribes[index].members - Array(element)\n eliminated << element\n end\n puts \"Phase 1 eliminations: \".red\n puts \"----------------------------------------\"\n eliminated.each_with_index do |contestants,index|\n puts \"#{index+1}: #{contestants}\"\n end\n puts \"----------------------------------------\"\n eliminated.length\nend", "def josephus(items,k)\n result = []\n count = k\n until items.length == 0 do\n remove_these = []\n items.each_with_index do |item, i|\n if count == 1\n result << items[i]\n remove_these << i\n end\n count = count == 1 ? k : count -= 1\n end\n remove_these.reverse!\n remove_these.each do |r|\n items.delete_at(r)\n end\n end\n result\nend", "def pythagoreans (n)\r\n pythagoreans = Array.new\r\n for i in 1..n\r\n for h in 1..i\r\n sum = Math.sqrt(i**2+h**2)\r\n if sum%1 == 0 && sum <= n\r\n temp = [i,h,sum.round]\r\n temp.sort!\r\n pythagoreans.push(temp)\r\n end\r\n end\r\n end\r\n pythagoreans.sort!\r\n return pythagoreans\r\nend", "def josephus(items,k)\n killed = []\n # loop the following two until items == []\n until items.length == 0 do\n items = items.rotate(k)\n killed << items.pop\n end\n killed\nend", "def solve( n = 2_000 )\n # We can classify every tile according to its angular position around the\n # unit circle, setting position 0 at the top since that's where each row\n # starts in the problem statement. Positions 1-5 then follow every 60° as\n # we work our way counter-clockwise. Depending on which of these positions\n # each tile falls (or between which pair of positions), we use different\n # formulae to calculate its six neighbors to the N, NW, SW, S, SE, and NE:\n # \n # Pos 0: n even = fhp\n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n + ring - 1 (f)\n # SW = n + 1 NE = n + (2*ring + 5) (p)\n #\n # Pos 0-1: n even = bh, n odd = ag \n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + 1 NE = n - 1\n #\n # Pos 1: n even = bh, n odd = gi\n # N = n + ring (g) S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - 1\n #\n # Pos 1-2: n even = bh, n odd = ci\n # N = n - 1 S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2: n even = hj\n # N = n - 1 S = n + ring + 3 (j)\n # NW = n + ring + 1 (h) SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2-3: n even = dj, n odd = ci\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 3: n even = dj, n odd = ik\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + ring + 4 (k)\n # SW = n + ring + 2 (i) NE = n + 1\n #\n # Pos 3-4: n even = dj, n odd = ek\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + 1\n #\n # Pos 4: n even = jl\n # N = n + 1 S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + ring + 5 (l)\n #\n # Pos 4-5: n even = fl, n odd = ek\n # N = n + 1 S = n - 1\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5: n even = fl, n odd = km\n # N = n + ring + 6 (m) S = n - 1\n # NW = n + 1 SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, except last: n even = fl, n odd = gm\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n + 1 SE = n - 1\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, only last: n even = flo, n odd = gmo\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n - ring + 1 (f) SE = n - 1\n # SW = n - (2*ring - 7) (o) NE = n + ring + 5 (l)\n #\n # From these formula, we can derive the difference between a tile and each\n # of its neighbors. If we arrange all potential differences in ascending\n # order, it becomes obvious that for n even or odd, some deltas will al-\n # ways be even, and thus can never be prime (>2).\n #\n # Furthermore, we can see that only in certain positions will a tile ever\n # differ from three neighbors by odd amounts (position 0 and just to the\n # right of position 0). In all other cases, at most two deltas will be\n # odd, meaning PD(n) will be 2 or less.\n #\n # n even n odd\n # a = ring - 6 even a\n # b = ring - 5 b even\n # c = ring - 4 even c\n # d = ring - 3 d even\n # e = ring - 2 even e\n # f = ring - 1 f even\n # g = ring even g\n # h = ring + 1 h even\n # i = ring + 2 even i\n # j = ring + 3 j even\n # k = ring + 4 even k\n # l = ring + 5 l even\n # m = ring + 6 even m\n # o = 2ring - 7 o o\n # p = 2ring + 5 p p\n pd3 = [1, 2]\n base, ring = 8, 12\n \n while pd3.size < n\n # Only at position 0 and one tile to the right will there ever be three\n # odd deltas, so those are the only ones we have to check for primality.\n # Both share a delta of f = ring - 1.\n if (ring - 1).prime?\n # Check the other odd deltas for position 0. \n pd3 << base if (ring + 1).prime? && (2*ring + 5).prime?\n\n # Check the other odd deltas for one tile to the right of position 0.\n pd3 << base + ring - 1 if (ring + 5).prime? && (2*ring - 7).prime?\n end\n\n # Advance the first tile of the current ring (base), and the number of\n # tiles it contains (ring). \n base += ring\n ring += 6\n end\n\n pd3[-1]\n end", "def move_people(result)\n j=0\n while j<@projects.length do\n #(2) Find the most popular array, and move out those's whos second choice is a project that is incomplete. \n mostpopular_project= find_mostpopular_project(result)\n if result[mostpopular_project].length > @groupsizemax then\n i=result[mostpopular_project].length-1\n while(result[mostpopular_project].length>@groupsizemax && i>=0)\n #move students ID from this popular array to other array that are incomplete\n unlucky_student= result[mostpopular_project][i]\n second_choice= @preferences.find {|project| project['student_id']= unlucky_student} [:second]\n if(result[second_choice].length < @groupsizemax) then\n result[mostpopular_project].delete(unlucky_student)\n result[second_choice] << unlucky_student\n end\n i=i-1\n end\n end\n\n #(3) Find the most popular array, and move out those's whos third choice is a project that is incomplete. \n if result[mostpopular_project].length > @groupsizemax then\n i=result[mostpopular_project].length-1\n while(result[mostpopular_project].length>@groupsizemax && i>=0)\n #move students ID from this popular array to other array that are incomplete \n unlucky_student= result[mostpopular_project][i]\n #puts @preferences.inspect\n second_choice= @preferences.find {|project| project['student_id']= unlucky_student} [:third]\n if(result[second_choice].length < @groupsizemax) then\n result[mostpopular_project].delete(unlucky_student)\n result[second_choice] << unlucky_student\n end\n i=i-1\n end\n end\n \n #(4) If the array is still overpopulated, use random algo to move students out\n while result[mostpopular_project].length > @groupsizemax \n puts @grousizemin.inspect\n poor_student = result[mostpopular_project].delete(result[mostpopular_project].sample)\n result[result.find{|key,value| key != mostpopular_project && value.length<=@grousizemin}[0]] << poor_student\n end\n j=j+1\n\n \n end\n\n #(5) check for group that has too little students\n # puts \"current form:\", result.inspect\n unfilled = result.find{|key,value| value.length<@grousizemin}\n # puts unfilled.inspect\n while(!unfilled.nil?) do\n most_p= find_mostpopular_project(result)\n poor_student = result[most_p].delete_at(result[most_p].size-1)\n result[unfilled[0]] << poor_student\n unfilled = result.find{|key,value| value.length<@grousizemin}\n end\n puts \"current form after project Assign:\", result.inspect\n return result\n end", "def minimumBribes(q)\n bribe_count = 0\n # q.each_with_index do |person,i|\n i = q.size-1\n while i >= 0 do\n person = q[i]\n position = i+1\n offset = person - position\n\n if offset > 2\n puts \"Too chaotic\"\n return\n else\n j=[0,person-2].max\n while j < i do\n if q[j] > person\n bribe_count += 1\n else\n # break if j+1 == person\n end\n j+=1\n end\n end\n i-=1\n end\n puts bribe_count\nend", "def josephus(items,k)\n new_array = []\n while items.size > (k-1)\n new_array << items.delete_at(k-1)\n items.rotate!(k-1)\n end\n while items.size > 0\n items.rotate!(k-1)\n new_array << items.delete_at(0)\n end\n new_array\nend", "def correct(element)\n result = nil\n element.downto(0).each do |j|\n i = element - j\n if j == element && j % 3 == 0\n result = Array.new(j, 5)\n elsif i % 5 == 0 && j % 3 == 0\n result = Array.new(j, 5) + Array.new(i, 3)\n elsif i == element && i % 5 == 0\n result = Array.new(i, 3)\n end\n\n break if result\n end\n\n if result.nil?\n puts -1\n else\n puts result.join()\n end\nend", "def breed(players)\n (0..4).each do |i|\n players[i].successor(0, players[(i + 1) % 5])\n players[i].successor(1, players[(i - 1) % 5])\n players[i].successor(2, players[(i + 2) % 5])\n end\n end", "def icecreamParlor(m, arr)\n # Complete this function\n res = []\n arr.each_index do |i|\n if i + 1 !=nil\n j = i + 1\n while j <= arr.length - 1\n if arr[i]+arr[j] == m\n res.push([i+1,j+1])\n end\n j+=1\n end\n end\n end\n res\nend", "def pythagoreans (n)\n return (1..n).to_a.permutation(3).to_a.select { |a,b,c| a**2 + b**2 == c**2 }.each(&:sort!).uniq\nend", "def candies(n, arr)\n cc = []\n cc[0] = 1\n 1.upto(n-1) do |i|\n if arr[i] > arr[i-1]\n cc[i] = cc[i-1] + 1\n else\n cc[i] = 1\n end\n end\n p cc\n (n-2).downto(0) do |i|\n if arr[i] > arr[i+1] && cc[i] <= cc[i+1]\n cc[i] = cc[i+1] + 1\n end\n end\n p cc\n cc.reduce(:+)\nend", "def sol inp\n k, ins = inp.split(' ',2)\n k = k.to_i\n ps, pr, pi, pu, pw, pd, pl = ins.split.map(&:to_f)\n\n @ps = ps\n @pr = pr\n @pu = pu\n @pw = pw\n @pd = pd\n @pl = pl\n\n #\n # required_wins = 2\n # # winning 1st set\n # first_set = ps*pi + pr*(1-pi)\n # # winning 2nd set\n # first_set * winning_another_set + (1-first_set)*winning_another_set\n #\n # required_wins.times do |i|\n # count = 0\n # while count <= i\n # wins[i] = win_scene(pi,ps,pr, count)\n # count+=1\n # break if count == i\n # lose_scene(pi,ps,pr, pr,count)\n # end\n # end\n\n # winning second set after winning first + winning second set after winning one\n # wins[0]*win_scene(pi,ps,pr) + (1-wins[0])*lose_scene(pi,ps,pr)\n\n def win_scene(pi,round,required_wins,current_wins)\n return 0 if round >= required_wins\n # puts \"w #{' '*round},#{required_wins},#{current_wins})\"\n sunny = (round == 0) ? pi : (pi+(@pu*@pw))\n sunny = 1.0 if sunny > 1\n sunny = 0.0 if sunny < 0\n chance = sunny*@ps + (1-sunny)*@pr\n binding.pry if chance > 1\n\n if required_wins == current_wins+1\n chance\n else\n # return 0 if round > 100\n return 0 if (10**7*chance).to_i < 1\n wins = win_scene(sunny,round+1,required_wins,current_wins+1)\n # lose = lose_scene(sunny,round+1,required_wins,current_wins+1)\n chance * (wins)#+ (1-chance)*lose\n end\n end\n\n def lose_scene(pi,round,required_wins,current_wins)\n return 0 if round >= required_wins\n # puts \"l #{' '*round},#{required_wins},#{current_wins})\"\n sunny = (round == 0) ? pi : (pi-(@pd*@pl))\n sunny = 1.0 if sunny > 1\n sunny = 0.0 if sunny < 0\n chance = sunny*@ps + (1-sunny)*@pr\n binding.pry if chance > 1\n\n if required_wins == current_wins\n chance\n else\n # return 0 if round > 100\n return 0 if (10**7*chance).to_i < 1\n wins = win_scene(sunny,round+1,required_wins,current_wins+1)\n # lose = lose_scene(sunny,round+1,required_wins,current_wins+1)\n chance * (wins) #+ (1-chance)*lose\n end\n end\n\n # a = win_scene(pi,0,1,0)\n b = win_scene(pi,0,k,0)\n c = lose_scene(pi,0,k,0)\n # c = (k > 1) ? lose_scene(pi,1,k,0) : 0\n\n puts b\n puts c\n b +c\n # wtf?\n # 0.4* win_scene(pi,0,k,0)+ (1-0.6)*lose_scene(pi,0,k,0)\n\n# def smth(pi, ps, pr, setcount=0)\n# arr[1] = arr[0]\n# end\n# # set 2+ ?\n# set2 = ((ps+pu)*pw + ps*(1-pw))*pi\n# (1-set1)*((ps-pd)*pl + ps*(1-pl))\n# if k > 1\n# (k-1).times do\n#\n# end\n# end\nend", "def problem_108a\n i = 4\n max = 0\n solve = {}\n loop do\n num = 0\n a = Rational(1,i)\n 2.upto(i*2+1) do |j|\n if (a - Rational(1,j)).numerator == 1\n num += 1 \n# puts \"(#{a} - #{Rational(1,j)} == #{a - Rational(1,j)}\"\n end\n end\n\n solve[num] = [] unless solve[num]\n solve[num] << i.factors\n\n if num >= max\n puts \"####################################\"\n solve.each_key.sort.each do |k|\n s = solve[k].map do |v|\n h = {}\n v.each {|a| h[a] = (h[a] || 0) + 1 }\n h.values.sort.flatten\n end.uniq.sort\n puts \"k = #{k} groups: #{s.inspect}\"\n# puts solve[k].inspect\n end\n puts \"#{i} = #{num} #{i.factors} #{i.factors.length + i.divisors.length}\" \n max = num\n end\n break if num > 1000\n i += 1\n end\n i\nend", "def solve( n = 100 )\n n.partition_sieve[-1] - 1\n end", "def minimumBribes(q)\r\n moves = 0\r\n r = (0..q.size-1).to_a\r\n\r\n until q == (1..q.size).to_a do\r\n q.map { |a| a - 1 }\r\n .reverse_each.with_index do |person, i|\r\n i = q.size - i - 1\r\n if person - i > 2\r\n puts \"Too chaotic\"\r\n return\r\n end\r\n\r\n if person > r[i] && person > q[person] -1\r\n moves += person - r[i]\r\n q = q - [person + 1]\r\n q.insert(person, person + 1)\r\n end\r\n end\r\n end\r\n\r\n puts moves\r\nend", "def coast_guard_rank; end", "def josephus(arr, k)\n removed_elements = []\n while arr.length > 0 do\n arr = arr.rotate(k)\n removed_elements << arr.pop\n end\n removed_elements\nend", "def verify(ans_arr, arr)\n p1 = []\n p2 = []\n [0,1,2].each do |i|\n [0,1,2].each do |j|\n if arr[i][j] == 1 \n p1.push(ans_arr[i][j])\n elsif arr[i][j] == 0\n p2.push(ans_arr[i][j]) \n end\n end\n end\n \n if p1.length == 3 \n puts \"Player entering 1 won\" if p1[p1.length-1] + p1[p1.length-2] + p1[p1.length-3] == 15\n end\n if p1.length == 4\n puts \"Player entering 1 won\" if p1[p1.length-1] + p1[p1.length-2] + p1[p1.length-4] == 15\n puts \"Player entering 1 won\" if p1[p1.length-2] + p1[p1.length-3] + p1[p1.length-4] == 15\n puts \"Player entering 1 won\" if p1[p1.length-1] + p1[p1.length-3] + p1[p1.length-4] == 15\n end\n if p1.length == 5\n puts \"Player entering 1 won\" if p1[p1.length-1] + p1[p1.length-2] + p1[p1.length-5] == 15 || \n p1[p1.length-1] + p1[p1.length-3] + p1[p1.length-5] == 15 ||\n p1[p1.length-1] + p1[p1.length-4] + p1[p1.length-5] == 15 ||\n p1[p1.length-2] + p1[p1.length-3] + p1[p1.length-5] == 15 ||\n p1[p1.length-2] + p1[p1.length-4] + p1[p1.length-5] == 15 || \n p1[p1.length-3] + p1[p1.length-4] + p1[p1.length-5] == 15 \n end\n if p2.length == 3 \n puts \"Player entering 0 won\" if p2[p2.length-1] + p2[p2.length-2] + p2[p2.length-3] == 15\n end\n if p2.length == 4\n puts \"Player entering 0 won\" if p2[p2.length-1] + p2[p2.length-2] + p2[p2.length-4] == 15\n puts \"Player entering 0 won\" if p2[p2.length-2] + p2[p2.length-3] + p2[p2.length-4] == 15\n puts \"Player entering 0 won\" if p2[p2.length-1] + p2[p2.length-3] + p2[p2.length-4] == 15\n end\n if p2.length == 5\n puts \"Player entering 0 won\" if p2[p2.length-1] + p2[p2.length-2] + p2[p2.length-5] == 15 || \n p2[p2.length-1] + p2[p2.length-3] + p2[p2.length-5] == 15 ||\n p2[p2.length-1] + p2[p2.length-4] + p2[p2.length-5] == 15 ||\n p2[p2.length-2] + p2[p2.length-3] + p2[p2.length-5] == 15 ||\n p2[p2.length-2] + p2[p2.length-4] + p2[p2.length-5] == 15 || \n p2[p2.length-3] + p2[p2.length-4] + p2[p2.length-5] == 15 \n end\nend", "def solve( n = 16 )\n max = 0\n \n (1..10).each do |a|\n (1..10).each do |b|\n next if b == a\n (1..10).each do |c|\n next if c == b || c == a\n (1..10).each do |d|\n next if d == c || d == b || d == a\n (1..10).each do |e|\n next if e == d || e == c || e == b || e == a\n\n rotate = 3*[a, b, c, d, e].each_with_index.min[1]\n (1..10).each do |f|\n next if f == e || f == d || f == c || f == b || f == a\n (1..10).each do |g|\n next if g == f || g == e || g == d || g == c || g == b || g == a\n \n t = a + f + g\n (1..10).each do |h|\n next if h == g || h == f || h == e || h == d || h == c || h == b || h == a\n next unless t == b + g + h\n\n (1..10).each do |i|\n next if i == h || i == g || i == f || i == e || i == d || i == c || i == b || i == a\n next unless t == c + h + i\n\n (1..10).each do |j|\n next if j == i || j == h || j == g || j == f || j == e || j == d || j == c || j == b || j == a\n next unless t == d + i + j && t == e + j + f\n\n s = [a, f, g, b, g, h, c, h, i, d, i, j, e, j, f]\n rotate.times {s.push s.shift}\n\n s = s.join\n next if n != s.length\n\n max = [max, s.to_i].max\n end\n end\n end\n end\n end\n end\n end\n end\n end\n end\n\n max\n end", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def puppy_golden_age(arr)\r\n puppies = 0 # set the var for puppies born for later comparison\r\n years = [] # set empty array to later push the results of the comparison\r\n\r\n arr.each_with_index do |x, i| # looping through entire array. could have used #each_index without x.\r\n for i2 in i + 1...arr.length # set up loop for i2 which is needed to compare all elements in array above i1 and for return of second index. i + 1 protects against the return of the same index twice. see written test 3.\r\n if puppies < arr[i..i2].reduce(&:+) # comparison of the value puppies with the sum of the elements in arr where index > i.\r\n puppies = arr[i..i2].reduce(&:+) # if the net gain between these two indices is > the previous value for puppies, the new gain becomes the value\r\n years = [i, i2] # sets the indicies for the larger gain compared here: puppies < arr[i..i2].reduce(&:+)\r\n end\r\n end\r\n end\r\n\r\n years # when the loop is complete, the largest gain and their indicies will be set for the variables puppies/ years. question asks for the index of the years.\r\nend", "def pythagoreans (n)\n triples = []\n a = 1\n b = 1\n c = 1\n\n for c in (1..n)\n for b in (1..c)\n for a in (1..b)\n if a**2 + b**2 == c**2\n triples << [a,b,c]\n end\n end\n end\n end\n\n return triples.sort\nend", "def problem3 n\n 2.step(n,1).each do |x|\n return x-1 if n == 1\n n /= x if x.prime? && (n % x == 0)\n end\nend", "def josephus_survivor(n, k)\n survivors = (1..n).to_a\n loop do\n survivors.rotate!(k -1).shift\n return survivors[0] if survivors.length == 1\n end\nend", "def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend", "def threed(list)\n hasthree = 0\n inarow = 0\n list.size.times do |i|\n if list[i] == 3\n hasthree += 1\n end\n if list[i] == 3 && list[i+1] == 3 && i != (list.size - 1)\n inarow += 1\n end\n end\n if hasthree == 3 && inarow == 0\n return true\n else\n return false\n end\nend", "def runCase player_index\n\tp = player_index.sort_by{|val| val[0].power[1]}.reverse\n\ts = 0\n\ttemp = p[s][0]\n\tfor i in 0..player_index.length-2\n\t\tif(temp.power[1]==p[i+1][0].power[1])\n\t\t\twinner = 0\n\t\telsif(temp.power[1]<p[i+1][0].power[1] && temp.power[1]!=3)\n\t\t\twinner = p[i+1][1]\n\t\t\ttemp = p[i+1][0]\n\t\t\ts =i+1\n\t\telsif(temp.power[1]==3 && p[i+1][0].power[1]==14)\n\t\t\twinner = p[i+1][1]\n\t\t\ttemp = p[i+1][0]\n\t\t\ts =i+1\n\t\telse\n\t\t\twinner = p[s][1]\t\t\t\n\t\tend\t\n\tend\nend", "def pretentious_primes(arr, nth)\n\n arr.map do |ele|\n primes = 0\n i = ele\n\n if nth > 0\n while primes < nth\n i += 1\n primes += 1 if is_prime?(i)\n end\n i\n else \n while i > 0 && primes < -(nth)\n i -= 1\n primes += 1 if is_prime?(i)\n end\n i == 0 ? nil : i\n end\n end\n\nend", "def solve\n @time = Time.new\n for j in 0..@generations\n new_generation = Array.new\n @selection.init(@population)\n \n for i in 0..(@population_size/2)-1\n children = @reproduction.reproduce(@selection.select,@selection.select,@mutation)\n \n son = children[0]\n daughter = children[1]\n \n if son.fitness > @best_fitness\n @best_fitness = son.fitness\n @best_configuration = son.configuration.conf\n end\n \n if daughter.fitness > @best_fitness\n @best_fitness = daughter.fitness\n @best_configuration = daughter.configuration.conf\n end\n \n new_generation.push(son)\n new_generation.push(daughter)\n \n end\n \n @population = new_generation\n \n end\n @time = Time.new - @time\n end", "def detonate_mine(x,mines)\n a = []\n a << compare(x,mines)\n for i in 0...mines.length\n if a[0][i]\n a << compare(i,mines)\n end\n end\n#a # at this point a is an array of all the detonations that would happen\n a = a.inject { |result, element| array_or(result,element) }\n a.select{ |x| x }.count\nend", "def solve\n n = 33\n while true\n begin\n n += 2\n end while n.prime?\n\n s, ds = 2, 6\n while s < n && !(n - s).prime?\n s += ds\n ds += 4\n end\n\n break if s >= n\n end\n \n n\n end", "def replace_worst_ranked(offsprings)\n size = offsprings.length\n @population = @population [0..((-1*size)-1)] + offsprings\n end", "def solve2( n = 150_000_000 )\n # Brute force.\n sum = 10\n i = 20\n\n while i < n\n if 0 != i % 3\n i2 = i*i\n\n # Must verify that the primes are consecutive (i.e. there aren't any\n # primes hiding between entries).\n if (i2 + 1).miller_rabin? &&\n (i2 + 3).miller_rabin? &&\n (i2 + 7).miller_rabin? &&\n (i2 + 9).miller_rabin? &&\n !(i2 + 11).miller_rabin? &&\n (i2 + 13).miller_rabin? &&\n !(i2 + 17).miller_rabin? &&\n !(i2 + 19).miller_rabin? &&\n !(i2 + 21).miller_rabin? &&\n !(i2 + 23).miller_rabin? &&\n (i2 + 27).miller_rabin?\n \n sum += i\n i += 315410\n end\n end\n\n # From observation that 10 | a_n in similar sequences.\n i += 10\n end\n\n sum\n end", "def gimme(input_array)\n sorted_arr = input_array.sort\n median = (sorted_arr.length / 2)\n middle_element_index = 0\n i = 0\n\n input_array.length.times do\n if sorted_arr[median] == input_array[i]\n middle_element_index = i\n end\n i += 1\n end\n\n return middle_element_index\nend", "def find_fork(wins, forker, forkee)\n position_counts = count_positions(wins, forker, forkee)\n forking_moves = []\n position_counts.each do |position, count|\n forking_moves.push(position) if count > 1\n end\n forking_moves = (forking_moves - (forking_moves & forker))\n forking_moves.empty? ? [] : forking_moves\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 majority(array)\n \n array.sort!\n puts array[array.length/2]\n \n end", "def problem_76a\n num = 100\n solve = lambda do |a,off,max|\n n = 0\n while a[off] < max && (a.length-off) >= 2 \n a[off] += a.pop\n n += 1\n n += solve.call(a.dup,off+1,a[off]) if a.length - off > 1\n end\n n\n end\n puts 1 + solve.call([1] * num, 0,num-1)\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend", "def solveProblem lst\n big = -1\n numbers = {}\n half = lst.length / 2\n lst.each do |i|\n if numbers.has_key?(i) then\n numbers[i] += 1\n else\n numbers[i] = 1\n end\n if numbers[i] > half then return i end\n end\n return big\nend", "def pzoe\n sum = 0\n (0..9).each do |a|\n (0..9).each do |b|\n (0..9).each do |c|\n (0..9).each do |e|\n (0..9).each do |f|\n (0..9).each do |g|\n sum += a * 100000 + b * 10000 + c * 1000 + e * 100 + f * 10 + g if a * 100000 + b * 10000 + c * 1000 + e * 100 + f * 10 + g == a ** 5 + b ** 5 + c ** 5 + e ** 5 + f ** 5 + g ** 5\n end\n end\n end\n end\n end\n end\n sum - 1\nend", "def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend", "def solution1(seeds)\n turn_map = {}\n seeds.each_with_index { |n, turn| turn_map[n] = [1, turn + 1, turn + 1] }\n last_number = seeds.last\n\n ((seeds.length+1)..2020).each do |turn|\n last_stats = turn_map[last_number]\n if last_stats[TIMES_SPOKEN] == 1\n zero = turn_map[0] || [0, turn, turn]\n zero[TIMES_SPOKEN] += 1\n zero[FIRST_SPOKEN] = zero[LAST_SPOKEN]\n zero[LAST_SPOKEN] = turn\n \n turn_map[0] = zero\n last_number = 0\n else\n age = last_stats[LAST_SPOKEN] - last_stats[FIRST_SPOKEN]\n\n num = turn_map[age] || [0, turn, turn]\n num[TIMES_SPOKEN] += 1\n num[FIRST_SPOKEN] = num[LAST_SPOKEN]\n num[LAST_SPOKEN] = turn\n \n turn_map[age] = num\n last_number = age\n end\n end\n\n last_number\nend", "def find_amicables(n)\n pairs = []\n sum = 0\n for i in 0..n do \n next if pairs.include? i\n d = sum_proper_divisors(i)\n next if d == i\n p = sum_proper_divisors(d)\n if p == i \n pairs << d\n pairs << i\n sum += d + i\n end\n end\n return sum\nend", "def generate_cup_bracket(teams)\n @participants = teams\n @participant_number = @participants.length\n @levels = @participant_number.log2\n @levels = (1<<(@levels) == @participant_number) ? @levels -1 : @levels\n @total_matchups = 1<<(@levels)\n (@participant_number..(2*@total_matchups - 1)).each do |x| \n @participants << nil \n end\n \n # puts @levels\n\n left_index, right_index = 1, 2\n\n @tree = [[left_index, right_index]] \n @the_nodes = [] \n @match = 0\n\n (0..@levels).each do |level|\n game = (1<<level) - 1 \n nodes = @tree[-(game+1)/2,(game+1)/2].inject([]) {|s,e| s+e} \n @the_nodes << nodes\n i = 0\n nodes.each do |index| \n opponent = ((2*(game+1)-index+1) > @participant_number) ? nil : (2*(game+1) - index+1)\n if i < game\n @tree << [index, opponent]\n # puts \"[z]: #{index} vs #{opponent}\"\n else \n @tree << [opponent, index]\n # puts \"[M]: #{index} vs #{opponent}\"\n end \n i += 1\n end \n end\n \n @tree << [left_index, right_index]\n # puts \"[Final]: #{left_index} vs #{right_index}\"\n \n # @jornada = 0\n level = @levels\n counter = @levels + 1\n while counter > 0\n game = (1<<(level)) - 1 \n i = 0\n @the_nodes[counter-1].each do |index| \n next_game= \"\"\n\n player_1 = @participants[index-1].name \n home_id = @participants[index-1].id\n\n opponent = 'Bye' \n player_2 = 'Bye' \n away_id = nil\n\n unless (2*(game+1)-index+1) > @participant_number\n opponent = (2*(game+1) - index+1) \n player_2 = @participants[opponent-1].name \n away_id = @participants[opponent-1].id\n end\n\n\n last_game = get_the_last_game\n \n if level == @levels \n @game = Game.create!(:name => level_in_words(level), \n :cup_id => self.id, :home_id => home_id ,:away_id => away_id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'FirstGame', :jornada => last_game['jornada'], \n\t\t\t :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n\t\t\t :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n\t\t\t :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n\t\t\t :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n puts \"[#{level_in_words(level)}]: #{home_id} #{ away_id}\"\n \n else\n @previous_1 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, home_id], \n :order => \"id\") \n @previous_2 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, away_id], \n :order => \"id\")\n\n puts \"[#{level_in_words(level)}]: #{@previous_1.id} #{ @previous_2.id}\"\n\n @game = Game.create!(:name => level_in_words(level), \n :cup_id => self.id, :home_id => home_id ,:away_id => away_id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'SubsequentGame', :jornada => last_game['jornada'], \n\t\t\t :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n\t\t\t :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n\t\t\t :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n\t\t\t :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n @previous_1.next_game_id = @game.id\n @previous_1.save!\n @previous_2.next_game_id = @game.id\n @previous_2.save!\n end \n end\n\n level -= 1\n counter -=1\n end\n\n last_game = get_the_last_game\n \n # third place\n jornada = Game.last_cup_game(self).jornada.to_i + 1 \n @game = Game.create!(:name => level_in_words(99), :cup_id => self.id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'ThirdPlaceGame', :jornada => last_game['jornada'], \n :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n # final\n home_id = @participants[left_index-1].id\n away_id = @participants[right_index-1].id\n player_1 = @participants[left_index-1].name\n player_2 = @participants[right_index-1].name \n \n jornada = Game.last_cup_game(self).jornada.to_i + 1\n @previous_1 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, home_id], \n :order => \"id\") \n @previous_2 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, away_id], \n :order => \"id\")\n \n puts \"[#{level_in_words(0)}]: #{@previous_1.id} #{ @previous_2.id}\"\n \n last_game = get_the_last_game\n @game = Game.create!(:name => level_in_words(0), :cup_id => self.id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'FinalGame', :jornada => last_game['jornada'], \n :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n @previous_1.next_game_id = @game.id\n @previous_1.save!\n @previous_2.next_game_id = @game.id\n @previous_2.save!\n end", "def move_people(result)\n puts \"moving people\"\n index = 0\n while index < @projects.length do\n # find the most popular project, and move out those people whose second choice group has not been fulfilled\n most_popular_project = find_most_popular_project(result)\n if result[most_popular_project].length > @group_size_max then\n popular_group_size = result[most_popular_project].length - 1\n puts \"votes\"\n puts @votes\n while (result[most_popular_project].length > @group_size_max && popular_group_size >= 0)\n unlucky_student = result[most_popular_project][popular_group_size]\n puts \"unlucky_student\"\n puts unlucky_student\n second_choice = @votes.find { |vote| vote[:student_id] == unlucky_student}[:vote_second]\n if result[second_choice].length < @group_size_max then\n result[most_popular_project].delete(unlucky_student)\n result[second_choice] << unlucky_student\n end\n popular_group_size = popular_group_size - 1\n puts \"moved to second\"\n puts result\n end\n end\n\n # find the most popular project, and move out those people whose third choice group has not been fulfilled\n if result[most_popular_project].length > @group_size_max then\n popular_group_size = result[most_popular_project].length - 1\n while (result[most_popular_project].length > @group_size_max && popular_group_size >= 0)\n unlucky_student = result[most_popular_project][popular_group_size]\n puts \"unlucky_student for third choice\"\n puts unlucky_student.nil?\n third_choice = @votes.find { |vote| vote[:student_id] == unlucky_student}[:vote_third]\n if (result[third_choice].length < @group_size_max) then\n result[most_popular_project].delete(unlucky_student)\n result[third_choice] << unlucky_student\n end\n popular_group_size = popular_group_size - 1\n end\n end\n\n #if the group is still overpopulated, use random algo to move students out\n while result[most_popular_project].length > @group_size_max\n poor_student = result[most_popular_project].delete(result[most_popular_project].sample)\n result[result.find{ |key, value| key != most_popular_project && value.length <= @group_size_min }[0]] << poor_student\n end\n index = index + 1\n end\n\n # check if a group has too little students\n unfilled = result.find{ |key, value| value.length < @group_size_min}\n while (!unfilled.nil?) do\n most_p = find_most_popular_project(result)\n poor_student = result[most_p].delete_at(result[most_p].size - 1)\n result[unfilled[0]] << poor_student\n unfilled = result.find{|key, value| value.length < @group_size_min}\n end\n\n return result\n end", "def problem(nth = 6,i = 13)\n while nth < 10001\n i += 2\n nth += 1 if i.prime?\n end\n i\n end", "def replace_worst_ranked(offsprings)\n size = offsprings.length\n\n @population.sort!() # Make sure population is sorted so we replace the worst \n\n raise \"@population.first.fitness() >= @population.last.fitness()\" unless @population.first.fitness() >= @population.last.fitness()\n\n @population = @population [0..((-1*size)-1)] + offsprings\n end", "def process(n)\n foundpart = 0\n parts = []\n for i in 0..n-1 do # init participants ary\n parts.push 1\n end\n infolog {\"Starting, num-parts=#{n}\"}\n round = 0\n finished = false\n while !finished and round < @maxrounds\n round += 1\n numparts = parts.select{|it| it>0}.size\n infolog {\"ROUND ##{round}: num-parts=#{numparts}\"}\n deblog {\" parts=#{parts}\"}\n for i in 0..n-1 do\n if parts[i] > 0 and !finished\n for j in i+1..i+n do\n k = j % n\n #tracelog {\"k=#{k}\"}\n if parts[k] > 0\n parts[i] += parts[k]\n deblog {\"part##{i} steals from part#{k}: #{parts[k]} => #{parts[i]}\"}\n parts[k] = 0\n if parts[i] == n\n infolog {\"FINISHED at round##{round}, participant=#{i+1}\"}\n foundpart = i+1\n finished = true\n end\n break\n end\n end\n else\n tracelog {\"part##{i} has nothing, is skipped.\"} unless finished\n end\n end\n end\n foundpart\nend", "def pretentious_primes(arr, ran)\n\n primes = list_of_primes(arr.max, ran )\n # print primes\n\n arr.map do |num|\n i = 0\n primes[0..-2].each_with_index do |p , idx|\n if num == p \n i = idx\n \n elsif (num > p && num < primes[idx + 1]) && ran > 0 \n i = idx\n elsif (num > p && num < primes[idx + 1]) && ran < 0 \n i = idx + 1\n \n end\n end\n # p i\n # p ran\n if (i + ran) < 0\n \n nil\n else\n primes[i + ran]\n end\n\n end\n \nend", "def solution(number)\nn = 0..number\na = []\nfor i in n\n if i % 3 == 0 || i % 5 == 0\n a = a.push(i)\n end\n end\ns = 0\n# a.pop\na.each {|x| s += x}\ns\nend", "def predicted_deaths # Its gonna predict number of deaths based on population density by muliplying population by given factor, for each state\n array = [50, 100, 150, 200].reverse\n array.each do |end_of_range|\n if @population_density >= end_of_range\n number_of_deaths = ( @population * end_of_range / 500 )\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n break\n else\n number_of_deaths = (@population * 0.05).floor\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n break\n end\n end\n end", "def unrank_indices(m)\n result = Array.new(size, 0)\n for i in 0...size\n f = factorial(i)\n x = m % (f * (i + 1))\n m -= x\n x /= f\n result[size - i - 1] = x\n x -= 1\n for j in (size - i)...size\n result[j] += 1 if result[j] > x\n end\n end\n result\n end", "def steal_houses(array)\n return 0 if array.empty?\n\n amounts = [0, array[0]]\n\n i = 2\n while i <= array.length\n amounts[i] = [amounts[i - 1], amounts[i - 2] + array[i - 1]].max\n i += 1\n end\n\n amounts[-1]\nend", "def solutions(a)\r\n\r\n ary = a.sort\r\n ary.each_with_index do |num, index|\r\n if ary[index+1] != num + 1 && index != ary.length-1\r\n return num + 1\r\n end\r\n end\r\n\r\nend", "def freed_prisoners(arr)\n counter = 0\n return counter if arr[0] == 0\n arr.each do |cell|\n if cell == 1\n counter += 1\n arr.map! do |switch|\n if switch == 1\n switch = 0\n else\n swith = 1\n end\n end\n else\n next\n end\n end\n counter\nend", "def food_distribution(arr)\n sandwiches = arr.shift\n differences = []\n arr.each_with_index do |hunger, idx|\n break if idx >= arr.size - 1\n if arr[idx] > arr[idx + 1]\n while sandwiches > 0 && arr[idx] > arr[idx + 1]\n arr[idx] -= 1\n sandwiches -= 1\n end\n elsif arr[idx] < arr[idx + 1]\n while sandwiches > 0 && arr[idx] < arr[idx + 1]\n arr[idx + 1] -= 1\n sandwiches -= 1\n end\n end\n end\n arr.each_with_index do |hunger, idx|\n break if idx >= arr.size - 1\n differences << (hunger - arr[idx + 1]).abs\n end\n total = differences.reduce(:+)\n p sandwiches, arr, differences\n total\nend", "def sequence(hidden, open)\n weight = { 1 => \"A\", 2 => \"2\", 3 => \"3\", 4 => \"4\", 5 => \"5\", 6 => \"6\", 7 => \"7\", 8 => \"8\", 9 => \"9\", \n 10 => \"T\", 11 => \"J\", 12 => \"Q\", 13 => \"K\" }\n i = 0\n result = []\n inputs = 1\n differ = 0\n if weight.key(hidden[i]) > weight.key(hidden[i+2])\n small = weight.key(hidden[i+2])\n big = weight.key(hidden[i])\n differ = big - small\n elsif weight.key(hidden[i]) < weight.key(hidden[i+2])\n small = weight.key(hidden[i])\n big = weight.key(hidden[i+2])\n differ = big - small\n else\n return false\n end\n return false if differ > 4\n if differ > 1\n start = small + 1\n end1 = big - 1\n start.upto(end1) do |j|\n open.each_index do |k|\n if open[k] == weight[j]\n unless result.include? weight[j]\n result << open[k]\n result << open[k+1]\n inputs += 1\n end \n end \n end \n end\n end\n return false unless differ == inputs \n if result.size < 6\n steps = (6-result.size)/2\n start = big + 1\n end1 = big + steps\n start.upto(end1) do |j|\n open.each_index do |k|\n if open[k] == weight[j]\n unless result.include? weight[j]\n result << open[k]\n result << open[k+1]\n end \n end \n end \n end\n if result.size < 6\n steps = (6-result.size)/2\n return false if small - steps < 1 \n start = small - steps\n end1 = small - 1\n start.upto(end1) do |j|\n open.each_index do |k|\n if open[k] == weight[j]\n unless result.include? weight[j]\n result << open[k]\n result << open[k+1]\n end \n end \n end \n end\n return false if result.size < 6\n end\n end \n result \n end", "def solve jug_sizes, starting_state, has_drain, has_source\n if !block_given? \n raise \"Solve must be called with a block that checks a state (array of jug fill states) if it is a winning state.\"\n end\n\n if jug_sizes.length != starting_state.length \n raise \"The jug sizes array and starting state array must have the same length (i.e. for each jug there must be a size and fill state)\"\n end\n\n seen_states=[starting_state].to_set\n states_to_process = [[[], starting_state]]\n\n while states_to_process.length > 0\n state_to_process = states_to_process.delete_at(0)\n puts \"Processing state #{state_to_process[1]}...\"\n if yield(state_to_process[1]) \n puts \" problem solved.\"\n return state_to_process[0] \n end\n\n state=state_to_process[1]\n steps=state_to_process[0]\n\n for from in 0..jug_sizes.length-1\n for to in 0..jug_sizes.length-1\n next if from==to\n next if state[from]==0\n next if state[to]==jug_sizes[to]\n\n new_state=state[0..-1]\n if state[from] + state[to] > jug_sizes[to]\n new_state[to] = jug_sizes[to]\n poured_amount = jug_sizes[to] - state[to]\n new_state[from] = state[from] - poured_amount\n else\n new_state[to] = state[from] + state[to]\n new_state[from] = 0\n end\n\n puts \" after pouring from #{from} to #{to} reached #{new_state}.\"\n if !seen_states.include?(new_state)\n seen_states.add(new_state)\n new_steps = steps[0..-1]\n new_steps << \"#{from} -> #{to}\"\n states_to_process << [new_steps, new_state]\n end\n end\n end\n\n if has_drain \n for target in 0..jug_sizes.length-1\n new_state=state[0..-1]\n new_state[target]=0 \n puts \" after draining from #{target} reached #{new_state}.\"\n if !seen_states.include?(new_state)\n new_steps = steps[0..-1]\n new_steps << \"#{target} -> DRAIN\"\n states_to_process << [new_steps, new_state]\n end\n end\n end\n\n if has_drain \n for target in 0..jug_sizes.length-1\n new_state=state[0..-1]\n new_state[target]=jug_sizes[target]\n puts \" after filling #{target} reached #{new_state}.\"\n if !seen_states.include?(new_state)\n new_steps = steps[0..-1]\n new_steps << \"SOURCE -> #{target}\"\n states_to_process << [new_steps, new_state]\n end\n end\n end \n end\n\n raise \"No solution found.\"\nend", "def ideal_numbers(n)\n # perfects = []\n # factors = proper_factors(n)\n\n # while perfects.length <= n \n # factors.each do |factor|\n # sum = aliquot_sum(n)\n \n # if factor == perfect_number?(factor)\n # perfects << factor\n # end \n # end \n # end\n\n perfect_nums = []\n\n i = 1\n while perfect_nums.length < n \n perfect_nums << i if perfect_number?(i)\n i += 1\n end \n\n perfect_nums\nend", "def arrange_coins(n)\n k = 0\n while (n -= k) > k\n k += 1\n end\n k\nend", "def print_cut_rod_solution(p,n)\n\nend", "def sptriplet(n)\n divisors_of_500 = []\n1.upto(500) {|n| divisors_of_500 << n if 500 % n == 0}\ndivisors_of_500.inspect\n\n solutions = []\n for x in divisors_of_500\n for z in divisors_of_500\n if (x < z && z < 2*x) && n%(x*z) == 0\n y = z - x\n k = ((n/2) / x) / z\n\n a = k*(x*x-y*y)\n b = 2*k*x*y\n c = k*(x*x+y*y)\n\n solutions << [a,b,c]\n end\n end\n end\n\n product = 1\n solutions.map! {|arr| arr.sort}\n solutions.uniq!\n solutions[0].each {|num|product *= num}\n product\n\nend", "def problem_77a\n primes = Primes.upto(100)\n\n # off is the offset in the prime array, we can work down :-)\n solve = lambda do |a,off,max|\n n = 0\n while a[off] < max && (a.length-off) >= 2 \n a[off] += a.pop\n n += 1 if (a & primes).length == a.uniq.length\n n += solve.call(a.dup,off+1,a[off]) if a.length - off > 1\n end\n n\n end\n m = 0\n (2..100).each do |num|\n break if (m = solve.call([1] * num,0,num-1)) > 5000\n puts \"#{num} => #{m}\"\n end\n m\nend", "def slaughter_mice cages, index, debug = false\r\n\t# start off the slaughter by starting at the index\r\n\tcages = rearrange cages, index\r\n\r\n\t# the eating loop\r\n\tloop {\r\n\t\tp cages if debug\r\n\r\n\t\tcaughtIndex = nil # assume we fail\r\n\t\tcages.each_with_index do |cage, i|\r\n\t\t\tif cage == i+1 # arrays are 0-indexed\r\n\t\t\t\tcaughtIndex = i # the cage with the mouse we are going to eat\r\n\t\t\t\tbreak # out of each_with_index\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\t# did we fail?\r\n\t\treturn false unless caughtIndex\r\n\r\n\t\t# nope! yay!\r\n\t\t# now eat the mouse\r\n\t\tcages = nom cages, caughtIndex\r\n\t\tputs \"nommed #{caughtIndex}\" if debug\r\n\r\n\t\t# did we eat all of them?\r\n\t\treturn true if cages.empty?\r\n\t}\r\nend", "def rank_indices(p)\n result = 0\n for i in 0...size\n result += p[i] * factorial(size - i - 1)\n for j in (i + 1)...size\n p[j] -= 1 if p[j] > p[i]\n end\n end\n result\n end", "def corgi_golden_age(arr)\n\tmax_subset_sum = 0\n\tmax_i = 0\n\tmax_j = 0\n\tsum = 0\n\ti = 0\n\tj=i+1\n\twhile i < arr.length\n\t\twhile j < arr.length\n\t\t\tsum = arr[i]+arr[j]\n\t\t\tif sum > max_subset_sum\n\t\t\t\tmax_subset_sum = sum\n\t\t\t\tmax_i = i\n\t\t\t\tmax_j = j\n\t\t\tend\n\t\t\tj+=1\n\t\tend\n\t\ti+=1\n\tend\n\treturn [max_i, max_j]\n\nend", "def arrangements(open_spots)\n arrangements = 0\n open_spots.each do |array|\n arrangements += array.permutation(5).to_a.size\n end\n arrangements\n end", "def migratoryBirds(n, ar)\n birds = [0, 0, 0, 0, 0] \n ar.each do |number|\n birds[number-1] += 1 \n end \n return birds.index(birds.max) + 1\nend", "def fitness\n -(0..5).map{|t| \n $pors_store = 0 # reset store\n t_val = t\n values = {:rec=>proc{$pors_store},:T=>proc{ cv=t_val; t_val=0; cv} } # using T destroys T\n (eval_genes(values) - N*t).abs \n }.sum - 0.1*size # find a tree that multiplies T by 3\n end", "def find_relative_ranks(nums)\n hash = {}\n nums.each_with_index do |num, index|\n hash[num] = index\n end\n hash = hash.sort.to_h\n print hash\n count = 0\n hash.each do |k, v|\n if count == nums.size - 3\n nums[v] = \"Bronze Medal\"\n elsif count == nums.size - 2\n nums[v] = \"Silver Medal\"\n elsif count == nums.size - 1\n nums[v] = \"Gold Medal\"\n else\n nums[v] = (nums.size - count).to_s\n end\n count += 1\n end\n nums\nend", "def find_by_bayer_moore(array)\n candidate = 0\n count = 0\n # Pass 1 - Find the candidate maintaing a count \n for i in 0..array.size-1\n # binding.pry\n candidate = array[i] if count == 0\n if array[i] == candidate\n count += 1\n else\n count -= 1\n end\n end\n counter = 0\n # Pass 2 - To verify that the candidate from pass1 is acutally a majority\n array.each do |i|\n if i == candidate\n counter += 1\n end\n end\n if counter > array.size/2\n puts \"Found majority element is: #{candidate}\"\n else\n puts \"No majority element\"\n end\nend", "def walk_through\n count = 0\n for i in 0..@n-1\n for j in 0..@m-1\n if @garden[i][j] == 'W'\n @garden[i][j] = 'C'\n count += 1\n check_around(i,j)\n end\n end\n end\n puts count\n end", "def egg_drop(floors, eggs)\n # an array of arrays to store the values (building my dp matrix)\n # + 1 to include 0 floors\n results = []\n (floors + 1).times { results << [] }\n\n # defining my base cases\n (0..floors).each do |floor|\n results[floor][1] = floor\n results[floor][0] = 0\n end\n\n (0..eggs).each do |egg_number|\n results[1][egg_number] = 1\n results[0][egg_number] = 0\n end\n\n # filling up the matrix\n (2..floors).each do |floor|\n (2..eggs).each do |egg_number|\n # assigning a random high number\n results[floor][egg_number] = Float::INFINITY\n # first looking for the worst-case\n (1..floor).each do |current_floor|\n broken_egg = results[current_floor - 1][egg_number - 1]\n unbroken_egg = results[floor - current_floor][egg_number]\n # get the max, i.e. worst-case, add one for the current drop\n current_result = [broken_egg, unbroken_egg].max + 1\n # save the value if it's the minimum\n results[floor][egg_number] = current_result if current_result < results[floor][egg_number]\n end\n end\n end\n\n results[floors][eggs]\nend", "def solve(array, n)\n num_of_patches = 0\n\n 1.upto(n).each do |i|\n if !array.include?(i)\n array << i\n return num_of_patches if patched?(array, n)\n num_of_patches += 1\n end\n end\nend", "def phase_one\n puts \"Phase 1 Starting\".yellow\n counter = 8\n eliminated = []\n while counter > 0\n indexer = 8 - counter\n puts \"Phase one, round #{(indexer+1).to_s}:\".green\n tribe_selected = @borneo.immunity_challenge\n puts \"Tribe selected: #{tribe_selected.to_s}\".green\n puts \"Contestant #{tribe_selected.tribal_council} was eliminated without mercy!\".red\n counter -= 1\n end\n 8 # this is here to pass the test, but not sure it's ver useful beyond that\nend", "def sundaram\n limit = @limit/2 - 2\n j_limit = (limit-1)/3\n\n # only odd are needed.\n ary = (2..@limit/2).map{|t| 2*t - 1}\n\n (1..j_limit).each do |j|\n (1..j).each do |i|\n num = i + j + 2*i*j - 1\n break if num > limit\n ary[num] = nil\n end\n end\n ary.compact.unshift 2\n end", "def find_radius(houses, heaters)\n houses = houses.sort\n heaters = heaters.sort\n res = 0\n i = 0\n houses.each do |h|\n while i < heaters.size - 1 && heaters[i] + heaters[i + 1] <= h * 2 do \n i += 1\n end\n res = [res, (heaters[i] - h).abs].max \n end\n res\nend", "def acct_groups(array)\n group_1 = []\n group_2 = []\n group_3 = []\n group_4 = []\n group_5 = []\n group_6 = []\n group_7 = []\n group_8 = []\n group_9 = []\n group_10 = []\n prime_group = []\n\n i = 0\n while i < array.length\n if (i % 3 == 0) && !(i % 4 == 0) && !(i % 6 == 0) && !(i % 7 == 0) && !(i % 11 == 0) && !(i % 13 == 0)\n group_1 << array[i]\n elsif (i % 4 == 0) && !(i % 5 == 0) && !(i % 6 == 0) && !(i % 7 == 0) && !(i % 11 == 0) && !(i % 13 == 0)\n group_2 << array[i]\n elsif (i % 5 == 0) && !(i % 6 == 0) && !(i % 7 == 0) && !(i % 11 == 0) && !(i % 13 == 0)\n group_3 << array[i]\n elsif (i % 6 == 0) && !(i % 7 == 0) && !(i % 11 == 0) && !(i % 13 == 0)\n group_4 << array[i]\n elsif (i % 7 == 0) && !(i % 11 == 0) && !(i % 13 == 0)\n group_5 << array[i]\n elsif i % 11 == 0\n group_6 << array[i]\n elsif i % 13 == 0\n group_7 << array[i]\n else\n prime_group << array[i]\n end\n i += 1\n end\n x = 0\n while x < prime_group.length\n if (x % 2 == 0) && !(x % 3 == 0)\n group_8 << prime_group[x]\n elsif x % 3 == 0\n group_9 << prime_group[x]\n else\n group_10 << prime_group[x]\n end\n x += 1\n end\n\n\n\n puts group_1\n puts group_1.length\n puts group_2\n puts group_2.length\n puts group_3\n puts group_3.length\n puts group_4\n puts group_4.length\n puts group_5\n puts group_5.length\n puts group_6\n puts group_6.length\n puts group_7\n puts group_7.length\n #puts prime_group\n #puts prime_group.length\n puts group_8\n puts group_8.length\n puts group_9\n puts group_9.length\n puts group_10\n puts group_10.length\n puts array.length\nend", "def removNb(n)\n results = []\n (2..n).each do |a|\n b = (n*(n+1)/2.0-a)/(a + 1)\n results << [a, b.to_i] if b % 1 == 0 && b < n && b > 2\n end\n results\nend", "def score( dice )\n score = 0\n\n [1,6,5,4,3,2,1,5].each { |x|\n if dice.count(x) >= 3 # Three 1's => 1000 points\n 3.times { dice.delete_at(dice.index(x) || dice.length) }\n case x\n when 1\n score += 1000\n else\n score += (x*100)\n end\n end\n }\n\n 2.times {\n if dice.count(1) >= 1 # One 1 => 100 points\n dice.delete_at(dice.index(1) || dice.length)\n score += 100\n end\n\n if dice.count(5) >= 1 # One 5 => 100 points\n dice.delete_at(dice.index(5) || dice.length)\n score += 50\n end\n }\n score\nend", "def dp_possible_trees(n)\n array = Array.new(n+2) { Array.new(n+1) { 0 } }\n (0...n+2).to_a.each do |i|\n array[i][0] = 1\n end\n\n sum = 0\n (1...n+1).to_a.each do |i|\n sum = 0\n (1..i).to_a.each do |j|\n array[j][i] = array[n+1][i-j] * array[n+1][j-1]\n sum += array[j][i]\n end\n array[n+1][i] = sum\n end\n array[n+1].last\nend", "def huangtang(items, already_sorted = false)\n items = sort_items_by_profitability!(items.clone) unless already_sorted\n \n n = items.length-1\n h0 = 0\n (1..n).each do | j |\n min = items[0][:w].lcm(items[j][:w]) - items[j][:w]\n (1..(j-1)).each do | i |\n x = items[i][:w].lcm(items[j][:w]) - items[j][:w] \n min = x if x < min\n end\n h0 += min\n end\n\n h0 + 1\nend", "def oddities(array)\n initialcount = array.count\n n = (initialcount/2)\n i = 1\n n.times do \n array.delete_at(i)\n i +=1\n end \n p array\nend", "def cracklepop3\n (1..100).zip(Array.new 100, nil).map do |i,x|\n [i%3, i%5].map.with_index do |y, j| \n x = x.to_s + ['crackle','pop'][j] if y==0\n end\n x ? x : i\n end\nend", "def simulate(preferences, vote_order, debug = false)\n\t#winner is an array where the index indicates the round of voting, and the value \n\t#indicates the candidate that will win given that they've made it to this round\n\twinner = []\n\tnum_rounds = vote_order.length - 1\n\tnum_candidates = preferences.length\n\n\t#start with the final round of voting and build backwards\n\tnum_rounds.downto(1).each do |i|\n\t\tmatchup_a = vote_order[i - 1]\n\t\t#a vote for matchup_b is a vote for b OR whoever is going to win in the next round\n\t\tmatchup_b = vote_order[i]\n\n\t\t#vote is an array where the index indicates the candidate, and the value indicates which of the \n\t\t#two current candidates they are voting for (0 = a, 1 = b)\n\t\tvote = []\n\n\t\tif winner.length == 0\n\t\t\t#if this is the last round, next winner is matchup_b\n\t\t\tnext_winner = matchup_b\n\t\telse\n\t\t\t#if this is not the last round, next winner is the winner in the next round\n\t\t\tnext_winner = winner[0]\n\t\tend \n\n\t\t0.upto(num_candidates - 1).each do |j|\n\t\t\t#if candidate j prefers next_winner to a, they vote for b. Otherwise they vote for a.\n\t\t\t#note there can never be a tie in this formulation.\n\t\t\tif debug\n\t\t\t\tputs \"Candidate \" + j.to_s + \" voting between \" + matchup_a.to_s + \" and \" + next_winner.to_s + \"...\"\n\t\t\tend\n\t\t\tif preferences[j].index(matchup_a) < preferences[j].index(next_winner)\n\t\t\t\tif debug\n\t\t\t\t\tputs matchup_a\n\t\t\t\tend\n\t\t\t\tvote[j] = 0\n\t\t\telse\n\t\t\t\tif debug\n\t\t\t\t\tputs next_winner\n\t\t\t\tend\n\t\t\t\tvote[j] = 1\n\t\t\tend\n\t\tend\n\t\t#if vote.inject(:+) < num_candidates.to_f / 2.0\n\t\tif vote.inject(:+) <= num_candidates.to_f / 2.0\n\t\t\t#a has it, a is this round's winner\n\t\t\tif debug\n\t\t\t\tputs \"**** \" + matchup_a.to_s + \" wins!\"\n\t\t\tend\n\t\t\twinner.unshift(matchup_a)\n\t\telse\n\t\t\t#b has it, this round's winner is whoever wins the next round\n\t\t\tif debug\n\t\t\t\tputs \"**** \" + next_winner.to_s + \" wins!\"\n\t\t\tend\n\t\t\twinner.unshift(next_winner)\n\t\tend\n\tend\n\treturn winner\nend" ]
[ "0.66888964", "0.64809626", "0.62024534", "0.61218816", "0.6038506", "0.59638137", "0.59411454", "0.57927346", "0.5771708", "0.5732769", "0.5724178", "0.5691598", "0.5691496", "0.5671533", "0.56611985", "0.5651968", "0.56341136", "0.5632547", "0.55832565", "0.5575646", "0.5541445", "0.5538206", "0.5535332", "0.5527269", "0.5525433", "0.55152094", "0.5499259", "0.54853004", "0.5479047", "0.5477142", "0.5470402", "0.5466361", "0.54658985", "0.5448468", "0.54467756", "0.5441598", "0.54402167", "0.54185975", "0.5417269", "0.5411838", "0.5405442", "0.5401683", "0.53987646", "0.5396908", "0.5392822", "0.5386413", "0.5365769", "0.5359449", "0.5358493", "0.53494596", "0.53412896", "0.5327752", "0.53253144", "0.53242195", "0.53219795", "0.5321511", "0.5315142", "0.5312291", "0.5304378", "0.5302464", "0.53016156", "0.5298387", "0.5295275", "0.52853394", "0.5275423", "0.5273233", "0.5268877", "0.5260587", "0.52556145", "0.5254851", "0.52469516", "0.5239074", "0.5238432", "0.52367866", "0.52349377", "0.52281576", "0.5227576", "0.5223494", "0.52194995", "0.52131814", "0.5211221", "0.5207977", "0.52064383", "0.5202779", "0.5200829", "0.5199973", "0.5198913", "0.5197852", "0.5195587", "0.5192055", "0.51831913", "0.5180832", "0.51780176", "0.51744974", "0.516911", "0.5165593", "0.5160406", "0.5159634", "0.51594627", "0.51582265" ]
0.6649804
1
5.9 recursive Josephus implementation N people have decided to commit mass suicide by arranging themselves in a circle and killing the mth person around the circle, closing ranks as each person drops out of the circle. find out the order in which the people die
def josephus(n,m) while n.size>0 puts n.rotate!(m-1).shift(1) josephus(n,m) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def josephus_survivor(n,k)\n # (1..n) people are put into the circle\n items = (1..n).to_a\n Array.new(n){items.rotate!(k-1).shift}.last\nend", "def josephus(n,k)\n if(n == 1)\n return 0\n end\n\n (josephus(n-1, k) + k) % n\nend", "def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n result = (result + k - 1) % i + 1\n end\n \n result\nend", "def find_celebrity(n)\n current = 0\n while true\n next_person = (current + 1) % n\n while next_person != current && !knows(current, next_person)\n next_person = (next_person + 1) % n\n end\n if next_person == current\n 0.upto(n - 1) do |other|\n next if other == current\n return -1 unless knows(other, current)\n end\n return current\n end\n break if current == n - 1\n if next_person > current\n current = next_person \n else\n current += 1\n end \n end\n -1\nend", "def death(arr,pos,m)\n #define an empty result string\n result = \"\"\n #If the array size is 1, just return the first index\n if arr.size == 1\n return arr[0].to_s\n end\n #If the position is bigger than the size of the array\n if pos+m > arr.size\n #Set the pos back into size of the array\n pos = (pos+m)%arr.size\n # append the number in the position to result\n result << arr[pos].to_s\n #delete the number (a.k.a. kill it)\n arr.delete_at(pos)\n #Append to result a recursive call to death\n result += death(arr,pos,m)\n #return the result\n return result\n end\n #If the position is small than the size of the array\n if arr.size > pos+m \n #The next target is updated according to m\n pos = pos + m\n #Append the number in the position to result\n result << arr[pos].to_s\n #delete the number (a.k.a. kill it)\n arr.delete_at(pos)\n #Append the result of a recursive call to death\n result += death(arr,pos,m)\n \n return result\n end\n #if the target is past the end of the array\n if arr.size == pos+m \n #set the position to 0\n pos = 0\n #Append that number\n result << arr[pos].to_s\n #delete it\n arr.delete_at(pos)\n #Append the result of a recursive call to death\n result += death(arr,pos,m)\n #return\n return result\n end\nend", "def kill_sequence(n, m)\n people = Array.new(n, true) # true = alive\n sequence = []\n index = -1\n\n while sequence.length < n\n # Advance through list until we've landed on the mth alive person\n count = 0\n while count < m\n index = (index + 1) % n\n count += 1 if people[index]\n end\n\n # Kill them\n people[index] = false\n sequence << index\n end\n\n sequence\nend", "def josephus(n,m)\n arr = Array.new\n order = Array.new\n\n for i in 1..n\n arr[i] = i\n end\n\n arr.compact!\n\n for i in 0..n-1\n arr= arr.rotate(m-1)\n order << arr[0]\n arr[0] = nil\n arr.compact!\n end\n\n puts \"order: #{order.to_s}\"\nend", "def coast_guard_rank; end", "def josephus_survivor(n,k)\n arr = (1..n).to_a\n\n while arr.length > 1\n idx = k % arr.length\n\n if arr.length > k\n arr = arr.drop(k) + arr.take(k - 1)\n elsif arr.length == k \n arr = arr[0...-1]\n else\n arr = arr.drop(idx) + arr.take(idx - 1)\n end\n end\n \n arr[0]\nend", "def generate_cup_bracket(teams)\n @participants = teams\n @participant_number = @participants.length\n @levels = @participant_number.log2\n @levels = (1<<(@levels) == @participant_number) ? @levels -1 : @levels\n @total_matchups = 1<<(@levels)\n (@participant_number..(2*@total_matchups - 1)).each do |x| \n @participants << nil \n end\n \n # puts @levels\n\n left_index, right_index = 1, 2\n\n @tree = [[left_index, right_index]] \n @the_nodes = [] \n @match = 0\n\n (0..@levels).each do |level|\n game = (1<<level) - 1 \n nodes = @tree[-(game+1)/2,(game+1)/2].inject([]) {|s,e| s+e} \n @the_nodes << nodes\n i = 0\n nodes.each do |index| \n opponent = ((2*(game+1)-index+1) > @participant_number) ? nil : (2*(game+1) - index+1)\n if i < game\n @tree << [index, opponent]\n # puts \"[z]: #{index} vs #{opponent}\"\n else \n @tree << [opponent, index]\n # puts \"[M]: #{index} vs #{opponent}\"\n end \n i += 1\n end \n end\n \n @tree << [left_index, right_index]\n # puts \"[Final]: #{left_index} vs #{right_index}\"\n \n # @jornada = 0\n level = @levels\n counter = @levels + 1\n while counter > 0\n game = (1<<(level)) - 1 \n i = 0\n @the_nodes[counter-1].each do |index| \n next_game= \"\"\n\n player_1 = @participants[index-1].name \n home_id = @participants[index-1].id\n\n opponent = 'Bye' \n player_2 = 'Bye' \n away_id = nil\n\n unless (2*(game+1)-index+1) > @participant_number\n opponent = (2*(game+1) - index+1) \n player_2 = @participants[opponent-1].name \n away_id = @participants[opponent-1].id\n end\n\n\n last_game = get_the_last_game\n \n if level == @levels \n @game = Game.create!(:name => level_in_words(level), \n :cup_id => self.id, :home_id => home_id ,:away_id => away_id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'FirstGame', :jornada => last_game['jornada'], \n\t\t\t :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n\t\t\t :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n\t\t\t :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n\t\t\t :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n puts \"[#{level_in_words(level)}]: #{home_id} #{ away_id}\"\n \n else\n @previous_1 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, home_id], \n :order => \"id\") \n @previous_2 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, away_id], \n :order => \"id\")\n\n puts \"[#{level_in_words(level)}]: #{@previous_1.id} #{ @previous_2.id}\"\n\n @game = Game.create!(:name => level_in_words(level), \n :cup_id => self.id, :home_id => home_id ,:away_id => away_id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'SubsequentGame', :jornada => last_game['jornada'], \n\t\t\t :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n\t\t\t :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n\t\t\t :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n\t\t\t :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n @previous_1.next_game_id = @game.id\n @previous_1.save!\n @previous_2.next_game_id = @game.id\n @previous_2.save!\n end \n end\n\n level -= 1\n counter -=1\n end\n\n last_game = get_the_last_game\n \n # third place\n jornada = Game.last_cup_game(self).jornada.to_i + 1 \n @game = Game.create!(:name => level_in_words(99), :cup_id => self.id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'ThirdPlaceGame', :jornada => last_game['jornada'], \n :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n # final\n home_id = @participants[left_index-1].id\n away_id = @participants[right_index-1].id\n player_1 = @participants[left_index-1].name\n player_2 = @participants[right_index-1].name \n \n jornada = Game.last_cup_game(self).jornada.to_i + 1\n @previous_1 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, home_id], \n :order => \"id\") \n @previous_2 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, away_id], \n :order => \"id\")\n \n puts \"[#{level_in_words(0)}]: #{@previous_1.id} #{ @previous_2.id}\"\n \n last_game = get_the_last_game\n @game = Game.create!(:name => level_in_words(0), :cup_id => self.id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'FinalGame', :jornada => last_game['jornada'], \n :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n @previous_1.next_game_id = @game.id\n @previous_1.save!\n @previous_2.next_game_id = @game.id\n @previous_2.save!\n end", "def arrange_coins(n)\n k = 0\n while (n -= k) > k\n k += 1\n end\n k\nend", "def solve( n = 2_000 )\n # We can classify every tile according to its angular position around the\n # unit circle, setting position 0 at the top since that's where each row\n # starts in the problem statement. Positions 1-5 then follow every 60° as\n # we work our way counter-clockwise. Depending on which of these positions\n # each tile falls (or between which pair of positions), we use different\n # formulae to calculate its six neighbors to the N, NW, SW, S, SE, and NE:\n # \n # Pos 0: n even = fhp\n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n + ring - 1 (f)\n # SW = n + 1 NE = n + (2*ring + 5) (p)\n #\n # Pos 0-1: n even = bh, n odd = ag \n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + 1 NE = n - 1\n #\n # Pos 1: n even = bh, n odd = gi\n # N = n + ring (g) S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - 1\n #\n # Pos 1-2: n even = bh, n odd = ci\n # N = n - 1 S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2: n even = hj\n # N = n - 1 S = n + ring + 3 (j)\n # NW = n + ring + 1 (h) SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2-3: n even = dj, n odd = ci\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 3: n even = dj, n odd = ik\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + ring + 4 (k)\n # SW = n + ring + 2 (i) NE = n + 1\n #\n # Pos 3-4: n even = dj, n odd = ek\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + 1\n #\n # Pos 4: n even = jl\n # N = n + 1 S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + ring + 5 (l)\n #\n # Pos 4-5: n even = fl, n odd = ek\n # N = n + 1 S = n - 1\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5: n even = fl, n odd = km\n # N = n + ring + 6 (m) S = n - 1\n # NW = n + 1 SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, except last: n even = fl, n odd = gm\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n + 1 SE = n - 1\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, only last: n even = flo, n odd = gmo\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n - ring + 1 (f) SE = n - 1\n # SW = n - (2*ring - 7) (o) NE = n + ring + 5 (l)\n #\n # From these formula, we can derive the difference between a tile and each\n # of its neighbors. If we arrange all potential differences in ascending\n # order, it becomes obvious that for n even or odd, some deltas will al-\n # ways be even, and thus can never be prime (>2).\n #\n # Furthermore, we can see that only in certain positions will a tile ever\n # differ from three neighbors by odd amounts (position 0 and just to the\n # right of position 0). In all other cases, at most two deltas will be\n # odd, meaning PD(n) will be 2 or less.\n #\n # n even n odd\n # a = ring - 6 even a\n # b = ring - 5 b even\n # c = ring - 4 even c\n # d = ring - 3 d even\n # e = ring - 2 even e\n # f = ring - 1 f even\n # g = ring even g\n # h = ring + 1 h even\n # i = ring + 2 even i\n # j = ring + 3 j even\n # k = ring + 4 even k\n # l = ring + 5 l even\n # m = ring + 6 even m\n # o = 2ring - 7 o o\n # p = 2ring + 5 p p\n pd3 = [1, 2]\n base, ring = 8, 12\n \n while pd3.size < n\n # Only at position 0 and one tile to the right will there ever be three\n # odd deltas, so those are the only ones we have to check for primality.\n # Both share a delta of f = ring - 1.\n if (ring - 1).prime?\n # Check the other odd deltas for position 0. \n pd3 << base if (ring + 1).prime? && (2*ring + 5).prime?\n\n # Check the other odd deltas for one tile to the right of position 0.\n pd3 << base + ring - 1 if (ring + 5).prime? && (2*ring - 7).prime?\n end\n\n # Advance the first tile of the current ring (base), and the number of\n # tiles it contains (ring). \n base += ring\n ring += 6\n end\n\n pd3[-1]\n end", "def threed(list)\n hasthree = 0\n inarow = 0\n list.size.times do |i|\n if list[i] == 3\n hasthree += 1\n end\n if list[i] == 3 && list[i+1] == 3 && i != (list.size - 1)\n inarow += 1\n end\n end\n if hasthree == 3 && inarow == 0\n return true\n else\n return false\n end\nend", "def find_fork(wins, forker, forkee)\n position_counts = count_positions(wins, forker, forkee)\n forking_moves = []\n position_counts.each do |position, count|\n forking_moves.push(position) if count > 1\n end\n forking_moves = (forking_moves - (forking_moves & forker))\n forking_moves.empty? ? [] : forking_moves\n end", "def josephus(items,k)\n n = -1\n out = []\n while items.length > 0 do \n n = (n + k) % items.length \n out.push(items.slice!(n))\n n -= 1 \n end\n out\nend", "def breed(players)\n (0..4).each do |i|\n players[i].successor(0, players[(i + 1) % 5])\n players[i].successor(1, players[(i - 1) % 5])\n players[i].successor(2, players[(i + 2) % 5])\n end\n end", "def minimumBribes(q)\r\n moves = 0\r\n r = (0..q.size-1).to_a\r\n\r\n until q == (1..q.size).to_a do\r\n q.map { |a| a - 1 }\r\n .reverse_each.with_index do |person, i|\r\n i = q.size - i - 1\r\n if person - i > 2\r\n puts \"Too chaotic\"\r\n return\r\n end\r\n\r\n if person > r[i] && person > q[person] -1\r\n moves += person - r[i]\r\n q = q - [person + 1]\r\n q.insert(person, person + 1)\r\n end\r\n end\r\n end\r\n\r\n puts moves\r\nend", "def choose_team(n,k)\n return n if k == 1\n return 0 if n == 0\n choose_team(n-1,k-1) + choose_team(n-1,k)\nend", "def problem3 n\n 2.step(n,1).each do |x|\n return x-1 if n == 1\n n /= x if x.prime? && (n % x == 0)\n end\nend", "def josephus(items,k)\n killed = []\n # loop the following two until items == []\n until items.length == 0 do\n items = items.rotate(k)\n killed << items.pop\n end\n killed\nend", "def f_1_4tel_rek(n)\r\n if !n.integer? || n < 1\r\n return false\r\n end\r\n\r\n def end_rek(i, s)\r\n if i > 0\r\n end_rek(i - 1, (1.0 / (i * (i + 1.0) * (i + 2.0))) + s)\r\n else\r\n return s\r\n end\r\n end\r\n return end_rek(n, 0)\r\nend", "def make_change(n)\n\tdef change(amount, denoms, index)\n\t\treturn 0 if amount == 0\n\t\treturn 1 if index >= denoms.length\n\t\tcurrent_denom = denoms[index]\n\t\tways = 0\n\t\ti = 0\n\t\twhile i * current_denom <= amount\n\t\t\tamount_remaining = amount - i * current_denom\n\t\t\tways += change(amount_remaining, denoms, index + 1)\n\t\t\ti += 1\n\t\tend\n\t\tways\n\tend\n\tdenoms = [100, 20, 10, 5, 2, 1]\n\tchange(n, denoms, 0)\nend", "def hurdleRace(k, height)\n if height.max < k\n 0\n else\n height.max - k\n end\nend", "def josephus(items,k)\n result = []\n count = k\n until items.length == 0 do\n remove_these = []\n items.each_with_index do |item, i|\n if count == 1\n result << items[i]\n remove_these << i\n end\n count = count == 1 ? k : count -= 1\n end\n remove_these.reverse!\n remove_these.each do |r|\n items.delete_at(r)\n end\n end\n result\nend", "def solve\n n = 33\n while true\n begin\n n += 2\n end while n.prime?\n\n s, ds = 2, 6\n while s < n && !(n - s).prime?\n s += ds\n ds += 4\n end\n\n break if s >= n\n end\n \n n\n end", "def phase_one\n eliminated = []\n 8.times do\n elim_tribe = @borneo.immunity_challenge\n index = @borneo.tribes.index(elim_tribe)\n element = elim_tribe.tribal_council\n @borneo.tribes[index].members = @borneo.tribes[index].members - Array(element)\n eliminated << element\n end\n puts \"Phase 1 eliminations: \".red\n puts \"----------------------------------------\"\n eliminated.each_with_index do |contestants,index|\n puts \"#{index+1}: #{contestants}\"\n end\n puts \"----------------------------------------\"\n eliminated.length\nend", "def problem_108(size = 1001)\n func = lambda do |a|\n if a.length == 1\n a[0]+1\n else\n m = a[0]\n (2*m+1) * func.call(a[1,a.length]) -m\n end\n end\n\n primes = Primes.upto(200)\n prime_number = lambda do |a|\n r = 1\n a.sort.reverse.each_with_index { |m,i| r *= primes[i] ** m }\n r\n end\n\n values = {}\n last = 0\n 1.upto(100).each do |nn|\n nn.groupings do |a|\n sols = func.call a\n ans = prime_number.call a\n# puts \"np=#{nn} sols=#{sols} ans=#{ans} => #{a.inspect}\"\n if values[sols]\n values[sols] = [values[sols],[ans,a]].min\n else\n values[sols] = [ans,a]\n end\n true\n end\n size.upto(size*5/4) do |num|\n if values[num]\n puts \"for np = #{nn} => #{num} => #{values[num].inspect}\"\n if last == values[num]\n puts \"factors = #{values[num][0].factors}\"\n return values[num][0] \n end\n last = values[num]\n break\n end\n end\n #values.sort.each do |k,v|\n # puts \"#{k} => #{v}\"\n #end\n end\n nil\nend", "def fidder_crabs(names)\n\n # Create empty container for everyone in the group\n everybody = Hash.new\n # Create a counter for group number, defalt to 1\n counter = 1\n\n names.shuffle\n #Mix it up.!!!!!\n\n #while the list is longer than 8 people, put 5 each in a group.\n while names.length >= 8 do\n names_in_group = names[0..4]\n everybody[counter] = names_in_group\n counter +=1\n names = names.drop(5)\n end\n\n #if the remainder is 5, have the last group with 5 people\n if names.length == 5\n names_in_group = names[0..4]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(5)\n\n #if the remaiinder group is 7, then we need to split the group into 4 and 3\n elsif names.length == 7\n names_in_group = names[0..3]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(4)\n #creating the last group\n names_in_group = names[0..2]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(3)\n\n #if the remainder is 6, we can have 2 groups of 3's\n elsif names.length == 6\n names_in_group = names[0..2]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(3)\n #creating last group of 3\n names_in_group = names[0..2]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(3)\n\n #if there is a remainder of 4 then create 1 group\n elsif names.length == 4\n names_in_group = names[0..3]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(4)\n\n #if the remainder is 3, then create the last group with 3\n elsif names.length == 3\n names_in_group = names[0..2]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(3)\n else\n names.length < 3\n names_in_group = names[0..1]\n everybody[counter] = names_in_group\n names = names.drop(3)\n end\n\n # since we filter by 8, the highest remainder is 7 and the lowest is 3, only 7 and 6 need to be split into 2 groups, while 3 and 4 could be in 1 group by themselfs.\n everybody\n #Return the hash of everybody in their group number with their names.\nend", "def process(n)\n foundpart = 0\n parts = []\n for i in 0..n-1 do # init participants ary\n parts.push 1\n end\n infolog {\"Starting, num-parts=#{n}\"}\n round = 0\n finished = false\n while !finished and round < @maxrounds\n round += 1\n numparts = parts.select{|it| it>0}.size\n infolog {\"ROUND ##{round}: num-parts=#{numparts}\"}\n deblog {\" parts=#{parts}\"}\n for i in 0..n-1 do\n if parts[i] > 0 and !finished\n for j in i+1..i+n do\n k = j % n\n #tracelog {\"k=#{k}\"}\n if parts[k] > 0\n parts[i] += parts[k]\n deblog {\"part##{i} steals from part#{k}: #{parts[k]} => #{parts[i]}\"}\n parts[k] = 0\n if parts[i] == n\n infolog {\"FINISHED at round##{round}, participant=#{i+1}\"}\n foundpart = i+1\n finished = true\n end\n break\n end\n end\n else\n tracelog {\"part##{i} has nothing, is skipped.\"} unless finished\n end\n end\n end\n foundpart\nend", "def nip_it_in_the_bud\n while has_bud?(@sequence) do\n @sequence.shift\n @sequence.each { |entry| entry.level -= 1 }\n end\n end", "def josephus_survivor(n, k)\n survivors = (1..n).to_a\n loop do\n survivors.rotate!(k -1).shift\n return survivors[0] if survivors.length == 1\n end\nend", "def monkey(n)\n i = n\n loop do\n if i > 1\n p \"#{i} little monkeys jumping on the bed,\"\n p \"One fell off and bumped his head,\"\n p \"Mama called the doctor and the doctor said,\"\n p \"No more monkeys jumping on the bed\"\n else\n p \"#{i} little monkey jumping on the bed,\"\n p \"One fell off and bumped his head,\"\n p \"Mama called the doctor and the doctor said,\"\n p \"Get those monkeys right to bed!\"\n return 0 \n end\n i -= 1\n end\nend", "def solve( n = 100 )\n n.partition_sieve[-1] - 1\n end", "def bottles(n)\n if n.zero?\n puts \"no more bottles of beer on the wall\"\n return\n end\n\n puts \"#{n} bottles of beer on the wall\"\n\n bottles(n - 1)\nend", "def climb_stairs(n)\n return 1 if n == 1\n return 2 if n == 2\n phi = (Math.sqrt(5) + 1)/2\n inverse_phi = (Math.sqrt(5) - 1)/2\n \n return ((phi ** (n + 1) - (inverse_phi ** n))/Math.sqrt(5)).round\nend", "def find_relative_ranks(nums)\n hash = {}\n nums.each_with_index do |num, index|\n hash[num] = index\n end\n hash = hash.sort.to_h\n print hash\n count = 0\n hash.each do |k, v|\n if count == nums.size - 3\n nums[v] = \"Bronze Medal\"\n elsif count == nums.size - 2\n nums[v] = \"Silver Medal\"\n elsif count == nums.size - 1\n nums[v] = \"Gold Medal\"\n else\n nums[v] = (nums.size - count).to_s\n end\n count += 1\n end\n nums\nend", "def arrange_coins(n)\n coin_pile = n\n current_row = 1\n\n loop do\n coin_pile -= current_row\n if coin_pile == 0\n return current_row\n elsif coin_pile < 0\n return current_row - 1\n end\n current_row += 1\n end\nend", "def leaderboard_cyclopeptide_sequencing(spectrum, n)\n # To be fair, a cut should include anyone who is tied with the Nth-place competitor.\n # Thus, Leaderboard should be trimmed down to the “N highest-scoring linear peptides including ties”, \n # which may include more than N peptides. Given a list of peptides Leaderboard, a spectrum Spectrum, \n # and an integer N, define Trim(Leaderboard, Spectrum, N) as the collection of the top N highest-scoring \n # linear peptides in Leaderboard (including ties) with respect to Spectrum.\n\n # Note that Score(Peptide, Spectrum) currently only scores Peptide against Spectrum if Peptide is cyclic. \n # However, to generalize this scoring function when Peptide is linear, we simply exclude those subpeptides\n # of Peptide that wrap around the end of the string, resulting in a function LinearScore(Peptide, Spectrum). \n # For example, if Spectrum is the experimental spectrum of NQEL, then you can verify that LinearScore(Peptide, Spectrum) = 8.\n\n # LEADERBOARDCYCLOPEPTIDESEQUENCING(Spectrum, N)\n # Leaderboard ← {empty peptide}\n # LeaderPeptide ← empty peptide\n # while Leaderboard is non-empty\n # Leaderboard ← Expand(Leaderboard)\n # for each Peptide in Leaderboard\n # if Mass(Peptide) = ParentMass(Spectrum)\n # if Score(Peptide, Spectrum) > Score(LeaderPeptide, Spectrum)\n # LeaderPeptide ← Peptide\n # else if Mass(Peptide) > ParentMass(Spectrum)\n # remove Peptide from Leaderboard\n # Leaderboard ← Trim(Leaderboard, Spectrum, N)\n # output LeaderPeptide \n\n leader_board = []\n leader_peptide = \"\"\n parent_mass = spectrum[-1]\n loop do\n leader_board = expand_peptides(leader_board)\n # puts leader_board.join(\" \")\n leader_board.dup.each do |peptide|\n # puts parent_mass.to_s + \" \" + peptide_mass(peptide).to_s\n if peptide_mass(peptide) == parent_mass\n if linearpeptide_score(peptide, spectrum) > linearpeptide_score(leader_peptide, spectrum)\n leader_peptide = peptide\n end\n elsif peptide_mass(peptide) > parent_mass\n leader_board.delete(peptide)\n end\n end\n # puts leader_board.join(\" \")\n leader_board = leaderboard_trim(leader_board, spectrum, n) \n break if leader_board.empty?\n end\n return peptide_to_mass(leader_peptide)\n end", "def solve( n = 16 )\n max = 0\n \n (1..10).each do |a|\n (1..10).each do |b|\n next if b == a\n (1..10).each do |c|\n next if c == b || c == a\n (1..10).each do |d|\n next if d == c || d == b || d == a\n (1..10).each do |e|\n next if e == d || e == c || e == b || e == a\n\n rotate = 3*[a, b, c, d, e].each_with_index.min[1]\n (1..10).each do |f|\n next if f == e || f == d || f == c || f == b || f == a\n (1..10).each do |g|\n next if g == f || g == e || g == d || g == c || g == b || g == a\n \n t = a + f + g\n (1..10).each do |h|\n next if h == g || h == f || h == e || h == d || h == c || h == b || h == a\n next unless t == b + g + h\n\n (1..10).each do |i|\n next if i == h || i == g || i == f || i == e || i == d || i == c || i == b || i == a\n next unless t == c + h + i\n\n (1..10).each do |j|\n next if j == i || j == h || j == g || j == f || j == e || j == d || j == c || j == b || j == a\n next unless t == d + i + j && t == e + j + f\n\n s = [a, f, g, b, g, h, c, h, i, d, i, j, e, j, f]\n rotate.times {s.push s.shift}\n\n s = s.join\n next if n != s.length\n\n max = [max, s.to_i].max\n end\n end\n end\n end\n end\n end\n end\n end\n end\n end\n\n max\n end", "def fork_check(wins, player, opponent)\n block_fork = find_fork(wins, opponent, player)\n get_fork = find_fork(wins, player, opponent)\n if get_fork.size > 0 # if possible to create fork, do it\n move = get_fork.sample\n elsif block_fork.size > 1 # if opponent can create multiple forks, force block\n move = get_adj(wins, player, opponent)\n elsif block_fork.size == 1 # otherwise if opponent can create fork, block it\n move = block_fork[0]\n else\n get_cen(player, opponent) # otherwise see if center is available\n end\n end", "def climb_stairs_still_slow(n)\n\t# base cases\n\treturn 1 if n < 2\n\treturn 2 if n == 2\n\n\treturn 2 * climb_stairs_still_slow(n-2) + climb_stairs_still_slow(n-3)\nend", "def make_change( amount, coins=[25,10,5,1], avoid_pennies=true, recursing=false )\n # Don't sort in place, in case the user wants to preserve the coin array\n coins = coins.sort_by{ |coin| -coin }\n owed = amount\n change = []\n coins.each{ |coin|\n while owed >= coin\n owed -= coin\n change << coin\n end\n }\n change = nil unless owed == 0\n\n if recursing\n change\n else\n answers = [ change ]\n while coins.shift\n answers << make_change( amount, coins, avoid_pennies, true )\n end\n answers.compact.sort_by{ |answer|\n [\n answer.length,\n -answer.send( avoid_pennies ? :last : :first )\n ]\n }.first\n end\nend", "def minimumBribes(q)\n bribe_count = 0\n # q.each_with_index do |person,i|\n i = q.size-1\n while i >= 0 do\n person = q[i]\n position = i+1\n offset = person - position\n\n if offset > 2\n puts \"Too chaotic\"\n return\n else\n j=[0,person-2].max\n while j < i do\n if q[j] > person\n bribe_count += 1\n else\n # break if j+1 == person\n end\n j+=1\n end\n end\n i-=1\n end\n puts bribe_count\nend", "def problem_108a\n i = 4\n max = 0\n solve = {}\n loop do\n num = 0\n a = Rational(1,i)\n 2.upto(i*2+1) do |j|\n if (a - Rational(1,j)).numerator == 1\n num += 1 \n# puts \"(#{a} - #{Rational(1,j)} == #{a - Rational(1,j)}\"\n end\n end\n\n solve[num] = [] unless solve[num]\n solve[num] << i.factors\n\n if num >= max\n puts \"####################################\"\n solve.each_key.sort.each do |k|\n s = solve[k].map do |v|\n h = {}\n v.each {|a| h[a] = (h[a] || 0) + 1 }\n h.values.sort.flatten\n end.uniq.sort\n puts \"k = #{k} groups: #{s.inspect}\"\n# puts solve[k].inspect\n end\n puts \"#{i} = #{num} #{i.factors} #{i.factors.length + i.divisors.length}\" \n max = num\n end\n break if num > 1000\n i += 1\n end\n i\nend", "def stair_climb(n)\n end", "def bottles(n)\n if n == 0\n puts 'no more bottles of beer on the wall'\n elsif n == 1\n puts \"#{n} bottle of beer on the wall\"\n bottles(n - 1)\n else\n puts \"#{n} bottles of beer on the wall\"\n bottles(n - 1)\n end\nend", "def block_fork(board)\n if board.cells[0] == opponent_token && board.cells[8] == opponent_token\n return 2\n end\n if board.cells[2] == opponent_token && board.cells[6] == opponent_token\n return 2\n end\n if board.cells[5] == opponent_token && board.cells[7] == opponent_token\n return 3\n end\n end", "def move_people(result)\n j=0\n while j<@projects.length do\n #(2) Find the most popular array, and move out those's whos second choice is a project that is incomplete. \n mostpopular_project= find_mostpopular_project(result)\n if result[mostpopular_project].length > @groupsizemax then\n i=result[mostpopular_project].length-1\n while(result[mostpopular_project].length>@groupsizemax && i>=0)\n #move students ID from this popular array to other array that are incomplete\n unlucky_student= result[mostpopular_project][i]\n second_choice= @preferences.find {|project| project['student_id']= unlucky_student} [:second]\n if(result[second_choice].length < @groupsizemax) then\n result[mostpopular_project].delete(unlucky_student)\n result[second_choice] << unlucky_student\n end\n i=i-1\n end\n end\n\n #(3) Find the most popular array, and move out those's whos third choice is a project that is incomplete. \n if result[mostpopular_project].length > @groupsizemax then\n i=result[mostpopular_project].length-1\n while(result[mostpopular_project].length>@groupsizemax && i>=0)\n #move students ID from this popular array to other array that are incomplete \n unlucky_student= result[mostpopular_project][i]\n #puts @preferences.inspect\n second_choice= @preferences.find {|project| project['student_id']= unlucky_student} [:third]\n if(result[second_choice].length < @groupsizemax) then\n result[mostpopular_project].delete(unlucky_student)\n result[second_choice] << unlucky_student\n end\n i=i-1\n end\n end\n \n #(4) If the array is still overpopulated, use random algo to move students out\n while result[mostpopular_project].length > @groupsizemax \n puts @grousizemin.inspect\n poor_student = result[mostpopular_project].delete(result[mostpopular_project].sample)\n result[result.find{|key,value| key != mostpopular_project && value.length<=@grousizemin}[0]] << poor_student\n end\n j=j+1\n\n \n end\n\n #(5) check for group that has too little students\n # puts \"current form:\", result.inspect\n unfilled = result.find{|key,value| value.length<@grousizemin}\n # puts unfilled.inspect\n while(!unfilled.nil?) do\n most_p= find_mostpopular_project(result)\n poor_student = result[most_p].delete_at(result[most_p].size-1)\n result[unfilled[0]] << poor_student\n unfilled = result.find{|key,value| value.length<@grousizemin}\n end\n puts \"current form after project Assign:\", result.inspect\n return result\n end", "def phase_one\r\n # start with empty elimination array\r\n council_elimination = []\r\n # loop 8 times (game mechanics)\r\n 8.times do\r\n # tribe which has lost the challenge\r\n loosing_tribe = @borneo.immunity_challenge\r\n # tribal council for the loosing tribe will eliminate one participants\r\n council_elimination << loosing_tribe.tribal_council\r\n end\r\n # return all eliminations (used for the test szenario)\r\n return council_elimination.length\r\nend", "def move_people(result)\n puts \"moving people\"\n index = 0\n while index < @projects.length do\n # find the most popular project, and move out those people whose second choice group has not been fulfilled\n most_popular_project = find_most_popular_project(result)\n if result[most_popular_project].length > @group_size_max then\n popular_group_size = result[most_popular_project].length - 1\n puts \"votes\"\n puts @votes\n while (result[most_popular_project].length > @group_size_max && popular_group_size >= 0)\n unlucky_student = result[most_popular_project][popular_group_size]\n puts \"unlucky_student\"\n puts unlucky_student\n second_choice = @votes.find { |vote| vote[:student_id] == unlucky_student}[:vote_second]\n if result[second_choice].length < @group_size_max then\n result[most_popular_project].delete(unlucky_student)\n result[second_choice] << unlucky_student\n end\n popular_group_size = popular_group_size - 1\n puts \"moved to second\"\n puts result\n end\n end\n\n # find the most popular project, and move out those people whose third choice group has not been fulfilled\n if result[most_popular_project].length > @group_size_max then\n popular_group_size = result[most_popular_project].length - 1\n while (result[most_popular_project].length > @group_size_max && popular_group_size >= 0)\n unlucky_student = result[most_popular_project][popular_group_size]\n puts \"unlucky_student for third choice\"\n puts unlucky_student.nil?\n third_choice = @votes.find { |vote| vote[:student_id] == unlucky_student}[:vote_third]\n if (result[third_choice].length < @group_size_max) then\n result[most_popular_project].delete(unlucky_student)\n result[third_choice] << unlucky_student\n end\n popular_group_size = popular_group_size - 1\n end\n end\n\n #if the group is still overpopulated, use random algo to move students out\n while result[most_popular_project].length > @group_size_max\n poor_student = result[most_popular_project].delete(result[most_popular_project].sample)\n result[result.find{ |key, value| key != most_popular_project && value.length <= @group_size_min }[0]] << poor_student\n end\n index = index + 1\n end\n\n # check if a group has too little students\n unfilled = result.find{ |key, value| value.length < @group_size_min}\n while (!unfilled.nil?) do\n most_p = find_most_popular_project(result)\n poor_student = result[most_p].delete_at(result[most_p].size - 1)\n result[unfilled[0]] << poor_student\n unfilled = result.find{|key, value| value.length < @group_size_min}\n end\n\n return result\n end", "def phase_one\n introduction\n title \"Phase One\"\n losers = 0\n immune_members = []\n 8.times do\n losing_tribe = @borneo.tribes.shuffle.first\n puts \"The losing tribe is #{losing_tribe}\".red\n loser = losing_tribe.tribal_council()#no immune members\n puts \" The loser member is #{loser}\"\n losers += 1\n counting = 0\n @borneo.tribes.each{|tribe| counting += tribe.members.length}\n puts \" #{losers} gone!\"\n puts \" #{counting} remaining players\"\n end\nend", "def wonky_coins(n)\n return 1 if n == 0\n\n # call wonky_coins from inside itself. This is called *recursion*.\n return wonky_coins(n / 2) + wonky_coins(n / 3) + wonky_coins(n / 4)\nend", "def print_cut_rod_solution(p,n)\n\nend", "def play_recursive(deck)\n seen = Set.new\n\n (1..).each do\n key = (deck[0] + [-1] + deck[1]).join(\",\")\n return 0 if seen.include?(key)\n\n seen.add(key)\n cards = deck.map(&:shift)\n winner = if cards[0] <= deck[0].size && cards[1] <= deck[1].size\n d0 = deck[0].take(cards[0])\n d1 = deck[1].take(cards[1])\n if d0.max > d1.max\n 0 # P1 has to win this subgame\n else\n play_recursive([deck[0].take(cards[0]), deck[1].take(cards[1])])\n end\n elsif cards[0] > cards[1]\n 0\n else\n 1\n end\n deck[winner] += winner.zero? ? cards : cards.reverse\n return 1 if deck[0].empty?\n return 0 if deck[1].empty?\n end\n end", "def threed(list)\n num3 = 0\n\n (list.length).times do |i|\n\n if i < list.length\n if list[i] == 3\n num3 += 1\n end\n if list[i] == 3 && list[i+1] == 3\n return false\n end\n elsif i + 1 == list.length\n i += 1\n if list[i] == 3 \n num3 += 1\n end\n if list[i] ==3 && list[i-1] == 3\n return false\n end\n end\n\n end\n if num3 != 3\n return false\n else\n return true\n end\nend", "def decent_number(n)\n\tleft = 0\n\tright = 0\n\t(n+1).times do |i|\n\t\tleft = n - i \n\t\tright = n - left\n\t#\tputs \"#{left}%3 = #{left%3} | #{right}%5 = #{right%5}\"\n\t\tbreak if left % 3 == 0 && right % 5 == 0\n\tend\n\t#puts \"**l = #{left} r = #{right}\"\n\n\tif left % 3 == 0 && right % 5 == 0\n\t\tfives = \"5\"*left\n\t\tthrees = \"3\"*right\n\t\tputs fives+threes\n\telse\n\t\tputs -1\n\tend\nend", "def problem(nth = 6,i = 13)\n while nth < 10001\n i += 2\n nth += 1 if i.prime?\n end\n i\n end", "def counterGame(n)\n # Write your code here\n pows = [1]\n pows.push(pows[-1] * 2) until pows[-1] >= n\n\n turn = 0\n\n until n == 1\n target_pow_i = pows.find_index { |p| p >= n }\n target_pow = pows[target_pow_i]\n if n == target_pow\n n /= 2\n else\n n -= pows[target_pow_i - 1]\n end\n\n turn += 1\n end\n\n turn.odd? ? 'Louise' : 'Richard'\nend", "def threed(list)\n count3 = 0 \n next_to = 0\n list.each do |n|\n if n == 3\n count3 += 1\n end \n end \n (list.size-1).times do |n|\n if list[n] == list[n+1]\n return false\n end \n end\n if count3 == 3\n return true\n elsif count3 > 3 || count3 < 3 \n return false\n end \nend", "def bottles(n)\n if n.zero?\n return puts \"No more bottles of beer on the wall\"\n elsif n == 1\n puts \"1 bottle of beer on the wall\"\n else\n puts \"#{n} bottles of beer on the wall\"\n end\n bottles(n-1)\nend", "def solve2( n = 150_000_000 )\n # Brute force.\n sum = 10\n i = 20\n\n while i < n\n if 0 != i % 3\n i2 = i*i\n\n # Must verify that the primes are consecutive (i.e. there aren't any\n # primes hiding between entries).\n if (i2 + 1).miller_rabin? &&\n (i2 + 3).miller_rabin? &&\n (i2 + 7).miller_rabin? &&\n (i2 + 9).miller_rabin? &&\n !(i2 + 11).miller_rabin? &&\n (i2 + 13).miller_rabin? &&\n !(i2 + 17).miller_rabin? &&\n !(i2 + 19).miller_rabin? &&\n !(i2 + 21).miller_rabin? &&\n !(i2 + 23).miller_rabin? &&\n (i2 + 27).miller_rabin?\n \n sum += i\n i += 315410\n end\n end\n\n # From observation that 10 | a_n in similar sequences.\n i += 10\n end\n\n sum\n end", "def make_greedy_change(amount, bank = [25,10,5,1])\n return [] if amount == 0\n\n bank.each_with_index do |coin, idx|\n next if coin > amount\n\n remainder = amount - coin\n return [coin] + make_greedy_change(remainder, bank)\n end\nend", "def dp_possible_trees(n)\n array = Array.new(n+2) { Array.new(n+1) { 0 } }\n (0...n+2).to_a.each do |i|\n array[i][0] = 1\n end\n\n sum = 0\n (1...n+1).to_a.each do |i|\n sum = 0\n (1..i).to_a.each do |j|\n array[j][i] = array[n+1][i-j] * array[n+1][j-1]\n sum += array[j][i]\n end\n array[n+1][i] = sum\n end\n array[n+1].last\nend", "def sol inp\n k, ins = inp.split(' ',2)\n k = k.to_i\n ps, pr, pi, pu, pw, pd, pl = ins.split.map(&:to_f)\n\n @ps = ps\n @pr = pr\n @pu = pu\n @pw = pw\n @pd = pd\n @pl = pl\n\n #\n # required_wins = 2\n # # winning 1st set\n # first_set = ps*pi + pr*(1-pi)\n # # winning 2nd set\n # first_set * winning_another_set + (1-first_set)*winning_another_set\n #\n # required_wins.times do |i|\n # count = 0\n # while count <= i\n # wins[i] = win_scene(pi,ps,pr, count)\n # count+=1\n # break if count == i\n # lose_scene(pi,ps,pr, pr,count)\n # end\n # end\n\n # winning second set after winning first + winning second set after winning one\n # wins[0]*win_scene(pi,ps,pr) + (1-wins[0])*lose_scene(pi,ps,pr)\n\n def win_scene(pi,round,required_wins,current_wins)\n return 0 if round >= required_wins\n # puts \"w #{' '*round},#{required_wins},#{current_wins})\"\n sunny = (round == 0) ? pi : (pi+(@pu*@pw))\n sunny = 1.0 if sunny > 1\n sunny = 0.0 if sunny < 0\n chance = sunny*@ps + (1-sunny)*@pr\n binding.pry if chance > 1\n\n if required_wins == current_wins+1\n chance\n else\n # return 0 if round > 100\n return 0 if (10**7*chance).to_i < 1\n wins = win_scene(sunny,round+1,required_wins,current_wins+1)\n # lose = lose_scene(sunny,round+1,required_wins,current_wins+1)\n chance * (wins)#+ (1-chance)*lose\n end\n end\n\n def lose_scene(pi,round,required_wins,current_wins)\n return 0 if round >= required_wins\n # puts \"l #{' '*round},#{required_wins},#{current_wins})\"\n sunny = (round == 0) ? pi : (pi-(@pd*@pl))\n sunny = 1.0 if sunny > 1\n sunny = 0.0 if sunny < 0\n chance = sunny*@ps + (1-sunny)*@pr\n binding.pry if chance > 1\n\n if required_wins == current_wins\n chance\n else\n # return 0 if round > 100\n return 0 if (10**7*chance).to_i < 1\n wins = win_scene(sunny,round+1,required_wins,current_wins+1)\n # lose = lose_scene(sunny,round+1,required_wins,current_wins+1)\n chance * (wins) #+ (1-chance)*lose\n end\n end\n\n # a = win_scene(pi,0,1,0)\n b = win_scene(pi,0,k,0)\n c = lose_scene(pi,0,k,0)\n # c = (k > 1) ? lose_scene(pi,1,k,0) : 0\n\n puts b\n puts c\n b +c\n # wtf?\n # 0.4* win_scene(pi,0,k,0)+ (1-0.6)*lose_scene(pi,0,k,0)\n\n# def smth(pi, ps, pr, setcount=0)\n# arr[1] = arr[0]\n# end\n# # set 2+ ?\n# set2 = ((ps+pu)*pw + ps*(1-pw))*pi\n# (1-set1)*((ps-pd)*pl + ps*(1-pl))\n# if k > 1\n# (k-1).times do\n#\n# end\n# end\nend", "def deal5cards (n)", "def follows_conjecture?(n)\r\n 0.upto(n) do |i|\r\n break if i ** 2 > n\r\n 2.each_prime do |p|\r\n num = p + 2 * (i ** 2)\r\n return true if num == n\r\n break if num > n\r\n end\r\n end\r\n return false\r\nend", "def josephus(items,k)\n new_array = []\n while items.size > (k-1)\n new_array << items.delete_at(k-1)\n items.rotate!(k-1)\n end\n while items.size > 0\n items.rotate!(k-1)\n new_array << items.delete_at(0)\n end\n new_array\nend", "def bottles(n)\n if n == 0\n puts 'no more bottles of beer on the wall'\n else\n puts \"#{n} bottles of beer on the wall\"\n bottles(n - 1)\n end\nend", "def brute_resolve(num)\n while num != 1 && num != 89 do\n num = shrink num\n end\n num\nend", "def pzoe\n sum = 0\n (0..9).each do |a|\n (0..9).each do |b|\n (0..9).each do |c|\n (0..9).each do |e|\n (0..9).each do |f|\n (0..9).each do |g|\n sum += a * 100000 + b * 10000 + c * 1000 + e * 100 + f * 10 + g if a * 100000 + b * 10000 + c * 1000 + e * 100 + f * 10 + g == a ** 5 + b ** 5 + c ** 5 + e ** 5 + f ** 5 + g ** 5\n end\n end\n end\n end\n end\n end\n sum - 1\nend", "def solve( n = 99 )\n type = [0, 0, 0, 0]\n x, limit = 0, 0\n\n begin\n x += 1\n\n # As x increases, keep a running total of n*x and 100 times the count of\n # bouncy numbers so far. This makes our percentage check a simple (and\n # exact) comparison of integers for equality. \n limit += n\n type[ x.bounce ] += 100\n end while limit != type[3]\n\n x\n end", "def walk_through\n count = 0\n for i in 0..@n-1\n for j in 0..@m-1\n if @garden[i][j] == 'W'\n @garden[i][j] = 'C'\n count += 1\n check_around(i,j)\n end\n end\n end\n puts count\n end", "def bunny(n, ears = 0)\n if ears == n + n \n return ears\n else\n ears += n\n bunny(n, ears)\n end \nend", "def possible_king_moves(start_arr)\n\t\tx = start_arr[0]\n\t\ty = start_arr[1]\n\t\tcandidates = []\n\t\tcandidates << [x+1,y]\n\t\tcandidates << [x-1,y]\t\t\n\t\tcandidates << [x,y+1]\t\t\t\t\n\t\tcandidates << [x,y-1]\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tcandidates << [x+1,y+1]\n\t\tcandidates << [x-1,y-1]\t\n\t\tcandidates << [x-1,y+1]\t\t\t\t\n\t\tcandidates << [x+1,y-1]\t\t\t\t\n\t\tchildren = candidates.select { |pos| pos[0] >= 0 && pos[1] >= 0 && pos[0] <= 7 && pos[1] <= 7}\n\t\tchildren.delete_if do |child|\n\t\t\tif !(@board[child] == \"*\")\n\t\t\t\t# If pieces not same color\n\t\t\t\tif @board[child].color == @board[start_arr].color\n\t\t\t\t\tif occupied(child)\n\t\t\t\t\t\tcan_do = true\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tchildren\n\tend", "def saveThePrisoner(n, m, s)\n res = ((m - 1) + s) % n\n res == 0 ? n : res \nend", "def ninety_nine_bottles_of_beer\n 99.downto(1) do |n|\n nouns = Hash.new('bottles')\n nouns[1] = 'bottle'\n\n puts \"#{n} #{nouns[n]} of beer on the wall\"\n puts \"#{n} #{nouns[n]} of beer\"\n puts 'take one down, pass it around'\n puts \"#{n-1} #{nouns[n-1]} of beer on the wall\\n\\n\" if n > 1\n end\n puts 'no bottles of beer on the wall'\nend", "def find_kevin_bacon(actor)\n # deal with Kevin Bacon as input\n if actor.name == \"Kevin_Bacon\"\n puts \"Kevin Bacon:\"\n puts \"Nobody is closer to Kevin Bacon than Kevin Bacon.\"\n return\n end\n\n # call the \n answer = fkb(actor)\n if !answer\n puts \"There is either no connection between #{actor.name} and Kevin Bacon or the separation is greater than 6 degrees.\"\n return\n end\n\n # compute the degrees of separation\n degrees_of_separation = (answer.size - 1) / 2\n\n # pluralize degree appropriately (yes, I know there is a method for this, but it\n # was quicker to write this than look it up)\n if degrees_of_separation == 1\n degree = \"degree\"\n else\n degree = \"degrees\"\n end\n\n # output the degrees of separation and then cycle through the array, outputting\n # each edge and the resulting node\n puts \"#{actor.name} is separated from Kevin Bacon by #{degrees_of_separation} #{degree}.\"\n puts \"#{actor.name} was in:\"\n (1...answer.size - 2).step(2).each do |x|\n puts \"#{answer[x]} with #{answer[x + 1]} who was in:\"\n end\n puts \"#{answer[-2]} with Kevin Bacon.\"\nend", "def night_vote\n puts \"Its night time\"\n @players.each do |player|\n unless player.dead?\n if player.role == \"werewolf\"\n player.make_vote\n unless @player_names.include?(player.vote)\n puts \"You must kill someone in the game!\"\n player.make_vote\n end\n end\n end\n end\n vote_count = Hash.new(0)\n @players.each do |player|\n if player.role == \"werewolf\"\n vote_count[player.vote] += 1\n end\n end\n highest_vote = vote_count.max_by{ |k,v| v }\n highest_vote = highest_vote.delete_if {|item| item.is_a?(Integer)}\n if highest_vote.length == 1\n \t@players.each do |player|\n if player.name == highest_vote[0]\n player.kill\n @dead_players << player.name\n puts \"#{player.name} has been killed!\"\n end\n end\n else\n @players.each do |player|\n if player.name == highest_vote[rand(0..highest_vote.length)]\n player.kill\n @dead_players << player.name\n puts \"#{player.name} has been killed!\"\n end\n end\n end\n end", "def bottles(n)\n if n == 0 \n puts 'no more bottles of beer on the wall'\n else\n puts \"#{n} bottles of beer on the wall \"\n bottles(n-1)\n end\nend", "def turn\n #I always start a turn by show the player the latest values of all the piles by calling my showPiles function\n showPiles()\n\n #Here i set some out-of-bounds defaults so that the until statements start false, allowing the player to make their choice\n take = -1\n pile = -1\n sum = 0\n\n #at the start of the turn I check if the sum of the sticks in all the piles is 0 or less, indicating that there are no more moves to make and this player has won\n $piles.each do |i|\n sum += i.count\n end\n if sum <= 0\n puts $name.to_name + \", You win!!\"\n return #this return is to exit the turn function returning to the rest of the code which is empty, essentially stopping the game now that it has been determined to be won and over.\n end\n\n #this ensures that the pile chosen is a valid number,because until it is it wont stop asking\n until pile.between?(0,2)\n print $name.to_name + \", Choose a pile:\"\n pile = gets.chomp().to_i\n end\n\n #this ensures that the pile chosen isnt already empty by restarting the turn if the chosen piles count is 0 or less\n if $piles[pile].count <= 0\n puts \"That pile is already empty, try again\"\n turn()\n return\n end\n\n #this ensures that the pile chosen has enough sticks in it to complete the users move of taking their defined sticks.\n until take.between?(1,$piles[pile].count)\n print \"How many to remove from pile \" + pile.to_s + \":\"\n take = gets.chomp().to_i\n end\n\n #this will only be ran once everything above it has been determined the move to be a plausible move, and calls the take function for the users decided sticks from their decided pile\n $piles[pile].take(take)\n\n #this inverts the name boolean so that it will show the next players name on the next turn\n $name = !$name\n #this begins the next players turn by calling the turn function, now that this players turn is done\n turn()\nend", "def problem_57a\n root2 = lambda do |depth|\n if depth == 0\n Rational(1,2) \n else\n Rational(1,(root2.call(depth - 1) + 2))\n end\n end\n ret = 0\n 1000.times do |n|\n r = root2.call(n) + 1\n ret += 1 if r.numerator.to_s.length > r.denominator.to_s.length\n end\n ret\nend", "def bhaskara_brouncker(n)\r\n\t\tt = sqrt = isqrt(n)\r\n\t\tu, u1 = 0, sqrt\r\n\t\tc, c1 = 1, n - sqrt ** 2\r\n\t\ta, a1 = 1, sqrt\r\n\t\tb, b1 = 0, 1\r\n\r\n\t\tuntil 1 == c1\r\n\t\t\tt = (sqrt + u1) / c1\r\n\t\t\tu1, u = t * c1 - u1, u1\r\n\t\t\tc1, c = c + t * (u - u1), c1\r\n\t\t\ta1, a = a + t * a1, a1\r\n\t\t\tb1, b = b + t * b1, b1\r\n\t\tend\r\n\r\n\t\treturn a1, b1\r\n\tend", "def egyptian(rational_n)\n denominators = []\n next_denom = 1\n loop do\n denominators << next_denom\n sum = denominators.reduce(Rational(0)) do |accum, denom|\n accum + Rational(1, denom)\n end\n break if sum == rational_n\n denominators.pop if sum > rational_n\n next_denom += 1\n end\n denominators\nend", "def rank_starting_hand\r\n sorted_hand = @hole_cards.sort_by { |card| card.rank } # [4,2] => [2,4]\r\n\r\n # Shorthand variables for two cards in hand\r\n (first,second) = [sorted_hand[0],sorted_hand[1]]\r\n\r\n suited = first.suit == second.suit # True if cards have same suit\r\n paired = first.rank == second.rank # True if cards have same rank\r\n connected = first.rank + 1 == second.rank # True if cards have consecutive ranks\r\n\r\n # Check for playable hands and return their rank\r\n # (Some of these checks aren't necessary but are included for readibility)\r\n case first.rank\r\n when 8 then return 14 if paired # Pocket Eights\r\n when 9 then return 9 if paired # Pocket Nines\r\n when 10\r\n return 6 if paired # Pocket Tens\r\n return 20 if second.rank == 12 and suited # Queen-Ten Suited\r\n return 16 if second.rank == 13 and suited # King-Ten Suited\r\n return 12 if second.rank == 14 and suited # Ace-Ten Suited\r\n when 11\r\n return 4 if paired # Pocket Jacks\r\n return 17 if second.rank == 12 and suited # Queen-Jack Suited\r\n return 15 if second.rank == 13 and suited # King-Jack Suited\r\n if second.rank == 14\r\n return suited ? 10 : 18 # Ace-Jack Suited/Offsuit\r\n end\r\n when 12\r\n return 3 if paired # Pocket Queens\r\n if second.rank == 13\r\n return suited ? 11 : 19 # King-Queen Suited/Offsuit\r\n elsif second.rank == 14\r\n return suited ? 8 : 13 # Ace-Queen Suited/Offsuit\r\n end\r\n when 13\r\n return 2 if paired # Pocket Kings\r\n if second.rank == 14\r\n return suited ? 5 : 7 # Ace-King Suited/Offsuit\r\n end\r\n when 14 then return 1 if paired # Pocket Aces\r\n end\r\n # Still played if the hand is suited, paired, or connected, otherwise not played\r\n return (suited or paired or connected) ? 21 : -1\r\n end", "def candies(n, arr)\n cc = []\n cc[0] = 1\n 1.upto(n-1) do |i|\n if arr[i] > arr[i-1]\n cc[i] = cc[i-1] + 1\n else\n cc[i] = 1\n end\n end\n p cc\n (n-2).downto(0) do |i|\n if arr[i] > arr[i+1] && cc[i] <= cc[i+1]\n cc[i] = cc[i+1] + 1\n end\n end\n p cc\n cc.reduce(:+)\nend", "def simulate(preferences, vote_order, debug = false)\n\t#winner is an array where the index indicates the round of voting, and the value \n\t#indicates the candidate that will win given that they've made it to this round\n\twinner = []\n\tnum_rounds = vote_order.length - 1\n\tnum_candidates = preferences.length\n\n\t#start with the final round of voting and build backwards\n\tnum_rounds.downto(1).each do |i|\n\t\tmatchup_a = vote_order[i - 1]\n\t\t#a vote for matchup_b is a vote for b OR whoever is going to win in the next round\n\t\tmatchup_b = vote_order[i]\n\n\t\t#vote is an array where the index indicates the candidate, and the value indicates which of the \n\t\t#two current candidates they are voting for (0 = a, 1 = b)\n\t\tvote = []\n\n\t\tif winner.length == 0\n\t\t\t#if this is the last round, next winner is matchup_b\n\t\t\tnext_winner = matchup_b\n\t\telse\n\t\t\t#if this is not the last round, next winner is the winner in the next round\n\t\t\tnext_winner = winner[0]\n\t\tend \n\n\t\t0.upto(num_candidates - 1).each do |j|\n\t\t\t#if candidate j prefers next_winner to a, they vote for b. Otherwise they vote for a.\n\t\t\t#note there can never be a tie in this formulation.\n\t\t\tif debug\n\t\t\t\tputs \"Candidate \" + j.to_s + \" voting between \" + matchup_a.to_s + \" and \" + next_winner.to_s + \"...\"\n\t\t\tend\n\t\t\tif preferences[j].index(matchup_a) < preferences[j].index(next_winner)\n\t\t\t\tif debug\n\t\t\t\t\tputs matchup_a\n\t\t\t\tend\n\t\t\t\tvote[j] = 0\n\t\t\telse\n\t\t\t\tif debug\n\t\t\t\t\tputs next_winner\n\t\t\t\tend\n\t\t\t\tvote[j] = 1\n\t\t\tend\n\t\tend\n\t\t#if vote.inject(:+) < num_candidates.to_f / 2.0\n\t\tif vote.inject(:+) <= num_candidates.to_f / 2.0\n\t\t\t#a has it, a is this round's winner\n\t\t\tif debug\n\t\t\t\tputs \"**** \" + matchup_a.to_s + \" wins!\"\n\t\t\tend\n\t\t\twinner.unshift(matchup_a)\n\t\telse\n\t\t\t#b has it, this round's winner is whoever wins the next round\n\t\t\tif debug\n\t\t\t\tputs \"**** \" + next_winner.to_s + \" wins!\"\n\t\t\tend\n\t\t\twinner.unshift(next_winner)\n\t\tend\n\tend\n\treturn winner\nend", "def next_unattempted\n fewest_potential_pairs(unattempted_people)\n end", "def rig_santas(people)\n santas = people.dup\n santas[0] = people[5] # 0 gets from 5\n santas[1] = people[2] # 1 gets from 2\n santas[2] = people[0] # 2 gets from 0\n santas[3] = people[4] # 3 gets from 4\n santas[4] = people[1] # 4 gets from 1\n santas[5] = people[3] # 5 gets from 3\n (0..(people.size-1)).each { |n| people[n].santa = santas[n] }\n santas\nend", "def fitness\n -(0..5).map{|t| \n $pors_store = 0 # reset store\n t_val = t\n values = {:rec=>proc{$pors_store},:T=>proc{ cv=t_val; t_val=0; cv} } # using T destroys T\n (eval_genes(values) - N*t).abs \n }.sum - 0.1*size # find a tree that multiplies T by 3\n end", "def try_to_loan(loan)\n atms = Array.new(100) { |i| i.even? ? 2**i : -2**i }\n signs = atms.dup\n moves = []\n while loan != 0\n # binding.pry\n first_bigger, method = next_value(loan, atms)\n break if first_bigger == false\n if method == :cut\n moves << signs.index(atms[first_bigger])\n loan -= atms.delete_at(first_bigger)\n moves << signs.index(atms[first_bigger - 1]) if loan != 1\n loan -= atms.delete_at(first_bigger - 1) if loan != 1\n else\n moves << signs.index(atms[first_bigger - 2])\n loan -= atms.delete_at(first_bigger - 2)\n end\n p moves\n p loan\n end\nend", "def work(toy_index, cube)\n if $debug && cube.available_heads.empty?\n puts \"\\t\" * toy_index + \"Working for piece #{toy_index} but it has no available heads; recursing.\"\n end\n\n if $debug\n puts \"\\t\" * toy_index + \"Working for piece #{toy_index} which has #{cube.available_heads.count} available heads. Cube:\"\n cube.display_in_line(toy_index)\n end\n\n cube.available_heads.each do |available_head|\n cah = C.new(available_head[:face], available_head[:row], available_head[:left])\n\n puts \"\\t\" * toy_index + \"Attempting to place piece #{toy_index} from head #{cah.to_s}\" if $debug\n\n [:vertical_up, :vertical_down, :sideways_right, :sideways_left, :long_far, :long_near].each do |orientation|\n if cube.place! piece: $toy[toy_index], orientation: orientation, c: cah\n puts \"\\t\" * toy_index + \"\\tPlaced piece #{toy_index} in orientation #{orientation}\" if $debug\n\n if cube.complete?\n $solution_counter += 1\n puts \"====================== SOLUTION #{$solution_counter} FOUND! ===========================\"\n cube.display_in_line\n else\n if toy_index <= $toy.size && !cube.available_heads.empty?\n work(toy_index + 1, cube.clone2)\n else\n puts \"\\t\" * toy_index + \"Not progressing to piece #{toy_index + 1}, no available heads.\" if $debug\n end\n end\n\n puts \"\\t\" * toy_index + \"Undo orientation #{orientation} and progressing to the next one.\" if $debug\n cube.undo!\n else\n puts \"\\t\" * toy_index + \"\\t\\tTried to place piece #{toy_index} in orientation #{orientation} but it didn't work\" if $debug\n end\n end\n puts \"\\t\" * toy_index + \"Tried all possible orientations, moving to the next available head.\" if $debug\n end\n puts \"\\t\" * toy_index + \"Tried all available heads. Recurse back from piece #{toy_index} to piece #{toy_index - 1}.\" if $debug\nend", "def solution(a)\n\traise ArgumentError.new(\"a has to be non empty array of max size #{MAX_LEN}\") if !a.is_a? Array or a.empty? or a.length > MAX_LEN\n\tret = 0\n\t#puts a.inspect\n\tmy_h = Hash.new\n\ta.each do |e|\n\t\tif my_h.include? e\n\t\t\tmy_h[e] += 1\n\t\telse\n\t\t\tmy_h[e] = 1\n\t\tend\n\tend\n\n\tmy_h_sort = my_h.sort_by {|k, v| -v}\n\t# -> my_h_sort[value][occurances]\n\treturn 0 if my_h_sort.first[1] < a.size/2\n\tleader_val = my_h_sort.first[0]\n\n\tocc_array = Array.new\n\toccurances = 0\n\ta.each do |e|\n\t\toccurances += 1 if e == leader_val\n\t\tocc_array.push(occurances)\n\tend\n\t#puts occ_array.inspect\n\n\tfor idx in (0...a.length-1) do\n\t\tsum1 = occ_array[idx]\n\t\tsum2 = occ_array.last - occ_array[idx]\n\n\t\t# puts \"#{idx}+1 < #{sum1*2}\"\n\t\t# puts \"#{(a.length - idx -1)} < #{(sum2*2 )} \"\n\n\t\tif (idx+1) < sum1 * 2 && (a.length - idx - 1 ) < sum2 * 2\n\t\t\t## we have a leader\n\t\t\t#puts \"YEAH #{idx}\"\n\t\t\tret += 1\n\t\tend\n\t\t\t#puts \"-------- ret: #{ret}\"\n\tend\n\treturn ret\nend", "def bunny(n)\n if n == 0\n return n\n else\n return 2 + bunny(n-1)\n end\nend", "def change_possibilities_bottom_up(amount, denominations)\n ways_of_doing_n_cents = [0] * (amount + 1)\n ways_of_doing_n_cents[0] = 1\n\n denominations.each do |coin|\n (coin..amount).each do |higher_amount|\n higher_amount_remainder = higher_amount - coin \n ways_of_doing_n_cents[higher_amount] += ways_of_doing_n_cents[higher_amount_remainder]\n end\n end\n ways_of_doing_n_cents\nend", "def towers_of_hanoi(ndisks, startPeg, endPeg)\n # solves the towers of hanoi problem\n\n # variable\n six = 6\n\n # if statement\n if ndisks == 1\n puts \"Move disk 1 from peg #{startPeg} to peg #{endPeg}\"\n else\n towers_of_hanoi(ndisks - 1, startPeg, six - startPeg - endPeg)\n puts \"Move disk #{ndisks} from peg #{startPeg} to peg #{endPeg}\"\n towers_of_hanoi(ndisks - 1, six - startPeg - endPeg, endPeg)\n end\nend", "def ideal_numbers(n)\n # perfects = []\n # factors = proper_factors(n)\n\n # while perfects.length <= n \n # factors.each do |factor|\n # sum = aliquot_sum(n)\n \n # if factor == perfect_number?(factor)\n # perfects << factor\n # end \n # end \n # end\n\n perfect_nums = []\n\n i = 1\n while perfect_nums.length < n \n perfect_nums << i if perfect_number?(i)\n i += 1\n end \n\n perfect_nums\nend", "def runCase player_index\n\tp = player_index.sort_by{|val| val[0].power[1]}.reverse\n\ts = 0\n\ttemp = p[s][0]\n\tfor i in 0..player_index.length-2\n\t\tif(temp.power[1]==p[i+1][0].power[1])\n\t\t\twinner = 0\n\t\telsif(temp.power[1]<p[i+1][0].power[1] && temp.power[1]!=3)\n\t\t\twinner = p[i+1][1]\n\t\t\ttemp = p[i+1][0]\n\t\t\ts =i+1\n\t\telsif(temp.power[1]==3 && p[i+1][0].power[1]==14)\n\t\t\twinner = p[i+1][1]\n\t\t\ttemp = p[i+1][0]\n\t\t\ts =i+1\n\t\telse\n\t\t\twinner = p[s][1]\t\t\t\n\t\tend\t\n\tend\nend", "def bunny(n)\n\n return 0 if n == 0\n return 2 if n == 1\n bunny(n - 1) + 2\n\nend", "def replace_worst_ranked(offsprings)\n size = offsprings.length\n @population = @population [0..((-1*size)-1)] + offsprings\n end", "def forw(members, up_to, counter, player)\n\n\t\t\t# Skips player\n\t\t# if number(Counter) is divisible by 11 will add 1 to player to skip player.\n\tif counter % 11 == 0 && counter != 0\n\t\tplayer += 1\n\n\t\t\t# Fail-Safe to prevent players go above real number of players\n\t\tif player == (members + 1)\n\t\t\tplayer = 1\n\t\tend\n\n\t\t\t# Not nesesary: will inform what player gets skiped\n\t\tputs \" Player #{player} skipt\"\n\tend \n\n\n\t\t# adding 1 to the variables received\n\tplayer += 1\t\n\tcounter += 1\n\n\n\t\t# fail-safe to reset player number if it goes above number provided\n\tif player == (members + 1)\n\t\tplayer = 1\n\tend\n\t\t\n\n\t\t# Not nesesary but provides better format on the output\n\t\t# it adds a extra space when player # is less than 10\n\tif player < 10\n\t\tspace = \" \"\n\telse\n\t\tspace = \"\"\n\tend\n\n\n\t\t# \tthis if is not needed, it just provide a fancy output to the las player\n\tif counter == up_to\n\t\tputs \" ---------------------------------\"\n\t\tputs \n\t\tputs \" Player '#{player}' with the Number: #{counter} \"\n\t\t\n\n\t\t# \tOutput for each player this provide the folowing information:\n\t\t# \t01 - What method was executed\n\t\t# \t02 - What player turn is\n\t\t# \t03 - What number such player said\n\telse\n\t\tputs \"Forw - Player: #{space}#{player} - Number: #{counter}\"\n\tend\n\n\n\t\t# will exit this method and call the \"back()\"\" method to make players sequence go backwas\n\t\t# will pass current value of parameters. \n\tif counter % 7 == 0\n\t\t\t# the next line is Not nesesary: will inform the change of direction.\n\t\tputs \" Change direction\"\n\t\tback(members, up_to, counter, player)\n\tend\t\n\n\n\t\t# will exit this method and call the \"done()\" method to end the game\n\tif counter == (up_to)\n\t\tdone()\n\tend\n\n\n\t# will start this method again, pasing current value of parameters\n\t\tforw(members, up_to, counter, player)\nend" ]
[ "0.6541671", "0.6340938", "0.6337015", "0.62028027", "0.6059637", "0.5977629", "0.5865469", "0.5836", "0.5833611", "0.580552", "0.5775551", "0.57754505", "0.5735182", "0.5722435", "0.5682892", "0.5675171", "0.5675109", "0.560567", "0.5578288", "0.5578102", "0.5573333", "0.55381113", "0.5507158", "0.5479867", "0.54628444", "0.54592997", "0.54490036", "0.54464626", "0.54225004", "0.54191023", "0.5394134", "0.53735524", "0.5372588", "0.5370053", "0.5355079", "0.53508604", "0.534199", "0.53410596", "0.53388405", "0.53311944", "0.5331008", "0.53127074", "0.53063315", "0.5288357", "0.5287475", "0.5287051", "0.52729255", "0.52714324", "0.5263632", "0.52522546", "0.5243083", "0.52398276", "0.5230861", "0.5228047", "0.5220402", "0.52191615", "0.52138484", "0.5211607", "0.52085966", "0.5195369", "0.51940703", "0.5192346", "0.5190604", "0.5187503", "0.51814353", "0.5179686", "0.51769966", "0.5169265", "0.51664156", "0.5155075", "0.5149536", "0.51451504", "0.51440424", "0.514278", "0.51293504", "0.5129274", "0.51280046", "0.5120263", "0.5118826", "0.51140654", "0.5111423", "0.51112807", "0.5109461", "0.5105532", "0.5101494", "0.50986993", "0.50982755", "0.50932926", "0.50927234", "0.5092349", "0.5091655", "0.5091052", "0.50904083", "0.50892943", "0.50846934", "0.50842565", "0.5082347", "0.5077868", "0.5076784", "0.5076174" ]
0.60070944
5
josephus([1,2,3,4,5,6,7,8,9],5) nonrecursive but still beautiful
def factorial(n) (1..n).inject(1) {|product, n| product * n } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def josephus(items,k)\n n = -1\n out = []\n while items.length > 0 do \n n = (n + k) % items.length \n out.push(items.slice!(n))\n n -= 1 \n end\n out\nend", "def josephus(items, k)\n result = []\n items.length.times do\n items.rotate!(k - 1)\n result << items.shift\n end\n result\nend", "def josephus(n,m)\n\n while n.size>0\n puts n.rotate!(m-1).shift(1)\n josephus(n,m)\n end\nend", "def josephus(items,k)\n killed = []\n # loop the following two until items == []\n until items.length == 0 do\n items = items.rotate(k)\n killed << items.pop\n end\n killed\nend", "def josephus(items,k)\n Array.new(items.size) { items.rotate!(k).pop }\nend", "def josephus(n,k)\n if(n == 1)\n return 0\n end\n\n (josephus(n-1, k) + k) % n\nend", "def josephus(items,k)\n result = []\n count = k\n until items.length == 0 do\n remove_these = []\n items.each_with_index do |item, i|\n if count == 1\n result << items[i]\n remove_these << i\n end\n count = count == 1 ? k : count -= 1\n end\n remove_these.reverse!\n remove_these.each do |r|\n items.delete_at(r)\n end\n end\n result\nend", "def josephus_2(items, k)\r\n Array.new(items.length) { items.rotate!(k).pop }\r\nend", "def josephus(items,k)\n new_array = []\n while items.size > (k-1)\n new_array << items.delete_at(k-1)\n items.rotate!(k-1)\n end\n while items.size > 0\n items.rotate!(k-1)\n new_array << items.delete_at(0)\n end\n new_array\nend", "def josephus_survivor(n,k)\n # (1..n) people are put into the circle\n items = (1..n).to_a\n Array.new(n){items.rotate!(k-1).shift}.last\nend", "def josephus(list, step)\n \n link_to_update = list.head\n current_link = list.head\n \n while true\n (step - 2).times do \n link_to_update = link_to_update.nxt\n end\n \n step.times do \n current_link = current_link.nxt\n end\n \n return link_to_update.content if (link_to_update == current_link && step % 2 == 0)\n return current_link.content if (link_to_update == link_to_update.nxt && step % 2 == 1)\n \n link_to_update.nxt = current_link\n link_to_update = current_link\n end\n \nend", "def given\n [6,5,3,1,8,7,2,3]\nend", "def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n result = (result + k - 1) % i + 1\n end\n \n result\nend", "def josephus(n,m)\n arr = Array.new\n order = Array.new\n\n for i in 1..n\n arr[i] = i\n end\n\n arr.compact!\n\n for i in 0..n-1\n arr= arr.rotate(m-1)\n order << arr[0]\n arr[0] = nil\n arr.compact!\n end\n\n puts \"order: #{order.to_s}\"\nend", "def josephus(arr, k)\n removed_elements = []\n while arr.length > 0 do\n arr = arr.rotate(k)\n removed_elements << arr.pop\n end\n removed_elements\nend", "def ptn(a)\n if a.size == 1 then\n return [a]\n end\n ret = Array.new\n # 重ならないパターン\n ret += a.perms\n # 重なるパターン\n h1 = Hash.new\n for i in 0..a.size - 1\n for j in i + 1..a.size - 1\n key = [a[i], 0, a[j]].to_s\n if !h1.key?(key) then\n h1.store(key, nil)\n h2 = Hash.new\n # a[i]とa[j]を範囲をずらしながら重ねる\n for k in 0..a[i].size + a[j].size\n t = [0] * a[j].size + a[i] + [0] * a[j].size\n for m in 0..a[j].size - 1\n t[k + m] += a[j][m]\n end\n # 余分な0を取り除く\n t.delete(0)\n # 4より大きい値がないかチェック\n next if t.any? {|v| v > 4}\n # 9より長くないかチェック\n next if t.size > 9\n # 重複チェック\n if !h2.key?(t.to_s) then\n h2.store(t.to_s, nil)\n # 残り\n t2 = a.dup\n t2.delete_at(i)\n t2.delete_at(j - 1)\n # 再帰呼び出し\n ret += ptn([t] + t2)\n end\n end\n end\n end\n end\n return ret\nend", "def josephus_survivor(n,k)\n arr = (1..n).to_a\n\n while arr.length > 1\n idx = k % arr.length\n\n if arr.length > k\n arr = arr.drop(k) + arr.take(k - 1)\n elsif arr.length == k \n arr = arr[0...-1]\n else\n arr = arr.drop(idx) + arr.take(idx - 1)\n end\n end\n \n arr[0]\nend", "def perm_recur(ans=\"\",s)\n if s.length == 0\n return\n end\n\n if s.length == 1\n puts ans + s\n return\n end\n \n if s.length == 2\n puts ans + s[0] + s[1] \n puts ans + s[1] + s[0]\n return\n end\n\n (0..s.size-1).each do |l|\n new = s.chars.rotate(l).join('')\n element = new[0] \n rest = new[1..new.size-1]\n perm_recur(ans + element, rest)\n end\nend", "def rotate(nums, k)\n k.times do\n ele = nums.pop\n nums.unshift(ele)\n end\nreturn nums\nend", "def k(n); 5 * n * n; end", "def walker(list)\nidx = 1\n if list.length <= 2\n return list.flatten,list.length\n end\n walked = [list[0]]\n starting_list = list[1,list.length]\n starting_list.each do |el|\n if el == walked[-1] + 1\n walked.append(el)\n idx += 1\n else\n break\n end\n end\n if walked.length >= 3\n return \"#{walked[0]}-#{walked[-1]}\",idx\n else\n return walked.flatten,idx\n end\nend", "def multiples_rec(num)\n if num.zero?\n return num\n elsif num % 5 == 0 || num % 3 == 0\n num + multiples_rec(num - 1)\n else\n multiples_rec(num - 1)\n end\nend", "def series_up(n)\n list = []\n (n+1).times do |a|\n a.times do |b|\n list.push(b+1)\n end \n end\n return list\nend", "def factorials_rec(num)\r\n return [1,1].take(num) if num < 3\r\n factorials = factorials_rec(num - 1)\r\n factorials << factorials.last * (num -1)\r\nend", "def factorials_rec(num)\n return [1] if num == 1\n return [] if num == 0\n prev_seq = factorials_rec(num-1)\n prev_seq << factorials(num)\n prev_seq\n\nend", "def series_up(nums) \r\n series = 0 # start the list at the right \r\n list = [] # the list is empty at the start \r\n nums.times do |seq| \r\n n = 0 \r\n nums.times do |nums| # run a loop for the sequence \r\n list[n + series] = n + 1 \r\n n += 1 \r\n end \r\n series += seq + 1 # exponential growth \r\nend \r\n return list \r\nend", "def series_up(n) # given n, return a list that goes [1,1,2,1,2,3... n]\n n_list = []\n (n+1).times do |m|\n m.times do |val|\n n_list.push(val+1)\n end\n end\n return n_list\nend", "def solve(nums, k)\n k.times do\n nums.push(nums.shift)\n end\n return nums\nend", "def multiply(arr, beg, result)\n while arr[result*5].nil?\n arr.push(2 * arr[beg] + 1).push(3 * arr[beg] + 1).uniq!\n arr.sort!\n multiply(arr, beg + 1 ,result)\n end\nend", "def prime_factorization(num)\n return [num] if prime?(num)\n [2,3,5].each do |factor|\n if num % factor == 0\n return [factor] + prime_factorization(num / factor)\n end\n end\nend", "def lucas_sequence(n)\n return [] if n == 0\n return [2] if n == 1\n return [2,1] if n== 2\n\n result = lucas_sequence(n-1)\n result << result[-1] + result[-2]\n result\nend", "def solution(number)\r\n (3...number).each_with_object([]) { |n, arr| arr << n if (n % 3).zero? || (n % 5).zero? }.uniq.sum\r\nend", "def factorials_rec(num)\n #6 == [0!, 1!, 2!, 3!, 4!, 5!]\n return [1] if num == 1\n\n factorials_rec(num-1) + [(num-1) * factorials_rec(num-1).last]\nend", "def lucas_sequence(num)\n return [] if num == 0\n return [2] if num == 1\n return [2,1] if num == 2\n prev = lucas_sequence(num-1)\n el = prev[-1] + prev[-2]\n prev << el\nend", "def slippery_numbers(n)\nend", "def series_up(n) # Got help again. My first code couldn't adapt at all. This one has a reset limit, meaning it loops the amount of times it needs to for each interger. Still not perfect, but almost there. \n list = [1]\n i = 1\n length = n*(n+1)/2\n reset = 3\n list.push i\n i += 1\n if i == reset\n reset += 1\n end\n return list\nend", "def ject(ary)\nr = [ary]\nw = []\n\nr.flatten.each do |y| \n\tif y == 0\n\t\tw << 0\n\telse\n\t\t3.times {|idx| w << ( y / (idx + 2) )}\n\tend\nend\nw\nend", "def doubler(numbers)\n new_numbers = []\n # numbers.each { |num| new_numbers << num * 2 }\n numbers.each { |num| new_numbers.push(num * 2) }\n new_numbers\nend", "def multiples_of_3_and_5_recursive(num, sum = 0)\n return sum if num == 0\n\n num = num - 1\n\n if (num % 3 == 0) || (num % 5 == 0)\n sum += num\n end\n\n multiples_of_3_and_5_recursive(num, sum)\n\nend", "def make_pattern(array = [], number) # Define a method with two paremeter one array which will be the output and another one which is the given number.\r\n if number <= 0 # This is our base case it will stop if the number is 0 or less than that.\r\n array << number #Then we will push the number in to the array.\r\n\t\tarray << array.reverse #Now we will push the array in to it self, But in reverse order.\r\n\t\tarray.flatten! # At this two point we have a nested array it should be turn to one array.\r\n array.delete_at(array.length / 2) # Now there is a problem in our array the middle element of the array is repeated twice.So we delete one.\r\n return array # The array is ready to be called.\r\n end\r\n array << number # It pushes the number in to array \r\n make_pattern(array , number - 5) # This will make our method recursive.It will deduct 5 from our number at each time the method execute.\r\nend", "def collapse(nums)\n (0...nums.length - 1).each do |i|\n if nums[i] + 1 == nums[i + 1] || nums[i] == nums[i + 1] + 1\n return nums[0...i] + nums[i + 2..-1]\n end\n end\n\n nums\nend", "def rotate3(nums, k)\n k.times do\n nums.unshift(nums.pop)\n end\n nums\nend", "def series_up(n)\n #nlist is the list that will be the output of the code\n nlist = []\n #i changed from an if statement to a loop.\n (n*(n+1)/2+1).times do |i|\n i.times do |x|\n nlist.push(x+1)\n end\n end\n #I use three dots to only get the information i need from the code\n return nlist[0...(n*(n+1)/2)].to_a\nend", "def multiples_up_to(limit, divisor, multiples_to_limit=[])\n if limit < 1\n return multiples_to_limit\n end\n multiple = limit - (limit % divisor)\n multiples_to_limit << multiple\n multiple -= divisor\n multiples_up_to(multiple, divisor, multiples_to_limit) \nend", "def seriesup(n)\n list = [] \n (n+1).times do |b| # added the +1 because this code needs to run 1 more time than the input\n b.times do |a|\n list.push(a+1) #changed the variable from b to a because it doesn't need to use the first variable, you have to use the second one to make it repeat from 1. Also, I had a space between the list.push and the (), so the push didnt even work with this space.\n end\n end\n return list\nend", "def series_up(num)\n seq = 0\n list = []\n # list[(num * (num + 1) / 2) - 1] = num wasn't doing anything for me\n num.times do |pat| # I swtiched to num.times because I couldn't do list.each because list is blank\n t = 0\n num.times do |numb|\n list[t + seq] = t + 1 # How it knows where to put what number\n t += 1\n end\n seq += pat + 1 # grows exponentially to make it add a new space every time\n end\n return list\nend", "def collapse(nums)\n (0...nums.length - 1).each do |i|\n if nums[i] + 1 == nums[i + 1] || nums[i] == nums[i + 1] + 1\n return nums[0...i] + nums[i + 2..-1]\n end\n end\n\n nums\nend", "def sequence(num)\n\n results = []\n\n 1.upto(num) { |num| results << num }\n\n results\n\nend", "def recursive => nil", "def fifth_of_array(array)\nend", "def append3(ary, n)\n n.downto(0) { |n| ary << n }\n ary\n #5.downto(1) { |n| ary << n }\nend", "def factorials_rec(num)\n return [1] if num <= 1\n\n result = factorials_rec(num-1)\n result << (num-1) * result[-1]\n\nend", "def josephus_survivor(n, k)\n survivors = (1..n).to_a\n loop do\n survivors.rotate!(k -1).shift\n return survivors[0] if survivors.length == 1\n end\nend", "def doubler(numbers)\n\tfor i in 0..numbers.length-1\n numbers[i] = numbers[i] * 2\n end\n return numbers\nend", "def factorials_rec(num)\n answer = []\n return [1] if num == 1\n return [1, 1] if num == 2\n next_num = (num - 1) * factorials_rec(num - 1)[-1]\n answer << next_num\n #answer\nend", "def factorials_rec(num)\n return 'error' if num < 0\n return [1] if num == 1\n return [1, 1] if num == 2\n fac = factorials_rec(num - 1)\n fac << fac.last * (num - 1)\n fac\n\nend", "def buy_fruit(array)\n returner = []\n array.each{|subarray| subarray[1].times{returner << subarray[0]}}\n returner\nend", "def doubler(array)\r\n res = []\r\n array.each do |ele|\r\n res << ele * 2\r\n end\r\n res\r\nend", "def combinations(n)\n \n end", "def solution(num)\n (1..num-1).select {|x| x % 3 == 0 || x % 5 == 0 }.inject(:+)\n # inject method is like reduce \n # can take in a range or array of numbers and optionally receive a block\n # passes each element and accumulates each sequentially\nend", "def rings\n my_list = [6, 5, 3, 1]\n 3.times do\n index = 0\n my_list.length.times do\n print my_list[index].to_s + \" \"\n index += 1\n end\n end\nend", "def factorials_rec(num)\n # p num\n # p \"num #{num} \"\n if num <= 0\n return [1]\n end\n if num == 1\n return [1]\n end\n if num == 2\n return [1, 1]\n end\n # p factorial(3)\n # factorial = num-1 * factorials_rec(num-2)\n # p factorial\n return factorials_rec(num-1) + [factorial(num-1)]\n \nend", "def rotate(nums, k)\n k.times do\n el = nums.pop\n nums.unshift(el)\n end\nend", "def factorials_rec(num)\n return [1] if num == 1\n\n factorials_rec(num-1) << factorials_rec(num-1).last * (num - 1)\nend", "def factorials_rec(num)\n return [1] if num == 1\n prev = factorials_rec(num - 1)\n prev << prev[-1] * (num - 1)\n prev\nend", "def factorials_rec(num)\n return [1] if num == 1\n facs = factorials_rec(num - 1)\n facs << facs.last * num\nend", "def series_up(nums)# did not have time to do this function\n series = 0 # start the list at the right value\n list = [] # the list is empty at the start \n nums.times do |seq| # Run a loop for the sequence\n n = 0# set it equal to orignal num\n nums.times do |nums|\n list[n+ series] = n + 1\n n += 1\n end\n\n series += seq + 1 # exponetial growth \n end\n return list\n\nend", "def factorials_rec(num)\n return [] if num == 0\n return [1] if num == 1\n prev = factorials_rec(num - 1)\n prev + [prev.last * (num - 1)]\nend", "def lucas_sequence(num)\n\n return [] if num==0\n\n return [2] if num==1\n\n return [2,1] if num == 2\n\n lucas_sequence(num-1)+ [lucas_sequence(num-1)[-1]+lucas_sequence(num-1)[-2]] \n\nend", "def permute(nums)\n result = []\n permute_helper(nums, [], result)\n result\nend", "def factorials_rec(num)\n return [1] if num == 1\n\n facs = factorials_rec(num - 1)\n facs << facs.last * (num - 1)\n facs\n\n\nend", "def problem1 limit\n (0...limit).map {|n| (n%3==0 || n%5==0) ? n : 0 }.reduce(:+)\nend", "def factorials_rec(num)\n return [1] if num == 1\n factorials_rec(num-1) + [(1...num).to_a.reduce(:*)]\nend", "def prime_factorization(num)\n return [num] if prime?(num)\n (2...num).each do |i|\n if prime?(i) && num % i == 0\n return [i].concat(prime_factorization(num / i))\n end\n end\nend", "def prime_factorization(num)\n if is_prime(num)\n return [num]\n else\n n = 2\n while (num % n) != 0\n n += 1\n end\n return [n] + prime_factorization(num / n)\n end\nend", "def series_up(n)\n new_list=[] # to push into a new list\n (n + 1).times do |index| #You need the nested loop index.times to run at least once. Since Index starts at 0, you need to add 1 so that it runs at least once\n index.times do |value| # this runs the loop each time until it reaches the number needed\n new_list.push(value + 1) #Same as the loop above. Since the value starts at 0, you need to start at 1 bc that's what the challenge wants you to do. the .push pushes it into the new list \n end \n end \n return new_list # this makes the function print the newly created list\nend", "def prime_factorization(num)\n # return [num] if prime?(num)\n # first_prime = find_prime_factor(num)\n # return [first_prime] + prime_factorization(num/first_prime)\n (2...(num/2)).each do |n|\n if num % n == 0\n multiplier = num / n\n return prime_factorization(n) + prime_factorization(multiplier)\n end\n end\n [num]\nend", "def kids_ways(length, steps_so_far=0)\n return 1 if steps_so_far == length\n return 0 if steps_so_far > length\n [1,2,3].map do |n|\n kids_ways(length, steps_so_far + n)\n end.reduce(:+)\nend", "def factorials_rec(num)\n return [1] if num == 1\n\n result_array = factorials_rec(num-1)\n result_array = result_array + [result_array.last * (num-1)]\n\nend", "def recurse(curr, k, nums, res, start)\n# add, recurse, undo\n # basically forcing a base case\n if k == 0\n res << curr[0..-1] \n return\n end\n # start elims duplicates (like [3, 2] [2, 3])\n i = start\n while i < nums.length\n curr << nums[i]\n recurse(curr, k - 1, nums, res, i + 1)\n curr.pop\n i+=1\n end\n \n end", "def getPermutations3(s,perm=[])\n subresult = getPermutations2(s[1..3])\n subresult.each do |item|\n perm.push(item.insert(0,s[0]))\n end\n if perm.length >= factorial(s.length)\n return perm\n else\n s = rotateChar(s)\n getPermutations3(s,perm)\n end\nend", "def series_up(num)\n size = num*(num+1)/2\n list = [1, 1, 2, 1, 2, 3, 1, 2, 3, 4]\n string = list[0..size-1]\n print string\nend", "def solution(number)\n ans = 0\n (3...number).step(3) {|n| ans += n}\n (5...number).step(5) {|n| n % 3 == 0 ? next : ans += n}\n return ans\nend", "def lucas_sequence(n)\n return [] if n == 0\n return [2] if n == 1\n return [2, 1] if n == 2\n\n sequence = lucas_sequence(n - 1)\n next_sequence = sequence[-1] + sequence[-2]\n sequence << next_sequence\nend", "def fator n\n\n\treturn [-1, 1] if n<0\n\treturn [0, 1] if n==0\n\treturn [1, 1] if n==1\n\treturn [2, 1] if n==2\n\treturn [n>>1,2] if ((n%2)==0)\n\n\ti, j, k = n, 0, 0\n\n\ti += j and k = (i**(0.5)).to_i and j += ((j==0)?1:2) while (i-k*k>0)\n\n\tk += (j-1)>>1;\n\tn /= k;\n\n\treturn [n,k] if n>=k\n\treturn [k,n] if n<k\n\nend", "def lucas_sequence(n)\n if n == 0\n []\n elsif n == 1\n [2]\n elsif n == 2\n [2, 1]\n else\n seq = lucas_sequence(n-1)\n seq << seq[-1] + seq[-2]\n end\nend", "def factorials_rec(num)\n return [1] if num==1\n return [1,1] if num==2\n factorials_rec(num-1) + [(num-1) * factorials_rec(num-1).last]\nend", "def permutations(array)\n #[1,2]\nreturn [array] if array==[1]\n\n\n\n\nprevious=permutations(array[0...-1])\nlast = array.last\nresult=[]\nprevious.each do |ele|\n (0...array.length-1).each do |i|\n result << ele[0..i]+[last]+ele[i+1..-1]\n \n \n end\n result << [last]+ele\n\n end\n result\nend", "def permute(nums)\n result = []\n permute_helper(nums, [], result)\n result\nend", "def factorials_rec(num)\n return [1] if num == 1\n fact = factorials_rec(num-1)\n fact << fact.length * fact[-1]\nend", "def prime_factorization(num)\n (2...num).each do |factor|\n if num % factor == 0\n other = num / factor\n return prime_factorization(factor).concat(prime_factorization(other))\n end\n end\n\n [num]\nend", "def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend", "def factorials_rec(num)\n\treturn [1] if num == 1\n\tfactorials_arr = factorials_rec(num - 1)\n\tfactorials_arr << num * factorials_arr[-1]\nend", "def factorials_rec(num)\n if num == 1\n [num]\n else\n factorials = factorials_rec(num - 1)\n factorials << factorials.last * (num - 1)\n factorials\n end\nend", "def series_up(x)\nbignum = 1\ncount = 1 #made it one beacsue when it was 0 it only printed the number - 1\nlist = [] # changed it to list so i dont get confused\n x.times do #loop in a loop \n count = 1 #It resets it to one so it follows the pattern\n while count <= bignum #while count is less than or equal too this loop will keep on going\n list.push(count) #pushes count into the list\n count = count + 1 #making count equal to count + 1. So if count is 2, it will come out as 3\n end\n bignum = bignum + 1 #setting big number so the loop keeps on going\n end\n return list #when the loop is over it takes the list and prints it\nend", "def iterativeMap(list)\n list.each do |i|\n list[i-1] = list[i-1] * 2\n end\n return list\nend", "def lucas_sequence(n)\n return [] if n == 0\n lucas_sequence(n-1)+[lucas_number(n)]\nend", "def tribonacci(signature,n)\n res = []\n n.times {\n res.push(signature.count > 0 ? signature.shift : res[-3..-1].reduce(:+))\n }\n res\nend", "def lucas_sequence(n)\n if n == 0\n return []\n end\n if n == 1 \n return [2]\n end\n if n == 2\n return [2,1]\n end\n lucas_sequence(n-1) << lucas_sequence(n-1)[-1] + lucas_sequence(n-1)[-2]\nend", "def factorials_rec(num)\n return [1] if num == 1\n results = []\n num.times do \n last_facs = factorials_rec(num - 1)\n results = last_facs << (last_facs.last * (num - 1))\n end\n results\n \nend", "def solution(number)\nn = 0..number\na = []\nfor i in n\n if i % 3 == 0 || i % 5 == 0\n a = a.push(i)\n end\n end\ns = 0\n# a.pop\na.each {|x| s += x}\ns\nend" ]
[ "0.7068945", "0.68216574", "0.68065155", "0.67286474", "0.6677804", "0.6672863", "0.65613306", "0.64280576", "0.642564", "0.6402558", "0.6165049", "0.61328155", "0.60580647", "0.60088444", "0.59595394", "0.59188026", "0.59186095", "0.5899984", "0.58468854", "0.5791485", "0.5761334", "0.5760884", "0.574102", "0.5739669", "0.57305616", "0.5712828", "0.5707703", "0.570707", "0.5701682", "0.5697729", "0.56912786", "0.5688426", "0.5685", "0.56812215", "0.5677624", "0.56775576", "0.56744665", "0.5667952", "0.5667827", "0.56655884", "0.5653407", "0.56498635", "0.5632946", "0.56208366", "0.56194675", "0.5614698", "0.5607661", "0.55955076", "0.5595168", "0.5594753", "0.5586536", "0.5581587", "0.5579043", "0.55754066", "0.5568823", "0.55685", "0.55683726", "0.5568184", "0.5559569", "0.5556821", "0.555576", "0.55528563", "0.5551652", "0.55507433", "0.5542361", "0.5536853", "0.553297", "0.55314803", "0.5529453", "0.55257607", "0.55255497", "0.5521765", "0.5521236", "0.5520316", "0.55160433", "0.5510462", "0.55097896", "0.550862", "0.5508051", "0.5507903", "0.55078936", "0.55049306", "0.5504595", "0.54965085", "0.54929614", "0.54862493", "0.5482649", "0.54818547", "0.5475925", "0.54707706", "0.54683876", "0.54662913", "0.54657626", "0.54647255", "0.5463109", "0.5462526", "0.54619354", "0.5460618", "0.5459029", "0.54580337", "0.5457865" ]
0.0
-1
because it makes no sense to make a recursive fibonacci call ...
def nonRecursiveFibonacci(n) a=Array.new a[0] = a[1] = 1 for i in 2..n a[i]=a[i-1] + a[i-2] end return a[n] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fibonacci (num)\n if num < 0\n puts \"error: cannot calcuate fibonacci of a negative number\"\n return 0\n elsif num == 0\n return 0\n elsif num == 1\n return 1\n end\n fibonacci(num - 1) + fibonacci(num - 2)\nend", "def fibonacci(n)\r\n if n == 0\r\n return 0\r\n elsif n == 1\r\n return 1\r\n else\r\n return fibonacci(n-1) + fibonacci(n-2)\r\n end\r\nend", "def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n \n\n fib(n - 1) + fib(n - 2)\nend", "def fibonacci(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def recursive_fibonacci(n)\n n <= 1 ? n : fibonacci( n - 1 ) + fibonacci( n - 2 )\nend", "def fibonacci(n)\n if n == 0 or n == 1\n return n\n else\n return fibonacci(n - 1) + fibonacci(n - 2)\n end\nend", "def fibonacci(n)\n return n if n == 1 || n == 0 \n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(n)\n return n unless n > 1\n fibonacci(n -1) + fibonacci(n -2)\nend", "def fibonacci(n)\n n = fibonacci( n - 1 ) + fibonacci( n - 2 ) if n > 1\n n\nend", "def fibonacci(n)\n return 0 if n == 1\n return 1 if n == 2\n return fibonacci(n-1)+fibonacci(n-2)\nend", "def recursive_fibonacci(n)\nreturn [1] if n == 1 \nreturn [1,1] if n== 2\n# a = recursive_fibonacci(n-1)\n# b = a[-1]\n# c=a[-2]\n# a+=(b+c)\nrecursive_fibonacci(n-1)+([recursive_fibonacci(n-1)[-2]+recursive_fibonacci(n-1)[-1]])\n# +([recursive_fibonacci(n-1)[-1]]+[recursive_fibonacci(n-1)[-2]])\n#fibonacci(n)=fibonacci(n-1) +=(fibonacci(n-1)[-1]+fibonacci(n-1)[-2])\nend", "def fibonacci(n)\n return 1 if n == 1\n return 1 if n == 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fib_rec( n )\n $call_count += 1\n # Define the base case\n if n < 2\n return 1\n else\n # do the recursive calculation:\n return fib_rec( n - 1 ) + fib_rec( n - 2 )\n end\n\nend", "def fibonacci(n)\n if n == 0\n 1\n elsif n == 1\n 1\n else\n fibonacci(n-2) + fibonacci(n-1)\n end\nend", "def fibonacci(n)\n return 1 if n <= 2\n \n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(num)\n return 0 if num.zero?\n\n if num == 1\n 1\n else\n fibonacci(num - 1) + fibonacci(num - 2)\n end\nend", "def fibonacci( n )\n return n if n <= 1 \n fibonacci( n - 1 ) + fibonacci( n - 2 ) \nend", "def fibonacci(n)\n if n < 2\n n\n else\n fibonacci(n - 1) + fibonacci(n - 2)\n end\nend", "def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 2) + fibonacci(n - 1)\nend", "def recursive_fib n\n return 1 if n == 1 || n == 2\n recursive_fib(n-1) + recursive_fib(n-2)\nend", "def fibonacci(n)\n if n <= 2\n 1\n else\n fibonacci(n - 1) + fibonacci(n - 2)\n end\nend", "def fibonacci(n)\n if n <= 1\n return n\n else\n return fibonacci(n - 1) + fibonacci(n - 2)\n end\nend", "def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 1 ) + fibonacci(n - 2)\nend", "def fibonacci(n)\n return 1 if n == 1 || n == 2\n\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci n\n return n if n < 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(n)\n return 1 if n == 1 || n == 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(n)\n return 1 if n == 1 || n == 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fib(n)\n #if n > 4000000\n #\treturn puts n\n #end\n return n if (0..1).include? n\n fib(n-1) + fib(n-2) if n > 1\nend", "def fib(n)\n return 1 if n == 2\n return 0 if n == 1\n\n fib(n-1) + fib(n-2)\nend", "def fibonacci(n)\n\treturn 0 if n == 0\n\treturn 1 if n == 1\n\tfibonacci(n-1) + fibonacci(n-2)\nend", "def fib(n)\n return 0 if n <= 0\n return 1 if n == 1\n\n fib(n - 1) + fib(n - 2)\nend", "def fib(n)\n if n == 0 || n == 1\n return n\n else\n fib(n-1) + fib(n-2)\n end\nend", "def fibonacci(n)\n\n return 1 if n == 1 || n == 2\n return 0 if n == 0\n raise ArgumentError if n < 0 \n\n fibonacci(n - 1) + fibonacci(n - 2)\n \nend", "def fibonacci(n)\n return n if (0..1).include? n\n (fibonacci(n - 1) + fibonacci(n - 2))\nend", "def fibonacci(number)\r\n if number < 2\r\n number\r\n else\r\n fibonacci(number - 1) + fibonacci(number - 2)\r\n end\r\nend", "def fibonacci(n)\n if n == 1 || n == 2\n 1\n else\n fibonacci(n-1) + fibonacci(n-2)\n end\nend", "def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n\n return fib(n-1) + fib(n-2)\nend", "def fib(n)\r\n if n == 1 then\r\n 10\r\n elsif n == 0 then\r\n 1\r\n else\r\n fib(n - 1) + fib(n - 2)\r\n end\r\nend", "def fib(n)\n # your implementation here\n if n==0 then\n 1\n elsif n==1 then\n 1\n else \n fib(n-2) + fib(n-1)\n end\nend", "def recursive_fib(n, a=0, b=1)\r\n if n == 0\r\n return a\r\n else\r\n recursive_fib(n - 1, b, a + b)\r\n end\r\nend", "def fib(n)\n if (n <= 1) \n return n;\n else\n return fib(n-1)+fib(n-2);\n end\nend", "def fibonacci(n)\n if n < 2\n return n\n else\n fibonacci(n-1) + fibonacci(n-2)\n end\nend", "def fibonacci( n )\n return n if ( 0..1 ).include? n\n ( fibonacci( n - 1 ) + fibonacci( n - 2 ) )\nend", "def fibonacci( n )\n return n if ( 0..1 ).include? n\n ( fibonacci( n - 1 ) + fibonacci( n - 2 ) )\nend", "def fibonacci( n )\n return n if ( 0..1 ).include? n\n ( fibonacci( n - 1 ) + fibonacci( n - 2 ) )\nend", "def fibonacci(num)\n return 1 if num <= 2\n fibonacci(num - 1) + fibonacci(num -2)\nend", "def fibonacci(number)\n if number < 2\n number\n else\n # 2 recursive calls in the recursive case\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend", "def fib(n)\n if n == 0\n 0\n elsif n == 1 || n == 2\n 1\n else fib(n - 2) + fib(n - 1)\n end\nend", "def fibonacci_recursive(n)\n if n == 0 || n == 1\n return n\n end\n # ex n = 5: fib(4) + fib(3) ==> fib(3) + fib(2) ==> fib(2) + 1 =\n return fibonacci_recursive(n-1) + fibonacci_recursive(n-2)\nend", "def fibonacciTailRecursion(n)\n return \"ERROR: fibonacci is not count for negative numbers \" if n < 0\n return n if n < 2\n\n return fibonacciTailRecursion(n-1) + fibonacciTailRecursion(n-2)\nend", "def fibonacciR( n )\r\n return n if n <= 1\r\n fibonacciR( n - 1) + fibonacciR( n - 2)\r\nend", "def fibonacci(num)\n if num < 2\n num\n else\n fibonacci(num - 1) + fibonacci(num - 2)\n end\nend", "def fibonacci(num)\n if num < 2\n num\n else\n fibonacci(num - 1) + fibonacci(num - 2)\n end\nend", "def fibonacci(n)\n \n return n if n == 1\n \n if n > 2 \n fibonacci(n-1) + fibonacci(n-2)\n else\n fibonacci(n-1)\n end\nend", "def fibonacci(integer)\n return 1 if integer <= 2\n\n fibonacci(integer - 1) + fibonacci(integer - 2)\nend", "def fibonacci(n)\n if n < 2\n return n\n else\n return fibonacci(n-1) + fibonacci(n-2)\n end\nend", "def fibonacci_recursive(n)\n return [] if n < 1\n return [1] if n == 1\n return [1, 1] if n == 2\n fib_arr = fibonacci_recursive(n-1)\n fib_arr << fib_arr[-2..-1].reduce(:+)\nend", "def fib(n)\n\n if n == 1 or n == 2\n return 1\n else\n return fib(n-1) + fib(n-2)\n end\n\nend", "def fib(n)\n if n == 1 || n == 2\n return 1\n end\n return fib(n - 1) + fib(n - 2)\nend", "def show_fib(n)\n return 0 if n == 0\n return 1 if n == 1\n show_fib(n-1) + show_fib(n-2)\nend", "def fibonnaci(n)\n if n == 1 || n == 2\n 1\n else\n fibonnaci(n - 1) + fibonnaci(n - 2)\n end\nend", "def fib(n)\n return 1 if n == 1 || n == 2\n fib(n-1) + fib(n-2)\nend", "def fib(n)\n return n if n < 2\n fib(n-1) + fib(n-2)\nend", "def fibonacci(n)\n\tif n == 0 || n == 1\n\t\treturn 1\n\telse\n\t\treturn fibonacci(n-1) + fibonacci(n-2)\n\tend\nend", "def fib(num)\n if num == 0\n return 0\n elsif num == 1\n return 1\n else\n result = fib(num - 1) + fib(num - 2)\n return result\n end\nend", "def recursive_fib(num)\r\n\treturn num if num == 0 || num == 1\r\n\trecursive_fib(num - 1) + recursive_fib(num - 2)\r\nend", "def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n return 1 if n == 2\n # return 2 if n == 3\n fib(n - 1) + fib(n - 2)\nend", "def fibonacci(n)\n n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fib(n)\n if n == 1 || n == 2\n return 1\n end\n return fib(n-1) + fib(n-2)\nend", "def fib(n)\n if n == 1 || n == 2\n return 1\n end\n return fib(n-1) + fib(n-2)\nend", "def fib(n)\n if n < 2\n n\n else\n fib(n-1)+fib(n-2)\n end\nend", "def fibonacciRecursive(n)\n\tif n <= 1\n\t\treturn n\n\telse\n\t\treturn fibonacciRecursive(n - 1) + fibonacciRecursive(n - 2)\n\tend\nend", "def fib(n)\n return n if n <= 1\n fib(n-1) + fib(n-2)\nend", "def recursive_fib(n)\n if n<2\n return n\n else\n return (recursive_fib(n-1)+recursive_fib(n-2))\n end \nend", "def fibonacci(num)\n return num if [0, 1].include? num\n fibonacci(num - 2) + fibonacci(num - 1)\nend", "def fibonacci_recursive n\n return n if n < 2\n fibonacci_recursive(n-1) + fibonacci_recursive(n-2)\nend", "def fibonacci(number)\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend", "def fibonacci(number)\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend", "def fibonacci(number)\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend", "def fibonacci(number)\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend", "def fibonacci(n)\n \nend", "def fibonacci(n)\n raise ArgumentError, ('argument n cannot be a negative number') if n < 0\n return n if n == 1 || n == 0 #base case\n return fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibo(n)\n return n if n < 2\n return fibo(n- 1) + fibo(n - 2)\nend", "def fib(n)\n if n < 2\n 1\n else\n fib(n-2) + fib(n-1)\n end\nend", "def fib(n)\n return 1 if n <= 2\n fib(n - 1) + fib(n - 2)\nend", "def fib(n)\n return 0 if n < 0\n return n if n < 2\n return fib(n-1) + fib(n-2)\nend", "def fib(n)\n if n == 0 || n == 1\n return n\n else\n fib(n - 1) + fib(n - 2)\n end\n end", "def fibonacci(n)\n \nend", "def fibonacci_recur(n)\n return 0 if n == 1\n return 1 if n == 2\n\n fibonacci_recur(n - 1) + fibonacci_recur(n - 2)\nend", "def fib n\n if n == 0\n 0\n elsif n == 1\n 1\n else\n fib(n-2) + fib(n-1)\n end\nend", "def recursive_fib(number)\n _recursive_fib(number, 0, 1)\nend", "def fib(n)\n if n == 1 || n == 2\n n\n else\n fib(n-1) + fib(n-2)\n end\nend", "def fib(n)\n return n if (0..1).include? n\n fib(n-1) + fib(n-2)\nend", "def fibonacci(n)\n # your code here :)\n if n < 0\n return \"You must provide a number greater than 0\"\n end\n\n if n == 1 || n ==2 \n 1\n else\n fibonacci(n-1) + fibonacci(n-2)\n end\n \nend", "def fib(n)\n return nil if n < 1\n return 1 if n == 1 || n == 2\n fib(n-1) + fib(n-2)\nend", "def recursive_fibonacci(n)\n if (n == 1)\n return 0\n elsif (n == 2 || n == 3)\n return 1\n end\n return recursive_fibonacci(n - 2) + recursive_fibonacci(n - 1)\n end", "def fib(n)\n return 1 if n <= 2\n fib(n-1) + fib(n-2)\nend", "def fib_rec(n)\n return 0 if n == 1\n return 1 if n == 2\n fib_rec(n - 1) + fib_rec(n - 2)\nend", "def fib n\n return n if n < 2\n fib(n - 1) + fib(n - 2)\nend" ]
[ "0.8371596", "0.83181506", "0.82866067", "0.82221943", "0.8220371", "0.8213923", "0.82010597", "0.8175801", "0.816849", "0.8154221", "0.81525403", "0.81516314", "0.8147122", "0.8139514", "0.8139414", "0.8138696", "0.8132659", "0.81302536", "0.8127112", "0.8115452", "0.81132454", "0.81111085", "0.81105405", "0.810757", "0.81034166", "0.81017405", "0.81017405", "0.8101559", "0.8101559", "0.80975455", "0.8096143", "0.80947953", "0.8092872", "0.80907583", "0.80887103", "0.8087137", "0.80706644", "0.8062989", "0.8056894", "0.8054744", "0.8052953", "0.80529046", "0.80523574", "0.8051975", "0.8048187", "0.8048187", "0.8048187", "0.8046046", "0.8043822", "0.8043311", "0.80406624", "0.8032131", "0.8031469", "0.8031421", "0.8031421", "0.8028137", "0.8028003", "0.8025214", "0.801754", "0.8005063", "0.80044603", "0.80019563", "0.79967123", "0.7987834", "0.7984993", "0.7984185", "0.79839987", "0.79784113", "0.7978079", "0.79762405", "0.7974586", "0.7974586", "0.7958389", "0.7953549", "0.7952465", "0.79417145", "0.79375434", "0.793709", "0.79367316", "0.79367316", "0.79367316", "0.79367316", "0.79365325", "0.7931986", "0.7929227", "0.7928305", "0.7927545", "0.792386", "0.7922976", "0.7922594", "0.7920022", "0.79199404", "0.7915877", "0.7911617", "0.79069424", "0.79049474", "0.7901793", "0.7900107", "0.78966916", "0.7894387", "0.78844005" ]
0.0
-1
input = gets.chomp.strip do puts display_board
def valid_move? (board, index) if index.between?(0, 8) && !position_taken?(board, index) true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play(board)\n input = gets.strip\nend", "def input_board\r\n print \"Enter your board with no spaces (ex: CUTERUBYCUBEKOAN): \"\r\n line = gets.chomp\r\n if line.length != 16 then\r\n puts \"You input the board incorrectly.\"\r\n return\r\n end\r\n @board = line.to_s\r\n to_s\r\nend", "def input\n puts \"It's #{@player_turn.capitalize}'s turn. Please enter your move/ command.\"\n @input = gets.chomp.upcase\n end", "def input(thing)\n print \"Enter #{thing}: \"\n gets.chomp\nend", "def player_input\n print \"> \"\n input = gets.chomp\n puts \"\\n\"\n return input\nend", "def player_input\n print \"> \"\n input = gets.chomp\n puts \"\\n\"\n return input\nend", "def play(board)\n #input = gets.strip\n until over?(board)\n \tturn(board)\n if won?(board)\n \tputs \"Congratulations #{winner(board)}!\"\n end\n if draw?(board)\n\tputs \"Cats Game!\"\n end\n end\n\nend", "def display input\n\tputs \"#\"*40\n\tputs input\n\nend", "def guess(board)\n print \"Make a guess: \"\n gets.chomp\n end", "def input\n print '>> '\n $input = gets.chomp.downcase\n end", "def input_move(db, cur_position)\r\n\tprint \"Enter a move for #{cur_player(db, cur_position)} in standard chess notation, or HELP for help: \"\r\n\tmove = gets.chomp.downcase\r\n\treturn move\r\nend", "def input msg\n puts msg\n print \" \"\n return STDIN.gets.chomp\nend", "def computer\r\n tab(4, \"Press Enter for AI move.\")\r\n input = gets\r\n end", "def display_board\n # phrase=\"Tic Tac Toe board\"\n # puts phrase\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n\nend", "def next_input\n print '>> '\n gets.chomp.strip.downcase\n end", "def get_input\n gets.chomp\n end", "def get_input\n gets.strip #chomp was also used..\nend", "def display_board(brd)\n system \"clear\"\n puts \"You're a #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"_____+_____+_____\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"_____+_____+_____\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def display_board(board)\n system 'clear'\n puts \"\"\n puts \" 1 2 3\"\n puts \"\"\n puts \" | |\"\n puts \"A #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \" | |\"\n puts \" -----+-----+-----\"\n puts \" | |\"\n puts \"B #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \" | |\"\n puts \" -----+-----+-----\"\n puts \" | |\"\n puts \"C #{board[6]} | #{board[7]} | #{board[8]} \"\n puts \" | |\"\n puts \"\"\nend", "def user_input\n input = gets.chomp\n end", "def display_board(brd)\n system 'clear' || system('cls')\n puts \"You're a #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def user_input\n gets.chomp\nend", "def user_input\n gets.chomp\nend", "def get_input\n gets.chomp \nend", "def display_board(brd)\n system 'clear'\n puts \"You're a #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]} \"\n puts \" | |\"\n puts \" -----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]} \"\n puts \" | |\"\n puts \" -----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]} \"\n puts \" | |\"\n puts \"\"\nend", "def display_board(brd)\n system 'clear'\n puts \"You're a #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]} \"\n puts \" | |\"\n puts \" -----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]} \"\n puts \" | |\"\n puts \" -----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]} \"\n puts \" | |\"\n puts \"\"\nend", "def display_board(brd)\n system 'clear'\n puts \"You'e a #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def getInput(user,currentboard)\n #Gets input from the user, and returns the digit of square\n while true\n puts \"#{user}'s turn. Please pick a square:\"\n output = gets.chomp.to_i\n if (currentboard[output-1]==nil && output < 10 && output > 0)\n return output\n else\n puts \"Invalid input. Has the square already been taken?\"\n end\n end\nend", "def display_board(brd)\n system \"clear\"\n puts \"You're #{PLAYER_MARKER}'s. Computer is #{COMPUTER_MARKER}'s\"\n puts \" | | \"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]} \"\n puts \" | | \"\n puts \"=================\"\n puts \" | | \"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]} \"\n puts \" | | \"\n puts \"=================\"\n puts \" | | \"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]} \"\n puts \" | | \"\nend", "def display_board(brd)\n system 'clear'\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----|-----|-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----|-----|-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def display_board(brd)\n system 'clear'\n puts ''\n puts ' | |'\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]} \"\n puts ' | |'\n puts '-----+-----+-----'\n puts ' | |'\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts ' | |'\n puts '-----+-----+-----'\n puts ' | |'\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts ' | |'\n puts ''\nend", "def get_user_input(prompt)\n print \"#{prompt}: \"\n gets.chomp\nend", "def input(type)\r\n print \"#{type}>\"\r\n gets.chomp\r\nend", "def fetch_input(prompt)\n\tprint prompt\n\tgets.chomp #implicit return again\nend", "def display_board(brd, pco, cco)\n system \"clear\"\n prompt(\"You are a #{PLAYER_MARKER}. Computer is a #{COMPUTER_MARKER}.\")\n prompt(\"Player Score = #{pco}, Computer score = #{cco}\")\n puts \"\"\n puts \"1 |2 |3\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----+-----|-----\"\n puts \"4 |5 |6\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----+-----|-----\"\n puts \"7 |8 |9\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def gets_input\n\tgets.strip\nend", "def user_input\n user_input = gets.chomp\nend", "def display_board\n puts \" \" \"|\" \" \" \"|\" \" \"\n puts \"-----------\"\n puts \" \" \"|\" \" \" \"|\" \" \"\n puts \"-----------\"\n puts \" \" \"|\" \" \" \"|\" \" \"\nend", "def get_user_input\n gets.chomp\nend", "def get_user_input\n gets.chomp\nend", "def display_board(board)\n system('cls')\n puts \"Player is #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{board[1]} | #{board[2]} | #{board[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{board[4]} | #{board[5]} | #{board[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{board[7]} | #{board[8]} | #{board[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def user_input\n puts \"Let's play rock, paper, scissors\"\n gets.chomp\nend", "def display_board(board)\n system 'clear'\n puts \"Player : #{PLAYER_MARKER}\"\n puts \"Computer: #{COMPUTER_MARKER}\"\n puts \"\"\n puts \" | |\"\n puts \" #{board[1]} | #{board[2]} | #{board[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{board[4]} | #{board[5]} | #{board[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{board[7]} | #{board[8]} | #{board[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def user_input\n\tgets\nend", "def prompt(display, chomp = true)\n print \"#{display} \"\n STDOUT.flush\n line = gets\n chomp ? line.chomp! : line\nend", "def prompt\n puts\"=>\"\n gets.chomp\nend", "def get_user_input\n input = gets.chomp\n #input\nend", "def get_user_input\n gets.strip\nend", "def ask_for(detail)\n puts \"Enter #{detail}\"\n STDIN.gets.chomp \nend", "def display_board(board)\n\nputs \" #{board[0]} | #{board[1]} | #{board[2]} \\n\"\nputs \"-----------\\n\"\nputs \" #{board[3]} | #{board[4]} | #{board[5]} \\n\"\nputs \"-----------\\n\"\nputs \" #{board[6]} | #{board[7]} | #{board[8]} \\n\"\n \nend", "def display_board(board)\n current_board = \" #{board[0]} | #{board[1]} | #{board[2]} \\n-----------\\n #{board[3]} | #{board[4]} | #{board[5]} \\n-----------\\n #{board[6]} | #{board[7]} | #{board[8]} \"\n puts current_board\nend", "def take_turn\n puts \"Pick a space, #{@name}\"\n space = gets\n parse_input(space)\n end", "def get_input message\n\n puts message\n input = gets.chomp.downcase\n\nend", "def pre_game\n puts \n puts \"Get ready for the Horde - Level 1....\"\n puts \"Press enter when you're ready...\"\n gets\n display_word\nend", "def get_input\n story = gets.chomp\nend", "def read_input()\n @board = []\n (1..9).each do\n @board << gets.scan(/./).map(&:to_i)\n end\n end", "def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \\n-------------\\n #{board[3]} | #{board[4]} | #{board[5]} \\n-------------\\n #{board[6]} | #{board[7]} | #{board[8]} \\n\"\nend", "def display_board(brd)\n puts \"You are #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def display_board\n board = \" | | \n-----------\n | | \n-----------\n | | \"\n puts board\nend", "def display_board(board)\nputs \" #{board[0]} | #{board[1]} | #{board[2]} \"\nputs \"-----------\"\nputs \" #{board[3]} | #{board[4]} | #{board[5]} \"\nputs \"-----------\"\nputs \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend", "def display_board(board)\nputs \" #{board[0]} | #{board[1]} | #{board[2]} \"\nputs \"-----------\"\nputs \" #{board[3]} | #{board[4]} | #{board[5]} \"\nputs \"-----------\"\nputs \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend", "def display_board(board)\nputs \" #{board[0]} | #{board[1]} | #{board[2]} \"\nputs \"-----------\"\nputs \" #{board[3]} | #{board[4]} | #{board[5]} \"\nputs \"-----------\"\nputs \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend", "def player_guess\n puts \"Please enter the row you think the ship is in:\"\n @row_input = gets.chomp\n puts \"Please enter the column you think the ship is in:\"\n @column_input = gets.chomp\nend", "def player_2_input\n print \"Player 2, it's your turn:\"\n input = gets.chomp.to_i\n\n # while input<1 || input>9\n # puts \"You need to put a number between 1 and 9, try again:\"\n # input = gets.chomp.to_i\n # end\n\n while input<1 || input>9 || $a[input] != ' '\n if input<1 || input>9\n print \"You need to put a number between 1 and 9, try again:\"\n else\n print \"Sorry, this field is already taken, please choose a different field:\"\n end\n input = gets.chomp.to_i\n end\n\n $a[input]='O'\n \n draw_board\nend", "def display_board(entry)\n puts \" #{entry[0]} | #{entry[1]} | #{entry[2]} \"\n puts \"-----------\"\n puts \" #{entry[3]} | #{entry[4]} | #{entry[5]} \"\n puts \"-----------\"\n puts \" #{entry[6]} | #{entry[7]} | #{entry[8]} \"\nend", "def display_board(board)\r\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\r\n puts \"-----------\"\r\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\r\n puts \"-----------\"\r\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\r\nend", "def display_board(board)\n\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n\nend", "def display_board (s)\n puts \" #{s[0]} | #{s[1]} | #{s[2]} \"\n puts \"-----------\"\n puts \" #{s[3]} | #{s[4]} | #{s[5]} \"\n puts \"-----------\"\n puts \" #{s[6]} | #{s[7]} | #{s[8]} \"\nend", "def view_fight_input\n puts \"Would you like to view a specific fight? (y/n)\"\n input = gets.strip.downcase\n end", "def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n\nend", "def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n\nend", "def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \\n-----------\\n #{board[3]} | #{board[4]} | #{board[5]} \\n-----------\\n #{board[6]} | #{board[7]} | #{board[8]} \"\nend", "def draw_board(b)\n system 'clear'\n puts \"Make a selection by entering any number displayed on the board.\"\n puts \" \"+\"#{b[1]} | #{b[2]} | #{b[3]}\"\n puts \" \"+\"----------\"\n puts \" \"+\"#{b[4]} | #{b[5]} | #{b[6]}\"\n puts \" \"+\"----------\"\n puts \" \"+\"#{b[7]} | #{b[8]} | #{b[9]}\"\nend", "def display_board\n puts \" | | \" \n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend", "def display_board\n puts \" | | \"\n puts\"-----------\"\n puts \" | | \"\n puts\"-----------\"\n puts \" | | \"\nend", "def get_user_input(message)\n puts message\n gets.chomp\n end", "def display_board(brd)\n # system 'clear'\n puts \"\"\n puts \".....|.....|\"\n puts \"..#{brd[1]}..|..#{brd[2]}..|. #{brd[3]}\"\n puts \".....|.....|\"\n puts \"-----+-----+-----\"\n puts \".....|.....|\"\n puts \"..#{brd[4]}..|..#{brd[5]}..|. #{brd[6]}\"\n puts \".....|.....|\"\n puts \"-----+-----+-----\"\n puts \".....|.....|\"\n puts \"..#{brd[7]}..|..#{brd[8]}..|. #{brd[9]}\"\n puts \".....|.....|\"\n puts \"\"\nend", "def ask_move\n puts (\"Please enter 1-9:\")\n return gets.strip\nend", "def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n \nend", "def menu\n\tputs \"Welcome to My Tournament Generator. Enter a selection:\"\n\tputs \"1. Enter teams\"\n\tputs \"2. List teams\"\n\tputs \"3. List matchups\"\n\tputs \"0. Exit program\"\n\t$input = gets.chomp.to_i\nend", "def get_input\n @input = gets.strip\n end", "def display_board\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend", "def display_board\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend", "def display_board(board)\n\n puts \"#{board [0]} |#{board [1]} |#{board [2]} \"\n puts \"-----------\"\n puts \"#{board [3]} | #{board [4]} | #{board [5]} \"\n puts \"-----------\"\n puts \"#{board [6]} | #{board [7]} | #{board [8]} \"\n\nend", "def display_board\nputs \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\nputs \"-----------\"\nputs \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\nputs \"-----------\"\nputs \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\nend", "def player_turn!(brd)\n square = ''\n loop do\n prompt(\"Make your move: #{joinor(empty_squares(brd))}\")\n square = gets.chomp.to_i\n break if empty_squares(brd).include?(square)\n puts \"Choice not available...\"\n end\n brd[square] = PLAYER_MARKER\nend", "def prompt\n gets.strip\nend", "def display_board(brd)\n puts\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]} \"\n puts \"---+---+---\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]} \"\n puts \"---+---+---\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]} \"\n puts\nend", "def get_input\n @input = gets.chomp\n end", "def prompt(input)\r\n empty_line\r\n input = input.strip\r\n print (input + ': ').colorize(:light_blue)\r\n return gets.chomp\r\n end", "def turn\n display_board\n puts \"Please enter 1-9:\"\n input = gets.strip\n if !valid_move?(input)\n turn\n end\n move(input, current_player)\n display_board\nend", "def get_input\n input = gets.chomp\n until valid_input?(input)\n puts \"Invalid input. Please type in an EMPTY cell number from \"\\\n \"1-9, 'quit', or 'restart'.\"\n print \">> \"\n input = gets.chomp\n end\n input\n end", "def get_input\n puts \"Input [L] to turn Left, [R] to turn right and [M] to move your Mars rover forward. Type [Q] to leave. See you, Space Cowboy\"\n @input = gets.chomp.downcase\n # Loops through the array of inputs to specify commands for each specific instruction with a case statement\n @input.each_char do |i|\n case i\n # If l is inputted, make the Rover face left\n when \"l\"\n turn_left\n # If r is inputted, make the Rover face right\n when \"r\"\n turn_right\n # Get the rover to move forward in the direction it's facing.\n when \"m\"\n move\n # Exit the game when q is typed\n when \"q\"\n exit\n end\n # Convert the results to a string\n to_s\n end\n end", "def print_board(turn_type)\n puts\n puts\n puts \" 1 2 3 \"\n puts \"a #{self.board_markers[:a1]} | #{self.board_markers[:a2]} | #{self.board_markers[:a3]} \"\n puts \" ___|___|___\"\n puts \"b #{self.board_markers[:b1]} | #{self.board_markers[:b2]} | #{self.board_markers[:b3]} \"\n puts \" ___|___|___\"\n puts \"c #{self.board_markers[:c1]} | #{self.board_markers[:c2]} | #{self.board_markers[:c3]} \"\n puts \" | | \"\n puts\n\n if turn_type == \"invalid_entry\"\n puts \"Invalid entry. Please try again.\"\n puts\n elsif turn_type == \"already_taken\"\n puts \"Move already taken. Please try again.\"\n puts\n elsif turn_type == \"new_turn\"\n puts \"Move successful!\"\n puts\n end\n\n puts \"#{self.all_players[self.current_player][:display_name]}'s turn. (Your marker is \\\"#{self.all_players[self.current_player][:marker]}\\\".)\"\n puts \"Please enter a move (or enter \\\"h\\\" for help): \"\n input_string = gets.chomp\n end", "def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend", "def display_string_menu(prompt, message)\n puts \"\\n\" * (3 - message.count)\n message.each {|line| puts \" \" * $sp[:l] + line}\n prompt.each {|line| print \"\\n\" + \" \" * $sp[:l] + line}\n input = gets.strip\nend", "def display_board\n system \"clear\"\n puts \"Super Fight Bros. Leaderboard by Combat\"\n header = ['#', 'Player', 'Power', 'Combat']\n rows = parse_players(Superhero.order(combat: :desc).limit(10))\n table = TTY::Table.new header, rows\n puts table.render(:unicode)\n begin \n puts \"Please press M to go back to the menu\"\n end while !input_check(\"M\")\n end", "def display_board(brd)\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend", "def new_board_name\n puts \"Enter a name for this new noteboard.\"\n file_name = $stdin.gets.chomp\n \nend", "def display_board(board)\n puts \" #{board[0] } | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3] } | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6] } | #{board[7]} | #{board[8]} \"\nend", "def get_input\n\t#Get input from the user.\n return gets.chomp\nend" ]
[ "0.82752734", "0.7910965", "0.7334006", "0.7257549", "0.72522396", "0.72522396", "0.7227485", "0.7184913", "0.7141396", "0.71309173", "0.71083325", "0.7103268", "0.70772344", "0.70543283", "0.70354396", "0.7000058", "0.69922227", "0.6984464", "0.6982877", "0.6980854", "0.69751436", "0.6964163", "0.6964163", "0.69548", "0.6953771", "0.6953771", "0.69536066", "0.69362926", "0.69187105", "0.69150364", "0.69060653", "0.6900187", "0.6878341", "0.68618435", "0.68535644", "0.6823077", "0.68162966", "0.68102634", "0.6794697", "0.6794697", "0.679315", "0.6792052", "0.6789672", "0.6783506", "0.676405", "0.6764002", "0.67613316", "0.6756315", "0.6753318", "0.6751674", "0.6746973", "0.67456234", "0.6743412", "0.67421776", "0.67350495", "0.6733555", "0.67264843", "0.67182684", "0.671065", "0.6706373", "0.6706373", "0.6706373", "0.6699576", "0.669843", "0.66977257", "0.6697548", "0.6688089", "0.6685298", "0.6673721", "0.6673497", "0.6673497", "0.6673448", "0.66722226", "0.666966", "0.6668766", "0.6667967", "0.6659307", "0.665732", "0.6655468", "0.6651839", "0.6651627", "0.66450167", "0.66450167", "0.6643866", "0.66438216", "0.663949", "0.66390425", "0.6624787", "0.6623779", "0.66223174", "0.6609816", "0.6606298", "0.6600782", "0.66004884", "0.65992475", "0.65872914", "0.65850776", "0.65831447", "0.6582124", "0.65806013", "0.657732" ]
0.0
-1
turn(board,index) move(array,index,value = "X") display_board(board) else turn(board) end get input convert input to index if index is valid make the move for input else ask for input again until you get a valid input end
def position_taken?(board,index) foo = nil if (board[index] == "" || board[index] == " " || board[index] == nil) foo = false else foo = true end foo end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index) == true\n move(board, index, token = \"X\")\n display_board(board)\n else\n turn(board)\n end\nend", "def turn (board)\n#Ask the user to tell you where they want to move on the board\n puts \"Please enter 1-9:\"\n#Get the user input\n user_input=gets.strip\n index=input_to_index(user_input)\n # If the move is a valid move, then make the move and display the board\n if valid_move?(board,index)\n move(board,index,\"X\")\n display_board(board)\n#If the user puts in an invalid answer or the space in the array is not free, go back to turn and start over\n else turn(board)\nend\nend", "def turn(board)\n character = \"X\"\nputs \"Please enter 1-9:\"\nuser_input = gets.strip\nuser_input = user_input.to_i\nindex = input_to_index(user_input)\n if valid_move?(board, index) == true\n move(board, index, character = \"X\")\n display_board(board)\n else \n turn(board)\n end\nend", "def turn(board)\n # ask the user for input:\n puts \"Please enter 1-9:\"\n # gets the user input\n input = gets.strip\n # calls the input_to_index method\n index = input_to_index(input)\n #validates the input correctly\n if valid_move?(board, index)\n # makes valid move\n move(board, index, \"X\")\n else\n # asks for input again after a failed validation\n turn(board)\n end\n # displays a correct board after a valid turn\n display_board(board)\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.chomp\n index = input_to_index(input)\n if valid_move?(board, index) == true\n move(board, index, character = \"X\")\n puts display_board(board)\n else\n turn(board)\n end\nend", "def turn(array)\r\n puts \"Please enter 1-9:\"\r\n input = gets.strip\r\n index = input_to_index(input)\r\n if valid_move?(array,index) == true\r\n move(array, index, \"X\")\r\n display_board(array)\r\n else\r\n puts \"This move is not correct.\"\r\n turn(array)\r\n end\r\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n user_input = gets\n index = input_to_index(user_input)\n until valid_move?(board, index)\n puts \"Please enter 1-9:\"\n user_input = gets\n index = input_to_index(user_input)\n end\n move(board, index, \"X\")\n display_board(board)\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n user_input = gets.strip\n index = input_to_index(user_input)\nif valid_move?(board,index)\n move(board, index, current_player(board))\n display_board(board)\nelse\n turn(board)\nend\nend", "def turn(board)\nputs \"Please enter 1-9:\"\nuser_input = gets.strip\nindex = input_to_index(user_input)\nif !valid_move?(board, index) #asks for input again is the input is not valid\n turn(board)\nelse #if the input is valid makes the move then\n move(board, index, current_player(board))\n end\n display_board(board)\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board,index)\n # puts \"Please enter X or O\"\n # xo = gets.strip\n puts \"The move is valid\"\n move(board,index,current_player(board))\n display_board(board)\n else\n puts \"Input invalid and provide valid location\"\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index)\n display_board(board)\n else\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index)\n display_board(board)\n else\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n user_input = gets.strip # Gets user input\n index = input_to_index(user_input) # Passes user input to input_to_index method as argument\n if valid_move?(board, index) == true # Test Code not valid then turn(board) to run again\n move(board, index, value = \"X\")\n display_board(board)\n else\n turn(board)\n end\n end", "def turn\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(index)\n move(index,current_player)\n display_board\n else\n turn\n end\n end", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index, char = \"X\")\n puts \"position #{index + 1}\"\n display_board(board)\n else\n until valid_move?(board, index)\n puts \"Invalid Move, Please Choose Again (Must Be A Number 1-9)\"\n index = input_to_index(gets.strip)\n end\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if !valid_move?(board, index)\n turn(board)\n else\n move(board,index,current_player(board))\n display_board(board)\n end\nend", "def turn(board)\r\n puts \"Please enter 1-9:\"\r\n input = gets.strip\r\n index = input_to_index(input)\r\n if valid_move?(board, index)\r\n move(board, index)\r\n display_board(board)\r\n else\r\n turn(board)\r\n end\r\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index, character = \"X\")\n display_board(board)\n else\n puts \"That is an invalid move\"\n turn(board)\n end\nend", "def turn(board)\n#This is the initial prompt telling our user to input\n puts \"Please enter 1-9:\"\n#this gets our user input\n user_input= gets.strip\n#I set the index variable for later methods to = the outcome of the input to index method\n index = input_to_index(user_input)\n#If the outcome of the valid move method is true then run the board method and display the board\n if valid_move?(board, index) == true\n move(board, index, char = \"X\")\n display_board(board)\n#if not run the turn method again\n else\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n num = gets.chomp\n index = input_to_index(num)\n if valid_move?(board, index) == true\n move(board, index)\n display_board(board)\n else\n turn(board)\n end\nend", "def turn (board)\n puts \"Please enter 1-9:\"\n num = gets.chomp\n index = input_to_index(num)\n if valid_move?(board, index) == true\n move(board, index)\n display_board(board)\n else\n turn(board)\n end\nend", "def turn (board)\n puts \"Please enter 1-9:\"\n num = gets.chomp\n index = input_to_index(num)\n if valid_move?(board, index) == true\n move(board, index)\n display_board(board)\n else\n turn(board)\n end\nend", "def turn (board)\n puts \"Please enter 1-9:\"\n num = gets.chomp\n index = input_to_index(num)\n if valid_move?(board, index) == true\n move(board, index)\n display_board(board)\n else\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n user_input = gets.strip\n index = input_to_index(user_input)\n\n # A simple loop that will check the validity of the move,\n # then update the game accordingly.\n if valid_move?(board, index) == true\n move(board, index, player_choice = \"X\")\n\n display_board(board)\n\n puts board\n else\n puts \"Error! Out of index!\"\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index, current_player(board))\n display_board(board)\n else\n turn(board)\n end\nend", "def turn\n puts \"Please enter 1-9:\"\n user_input = gets.strip\n index = input_to_index(user_input)\n if valid_move?(index) == true\n move(index, current_player)\n else\n turn\n end\n display_board\n end", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board,index,current_player(board))\n display_board(board)\n else\n turn(board)\n end\nend", "def turn\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(index)\n move(index, current_player)\n display_board\n else\n turn\n end\n end", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board,index)\n move(board,index,current_player(board))\n else\n puts \"Hey, pay attention!\"\n turn(board)\n end\n display_board(board)\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n \n if valid_move?(board, index)\n move(board, index, current_player(board))\n display_board(board)\n else\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n user_input = gets.strip\n index = input_to_index(user_input)\n if valid_move?(board, index)\n move(board, index, character = current_player(board))\n display_board(board)\n else\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n valid = valid_move?(board,index)\n\n if !valid_move?(board,index)\n turn(board)\n else\n token = current_player(board)\n move(board, index, token)\n display_board(board)\n end\nend", "def turn(board)\n puts 'Please enter 1-9:'\n user_input = gets.strip\n index = input_to_index(user_input)\n\n if valid_move?(board, index)\n move(board, index, current_player(board))\n display_board(board)\n else\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n user_input = gets.strip\n arr_index = input_to_index(user_input)\n position = current_player(board)\n\n if !valid_move?(board, arr_index)\n puts \"Please enter a different option\"\n user_input = gets.strip\n else\n move(board, arr_index, position)\n display_board(board)\n end\n\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip #get user input and store in variable 'input'\n index = input_to_index(input) #convert user response into an integer and subtract 1\n\n\n # maybe need something (like an IF stmt) to check for if the position is not occupied with an X or O,\n # make the move, otherwise run the Turn method again.\n if valid_move?(board, index) #check if user input is in correct range of array 0-8, and position taken is true.\n move(board, index)\n display_board(board) #display the board after all these above checks\n else\n turn(board)\n end\n\nend", "def turn(board)\n player=current_player(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index,player)\n display_board(board)\n else\n turn(board)\n end\nend", "def turn(board)\r\n puts \"Please enter 1-9:\"\r\n user_input = gets.strip\r\n index = input_to_index(user_input)\r\n if valid_move?(board, index)\r\n move(board, index, current_player(board))\r\n display_board(board)\r\n else\r\n turn(board)\r\n end\r\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n position = gets.strip\n index = input_to_index(position)\n if valid_move?(board, index)\n current_player = current_player(board)\n move(board, index, current_player)\n display_board(board)\n else\n turn(board)\n end\nend", "def turn \n player = current_player\n puts \"Player '#{player}' enter a move [1-9]\"\n input = gets.chomp \n index = input_to_index(input)\n if valid_move?(index)\n move(index,player)\n display_board\n else \n turn\n end\n end", "def turn\n character = current_player\nputs \"Please enter 1-9:\"\nuser_input = gets.strip\nuser_input = user_input.to_i\nindex = input_to_index(user_input)\n if valid_move?(index) == true\n move(index, character)\n display_board\n else \n turn\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index) == true\n move(board, index)\n else\n puts \"Not a valid entry, position must be between 1 and 9 and not be currently occupied\"\n turn(board)\n end\n display_board(board)\nend", "def turn\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(index)\n move(index, current_player)\n display_board\n else\n turn\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index, current_player(board))\n display_board(board)\n else\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index, current_player(board))\n display_board(board)\n else\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index, current_player(board))\n display_board(board)\n else\n turn(board)\n end\nend", "def turn(board)\n\nputs \"Please enter 1-9:\"\ninput = gets.strip\nindex = input_to_index(input)\nif valid_move?(board, index) == true\n token = current_player(board)\n move(board, index, token)\n display_board(board)\n\nelse\n puts \"Please enter 1-9:\"\n turn(board)\n\nend\nend", "def turn\n puts \"Please enter 1-9:\"\n user_input = gets.strip\n index = input_to_index(user_input)\n\n until valid_move?(index)\n puts \"Invalid Move! Try again.\"\n user_input = gets.strip\n index = input_to_index(user_input)\n\n end\n\n move(index, current_player)\n display_board\n end", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n value = current_player(board)\n move(board, index, value)\n display_board(board)\n else\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\" #get the user input\n user_input = gets.strip\n index = input_to_index(user_input) # input to index\n value = current_player(board)\n\n if valid_move?(board, index)\n move(board,index,value)\n display_board(board)\n else\n puts \"Oops, invalid move! Please try again.\"\n turn(board)\n end\nend", "def turn(board)\n print \"Please enter 1-9: \"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index, current_player(board))\n display_board(board)\n else\n turn(board)\n end\nend", "def turn\n puts \"Please enter 1-9:\"\n user_input = gets.strip\n user_input = input_to_index(user_input)\n if valid_move?(user_input)\n move(user_input, current_player)\n else \n turn\n end\n display_board\nend", "def turn(board)\n \n current_player = current_player(board)\n \n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index, current_player)\n display_board(board)\n else\n turn(board)\n end\nend", "def turn(board)\n puts \"Make your move, enter a grid value from 1 - 9: \"\n input = gets.strip\n index = input_to_index(input)\n value = current_player(board)\n if valid_move?(board, index)\n move(board, index, value)\n else\n turn(board)\n end\n display_board(board)\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n user_number = gets.strip\n index = input_to_index(user_number)\n if !(valid_move?(board,index)) \n puts \"Not a valid move. Try again.\"\n turn(board)\n else\n move(board, index, sign)\n end\nend", "def turn(board)\n index = -1\n player = current_player(board)\n until valid_move?(board, index) do\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n end\n move(board, index, player)\n display_board(board)\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n \n if valid_move?(board, index) == true\n move(board, index)\n display_board(board)\n else\n until valid_move?(board, index) == true\n turn(board)\n break\n end\n end\nend", "def turn(board)\n valid_move = false\n puts \"Please enter 1-9:\"\n user_input = gets.strip\n index = input_to_index(user_input)\n valid_move = valid_move?(board, index)\n if valid_move\n token = current_player(board)\n move(board, index, token)\n else\n turn(board)\n end\nend", "def turn\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n is_valid = valid_move?(index)\n if is_valid === true\n current_turn = current_player\n move(index,current_turn)\n display_board\n else\n puts 'Please enter correct input'\n puts \"Please enter 1-9:\"\n input = gets.strip\n end\n end", "def turn(board)\n puts \"Please enter 1-9:\"\n user_input = gets.strip\n index = input_to_index(user_input)\n token = current_player(board)\n if valid_move?(board,index)\n puts 'valid move'\n move(board, index, token)\n display_board(board)\n else\n puts 'try again'\n turn(board)\n end\n display_board(board)\nend", "def turn()\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(index)\n move(index, current_player())\n display_board()\n else\n turn()\n end\n end", "def turn\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n char = current_player\n if valid_move?(index)\n move(index, char)\n display_board\n else\n turn\n end\nend", "def turn\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n char = current_player\n if valid_move?(index)\n move(index, char)\n display_board\n else\n turn\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n user_input = gets.chomp\n int_input = input_to_index(user_input) #convert user_input to int\n move_okay = valid_move?(board, int_input)\n\n if move_okay == true\n move(board, int_input)\n display_board(board)\n else\n turn(board)\n end\nend", "def turn\r\n puts \"Please enter 1-9:\"\r\n user_input = gets.strip\r\n user_move = input_to_index(user_input)\r\n \r\n if valid_move?(user_move)\r\n move(user_move,current_player)\r\n display_board\r\n else\r\n turn\r\n end\r\n end", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index, current_player(board))\n display_board(board)\n else\n puts \"Incorrect entry. Try again.\"\n turn(board)\n end\nend", "def turn\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(index)\n move(index, current_player)\n display_board\n else\n turn\n end\n end", "def turn\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(index)\n move(index, current_player)\n display_board\n else\n turn\n end\n end", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n character = current_player(board)\n if valid_move?(board, index)\n move(board, index, character)\n display_board(board)\n else\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index, current_player(board))\n display_board(board)\n else\n turn(board)\n end\n end", "def turn(array)\r\n puts \"Please enter 1-9:\"\r\n user_input = gets.strip\r\n user_move = input_to_index(user_input)\r\n if valid_move?(array,user_move)\r\n move(array,user_move,current_player(array))\r\n display_board(array)\r\n else \r\n turn(array)\r\n end\r\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.chomp\n index = input_to_index(input)\n if valid_move?(board, index) == true\n move(board, index, current_player(board))\n display_board(board)\n else\n puts \"That is an invalid move, please enter 1-9:\"\n turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n input = input_to_index(input)\n if !valid_move?(board, input)\n\t turn(board)\n end\n move(board,input,current_player(board))\n display_board(board)\nend", "def turn\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(index)\n value = current_player\n move(index, value)\n display_board\n else\n turn\n end\n end", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board,index)\n move(board,index,current_player(board))\n display_board(board)\n else \n puts 'Please make sure square is not taken and is between 1-9'\n turn(board)\n end\nend", "def turn\n #asks for user input, converts input to integer\n puts \"Enter the position you like to play (1-9): \"\n user_input = gets.strip\n\n #if move is valid, accepts move as index and displays new board\n if valid_move?(user_input)\n token=current_player\n move(user_input, token)\n display_board\n else\n turn\n end\n end", "def turn(board)\n puts \"Please enter 1-9:\"\n input=gets.strip\n index = input_to_index(input)\n if valid_move?(board, index) == false\n turn(board)\n else\n move(board, index, current_player(board))\n display_board(board)\n end\n end", "def turn\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n character = current_player\n if valid_move?(index)\n move(index, character)\n display_board\n else\n # puts \"Invalid move\"\n turn\n end\n end", "def turn(board)\r\n # if draw?(board)\r\n # puts \"Cat's Game!\"\r\n # elsif over?(board) \r\n # puts \"Congratulations #{winner(board)}!\"\r\n # else\r\n puts \"Please enter 1-9:\"\r\n input = gets.strip\r\n index = input_to_index(input)\r\n if valid_move?(board, index)\r\n token = current_player(board)\r\n player_move(board, index, token)\r\n display_board(board)\r\n else\r\n turn(board)\r\n end\r\n # end\r\nend", "def turn\n puts \"Please enter 1-9:\"\n input = gets\n go = input_to_index(input)\n if valid_move?(go)\n move(go, current_player)\n display_board\n else\n turn\n end\nend", "def turn\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(index)\n move(index, current_player)\n display_board\n else\n turn\n end\n end", "def turn(board)\n \n loop do\n puts \"Please enter 1-9:\"\n index = input_to_index( gets.chomp )\n if valid_move?( board, index )\n move( board, index)\n display_board( board )\n break\n else\n puts \"That was an invalid entry\"\n end\n end\nend", "def turn\r\n current_player = self.current_player\r\n #Ask the user for, and obtain, their move, a position between 1-9.\r\n print \"#{current_player}, enter your move (1-9): \"\r\n move_index = gets.chomp\r\n print \"\\n\"\r\n \r\n #Translate user input to valid index\r\n move_index = self.input_to_index(move_index)\r\n \r\n #Check if user input is valid move\r\n valid = false\r\n while !valid do\r\n if self.valid_move?(move_index)\r\n #If valid, make the move and display the board.\r\n self.move(move_index, current_player)\r\n self.display_board\r\n valid = true\r\n else\r\n #If invalid, ask for a new move until a valid move is received.\r\n puts \"That is not a valid move.\"\r\n print \"#{current_player}, enter your move (1-9): \"\r\n move_index = gets.chomp\r\n print \"\\n\"\r\n move_index = self.input_to_index(move_index)\r\n end\r\n end\r\n end", "def turn \n puts \"Make a move compadre\"\n input = gets.strip\n location = input_to_index(input)\n if valid_move?(location)\n tictac = current_player\n move(location, tictac)\n display_board\n else\n turn\n end\n end", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n position = input_to_index(input)\n token = current_player(board)\n if valid_move?(board, position)\n move(board, position, token)\n display_board(board)\n else\n turn(board)\n end\nend", "def turn\n puts \"Choose a spot between 1-9\"\n spot = gets.strip\n #calls #input_to_index, #valid_move?, and #current_player\n #makes valid moves and displays the board\n #loop back spot/input if/else statement to ask for input again after a failed validation\n spot = input_to_index(spot)\n if valid_move?(spot)\n move(spot, current_player)\n else\n turn\n end\n display_board\n end", "def turn()\n player = current_player()\n puts \"Player #{player}, Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n\n is_valid = false\n until is_valid\n if valid_move?(index)\n move(index, player)\n display_board()\n is_valid = true\n else\n puts \"Invalid Selection! Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n end\n end\n end", "def turn(board)\n player = current_player(board)\n puts \"Player #{player}, Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n\n is_valid = false\n until is_valid\n if valid_move?(board, index)\n move(board, index, player)\n display_board(board)\n is_valid = true\n else\n puts \"Invalid Selection! Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n end\n end\nend", "def turn\n puts \"Please enter 1-9:\"\n input = gets.strip\n position = input_to_index(input)\n\n if valid_move?(position)\n player = current_player\n move(position, player)\n display_board\n else\n turn\n end\n end", "def turn\n puts \"Please enter 1-9:\"\n user_input = gets.chomp\n user_input = input_to_index( user_input )\n if valid_move?( user_input ) == true\n puts \"Valid move was made\"\n character = current_player\n move( user_input, character )\n display_board\n else\n while valid_move?( user_input ) == false\n puts \"Please enter a valid move: \"\n user_input = gets.chomp\n user_input = input_to_index( user_input )\n end\n if valid_move?( user_input ) == true\n puts \"Valid move was made\"\n character = current_player\n move( user_input, character )\n display_board\n end\n end\n end", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n position = input_to_index(input)\n \n if valid_move?(board, position) == true\n move(board, position, current_player(board))\n display_board(board)\n else\n until valid_move?(board, position) == true\n turn(board)\n break\n end\n end\nend", "def turn(board)\n input = ask_move\n index = input_to_index(input)\n if (valid_move?(board, index) == true)\n move(board, index)\n elsif (valid_move?(board, index) == false)\n puts \"This is not a valid move.\"\n false\n while (turn(board) == false)\n turn(board)\n end\n end\nend", "def turn \n\t\tputs \"\"\n\t\tputs current_player + \", Enter a square to take:\"\n\t\tindex = gets.strip\n\t\tindex = input_to_index(index)\n\t\tif valid_move?(index)\n\t\t\tmove(index, current_player)\n\t\telse \n\t\t\tputs \"Invald space, try again\" \n\t\tend\n\tend", "def turn(board)\n puts \"Please enter 1-9:\"\n user_input = gets.strip\nindex = input_to_index(user_input)\nif valid_move?(board, index) == false\n #puts \"Please enter 1-9:\"\n #use recursion instead\n turn(board) #recursive\nelse\n move(board, index, char = \"X\")\n display_board(board)\nend\nend", "def turn\n # Asks user for input.\n puts \"Please enter 1-9:\"\n # Places the user's answer into the variable 'input'.\n input = gets.strip\n # Uses the conversion method to place it into variable 'index'.\n index = input_to_index(input)\n # Goes through an if/else loop to check if move is valid.\n if valid_move?(index)\n # Adds the player's input if valid.\n move(index, current_player)\n # Displays the board back to the player in the CLI afterwards.\n display_board()\n else\n # Recursively calls the turn method if an incorrect move is played.\n turn()\n end\n end", "def turn(board)\n display_board(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n \n ##if valid_move?(board, input) == true\n ##display_board(board)\n if valid_move?(board, input) == false\n turn(board)\n else\n move(board, input)\n display_board(board)\n end\n \nend", "def turn()\n puts \"Please enter 1-9:\"\n input = gets.strip\n intger=input.to_i\n #position = intger.to_i -1\n if valid_move?(input)\n move( intger,current_player())\n display_board()\n else\n turn()\n end\nend", "def turn(board)\n player = current_player(board)\n puts \"It's #{player}'s turn!\"\n puts \"Please enter 1-9:\"\n input = gets.strip\n i = input_to_index(input)\n if valid_move?(board, i)\n move(board, i, current_player(board))\n elsif valid_move?(board, i) == false\n puts \"Sorry, that move isn't valid. Try again.\"\n puts \"\\n\"\n puts turn(board)\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n position = gets.chomp\nif valid_move?(board, position)\n move(board, position)\n display_board(board)\nelse\n turn(board)\nend\nend", "def turn\n display_board\n puts \"Please enter 1-9:\"\n input = gets.strip\n if !valid_move?(input)\n turn\n end\n move(input, current_player)\n display_board\nend", "def turn(board)\n player = current_player(board)\n got_valid = false\n puts \"Please choose a position between 1-9:\"\n while got_valid == false\n user_input = gets.strip\n position = input_to_index(user_input)\n if valid_move?(board, position)\n move(board, position, player)\n display_board(board)\n got_valid = true\n end\n end\nend", "def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n if valid_move?(board,input)\n move(board,input,current_player(board))\n else\n turn(board)\n end\n display_board(board)\nend" ]
[ "0.86453575", "0.86306924", "0.86284745", "0.8608867", "0.86050963", "0.8595847", "0.85849005", "0.8576422", "0.8570284", "0.85622907", "0.8533654", "0.8533654", "0.8528928", "0.8526603", "0.852346", "0.85180306", "0.8517789", "0.85125995", "0.85089785", "0.84984756", "0.8498251", "0.8498251", "0.8497584", "0.84974295", "0.8496481", "0.849334", "0.8490644", "0.84870327", "0.84825194", "0.8480026", "0.8476352", "0.8476311", "0.8470506", "0.8470355", "0.84642124", "0.8457732", "0.8456853", "0.84450185", "0.84416944", "0.8440861", "0.8431112", "0.8426182", "0.842495", "0.842495", "0.842495", "0.84151757", "0.84109825", "0.84012264", "0.83950156", "0.83500534", "0.8346789", "0.8339877", "0.8338318", "0.83341455", "0.8333394", "0.833126", "0.8329852", "0.83156717", "0.8312902", "0.8303597", "0.8292705", "0.8292705", "0.828947", "0.828865", "0.8287067", "0.8286641", "0.8286641", "0.8275783", "0.8274527", "0.8268026", "0.82597345", "0.8259331", "0.825714", "0.8196848", "0.81950897", "0.81945795", "0.8172995", "0.8171108", "0.8161896", "0.8157367", "0.81219095", "0.8119684", "0.8080984", "0.8064049", "0.8063501", "0.8058836", "0.80403066", "0.80256855", "0.7995482", "0.7950918", "0.7935728", "0.79249024", "0.78878105", "0.786229", "0.7798079", "0.7726125", "0.77184415", "0.7716725", "0.7690858", "0.76632434", "0.76542705" ]
0.0
-1
Return full path of requireable file given relative path.
def find_requireable_file(file) root = full_gem_path require_paths.each do |lib| base = File.join(root, lib, file) Gem.suffixes.each do |suf| path = "#{base}#{suf}" return path if File.file? path end end return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_relative_path(path)\n Util::path_rel_to_path(path, recipe_file.path).to_s\n end", "def require_path\n val = require_paths and val.first\n end", "def relative_path\n must_be File\n Pathname.new(self.full_path).relative_path_from(Pathname.new(Dir.pwd)).to_s\n end", "def require_relative(path)\n require File.join(File.dirname(caller[0]), path.to_str)\nend", "def expanded_path\n relative_path(dependency.berksfile.filepath)\n end", "def rel_path(path)\n Pathname(path).expand_path.relative_path_from(Pathname(Dir.pwd))\n end", "def require_relative(path, from: :both)\n caller_path = caller_locations.first.path.to_s\n caller_dir = Pathname.new(caller_path).dirname.to_s\n prefix = Ruar.path_prefix.to_s\n\n # Ruar Internal File\n caller_dir = caller_dir.delete_prefix(prefix).prepend(File::SEPARATOR) if caller_dir.start_with?(prefix)\n\n resolved_path = File.expand_path(path, caller_dir)\n require(resolved_path, from: from)\n end", "def figure_path(file)\n return file if Pathname.new(file).absolute?\n $LOAD_PATH.each do |path|\n found = File.join(path, file)\n return File.expand_path(found) if File.file?(found)\n end\n file\n end", "def path_to_require\n name = self.rpartition('.').first\n $LOAD_PATH.each do |lib|\n name.sub!(lib+\"/\", '')\n end\n name\n end", "def determine_path\n if source_line.file == SourceLine::DEFAULT_FILE\n return source_line.file\n end\n\n full_path = File.expand_path(source_line.file)\n pwd = Dir.pwd\n\n if full_path.start_with?(pwd)\n from = Pathname.new(full_path)\n to = Pathname.new(pwd)\n\n return from.relative_path_from(to).to_s\n else\n return full_path\n end\n end", "def relative_path_to(path, relative_to = nil)\n if relative_to\n path = File.expand_path(\n # symlink, e.g. \"../../../../grid5000/environments/etch-x64-base-1.0.json\"\n path,\n # e.g. : File.join(\"/\", File.dirname(\"grid5000/sites/rennes/environments/etch-x64-base-1.0\"))\n File.join('/', File.dirname(relative_to))\n ).gsub(%r{^/}, '')\n end\n path\n end", "def path(rel)\n File.join(File.dirname(__FILE__), \"..\", rel)\nend", "def rel relative_path\r\n return File.dirname(__FILE__) + \"/../\" + relative_path\r\nend", "def gem_expand_file(rel_file)\n if File.exist?(a=File.join(GEM_ROOT, rel_file))\n File.expand_path(a)\n else\n raise Errno::ENOENT, rel_file\n end\n end", "def find_requirable_file(file)\n root = full_gem_path\n\n require_paths.each do |lib|\n base = \"#{root}/#{lib}/#{file}\"\n Gem.suffixes.each do |suf|\n path = \"#{base}#{suf}\"\n return path if File.file? path\n end\n end\n\n return nil\n end", "def relative_file_path(file_path)\n file_path.gsub(/#{pwd}\\//, '')\n end", "def relative_path(path)\n path = File.expand_path(File.dirname(__FILE__) + '/' + path)\n \"'#{path}'\"\nend", "def require_relative(x)\n REPLSupport.req_rel(x)\nend", "def getFullPath(relativePath)\n return baseDir + relativePath\n end", "def file() = pathname.relative_path_from(Cnfs.config.paths.definitions)", "def resolve_path(path)\n path = File.absolute_path(path) if path.start_with?('./', '../')\n\n abs_path = File.absolute_path(path)\n if path == abs_path\n path if (@load_paths_subset || File).exist?(path)\n else\n (@load_paths_subset || self).load_paths.each do |load_path|\n possible_path = File.absolute_path(path, load_path)\n\n next unless (@load_paths_subset || File).exist?(possible_path)\n # Ruby 2.5 changed some behaviors of require related to symlinks in $LOAD_PATH\n # https://bugs.ruby-lang.org/issues/10222\n return File.realpath(possible_path) if RUBY_VERSION >= '2.5'\n return possible_path\n end\n nil\n end\n end", "def path_from(relative_path)\n path.sub(/^#{Regexp.escape(relative_path)}\\/?/, '')\n end", "def path_from(relative_path)\n path.sub(/^#{Regexp.escape(relative_path)}\\/?/, '')\n end", "def relative_path(target = '.')\n my_path = Pathname.new(path).expand_path\n target_path = Pathname.new(target.to_s).expand_path\n target_path = target_path.dirname if target_path.file?\n\n new_path = my_path.relative_path_from(target_path).to_s\n\n return new_path if new_path.index('.') == 0\n \"./#{new_path}\"\n end", "def relative_path(target = '.')\n my_path = Pathname.new(path).expand_path\n target_path = Pathname.new(target.to_s).expand_path\n target_path = target_path.dirname if target_path.file?\n\n new_path = my_path.relative_path_from(target_path).to_s\n\n return new_path if new_path.index('.') == 0\n \"./#{new_path}\"\n end", "def gemfile_path\n @gemfile_path ||= begin\n path = ::File.expand_path(new_resource.path)\n if ::File.file?(path)\n # We got a path to a real file, use that.\n path\n else\n # Walk back until path==dirname(path) meaning we are at the root\n while path != (next_path = ::File.dirname(path))\n possible_path = ::File.join(path, 'Gemfile')\n return possible_path if ::File.file?(possible_path)\n path = next_path\n end\n end\n end\n end", "def relative_path(pathname)\n pwd = Pathname.new('.').realpath\n pathname.file_ref.real_path.relative_path_from(pwd)\n end", "def require_real_file(file)\n return unless file\n require File.realpath(file)\n end", "def rel_path(file)\n File.dirname(file)\n end", "def relative_path(path)\n\t\tSass::Script::String.new(File.join(File.expand_path(Dir.pwd), path.value))\n\tend", "def resolve_path(path)\n fail_script_unless_file_exists path\n return path\n end", "def resolve_path(path)\n fail_script_unless_file_exists path\n return path\n end", "def file_path path\n File.join(output_path, manifest.lookup(path).split('/')[2..-1])\n end", "def load_resource_relative(path, mode='r')\n\n absolute_path = File.dirname(caller_locations(1,1)[0].path) + '/' + path\n if absolute_path.to_s.chars.first == ':'\n absolute_path = OpenStudio.get_absolute_path(absolute_path)\n end\n\n if EmbeddedScripting::hasFile(absolute_path)\n return EmbeddedScripting::getFileAsString(absolute_path)\n end\n\n result = \"\"\n if File.exists?(absolute_path)\n File.open(absolute_path, mode) do |file|\n result = file.read\n end\n elsif File.exists?(path)\n File.open(path, mode) do |file|\n result = file.read\n end\n end\n return result\n end", "def require_reference path\r\n # @type [Gem::Specification]\r\n spec = spec_for_require(path)\r\n spec.full_require_paths.each do |rp|\r\n file = File.join(rp, \"#{path}.rb\")\r\n next unless File.file?(file)\r\n return Solargraph::Location.new(file, Solargraph::Range.from_to(0, 0, 0, 0))\r\n end\r\n nil\r\n rescue Gem::LoadError\r\n nil\r\n end", "def resource_path(path)\n path = Pathname.new(path).expand_path.relative_path_from(Pathname.pwd).to_s\n path = path.sub('.rb', '')\n path = path.split('/')\n from_block_dir_path = false\n path.shift if path.first == 'app'\n path.shift if path.first == 'lib'\n if path.first == 'blocks'\n path.shift\n from_block_dir_path = true\n end\n path.shift if path.first == underscored_app_namespace\n if path.include?('derivatives')\n path.delete('derivatives')\n from_block_dir_path = true\n end\n if from_block_dir_path\n path.delete('sub_blocks')\n path.pop if path.last == 'model'\n if path.last == 'controller'\n path.pop\n path << \"#{path.pop}_controller\"\n end\n end\n path.join('/')\n end", "def full_path(relative_filename)\n File.join(@mount_dir, relative_filename)\n end", "def user_file_path(file)\n path = \"#{Settings.source_dir}/#{file}\"\n ext = \".#{Settings.partials_extension}\"\n return path if path.end_with? ext\n\n \"#{path}#{ext}\"\n end", "def require_relative(relative_feature)\n c = caller.first\n e = c.rindex(/:\\d+:in /)\n file = $`\n if /\\A\\((.*)\\)/ =~ file # eval, etc.\n raise LoadError, \"require_relative is called in #{$1}\"\n end\n absolute_path = File.expand_path(File.join(File.dirname(file),\n relative_feature))\n require absolute_path\nend", "def full_path\n must_be File\n File.realpath(self.path)\n end", "def absolute_path(relative_path)\n quoted_string(File.expand_path(File.join(File.dirname(options[:filename]), relative_path.value)))\n end", "def gem_deps_file # :nodoc:\n File.basename @path\n end", "def relative_path(filename)\n pieces = split_filename(File.expand_path(filename))\n File.join(pieces[@mount_dir_pieces.size..-1])\n end", "def relative_path_from(from); end", "def relative_path(options = {})\n @relative_path ||= Pathname.new(filename).relative_path_from(Pathname.new(base)).to_s\n path_with_cache_buster(@relative_path, options)\n end", "def relative_path(path)\n path = destination_root.relative_path(path) || path\n path.empty? ? \".\" : path\n end", "def relative_path\n @relative_path ||= File.join(@dir, @target)\n end", "def require_relative(relative_feature)\n c = caller.first\n fail \"Can't parse #{c}\" unless c.rindex(/:\\d+(:in `.*')?$/)\n file = $`\n if /\\A\\((.*)\\)/ =~ file # eval, etc.\n raise LoadError, \"require_relative is called in #{$1}\"\n end\n absolute = File.expand_path(relative_feature, File.dirname(file))\n require absolute\nend", "def require_relative(file, *args)\n paths = $:\n paths.push(File.realpath(File.absolute_path(File.dirname(caller[0][/^([^:]+)/,1]))))\n\n paths.each do |p|\n path = File.join(p, file)\n path = \"#{path}.rb\" unless path.end_with? \".rb\"\n if File.exists?(path) || File.exists?(path + \".rb\")\n file = File.realpath(path)\n break\n end\n end\n\n @@__sets[file] = :original\n\n __require_relative(file, *args)\n end", "def ovl_expand_file(rel_file)\n if File.exist?(rel_file)\n File.expand_path(rel_file)\n elsif File.exist?(a=File.join(GEM_ROOT, rel_file))\n File.expand_path(a)\n else\n raise Errno::ENOENT, rel_file\n end\n end", "def ovl_expand_file(rel_file)\n if File.exist?(rel_file)\n File.expand_path(rel_file)\n elsif File.exist?(a=File.join(GEM_ROOT, rel_file))\n File.expand_path(a)\n else\n raise Errno::ENOENT, rel_file\n end\n end", "def relative_path; end", "def relative_path; end", "def relative_path; end", "def relative_path; end", "def relative_path; end", "def relative_path\n @relative_path ||= File.join(@dir, @name)\n end", "def ensure_file_at_relative_path(path)\n path_components = fully_split_path(path)\n file_name = path_components.pop\n ensure_file_with_directory_components(file_name, path_components)\n end", "def relative_path\n @relative_path ||= File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).delete_prefix(\"/\")\n end", "def relative_path(path = @pwd, to = @root)\n Pathname.new(path).relative_path_from(Pathname.new(to)).to_s\n end", "def get_absolute_path(file)\n File.expand_path file\nend", "def relative_src(filename, dir=nil)\n file = expand_src filename, dir\n base = Pathname.new File.dirname path_info\n Pathname.new(file).relative_path_from(base).to_s\n end", "def to_fullpath(path)\n if activated?\n @paths_map ||= {}\n @paths_map[path] ||=\n begin\n fullpath = nil\n suffixes = Gem.suffixes\n suffixes.find do |suf|\n full_require_paths.find do |dir|\n File.file?(fullpath = \"#{dir}/#{path}#{suf}\")\n end\n end ? fullpath : nil\n end\n else\n nil\n end\n end", "def abspath(file)\n File.absolute_path(file)\nend", "def to_relative_path\n File.join('.', to.path(identify).to_s)\n end", "def getFullPath(relativePath)\n return @baseDirectory.fullPath + relativePath\n end", "def resolve_relative_path(path, base_path)\n p = Pathname(base_path)\n p = p.dirname unless p.extname.empty?\n p += path\n\n p.cleanpath.to_s\n end", "def relative_path(filename)\n @mount_dir_pieces ||= @mount_dir.size\n pieces = split_filename(File.expand_path(filename))\n File.join(pieces[@mount_dir_pieces..-1])\n end", "def getPath(target)\n File.expand_path(File.join(File.dirname(__FILE__), target))\nend", "def require_p(path)\n require join(project_dir,path)\n end", "def lookup(base_path, relative_path, options={})\n exts = default_file_extensions\n if options[:load] or exts.include?(File.extname(relative_path))\n abspath = File.join(base_path, relative_path)\n File.exist?(abspath) ? abspath : nil\n else\n exts.each do |ext|\n abspath = File.join(base_path, relative_path + ext)\n return abspath if File.exist?(abspath)\n end\n nil\n end\n end", "def gemfile_path\n @gemfile_path ||= GEMFILES.map { |g| @config.pwd.join g }\n .find { |f| f.exist? }\n end", "def resolve_path(path)\n path = File.absolute_path(path) if path.start_with?('./') || path.start_with?('../')\n\n if Pathname.new(path).absolute?\n return path if File.exists?(path)\n return nil\n end\n\n @load_path.each do |load_path|\n possible_path = File.absolute_path(path, load_path)\n return possible_path if File.exists?(possible_path)\n end\n\n nil\n end", "def require_reference(path); end", "def min_file_path\n compiled_path || current_file_path\n end", "def relative_file_path_for(md_path)\n rel_md_path = relativize(md_path)\n\n if rel_md_path.end_with?(MetadataSerializer::metadata_suffix)\n rel_md_path[0..-MetadataSerializer::metadata_suffix.length - 1]\n else\n rel_md_path\n end\n end", "def relative_path(*relative)\n Pathname.pwd.join(*(relative.flatten.map(&:to_s))).expand_path\n end", "def relative_path\n @relative_path ||= PathManager.join(@dir, @name).delete_prefix(\"/\")\n end", "def require_relative(name)\n scope = Rubinius::StaticScope.of_sender\n Rubinius::CodeLoader.require_relative(name, scope)\n end", "def absolute_template_filename_for(relative_filename)\n File.expand_path(File.join(self.class.template_load_path, relative_filename))\n end", "def relative(filename)\n filename.sub(%r{#{File.expand_path(File.join(File.dirname(__FILE__), \"..\", \"src\"))}/}, \"\")\nend", "def relative_path path, base\n (root? path) && (offset = descends_from? path, base) ? (path.slice offset, path.length) : path\n end", "def full_gen_path\n File.expand_path(gen_dir, recipe_file.path)\n end", "def ruby_relative_path\n ruby_pathname = Pathname.new(ruby)\n bindir_pathname = Pathname.new(target_bin_dir)\n ruby_pathname.relative_path_from(bindir_pathname).to_s\n end", "def resource_path\n '.' + Dir[File.dirname(__FILE__)][/\\/resource\\/.*/]\n end", "def relative_path\n name\n end", "def abspath(path)\n Pathname.new(File.expand_path(path)).realpath.to_s\n end", "def resolve_path(source, required)\n Pathname.new(source).dirname.join(required.to_str).cleanpath.to_path\n end", "def relroot\n Pathname.new(File.expand_path(path)).\n relative_path_from(Pathname.new(File.expand_path(root))).to_s\n end", "def relative_path(p = path)\n anchor = p.ftype == \"directory\" ? @root_path : \"public\"\n p.relative_path_from(Pathname.new(anchor).realpath)\n end", "def relative_path\n @local_path.relative_path_from(@platform.local_path)\n end", "def file_to_path(file)\n file = File.expand_path(file, @app.root)\n \n prefix = @app.source_dir.sub(/\\/$/, \"\") + \"/\"\n return false unless file.include?(prefix)\n \n path = file.sub(prefix, \"\")\n extensionless_path(path)\n end", "def getRealPath(path) Pathname.new(path).realpath.to_s; end", "def getRealPath(path) Pathname.new(path).realpath.to_s; end", "def abs_path_with(rel_path)\n path = abs_path\n return rel_path if path.nil?\n return \"#{path}.#{rel_path}\"\n end", "def relative_path\n @relative_path ||= absolute_path.sub(/^#{Bookshelf::remote_folder}\\/?/,'')\n end", "def gemspec_path\n Pathname.glob('*.gemspec').first\n end", "def r(filename)\n require \"./#{filename}\"\nend", "def my_path\n File.expand_path(File.dirname(__FILE__))\n end", "def relative_path\n File.join(@repo, @bundle)\n end" ]
[ "0.74855363", "0.74143714", "0.73208064", "0.7261118", "0.70347613", "0.6940703", "0.6902004", "0.6872478", "0.6856985", "0.68353003", "0.6803622", "0.6762107", "0.6758233", "0.674405", "0.6741542", "0.67345953", "0.6726295", "0.669072", "0.66726506", "0.6664007", "0.6629192", "0.661086", "0.661086", "0.658554", "0.658554", "0.657888", "0.64773935", "0.647681", "0.6475495", "0.6467013", "0.6466593", "0.6466593", "0.64540195", "0.6425062", "0.64232534", "0.64188683", "0.6379905", "0.6362046", "0.63587046", "0.6349597", "0.63461524", "0.6344362", "0.6341457", "0.6325056", "0.6317437", "0.6304121", "0.6287447", "0.628566", "0.627523", "0.62717474", "0.62717474", "0.6270019", "0.6270019", "0.6270019", "0.6270019", "0.6270019", "0.6267542", "0.62562376", "0.6233341", "0.62319916", "0.6220135", "0.6219008", "0.62133414", "0.6208592", "0.6207232", "0.6204069", "0.6203197", "0.62022984", "0.62020135", "0.62019217", "0.6184156", "0.6168666", "0.6167725", "0.61620796", "0.6155888", "0.6148994", "0.61364776", "0.6133285", "0.6126715", "0.61246926", "0.6122535", "0.610805", "0.60980207", "0.60955316", "0.60866153", "0.60823387", "0.6080093", "0.60727376", "0.6066029", "0.6059423", "0.60580456", "0.605394", "0.6045946", "0.6045946", "0.6045716", "0.60393476", "0.60175437", "0.601536", "0.6003624", "0.60026246" ]
0.7173465
4
return the next line of the file that contains content, "EOF" if finished
def next lines.shift end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nextline\n # handle last file\n\n if @curr.nil?\n @curr=File.open @files.next rescue nil\n end\n\n return if @curr.nil? # Still Nil?\n\n # handle EOF\n if (line = @curr.gets).nil?\n @curr=nil\n :eof\n else\n line.chomp\n end\n end", "def get_next\n return if eof?\n\n @buffer << @io.gets if @buffer.empty?\n\n until @io.eof?\n line = @io.gets\n next unless line\n\n if @parser.start_new?(line) || @buffer.empty?\n @buffer << line\n break\n else\n @buffer.last << line\n end\n end\n\n return if @buffer.empty?\n @parser.parse(@buffer.slice!(0)) || self.get_next\n end", "def read_next()\n return nil if @at_end\n\n begin\n pos = @marker.position\n\n if @marker.character == ?\\n\n pos.line += 1\n pos.column = 0\n end\n\n @marker.character = @reader.next\n @marker.source_index += 1\n pos.column += 1\n rescue StopIteration\n @at_end = true\n @marker.character = nil\n end\n\n @marker.character\n end", "def get_next\n return if eof?\n\n @buffer << gets if @buffer.empty?\n\n until @io.eof? && @io_buf.empty?\n line = gets\n next unless line\n\n if @parser.start_new?(line) || @buffer.empty?\n @buffer << line\n break\n else\n @buffer.last << line\n end\n end\n\n return if @buffer.empty?\n @parser.parse(@buffer.slice!(0)) || self.get_next\n end", "def current_line\n\n seek_line_head\n @file.gets\n end", "def next_line\n return nil if @input.eof?\n line, ch, @pos, @line_no = '', '', 0, @line_no + 1\n until ch == \"\\r\" || ch == \"\\n\" || ch.nil?\n ch = @input.getc\n line += ch unless ch.nil?\n end\n if ch == \"\\r\"\n ch = @input.getc\n @input.ungetc(ch) unless ch == \"\\n\" || ch.nil?\n end\n line.chomp << \"\\n\"\n end", "def next\n raise IOError.new(\"Stream is at the end of file.\") if eof?\n end_of_token = false\n token = \"\"\n while not end_of_token\n c = @file.getc\n puts \"next c: #{c.inspect} v: #{valid_char?(c)} s: #{single_char?(c)} e: #{is_end_character?(c)}\" if @debug\n if eof? then\n end_of_token = true\n elsif (single_char?(c)) then\n if (token.empty?) then\n token = c\n next_token = @file.getc\n if ('#' == token and '#' == next_token) then\n token << next_token\n else\n @file.seek(-1, IO::SEEK_CUR)\n end\n else\n @file.seek(-1, IO::SEEK_CUR)\n end\n end_of_token = true\n elsif (valid_char?(c)) then\n token << c\n elsif is_end_character?(c) then\n move_till_next_token\n end_of_token = (not token.empty?)\n end\n end\n puts \"next\" if @debug\n build_token(token)\n end", "def read_next_command\n\n\t\tif !@file.eof\n\t\t\t@file.readline\n\t\telse\n\t\t\t@file.close\n\t\tend\n\n\tend", "def move_to_next_line()\r\n while @seek_ptr < @len && @fileBuf.at(@seek_ptr) != \"\\n\"\r\n @seek_ptr = @seek_ptr + 1\r\n end\r\n end", "def eof; @file.eof; end", "def next\n displacement = @file.gets.try(:chomp).try(:to_f)\n return nil unless displacement\n\n ret = @curr_val\n @curr_val += displacement\n ret\n end", "def next_char\n temp = @file.eof? ? '^' : @file.getc\n @line += temp;\n @columnCount+=1\n return temp\n end", "def readline\n @handle ||= fs.s3.interface.get_object(fs.bucket(path), fs.key_path(path)).each\n begin\n @handle.next\n rescue StopIteration, NoMethodError\n @handle = nil\n raise EOFError.new(\"end of file reached\")\n end\n end", "def next_block\n lines = []\n\n line = @fh.gets\n while !start_of_block?(line)\n line = @fh.gets\n return \"\" if @fh.eof?\n end\n\n while(!@fh.eof? && !end_of_block?(line))\n lines << line.chomp\n line = @fh.gets\n end\n\n lines.join(\"\\n\")\n end", "def eof?() end", "def eof?() end", "def eof?() end", "def get_next_line(file, index)\n index.value += 1\n return get_current_line(file, index)\nend", "def peek_next()\n return nil if @at_end\n\n begin\n @reader.peek\n rescue StopIteration\n nil\n end\n end", "def eof() end", "def eof() end", "def eof() end", "def nextCh()\r\n\t\tif (! @f.eof?)\r\n\t\t\t@c = @f.getc()\r\n\t\telse\r\n\t\t\t@c = \"!eof!\"\r\n\t\tend\r\n\t\t\r\n\t\treturn @c\r\n\tend", "def do_eof; end", "def next_line\r\n while true\r\n if (@lexemes[@pointer] != nil && @lexemes[@pointer] != '@')\r\n @pointer = @pointer.next\r\n else\r\n break\r\n end\r\n end\r\n end", "def skip_to_eoln\r\n @source.get until @source.eoln?\r\n true\r\n end", "def nextLine\r\n\t\twhile (@allLines[0] == \"\" || @allLines[0] == \"\\r\\n\" || @allLines[0] == \"\\n\")\r\n\t\t\t@allLines.shift\r\n\t\tend\r\n\t\tif(@allLines[0]!=nil)\r\n\t\t\t@Line = @allLines[0]\r\n\t\t\t@allLines.shift\r\n\t\t\tcheckSpace\r\n\t\tend\r\n\tend", "def current_line\n STDIN.each_line.next\nend", "def eof!; end", "def next()\n @stream.next\n end", "def readable_after_eof?\n true\n end", "def readable_after_eof?\n true\n end", "def readable_after_eof?\n true\n end", "def readable_after_eof?\n true\n end", "def readable_after_eof?\n true\n end", "def read\n @lines.shift\n end", "def collect_next_line\n line = @io.gets\n return nil unless line\n\n if line =~ ONE_LINE_TEST_RESULT_REGEX\n process_test_result $1\n\n elsif line.include? TEST_RESULT_START_TOKEN\n @partial_test_result << line.sub(TEST_RESULT_START_TOKEN, '')\n\n elsif line.include? TEST_RESULT_END_TOKEN\n @partial_test_result << line.sub(TEST_RESULT_END_TOKEN, '')\n process_test_result @partial_test_result\n @partial_test_result = ''\n\n elsif !@partial_test_result.empty?\n # Middle of a test result\n @partial_test_result << line\n\n else\n @on_non_test_result_line_block.call(line) if @on_non_test_result_line_block\n\n end\n\n line\n end", "def readable_after_eof?\n true\n end", "def readable_after_eof?\n true\n end", "def readable_after_eof?\n true\n end", "def eof?\n ref_line.nil? && output_line.nil?\n end", "def readline\n bucket,key = fs.split_path(path)\n @handle ||= fs.s3.interface.get_object(bucket, key).each\n begin\n @handle.next\n rescue StopIteration, NoMethodError\n @handle = nil\n raise EOFError.new(\"end of file reached\")\n end\n end", "def eof?\n end", "def read\n @index += 1\n line = @last ? @last : @lines[@index]\n @last = nil\n line\n end", "def read_line\n @line = @file.gets\n @file.close if @line.nil?\n end", "def read_row\n return if end_of_file?\n\n @current_row = @next_row || _read_row\n @line_number = current_row.nil? ? nil : @line_number + 1\n @next_row = nil\n\n current_row\n end", "def next\n fil_header[:next]\n end", "def get_next_char(file)\n orig = file.tell\n while true\n next_char = file.read(1)\n #End of file\n if (not next_char) \n break\n #Not whitespace, so this is the next valid character\n elsif (not (next_char =~ /[\\r|\\t|\\n|\\f| ]/)) \n break\n end\n end\n #Set file back to original position\n file.seek(orig, IO::SEEK_SET)\n return next_char\n end", "def eof?; end", "def eof?; end", "def next\n if @state == :start && @scanner.eos?\n return nil\n else\n scan_next_token\n end\n end", "def eof?\n @io.eof?\n end", "def eof?\n @io.eof?\n end", "def eof?\n @io.eof?\n end", "def eof?\r\n false\r\n end", "def eof?\n @eof\n end", "def eof?\n @eof\n end", "def eof?\n @eof\n end", "def eof?\n io.eof?\n end", "def each(eol=$/)\n while line = self.gets(eol)\n yield line\n end\n end", "def next_line\n $stdin.tty? ?\n Readline.readline('> ', true) :\n $stdin.gets\n end", "def at_end?\n peek.type == :eof\n end", "def process_next_tx\n begin\n tx = nil\n until tx do\n tx = process_tx(@logfile.readline)\n end\n rescue EOFError\n return nil\n end\n tx\n end", "def read_new_line(decoder)\n begin\n line = decoder.poll\n rescue\n # At first time, java.lang.IllegalStateException is thrown\n end\n\n if line == nil\n return nil if decoder.nextFile == false\n read_new_line(decoder)\n else\n line\n end\n end", "def eof\n end", "def eof?\n @eof\n end", "def eof?\n @eof\n end", "def eof?\n @eof\n end", "def get_current_line(file, index)\n current_line = file[index.value]\n if !current_line.nil?\n current_line.chomp()\n end\n while (!current_line.nil?) && current_line.match(/\\A\\s*\\Z/)\n index.value += 1\n current_line = file[index.value]\n if !current_line.nil?\n current_line.chomp()\n end\n end\n return current_line\nend", "def get_line(filename, lineno)\n File.open(filename) do |f|\n f.gets until f.lineno == lineno - 1\n f.gets\n end\n end", "def on_eof(&block); end", "def eof?\n @input.eof?\n end", "def eof?\n @stream.eof?\n end", "def eof?\n @stmt.done?\n end", "def next_line\n CSI + 'E' + column(1)\n end", "def eof?\n return @stream.eof?\n end", "def eof?; @io.size == @rio end", "def next_byte(close)\n if !is_file_open?\n open_file\n end\n \n begin\n current_byte = @file_handle.getc\n \n if current_byte == nil or close\n close_file\n else\n @position += 1\n end\n\n return current_byte\n rescue\n # re-raise system the excepiton\n raise\n close_file\n return nil\n end\n \n end", "def next\n @opened && @cur_record_index < @num_records ? _read_next_record : nil\n end", "def eat_eol()\n if eol_as_token # if eol is significant in the language...\n position = build_position(:lexeme)\n eol_lexeme = scanner.scan(eol_pattern) # Consume the eol text\n eol_token = [:T_EOL, RaccLexer::Token.new(eol_lexeme, eol_lexeme, position)]\n queue.unshift eol_token\n else\n scanner.scan(eol_pattern) # Consume the eol text\n end\n\n @lineno += 1\n @line_offset = scanner.pos()\n end", "def end_of_stream?\n @next_chunk.nil?\n end", "def end_of_meta_data\n cur = tell\n\n seek 0\n line = _gets\n return unless META_SEP =~ line\n\n while line = _gets\n break if META_SEP =~ line\n end\n return if line.nil?\n tell\n\n ensure\n seek cur\n end", "def eof_found?\n @eof_found\n end", "def track_eof?\n true if track_eof\n end", "def first_line\n @first_line ||= begin\n file = ::File.new(@full_path)\n first_line = file.sysread(512)\n file.close\n first_line || ''\n rescue ::EOFError, ::SystemCallError\n # :nocov:\n file&.close\n # :nocov:\n first_line || ''\n end\n end", "def read_last_line(f)\n pos = 2\n f.seek(-pos, File::SEEK_END)\n c = f.getc\n result = ''\n while c.chr != \"\\n\"\n result.insert(0,c.chr)\n pos += 1\n f.seek(-pos, File::SEEK_END)\n c = f.getc\n end\n f.rewind\n return result\nend", "def next()\n\n @filehandler.pos = @list_of_positions[@current_iteration]\n\n if @list_of_positions.length > @current_iteration\n @current_iteration += 1\n end\n\n make_entry()\n\n end", "def eof?\n @read >= @size\n end", "def eof_flag\n @eof_flag\n end", "def readable_after_eof?\n false\n end", "def readable_after_eof?\n false\n end", "def next_contents\n content.to_a.compact\n end", "def process_new_line\n @status.line += 1\n\n @skip_next = true if ((@cur_char == \"\\n\" && @next_char == \"\\r\") ||\n (@cur_char == \"\\r\" && @next_char == \"\\n\"))\n end", "def next\n return callcc { |@ret| parse_doc } unless @parse_started\n # set up a return continuation which will be called when something\n # was parsed successfully\n return callcc { |@ret| @cc.call } if @cc\n nil\n end", "def get_next_list_entry!\n begin \n # Read out every line of list file\n # into an array\n full_file = []\n File.open(@list_file, 'r') do |file|\n while _line = file.gets\n unless _line == '' || _line.start_with?('#')\n full_file << _line.sub(/\\n/, '')\n end\n end\n end\n # If the array is not empty, shift the first\n # entry into an output variable and save the\n # shifted array in the file by overwriting.\n # Then, return the output variable\n if !full_file.empty?\n _out = full_file.shift.split('|')\n File.open(@list_file, 'w') do |file|\n full_file.each { |ln| \n file.puts ln \n }\n end\n return _out\n end\n return nil\n rescue Exception => e\n puts \"[FATAL ERROR] in 'DavidGetter#get_next_list_entry': #{e}\"\n exit\n end\n end", "def eof?\n @io.closed? || @io.eof?\n end", "def eof?\n peek_lit(nil).nil?\n end", "def prim_eof?\n false\n end", "def eof?\n not busy?\n end", "def next_file\n @current_file_index += 1\n\n if @current_file_index >= @files.length\n @current_file = @files.first\n @current_file_index = 0\n else\n @current_file = @files[@current_file_index]\n end\n\n @data = load_file(@current_file)\n end" ]
[ "0.7868099", "0.7150931", "0.682799", "0.681046", "0.68097353", "0.6637963", "0.65654916", "0.65270114", "0.6520292", "0.64652425", "0.6426724", "0.6370842", "0.63353896", "0.631827", "0.6264957", "0.6264957", "0.6264957", "0.6236848", "0.62321657", "0.62224424", "0.62224424", "0.62224424", "0.6187771", "0.6120514", "0.61166394", "0.6113407", "0.6074142", "0.60711545", "0.6065905", "0.60351896", "0.6032176", "0.6032176", "0.6032176", "0.6032176", "0.6032176", "0.6022467", "0.5987902", "0.59853166", "0.59853166", "0.59853166", "0.5979801", "0.5968543", "0.59653634", "0.59647197", "0.594676", "0.5931477", "0.59126014", "0.5908356", "0.5900663", "0.5900663", "0.5888833", "0.58836025", "0.58836025", "0.58836025", "0.5875144", "0.58714896", "0.58714896", "0.58714896", "0.5854831", "0.5850563", "0.58303225", "0.58289117", "0.58256537", "0.58252424", "0.58122194", "0.581209", "0.581209", "0.581209", "0.5807444", "0.5806115", "0.5796857", "0.5773989", "0.57504505", "0.5749286", "0.57419026", "0.57063484", "0.5703913", "0.57017756", "0.5693201", "0.56866693", "0.56807613", "0.56673276", "0.56663346", "0.5661366", "0.56489056", "0.56477714", "0.56387866", "0.562326", "0.5619001", "0.56029385", "0.56029385", "0.5587246", "0.5578363", "0.5574691", "0.55729836", "0.552556", "0.55126244", "0.55081123", "0.55038947", "0.55010104" ]
0.67533886
5
load the lines from the file, remove comments, blank lines, whitespace, set the ivar
def load_lines file lines = Array.new lines = @file.split("\n") #fuck that, i dont like the dyanmic feed, just pre-parse it lines.map! do |line| #map overwrites the old array if line.include? '#' split = line.split '#' #puts split.to_s split.shift else line end end #removing blank lines lines.delete_if do |line| true if line.empty? end lines.each { |line| line.chomp! } lines end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load\n @lines.select! do |line|\n line.strip.length != 0\n end.select! do |line|\n line[0] != '#'\n end.map! do |line|\n line.split(\" \")\n end\n\n self\n end", "def load_data\n self.open if @io.nil?\n @lines = @io.readlines\n @io.rewind\n @lines.delete_if {|line| line.match(/^\\s*$/)}\n @num_lines = @lines.count\n end", "def refresh!\n @lines = load_from_file\n end", "def to_set\n @lines ||= load_from_file\n end", "def line_maker\n @lines = File.readlines(path, chomp: true)\n end", "def load(fn) # :nodoc:\n lines = File.read fn\n lines.gsub!(/\\\\ /, SPACE_MARK)\n lines.gsub!(/#[^\\n]*\\n/m, \"\")\n lines.gsub!(/\\\\\\n/, \" \")\n lines.each_line do |line|\n process_line(line)\n end\n end", "def clean_lines\n lines = @file_content.split(\"\\r\").select { |line| !line.match(/$\\s*#/)} unless @file_content.nil?\n end", "def parse_file!\n File.open(@filepath, 'r') do |f|\n last_line = ''\n while this_line = f.gets\n coll = case this_line\n when /^\\s*def / : @methods\n when /^\\s*class / : @classes\n when /^\\s*module / : @modules\n when /^\\s*(attr_reader|attr_accessor|attr_writer) / : @attrs\n when /^\\s*[^a-z =]+\\s*=/ : @constants\n else nil\n end\n # add a true entry if comment precedes declaration or follows on same line\n coll << is_comment?(last_line) || has_comment?(this_line) if coll\n last_line = this_line\n end\n end\n end", "def read\n x = nil\n File.open(@filename, 'r') {|f| x = f.readlines }\n x.each do |line|\n\n line = self.class.remove_comments(line)\n\n if line.present?\n @data << self.class.extract_data_from_line(line)\n # puts self.class.extract_data_from_line(line).to_yaml\n end\n end\n end", "def restore()\n @inihash = Ini.read_from_file(@path)\n @comment = Ini.read_comment_from_file(@path)\n end", "def parse_file\n line_count = 0\n @text.each_line do |line|\n if line == nil || line == '' || line.size == 0 || line[0] == '#' || line[0] == \"\\n\"\n next\n end\n elements = line.split(' ')\n if elements.size > 2\n puts 'Waring : '.red + 'in file \"' + @file_name.yellow + '\" ignoring line ' + line_count.to_s.yellow + ' ( it has more than one space and is not a comment )'\n else\n if elements.size == 1\n @ret << Manga_data.new(nil, nil, nil, elements[0], nil)\n else\n @ret << Manga_data.new(nil, elements[0], elements[1], nil, nil)\n end\n end\n line_count += 1\n end\n end", "def parse_file\n filename = full_path_from_edict_file(@config[\"filename\"])\n ### Get all the line into memory\n file_obj = File.new(filename, \"r\")\n file_obj.each do |line|\n @added_lines.push line\n end\n end", "def load_data\n @data=[]\n marker_found=false\n @file.rewind\n @file.each_line do |line|\n if !marker_found && @sentinel.call(line) then\n marker_found=true\n end\n\n @data << line if marker_found\n end\n end", "def load(fn)\n return if ! File.exists?(fn)\n lines = File.read fn\n lines.gsub!(/\\\\ /, SPACE_MARK)\n lines.gsub!(/#[^\\n]*\\n/m, \"\")\n lines.gsub!(/\\\\\\n/, ' ')\n lines.each_line do |line|\n process_line(line)\n end\n end", "def initialize(file_path)\n @filepath = file_path\n @lines = []\n @empty = true\n @error = false\n @description = \"none\"\n @format = \"unknown\"\n @rows = []\n end", "def space_file_parser\n @space_names = File.open(\"text_files/space.txt\").readlines.each do |line|\n if line.include?(\"\\n\")\n line.gsub!(/\\n/, '')\n else\n line\n end\n end\nend", "def potential_lines(filename); end", "def modified_lines_in_file(_file)\n EMPTY_SET\n end", "def initial_load_range( line_a=1, line_b=-1 )\n\t\t@lines = []\n\t\tline_number = 0\n\t\tf = @data_source\n\t\tf.each do |line|\n\t\t\tline_number += 1\n\t\t\tnext unless line_number >= line_a\n\t\t\t@lines << Line.new(line_number, line.chomp )\n\t\t\tbreak if line_b != -1 && line_number >= line_b\n\t\tend\n\t\tf.close if f.is_a? File\n\t\t@lines\n\tend", "def initialize(file)\n @file = file\n @properties = {}\n IO.foreach(file) do |line|\n # skip the commented lines\n next if line =~ /^\\s*?#/\n @properties[$1.strip] = $2 if line =~ /([^=]*)=(.*)\\/\\/(.*)/ || line =~ /([^=]*)=(.*)/\n end\n end", "def parse\n self.data = BdlFile.strip_comments self.data\n save!\n tokenize\n Instruction.create_references!\n end", "def load_file_data(file)\n @data = separate_into_blocks(IO.readlines(file))\n end", "def initialize(lines, options = {})\n if lines.is_a?(String)\n lines = lines.split(\"\\n\")\n end\n self.meta = {}\n in_meta = true\n while in_meta and line = lines.shift do\n line.strip!\n matches = line.match /^([^:]+):\\s+(.+)/\n if matches\n if matches[1] =~ /(Chapter|Number|Position)/i and matches[2] =~ /\\d+/ and number.nil?\n self.number = matches[2].strip.to_i\n end\n self.meta[matches[1].downcase.to_sym] = matches[2]\n else\n lines = [line] + lines if line\n in_meta = false \n end\n end\n self.meta.merge!(options)\n self.file_name = self.meta[:file_name]\n self.content = lines.join\n end", "def lines\n File\n .read(@source_path)\n .lines\n .map(&:chomp)\n .reject { |line| line.strip.empty? || line.match(Tokens::COMMENT_MATCHER) }\n end", "def initialize(filename)\n file = File.open(filename, \"r\")\n self.data = file.read\n file.close\n\n # inicializacia atributov\n self.skip_spaces = true\n self.errors = []\n self.line = [0]\n self.length = data.length\n self.position = self.last_position = 0\n\n # zoznam terminalov a operatorov\n self.terminals = [\n 'BEGIN',\n 'END',\n ':=',\n ';',\n '(',\n ')',\n 'WRITE',\n 'READ',\n 'IF',\n 'THEN',\n 'ELSE',\n 'IDENT',\n '+',\n '-',\n 'NOT',\n 'AND',\n 'OR',\n 'TRUE',\n 'FALSE',\n ','\n ]\n\n end", "def lines\n load_data unless @lines\n @lines\n end", "def line_processor\n open(\"tmp/insert_YourFileName_lines.txt\") do |f|\n f.each do |line| \n unless line =~ /^$/\n puts line.to_s.to_textual\n end\n end\n end\n \nend", "def initialize file\n @file = file\n @properties = {}\n# IO.foreach(file) do |line|\n# @properties[$1.strip] = $2 if line =~ /([^=]*)=(.*)\\/\\/(.*)/ || line =~ /([^=]*)=(.*)/\n# @properties[$1.strip] = $2 if line =~ /([^=]*)=(.*)\\/\\/(.*)/ || line =~ /([^=]*)=(.*)/\n# end\nFile.open(file, 'r') do |properties_file|\n properties_file.read.each_line do |line|\n line.strip!\n if (line[0] != ?# and line[0] != ?=)\n i = line.index('=')\n if (i)\n @properties[line[0..i - 1].strip] = line[i + 1..-1].strip\n else\n @properties[line] = ''\n end\n end\n end\n end\nend", "def initialize(lines)\n @lines = lines\n end", "def initialize(filename)\n @name = ''\n @desc = ''\n @diagram = ''\n \n file = File.open(filename)\n \n while(line = file.gets)\n line.chomp!\n if(line == 'NAME')\n @name = file.gets.chomp!\n elsif(line == 'DESC')\n while((line = file.gets) && line != \"END\\n\")\n @desc += line\n end\n elsif(line == 'DIAGRAM')\n while((line = file.gets) && line != \"END\\n\")\n @diagram += line\n end \n end\n end\n file.close()\n end", "def import_config_content_from_file\n open(self.config_file) {|f| f.each_with_index do |line, i|\n\n line.strip!\n\n # force_encoding not available in all versions of ruby\n begin\n if i.eql? 0 and line.include?(\"\\xef\\xbb\\xbf\".force_encoding(\"UTF-8\"))\n line.delete!(\"\\xef\\xbb\\xbf\".force_encoding(\"UTF-8\"))\n end\n rescue NoMethodError\n end\n\n # validate if line is comment or not\n is_comment = false\n @comments.each do |comment|\n if (/^#{comment}/.match(line))\n is_comment = true\n break\n end\n end\n\n unless is_comment\n if(/#{@splitRegex}/.match(line))\n param, value = line.split(/#{@splitRegex}/, 2)\n var_name = \"#{param}\".chomp.strip\n\n # just in case value has trailing comments\n value = value.split('#').first.chomp.strip\n\n new_value = ''\n if (value)\n if value =~ /^['\"](.*)['\"]$/\n new_value = $1\n else\n new_value = value\n end\n end\n self.params[var_name] = new_value\n end\n end\n end}\n end", "def parsed_lines\n eval(file_lines)\n end", "def pbCompilerEachPreppedLine(filename)\r\n File.open(filename,\"rb\") { |f|\r\n FileLineData.file = filename\r\n lineno = 1\r\n f.each_line { |line|\r\n if lineno==1 && line[0].ord==0xEF && line[1].ord==0xBB && line[2].ord==0xBF\r\n line = line[3,line.length-3]\r\n end\r\n line.force_encoding(Encoding::UTF_8)\r\n line = prepline(line)\r\n if !line[/^\\#/] && !line[/^\\s*$/]\r\n FileLineData.setLine(line,lineno)\r\n yield line, lineno\r\n end\r\n lineno += 1\r\n }\r\n }\r\n end", "def load_raw_line opts = OPTS_REGEX.keys\n self.raw_line.chomp!\n opts.each do |xfield|\n pattern = OPTS_REGEX[xfield]\n did_set = raw_setter xfield, pattern\n #puts did_set\n end\n end", "def initialize(file)\n @lines = []\n command_file = File.open(file)\n command_file.each_line{|x| @lines.push(x.chomp)}\n command_file.close\n process_command_file.g\n end", "def initialize(confileinstance)\n\n #Duck typing check :)\n return unless confileinstance.instance_of?(File)\n \n #An Array based DS maintaining Keywords list\n @words_list=Array.new \n\n #A DS maintaining list of String which mark the beginning of single line comment in the programming language\n @single_line=Array.new\n \n #A DS maintaining pair of symbols as Hash which mark the beginning and end of multi line comment in the programming language\n @multi_line=Hash.new\n\n #boolean value to check if we are in the comment section of the conf file yet\n in_comment_section=false\n #boolean to check if we are in multicomment block\n in_multi_comment_section=false\n\n #Reading the file line by line\n confileinstance.each do |line|\n \n #Remove trailing newlines\n line.chomp!\n\n #Check if Essay type, if yes then we dont need to go through all the pain of parsing all the parameters\n break if line==\"Essay:\" \n\n #Skip the line which says 'Keywords:'\n next if line=='Keywords:'\n\n line_split=line.split(\" \")\n if line_split[0]==\"NoIdentifier:\"\n in_comment_section=true\n @no_identifiers=line_split[1...line_split.length]\n end\n\n #Once we encounter the line 'Comments:' we know we are in comments block\n if line=='Comments:'\n in_comment_section=true\n next\n end\n\n if line=='Multi:'\n in_multi_comment_section=true\n next\n end\n\n #Add the words as kewords if not in comment block\n @words_list.push(line) if in_comment_section==false \n \n #Add the comment demarkator to single_line DS \n @single_line.push(line) if in_comment_section==true && in_multi_comment_section==false \n\n #Add the comment demarkator to multi_line DS if in_multi_comment_section? is true\n #The two adjancent indexes will contain the begin and end demarkator\n if in_multi_comment_section==true then\n comment_starter=line.split\n @multi_line[comment_starter[0]]=[comment_starter[1]]\n end\n end\n \n confileinstance.close\n \n end", "def load_source!\n @source = load_file_contents\n end", "def fromFile( filename ) \n lines = IO.readlines( filename )\n loadAll( lines )\n end", "def import\n fragments.each(&:destroy)\n File.open(bin_file_name, \"rb\") do |f|\n order = 0\n new_lines = 0\n until f.eof?\n new_lines += import_next_object(f, order)\n order += 1\n end\n update! lines: new_lines\n end\n add_locations\n end", "def pbCompilerEachCommentedLine(filename)\r\n File.open(filename,\"rb\") { |f|\r\n FileLineData.file = filename\r\n lineno = 1\r\n f.each_line { |line|\r\n if lineno==1 && line[0].ord==0xEF && line[1].ord==0xBB && line[2].ord==0xBF\r\n line = line[3,line.length-3]\r\n end\r\n line.force_encoding(Encoding::UTF_8)\r\n if !line[/^\\#/] && !line[/^\\s*$/]\r\n FileLineData.setLine(line,lineno)\r\n yield line, lineno\r\n end\r\n lineno += 1\r\n }\r\n }\r\n end", "def initialize(source)\n self.source = source\n self.fields = []\n self.lines = []\n self.parse!\n end", "def load_from(file)\n open(file) do |io|\n io.each do |line|\n line.strip!\n next if line.empty? || /^#/ === line\n register *line.split(/\\s+/)\n end\n end\n true\n end", "def read_source(source_file)\n @source_lines = source_file.readlines()\n end", "def readFile\r\n\t\tfile = File.open(fileName, \"r\")\r\n\r\n\t\t#Array for partial matches\t\t\r\n\t\t@dictionary = Array.new\r\n\t\tfile.each do |line|\r\n\t\t\tif line != \"\\n\"\r\n\t\t\t\t@dictionary << line.split(/[:;\\n]/)\r\n\t\t\tend\r\n\t\tend\r\n\t\tstartStrategies\r\n\tend", "def missed_lines; end", "def missed_lines; end", "def initialize(file_name)\n\t\tPDF::Reader.open(file_name) do |reader|\n\t\t\tfull_content = \"\"\n\t\t\treader.pages.each do |page|\n\t\t\t\tfull_content = full_content + page.text\n\t\t\tend\n\n\t\t\t# Essa variável guarda um array com as linhas do arquivo\n\t\t\t@all_lines = full_content.lines\n\t\t\t\n\t\t\t# Removemos as linhas vazias\n\t\t\t@all_lines = @all_lines.delete_if { | line | \n\t\t\t\tline.strip.empty?\n\t\t\t}\n\t\tend\n\tend", "def initialize(*lines)\n @lines = normalised_lines(lines)\n end", "def source_lines; end", "def source_lines; end", "def source_lines; end", "def source_lines; end", "def remove_line_references(name, file)\n source = IO.readlines name\n source.reject! { |line| line =~ /^#line\\s(\\d+)\\s\"[^\"]+\"/ }\n File.open(name, \"w\") { |f| f.puts source }\nend", "def initialize(object, file)\n @file = file\n\n @source = PuppetStrings::Yard::Util.ast_to_text(object)\n @line = object.line\n @comments_range = nil\n end", "def load(filename)\n @filename = filename.to_s\n mode = :in_header\n IO.readlines(@filename).each do |line|\n case mode\n when :in_header\n if line =~ %r{^\\s*gem\\.}\n mode = :in_dev_body\n case line\n when %r{^\\s*gem\\.add_development_dependency}\n @dev_dependencies << line\n when %r{^\\s*gem\\.add_dependency}\n @gem_dependencies << line\n else\n @body << line\n end\n else\n @header << line\n end\n when :in_dev_body\n if line =~ %r{^\\s*end}\n mode = :in_footer\n @footer << line\n else\n case line\n when %r{^\\s*gem\\.add_development_dependency}\n @dev_dependencies << line\n when %r{^\\s*gem\\.add_dependency}\n @gem_dependencies << line\n else\n @body << line\n end\n end\n when :in_footer\n @footer << line\n end\n end\n end", "def parse_file\n @file ||= File.open(@file_name) unless @file_name.nil?\n @text = @file.readlines\n @file.close unless @file.nil?\n parse_text\n end", "def load_rewind_batch_lines\n @options = @text.rewind_batch.to_braille.lines.map { |l| l.to_text }\n @line_index = @options.size\n end", "def initialize(path)\n @path = path\n @file_lines = File.new(path).readlines\n\n split_out_lines\n end", "def read_auto_clean_up; end", "def from_file line\n\t\tvals = line.split(\"-\")\n\t\t@type = vals[0].to_i\n\t\t@obj = vals[1]\n\t\tif vals[2] != nil\n\t\t\t@sensor = vals[2]\n\t\tend\n\t\tif vals[3] != nil\n\t\t\t@value = vals[3].to_f\n\t\tend\n\tend", "def clean_comments(file)\n @in_file = file.readlines\n @in_file.delete_if{|index| index.match(/^[\\/]{2}/) }\n end", "def load_file(file)\n\n CachedFile.reset_seq\n\n cfile = nil\n File.foreach(file) do |line|\n next if line.empty?\n next if line[0] == ?#\n\n line.chomp!\n if line[0] == ?/\n cfile = CachedFile.new line\n next unless File.exist?(line) # sorry for the creat and abandon fuss\n cfile.init_attrs\n @cfile_by_name[cfile.file] = cfile if @@fstab[cfile.dev]\n elsif line =~ /^\\d+\\s+\\d+/\n idx, len = line.split\n cfile.add_page_range idx.to_i, len.to_i\n end\n\n end # File.foreach\n self\n end", "def populate_memory\n File.foreach(@file_name) do |line|\n @memory[@memory_counter] = line.chomp\n @memory_counter += 1\n\n @done = true if @memory_counter > 255\n end\n end", "def loadAll( lines )\n self.reset()\n mode = true\n lines.each{\n |line|\n if line =~ / *mode *= *([a-zA-Z]+) */ then\n if $1 != 'include' and $1 != 'exclude' then\n raise \"CRM114 mode non 'exclude' or 'include' was |#{$1}\"\n end\n mode = $1 == 'include'\n else\n line.strip!\n puts \"CRM114.loadAll; adding |#{line}| as regexp\\n\"\n @regexps << Regexp.new( '^'+line+'$', Regexp::IGNORECASE )\n @modes << mode\n end\n }\n end", "def parse_blank_line; end", "def consume_lines(lines)\n log \"Removing commented lines and sorting mentions\"\n\n statements = []\n mentions = []\n lines.each do |l|\n next if l.start_with?('#') # Remove commented lines\n next if l.include?('RT') || l.include?('MT') # Remove soft retweets\n\n if l[0]==('@') || l.match(/\\s@/)\n mentions << NLP.normalize(l)\n else\n statements << NLP.normalize(l)\n end\n end\n\n text = statements.join(\"\\n\").encode('UTF-8', :invalid => :replace)\n mention_text = mentions.join(\"\\n\").encode('UTF-8', :invalid => :replace)\n\n lines = nil; statements = nil; mentions = nil # Allow garbage collection\n\n log \"Tokenizing #{text.count('\\n')} statements and #{mention_text.count('\\n')} mentions\"\n\n mass_tikify(text, @smodel)\n mass_tikify(mention_text, @mmodel)\n\n @keywords.import(NLP.keywords(text).top(2000).map(&:to_s))\n log \"Top keywords: #{@keywords[0]} #{@keywords[1]} #{@keywords[2]}\"\n\n self\n end", "def construct\n @total_num_lines = File.readlines(@path).size\n tmp = {}\n prev = ''\n (@min..@total_num_lines).each { |i|\n if i > @max then\n tmp[i] = @lines[@max]\n else\n if !lines[i].nil? then\n tmp[i] = lines[i]\n prev = lines[i]\n else \n tmp[i] = prev\n end\n end\n }\n @lines = tmp\n end", "def comma_file_parser\n @comma_names = File.open(\"text_files/comma.txt\").readlines.each do |line|\n if line.include?(\"\\n\") # removes '\\n' (line breaker)\n line.gsub!(/\\n/, '')\n else\n line\n end\n end\nend", "def initialize(file)\n @file = file\n @properties = {}\n File.open(file).each_line do |line|\n @properties[Regexp.last_match(1).strip] = Regexp.last_match(2) if line =~ %r{([^=]*)=(.*)//(.*)} || line =~ /([^=]*)=(.*)/\n end\n end", "def line_cache; end", "def parse filename\n clear\n File.open filename do |f|\n f.each_line &method(:parse_line)\n end\n self\n end", "def initialize\n @emit_file_line_as_literals = true\n end", "def initialize\r\n\t\ttext = read_file\r\n\t\t@colors_hash = parse_data( text )\r\n\tend", "def load_entries\n @lines = IO.readlines(@filename)\n @lines.each_with_index do |line,idx|\n if entry_klass.is_entry?(line) then\n entry = entry_klass.from_line(line)\n v = { 'entry' => entry, 'line_index' => idx }\n @entries[entry.key] = v\n end\n end\n end", "def initialize(file)\n @name = PropertyName.new.read(file).name.val[0...-1]\n if @name != 'None'\n @data = strip_data(PropertyData.new.read(file), file)\n else\n @data = 'None'\n end\n end", "def read_txt\n # Open TXT file\n # f = File.open(self.fichero, \"r\")\n # Use TXT file content\n f = self.fichero\n # Loop thru open file lines\n f.each_line do |line|\n cod_reg = line[0,2]\n if cod_reg == '80'\n # Totals line\n amount = line[36,12]\n self.total_bills = line[22,6].to_i\n self.total_amount = (amount[0,10] + '.' + amount[10,2]).to_d\n elsif cod_reg == '02'\n # Header line\n pdate = line[36,6]\n self.nif = line[10,8]\n self.sufijo = line[18,3]\n self.process_date_time = Date.parse(pdate[4,2] + pdate[2,2] + pdate[0,2]) rescue Date.today\n elsif cod_reg == '01' || cod_reg == '90'\n # First or Last line\n else\n # Invoice charged line: Save in array\n amount = line[36,12]\n self.lista_cobros.push(bill_id: line[76,11].to_i,\n amount: (amount[0,10] + '.' + amount[10,2]).to_d,\n date: line[30,6],\n issuer: line[10,8],\n suffix: line[18,3],\n charge_code: line[21,1],\n charge_bank: line[22,4],\n charge_office: line[26,4],\n charge_id: line[48,6],\n iban_head: line[4,4],\n ccc_bank: line[54,4],\n ccc_office: line[58,4],\n ccc_dc: line[62,2],\n ccc_account_no: line[64,10],\n debit_code: line[74,1],\n cancel_code: line[75,1],\n reference: line[76,13])\n end\n end # f.each_line\n # f.close\n end", "def import_initial_lines(type)\n @initial_lines.each do |initial_line|\n import_lines(type, initial_line[:file_name]) unless (initial_line[:type] != type ||\n initial_line[:file_name].nil?)\n end\n @initial_lines.delete_if do |il|\n il.has_key?(:file_name) && il[:type] == type\n end # Remove all imported lines\n end", "def reset\n @line_no, @last_lexeme = 0, [\"\\n\"]\n super\n end", "def load_from_file\n lines = SortedSet.new\n \n @log.lines.each_with_index do |line, number|\n lines << Line.new(line, number, options)\n end\n\n lines\n end", "def strip_comments\n in_str = false\n @src_lines.each do |line|\n pos = line.each_char.with_index do |ch,i|\n if ch == '\"'\n if in_str\n in_str = false\n else\n in_str = true\n end\n end\n \n if ch == \";\" && !in_str\n break i\n end\n \n end\n \n if pos.class == Fixnum\n #strip them to the end of the file\n line.slice!(pos..-1)\n end\n \n end\n end", "def parse_file!(input_file)\r\n File.open(input_file, \"rb:UTF-8\").each(LOCSTR_END_OF_LINE + \"\\n\") do |line|\r\n strings << line.chomp(LOCSTR_END_OF_LINE + \"\\n\") + \"\\x00\"\r\n end\r\n\r\n @number_of_strings = @strings.size\r\n @offset_to_strings = 8 + 8 * @number_of_strings\r\n end", "def parse_file\n @filecontent ||= File.read(@filepath)\n end", "def initialize file_path\n\t\traise ArgumentError if file_path.nil? or not File.exist?(file_path)\n\n\t\t# Read the file as an array of strings (each line is an entry in the array) and remove unneeded whitespace\n\t\t@grammar_string = File.readlines(file_path).map { |x| x.strip }\n\t\t@production_rules = {}\n\n\t\t#a variable for the marker we use in LR parsing\n\t\t@marker = \".\"\n\n\t\tparse_grammar\n\tend", "def initialize(data = [], attributes = {}, &block)\n raw_source = []\n @attributes = attributes\n @references = {}\n\n data = data.split(\"\\n\") if data.is_a? String\n\n include_regexp = /^include::([^\\[]+)\\[\\]\\s*\\n?\\z/\n\n data.each do |line|\n if inc = line.match(include_regexp)\n if block_given?\n raw_source << yield(inc[1])\n else\n raw_source.concat(File.readlines(inc[1]))\n end\n else\n raw_source << line\n end\n end\n\n ifdef_regexp = /^(ifdef|ifndef)::([^\\[]+)\\[\\]/\n endif_regexp = /^endif::/\n defattr_regexp = /^:([^:!]+):\\s*(.*)\\s*$/\n delete_attr_regexp = /^:([^:]+)!:\\s*$/\n conditional_regexp = /^\\s*\\{([^\\?]+)\\?\\s*([^\\}]+)\\s*\\}/\n\n skip_to = nil\n continuing_value = nil\n continuing_key = nil\n @lines = []\n raw_source.each do |line|\n if skip_to\n skip_to = nil if line.match(skip_to)\n elsif continuing_value\n close_continue = false\n # Lines that start with whitespace and end with a '+' are\n # a continuation, so gobble them up into `value`\n if match = line.match(/\\s+(.+)\\s+\\+\\s*$/)\n continuing_value += ' ' + match[1]\n elsif match = line.match(/\\s+(.+)/)\n # If this continued line doesn't end with a +, then this\n # is the end of the continuation, no matter what the next\n # line does.\n continuing_value += ' ' + match[1]\n close_continue = true\n else\n # If this line doesn't start with whitespace, then it's\n # not a valid continuation line, so push it back for processing\n close_continue = true\n raw_source.unshift(line)\n end\n if close_continue\n @attributes[continuing_key] = continuing_value\n continuing_key = nil\n continuing_value = nil\n end\n elsif match = line.match(ifdef_regexp)\n attr = match[2]\n skip = case match[1]\n when 'ifdef'; !@attributes.has_key?(attr)\n when 'ifndef'; @attributes.has_key?(attr)\n end\n skip_to = /^endif::#{attr}\\[\\]\\s*\\n/ if skip\n elsif match = line.match(defattr_regexp)\n key = sanitize_attribute_name(match[1])\n value = match[2]\n if match = value.match(Asciidoctor::REGEXP[:attr_continue])\n # attribute value continuation line; grab lines until we run out\n # of continuation lines\n continuing_key = key\n continuing_value = match[1] # strip off the spaces and +\n Asciidoctor.debug \"continuing key: #{continuing_key} with partial value: '#{continuing_value}'\"\n else\n @attributes[key] = value\n Asciidoctor.debug \"Defines[#{key}] is '#{value}'\"\n end\n elsif match = line.match(delete_attr_regexp)\n key = sanitize_attribute_name(match[1])\n @attributes.delete(key)\n elsif !line.match(endif_regexp)\n while match = line.match(conditional_regexp)\n value = @attributes.has_key?(match[1]) ? match[2] : ''\n line.sub!(conditional_regexp, value)\n end\n # leave line comments in as they play a role in flow (such as a list divider)\n @lines << line\n end\n end\n\n # Process bibliography references, so they're available when text\n # before the reference is being rendered.\n @lines.each do |line|\n if biblio = line.match(REGEXP[:biblio])\n @references[biblio[1]] = \"[#{biblio[1]}]\"\n end\n end\n\n #Asciidoctor.debug \"About to leave Reader#init, and references is #{@references.inspect}\"\n @source = @lines.join\n Asciidoctor.debug \"Leaving Reader#init, and I have #{@lines.count} lines\"\n Asciidoctor.debug \"Also, has_lines? is #{self.has_lines?}\"\n end", "def local_lines\n strip.split(/\\n+/)\n end", "def clean_up()\n @lines.each { |line| line.delete!(' ') }\n @lines.delete_if { |line| line.start_with?(\"//\") }\n @lines.each { | line| line.chomp! }\n @lines.delete_if { |line| line.empty? }\n @lines = @lines.map { |line| line.split(\"//\")[0] }\n end", "def lines(source); end", "def source_line=(_); end", "def consume_lines(lines)\n log \"Removing commented lines\"\n\n statements = []\n lines.each do |l|\n next if l.start_with?(\"#\") # Remove commented lines\n statements << NLP.normalize(l)\n end\n\n text = statements.join(\"\\n\").encode(\"UTF-8\", :invalid => :replace)\n lines = nil; statements = nil # Allow garbage collection\n\n log \"Tokenizing #{text.count(\"\\n\")} statements\"\n\n @sentences = mass_tikify(text)\n\n log \"Ranking keywords\"\n @keywords = NLP.keywords(text).top(200).map(&:to_s)\n log \"Top keywords: #{@keywords[0]} #{@keywords[1]} #{@keywords[2]}\"\n\n self\n end", "def populate(file)\n words = file.split(\"\\n\")\n insert_words(words)\n end", "def initialize(file_content)\n # Set TXT file\n self.fichero = file_content\n # Initialize attribute default values\n self.lista_cobros = []\n end", "def line=(_); end", "def line=(_); end", "def read_file\n\t\tif @filename == \"\"\n\t\t\t@text = [\"\"]\n\t\t\treturn\n\t\telse\n\t\t\tif File.exists? @filename\n\t\t\t\ttext = IO.read(@filename)\n\t\t\telse\n\t\t\t\t@text = [\"\"]\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t\t# get rid of crlf\n\t\ttemp = text.gsub!(/\\r\\n/,\"\\n\")\n\t\tif temp == nil\n\t\t\t@eol = \"\\n\"\n\t\telse\n\t\t\t@eol = \"\\r\\n\"\n\t\tend\n\t\ttext.gsub!(/\\r/,\"\\n\")\n\t\t@text = text.split(\"\\n\",-1)\n\tend", "def initialize(lines, parser_options={ })\n if lines.is_a? Array then\n @lines = lines\n elsif lines.is_a? String then\n @lines = lines.split(\"\\n\")\n else\n raise \"Unsupported type for +lines+: #{lines.class}\"\n end\n\n @custom_keywords = []\n @headlines = Array.new\n @current_headline = nil\n @header_lines = []\n @in_buffer_settings = { }\n @options = { }\n @link_abbrevs = { }\n @parser_options = parser_options\n\n #\n # Include file feature disabled by default since \n # it would be dangerous in some environments\n #\n # http://orgmode.org/manual/Include-files.html\n #\n # It will be activated by one of the following:\n #\n # - setting an ORG_RUBY_ENABLE_INCLUDE_FILES env variable to 'true'\n # - setting an ORG_RUBY_INCLUDE_ROOT env variable with the root path\n # - explicitly enabling it by passing it as an option:\n # e.g. Orgmode::Parser.new(org_text, { :allow_include_files => true })\n #\n # IMPORTANT: To avoid the feature altogether, it can be _explicitly disabled_ as follows:\n # e.g. Orgmode::Parser.new(org_text, { :allow_include_files => false })\n #\n if @parser_options[:allow_include_files].nil?\n if ENV['ORG_RUBY_ENABLE_INCLUDE_FILES'] == 'true' \\\n or not ENV['ORG_RUBY_INCLUDE_ROOT'].nil?\n @parser_options[:allow_include_files] = true\n end\n end\n\n @parser_options[:offset] ||= 0\n\n parse_lines @lines\n end", "def parse\n @_current_section = nil\n @_current_param = nil\n @_current_value = nil\n\n @contents.split(\"\\n\").each do |line|\n line = line.chomp\n\n # we ignore comment lines and blank lines\n if line =~ @rgxp_comment\n finish_property\n next\n end\n\n # place values in the current section\n if line =~ @rgxp_section\n finish_property\n @_current_section = @ini[$1.strip]\n next\n end\n\n parse_property line\n\n end # while\n\n finish_property\n ensure\n @_current_section = nil\n @_current_param = nil\n @_current_value = nil\n end", "def loadConfigs()\n fh = File.open(@fileName_vars, \"r\")\n\n fh.each do |line| \n line.gsub!(/[\\s]/, '') # removes white spaces \n\n if(!(/^\\#/.match(line)) && /:/.match(line)) # only considers lines not begining with #\n line.sub!(/\\#.*$/, '') # removes all trailing comments\n line.upcase!\n arr_configs = line.split(/:/)\n case arr_configs[0] \n when FOLDER_DATA\n @folder_data = arr_configs[1]\n when FOLDER_DB\n @folder_db = arr_configs[1]\n when FOLDER_BLASTRES\n @folder_blastRes = arr_configs[1]\n when FOLDER_FINALRES\n @folder_finalRes = arr_configs[1]\n end \n #puts arr[0] + \"\\t\" + arr[1]\n #puts line\n end \n\n end \n\n fh.close\n end", "def load_weather_file(filepath)\n raise ArgumentError, 'path must not be empty' if filepath.empty?\n raise IOError, 'file does not exist' if !File.file?(filepath)\n \n # Initializes content to whatever lines there is in the file.\n content = File.readlines(filepath)\n # Delete two first lines.\n content.delete_at(0)\n content.delete_at(0)\n\n return content\nend", "def initialize(filename)\n @filename = filename\n @source_raw = File.read(filename)\n @source_raw.gsub!(/(?<!\\n)\\n(?!\\n)/, \" \") # strip out hard LFs at end of lines\n \n #create_word_distribution_array\n\n# @source_phrases = source_raw.split(/(?<=[?.!])/) # *** use individual phrases\n @source_phrases = source_raw.split(/\\n\\n/) # *** use paragraphs\n @phrase_length_array = []\n @pla_index = -1\n build_length_array(@source_phrases, @phrase_length_array)\n# dump_structure\n end", "def load1\nf = File.read(@filename)\nf.each_line do |line|\nif line.match('#undone')\n@pending << line\nelse\n@completed << line\nend\nend\nreturn @pending\nend" ]
[ "0.764171", "0.6941673", "0.6830841", "0.6649386", "0.65957516", "0.6537128", "0.6452292", "0.6394172", "0.63447845", "0.6273264", "0.6243285", "0.62396884", "0.62376386", "0.6186814", "0.6100277", "0.6082232", "0.6042146", "0.6033296", "0.5975077", "0.5934803", "0.5925693", "0.5897399", "0.58803064", "0.58516693", "0.5838658", "0.58332014", "0.5829992", "0.58234084", "0.5815625", "0.5809924", "0.58003366", "0.5773223", "0.5766347", "0.5759568", "0.574506", "0.5715419", "0.5709483", "0.57055014", "0.56992924", "0.5695753", "0.56947064", "0.5686779", "0.56779504", "0.567347", "0.56589216", "0.56589216", "0.56459975", "0.5629092", "0.5620809", "0.5620809", "0.5620809", "0.5620809", "0.5614875", "0.5613476", "0.5613261", "0.5608512", "0.55804294", "0.55742776", "0.55736774", "0.5569086", "0.55621696", "0.5561828", "0.55605996", "0.55388063", "0.5534599", "0.5526124", "0.551814", "0.5513325", "0.5512819", "0.5511035", "0.55081743", "0.55023044", "0.5491767", "0.5490896", "0.54878336", "0.5487355", "0.5484407", "0.5468306", "0.5456959", "0.5443664", "0.5443593", "0.54403794", "0.5436813", "0.5425782", "0.54253614", "0.5419096", "0.5414607", "0.54042923", "0.5396207", "0.53959036", "0.5384053", "0.53829604", "0.53829604", "0.53742814", "0.53522825", "0.5349483", "0.5347169", "0.53450483", "0.53399587", "0.53301543" ]
0.6953415
1
primary access control point: returns all tenant permissions for user currently not used as user will only have one tenant with current implementation
def current_tenant_permissions if current_or_guest_user current_or_guest_user.tenant_ids else nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def primary_tenant_permission\n if current_or_guest_user\n current_or_guest_user.tenant_ids.first\n else\n nil\n end\n end", "def permission_grants\n return @permission_grants\n end", "def quota_view_only\n return Quotum.none if @force_empty\n if @user.present?\n if @user.tenant_ids\n Quotum.where.not(tenant_id: @user.tenant_ids).or(Quotum.where(tenant_id: nil))\n else\n Quotum.all\n end\n else\n Quotum.all\n end\n end", "def quota_viewable\n return Quotum.none if @force_empty\n if @user.present?\n if @user.tenant_ids\n Quotum.where(tenant_id: @user.tenant_ids).or(Quotum.where(tenant_id: nil))\n else\n Quotum.where(tenant_id: nil)\n end\n else\n Quotum.where(tenant_id: nil)\n end\n end", "def get_active_permissions\n set_access_token\n if @access_token && !@permissions && set_uid\n # if we don't have permissions set but have an access token\n # grab the user's info\n @rest = Facebook::RestAPI.new(@access_token) \n result = @rest.fql_query(\"select #{all_permissions.join(\",\")} from permissions where uid = #{@uid.to_s}\")\n result.first\n end \n end", "def permission_grants()\n return MicrosoftGraph::PermissionGrants::PermissionGrantsRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def mapping_tenant\n @tenants = Tenant.where(:client_id => current_user.id, :is_active => true)\n @users = current_user.corporate_user\n end", "def quota_controllable\n return Quotum.none if @force_empty\n if @user.present?\n if @user.tenant_ids\n Quotum.where(tenant_id: @user.tenant_ids).all\n else\n Quotum.none.all\n end\n else\n Quotum.none.all\n end\n end", "def index\n @applicants = current_user.applicants rescue nil\n end", "def permission_grants()\n return MicrosoftGraph::Me::JoinedTeams::Item::PermissionGrants::PermissionGrantsRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def get_permissions_for_user(user)\n get_filtered_policy(0, user)\n end", "def core_getUsersPermissions\n # definisco permessi iniziali\n initial_permissions = (1...11).to_a\n\n unpermitted = core_getHideUsersPermissionsSettings\n permitted_permissions = initial_permissions\n permitted_permissions = initial_permissions - unpermitted if unpermitted\n\n permissions = []\n names = core_getUsersPermissionsNamesSettings\n return permitted_permissions if !names\n\n permitted_permissions.each do |permission|\n names.each do |name|\n permissions.push([permission, name.last]) if permission === name.first.to_i\n end\n end\n\n return permissions\n end", "def extra_perms_for_all_users\n can :create, [User, AccountSource]\n can :create, Version\n can :read, Team, :private => false\n can :read, Team, :private => true, id: @user.cached_teams\n can_list Team, { inactive: false }\n can_list Project, { 'joins' => :team, 'teams.inactive' => false }\n cannot :manage, BotUser\n\n # A @user can read a user if:\n # 1) @user is the same as target user\n # 2) target user is a member of at least one public team\n # 3) @user is a member of at least one same team as the target user\n can :read, User, id: @user.id\n can :read, [User, BotUser], teams: { private: false }\n can :read, [User, BotUser], team_users: { status: ['member', 'requested'], team_id: @user.cached_teams }\n\n # A @user can read project or team user if:\n # 1) team is private and @user is a member of that team\n # 2) team user is not private\n can :read, [Project, TeamUser, ProjectGroup, SavedSearch], team_id: @user.cached_teams\n can :read, [Project, TeamUser, ProjectGroup, SavedSearch], team: { private: false }\n\n # A @user can read any of those objects if:\n # 1) it's a source related to him/her or not related to any user\n # 2) it's related to at least one public team\n # 3) it's related to a private team which the @user has access to\n can :read, [Account, ProjectMedia, Source], user_id: [@user.id, nil]\n can :read, [Media, Link, Claim], project_medias: { team: { private: false } }\n can :read, [Media, Link, Claim], project_medias: { team_id: @user.cached_teams }\n\n can :read, Account, source: { user_id: [@user.id, nil] }\n can :read, Relationship, { source: { team_id: @user.cached_teams }, target: { team_id: @user.cached_teams } }\n can :read, ProjectMedia do |obj|\n (!obj.team.private || @user.cached_teams.include?(obj.team.id)) && obj.user_can_see_project?(@user)\n end\n\n can :read, Cluster do |obj|\n shared_team_ids = @context_team.shared_teams.map(&:id)\n team_ids = (shared_team_ids & @user.cached_teams)\n ProjectMedia.where(cluster_id: obj.id, team_id: shared_team_ids).exists? && !team_ids.empty?\n end\n\n can :read, BotUser do |obj|\n obj.get_approved || @user.cached_teams.include?(obj.team_author_id)\n end\n\n can [:read, :create, :update, :destroy], ProjectMediaUser do |obj|\n obj.user_id == @user.id\n end\n\n can [:read, :create], TiplineMessage do |obj|\n @user.cached_teams.include?(obj.team_id)\n end\n\n annotation_perms_for_all_users\n\n cannot :manage, ApiKey\n\n can [:create, :update], LoginActivity\n\n cannot :find_by_json_fields, DynamicAnnotation::Field\n\n can [:read, :create], Shortener::ShortenedUrl\n\n can :read, Feed do |obj|\n !(@user.cached_teams & obj.team_ids).empty?\n end\n\n can :read, FeedTeam do |obj|\n @user.cached_teams.include?(obj.team_id)\n end\n\n can :read, Request do |obj|\n !(@user.cached_teams & obj.feed.team_ids).empty?\n end\n end", "def user_access_control_account_all\n @account = Account.find(params[:account_id])\n user = @account.user\n\n unless !user.admin? && current_user.admin? || current_user?(user)\n response_access_denied\n end\n\n rescue\n response_access_denied\n end", "def verify_tenant_access\n begin\n\n yield\n\n MultiTenant.pending_verification.each do |pending|\n rec, model = pending\n curr_id = MultiTenant.current_tenant.id\n\n multi_tenant_incr(rec)\n\n rec_tenant = rec.send(model)\n if rec_tenant.nil? then\n # if no tenant, then must be globally accessible\n multi_tenant_decr()\n return\n end\n\n other_id = rec_tenant.id\n if curr_id != other_id then\n # PANIC\n multi_tenant_reset()\n raise AccessException, \"illegal access: tried to access tenant.id=#{other_id}; current_tenant.id=#{curr_id}\"\n end\n\n multi_tenant_decr()\n end\n\n ensure\n MultiTenant.pending_verification.clear\n MultiTenant.current_tenant = nil\n end\n end", "def apply_superuser_permissions(permission_types)\n []\n end", "def admin_grant_permissions\n @user = User.includes(:perms).find(params[:id])\n authorize @user\n user_perms = current_user.perms\n @perms = user_perms & [Perm.grant_permissions, Perm.modify_templates, Perm.modify_guidance, Perm.use_api, Perm.change_org_details]\n end", "def scope_current_tenant &block\n if current_user\n current_user.create_tenant # make sure there is a tenant\n \n current_tenant.scope_schema &block\n else\n yield\n end\n end", "def oauth2_permission_grants()\n return MicrosoftGraph::Oauth2PermissionGrants::Oauth2PermissionGrantsRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def limit_to_tenant! # rubocop:disable Metrics/AbcSize\n @stats[:user_count] = @stats[:user_count].where(tenant_id: current_user.tenant_id)\n @stats[:dataset_count] = @stats[:dataset_count].joins(resources: :user)\n .where(['stash_engine_users.tenant_id = ?', current_user.tenant_id]).distinct\n @stats[:user_7days] = @stats[:user_7days].where(tenant_id: current_user.tenant_id)\n @stats[:dataset_started_7days] = @stats[:dataset_started_7days].joins(:user)\n .where(['stash_engine_users.tenant_id = ?', current_user.tenant_id])\n @stats[:dataset_submitted_7days] = @stats[:dataset_submitted_7days].joins(resources: :user)\n .where(['stash_engine_users.tenant_id = ?', current_user.tenant_id]).distinct\n end", "def apps_permissions_users_list(_user_id=nil)\n #raise StandardError, \"APUL caller #{caller_method_name} user #{_user_id}\"\n return {} unless is_app_token?\n semaphore.synchronize {\n @apps_permissions_users_list ||= (\n r = get('/api/apps.permissions.users.list').parsed\n r['resources'].to_a.inject({}){|h,i| h[i['id']] = i; h} || {}\n )\n _user_id ? @apps_permissions_users_list[_user_id].to_h['scopes'] : @apps_permissions_users_list\n }\n end", "def all_permissions\n return permissions unless role\n (permissions + role.permissions).uniq\n end", "def user_access_control_all\n @user = User.find(params[:user_id])\n\n unless !@user.admin? && current_user.admin? || current_user?(@user)\n response_access_denied\n end\n\n rescue\n response_access_denied\n end", "def viewable_users\n @viewable_users ||= (controllable_users + request_applicants + controllable_users.map{|uu|uu.request_applicants}).flatten.uniq\n end", "def permissions\n User.do_find_permissions session_id: kb_session_id\n end", "def permissions_for(context=nil, force_context=nil)\n auth_scope do\n force_context ||= config.force_context\n context = Zuul::Context.parse(context)\n roles = roles_for(context)\n if force_context\n return role_and_subject_permissions_for(context, roles)\n else\n return role_and_subject_permissions_within(context, roles)\n end\n end\n end", "def check_permissions\n require_privilege(Privilege::USE, @environment)\n @environment.provider_accounts.reject! { |a| !check_privilege(Privilege::USE, a) }\n end", "def permissions_assignable_for_user(usr)\n return [] if usr.nil?\n if administrator?(usr)\n get_permissions.collect{|k| Permission.find_by_name(Lockdown.get_string(k)) }.compact\n else\n user_groups_assignable_for_user(usr).collect{|g| g.permissions}.flatten.compact\n end\n end", "def permissions_assignable_for_user(usr)\n return [] if usr.nil?\n if administrator?(usr)\n get_permissions.collect do |k| \n ::Permission.find_by_name(Lockdown.get_string(k))\n end.compact\n else\n user_groups_assignable_for_user(usr).collect do |g| \n g.permissions\n end.flatten.compact\n end\n end", "def index\n @merchant_account_permissions = MerchantAccountPermission.all\n end", "def permission_resources\n %w{roles sites employees classrooms students gapps_org_units}\n end", "def retrieve_user_access_list_for_app(user,app)\n user.groups.where(app_id: app.id)\n end", "def extra_perms_for_all_users\n can :create, User\n can :create, PaperTrail::Version\n can :read, Team, :private => false\n can :read, Team, :private => true, :team_users => { :user_id => @user.id, :status => 'member' }\n\n # A @user can read a user if:\n # 1) @user is the same as target user\n # 2) target user is a member of at least one public team\n # 3) @user is a member of at least one same team as the target user\n can :read, User do |obj|\n @user.id == obj.id || obj.teams.where('teams.private' => false).exists? || @user.is_a_colleague_of?(obj)\n end\n\n # A @user can read contact, project or team user if:\n # 1) team is private and @user is a member of that team\n # 2) team user is not private\n can :read, [Contact, Project, TeamUser] do |obj|\n team = obj.team\n !team.private || @user.is_member_of?(team)\n end\n\n # A @user can read any of those objects if:\n # 1) it's a source related to him/her or not related to any user\n # 2) it's related to at least one public team\n # 3) it's related to a private team which the @user has access to\n can :read, [Account, Source, Media, ProjectMedia, ProjectSource, Comment, Flag, Status, Tag, Embed, Link, Claim] do |obj|\n if obj.is_a?(Source) && obj.respond_to?(:user_id)\n obj.user_id == @user.id || obj.user_id.nil?\n else\n team_ids = obj.get_team\n teams = obj.respond_to?(:get_team_objects) ? obj.get_team_objects.reject{ |t| t.private } : Team.where(id: team_ids, private: false)\n if teams.empty?\n TeamUser.where(user_id: @user.id, team_id: team_ids, status: 'member').exists?\n else\n teams.any?\n end\n end\n end\n end", "def project_permissions\n user.project_permissions(rule.project)\n end", "def accessible_scopes\n [uid, shared_space.try(:uid)].compact\n end", "def index\n @tenants = current_user.tenants\n end", "def findProjectPermissions(workspace, user)\n query_result = @rally.find(:project_permission, :fetch => true, :pagesize => 100) {\n equal :\"user.login_name\", user.login_name\n }\n \n projectPermissions = []\n query_result.each { |pp|\n if ( pp.project.workspace == workspace)\n projectPermissions.push(pp)\n end\n }\n projectPermissions\n end", "def get_implicit_permissions_for_user(user, domain = nil)\n roles = get_implicit_roles_for_user(user, domain)\n roles.insert(0, user)\n res = []\n roles.each do |role|\n permissions = if domain\n get_permissions_for_user_in_domain(role, domain)\n else\n get_permissions_for_user(role)\n end\n\n res.concat(permissions)\n end\n\n res\n end", "def my_permissions\n @my_permissions ||= self.roles.map {|r| r.permissions.map {|p| p.name}}.flatten.freeze\n end", "def check_access_control_all\n @user = User.find(params[:user_id])\n\n response_access_denied unless current_user.has_role?(:admin) || current_user.id == @user.id\n rescue\n response_access_denied\n end", "def all_scopes(_user_id=nil)\n debug{\"_user_id: #{_user_id}, @all_scopes: #{@all_scopes}\"}\n if _user_id && !@all_scopes.to_h.has_key?('identity') || @all_scopes.nil?\n @all_scopes = (\n scopes = case\n when params['scope']\n {'classic' => params['scope'].words}\n when params['scopes']\n params['scopes']\n when is_app_token?\n apps_permissions_scopes_list\n end\n \n scopes['identity'] = apps_permissions_users_list(_user_id) if _user_id && is_app_token?\n params['scopes'] = scopes\n )\n else\n @all_scopes\n end\n end", "def all_chanperms\n Ricer::Irc::Chanperm.where(:user_id => self.id)\n end", "def user_permissions\n if user_signed_in? && (current_user.is_logistics? || current_user.is_clerical? || current_user.is_vendor? || current_user.is_customer?)\n authorize! :edit, Element\n end\n end", "def index\n authorize TokenPermissionType\n @user = current_user\n @token_types = @user.org.token_permission_types\n end", "def permissions(api_key=KillBillClient.api_key, api_secret=KillBillClient.api_secret)\n User.do_find_permissions :session_id => kb_session_id,\n :api_key => api_key,\n :api_secret => api_secret\n end", "def fb_permissions\n fb_user = FbGraph::User.new('me', :access_token => self.access_token)\n fb_user.permissions\n end", "def permissions(ob, user, query)\n\n policy = ob.is_a?(Policy) ? ob : ob.contribution.policy\n\n def permission_node(view, download, edit, category, id = nil, layout = false)\n node = LibXML::XML::Node.new('permission')\n category_node = LibXML::XML::Node.new('category')\n category_node << category\n node << category_node\n if id\n id_node = LibXML::XML::Node.new('id')\n id_node << id\n node << id_node\n end\n if view\n privilege = LibXML::XML::Node.new('privilege')\n privilege['type'] = \"view\"\n node << privilege\n end\n if download\n privilege = LibXML::XML::Node.new('privilege')\n privilege['type'] = \"download\"\n node << privilege\n end\n if edit\n privilege = LibXML::XML::Node.new('privilege')\n privilege['type'] = \"edit\"\n node << privilege\n end\n if layout\n use_layout_node = LibXML::XML::Node.new('use-layout')\n use_layout_node << 'true'\n node << use_layout_node\n end\n\n if view || edit || download\n node\n else\n nil\n end\n end\n\n permissions = LibXML::XML::Node.new('permissions')\n permissions << permission_node([0,1,2].include?(policy.share_mode),\n policy.share_mode == 0,\n false,\n 'public')\n\n unless ob.is_a?(Policy)\n permissions['uri'] = rest_access_uri(policy)\n permissions['resource'] = rest_resource_uri(policy)\n permissions['id'] = policy.id.to_s\n permissions['policy-type'] = policy.group_policy? ? 'group' : 'user-specified'\n end\n\n policy.permissions.select {|p| p.contributor_type == \"Network\"}.each do |perm|\n permissions << permission_node(perm.view, perm.download, perm.edit, 'group', perm.contributor_id,\n policy.layout == perm.contributor.layout_name)\n end\n\n permissions\nend", "def active_permissions(within_product=nil)\n perms = self.permissions.find_all do |perm|\n if(perm.customer_validate)\n customer_payments.detect do |customer_payment|\n customer_payment.valid_permission?(perm, within_product)\n end\n else\n true\n end\n end + self.customer_payments.map{|cust_pay|\n cust_pay.permission_list(within_product)\n }.map(&:all) + self.product_features(within_product).map(&:permissions)\n perms.flatten.compact.uniq\n end", "def get_fb_permissions\n if fb_access_token\n @graph = Koala::Facebook::API.new(fb_access_token)\n @graph.get_connections('me', 'permissions') rescue []\n else\n []\n end\n end", "def retrieve_user_access_list_for_app(user,app)\n user.groups.where(app_id: app.id)\n end", "def scoped_to_tenant?\n !!scoped_to_tenant_id\n end", "def index\n @grants = policy_scope(Grant.all)\n end", "def permission_grants=(value)\n @permission_grants = value\n end", "def check_access_control_account_all\n @account = Account.find(params[:account_id])\n\n response_access_denied unless current_user.has_role?(:admin) || current_user.id == @account.user_id\n rescue\n response_access_denied\n end", "def all_plans\n if current_user.typeofuser == \"admin\" then\n @tenant = current_user.tenant\n @current_plan = @tenant.pricing_plan\n @selected_plan = PricingPlan.find(@tenant.selected_plan_id)\n @pricing_plans = PricingPlan.where(:plan_type => 'public')\n end\n end", "def permissions( force_reload = false )\n\n # Two levels of joins here, so can't use has_many :through\n if force_reload\n @permissions = nil \n @permissions_by_class_and_op = {}\n end\n\n cond_str = 'role_id in ' + self.class.role_assigned_cond( '?' )\n if !instance_variable_defined?(\"@permissions\") || @permissions.nil?\n @permissions ||= Permission.where([cond_str, self]).to_a\n end\n\n return @permissions\n end", "def from?(some_user)\n tenant == some_user\n end", "def custom_permissions\n if current_user.admin?\n can :manage, :all\n end\n end", "def index\n @tenants = Tenant.get_tenant_list(current_user)\n @tenants = @tenants.paginate(:page => params[:page],:per_page => 10).order('id DESC')\n end", "def tenants\n @tenants\n end", "def gated_discovery_filters(permission_types = discovery_permissions, ability = current_ability)\n return [] if ability.current_user.administrator?\n super\n end", "def allowed_to_create_tenants\n return @allowed_to_create_tenants\n end", "def allow_access_by_any_user\n @attributes[:allow_access_by_any_user]\n end", "def approvable_users\n @approvable_users ||= (controllable_users + editable_request_applicants + controllable_users.map{|uu|uu.editable_request_applicants}).flatten.uniq\n end", "def apps_permissions_users_list\n return {} unless !skip_info? && is_app_token? && is_not_excluded?\n semaphore.synchronize {\n @apps_permissions_users_list_raw ||= access_token.get('/api/apps.permissions.users.list')\n @apps_permissions_users_list ||= @apps_permissions_users_list_raw.parsed['resources'].inject({}){|h,i| h[i['id']] = i; h}\n }\n end", "def find_all_accounts(authorizer)\n accounts = OMF::SFA::Model::Account.exclude(:name => '__default__')\n accounts.map do |a|\n begin\n raise InsufficientPrivilegesException unless authorizer.can_view_account?(a)\n a\n rescue InsufficientPrivilegesException\n nil\n end\n end.compact\n end", "def users_with_permissions()\n\t return LiveStreamSeriesPermission.where(:live_stream_series_id => self.id).collect{|p| p.user}\n end", "def get_current_permissions\n sd = get_security_descriptor(DO_NOT_REFRESH_SD)\n permissions = []\n unless sd.nil?\n permissions if sd.dacl.nil?\n sd.dacl.each do |ace|\n permissions << Puppet::Type::Acl::Ace.new(convert_to_permissions_hash(ace), self)\n end\n end\n permissions\n end", "def access_controls_for(object)\n all_acls.select{ |ac| ac.access_to_id == object.id }\n end", "def index\n @app_instances = parent_organization.app_instances.active.where(\"updated_at.gt\" => Time.at(timestamp)).select do |i|\n # force owner assignment to avoid a refetch in ability can?(:access,i)\n i.owner = parent_organization\n can?(:access,i)\n end\n end", "def ransackable_scopes(auth_object = nil)\n []\n end", "def get_current_privs\n query = @db_connection.query(\"SHOW GRANTS FOR current_user();\")\n query.each { |x| print_line(\"#{x[0]}\") }\n end", "def campus_patron_permissions\n anonymous_permissions\n end", "def campus_patron_permissions\n anonymous_permissions\n end", "def allowed?(action,user)\n\n if user.tenant?\n flash[:notice] = \"Sorry. You are not allowed to perform this action as a tenant\"\n return redirect_to action, notice:\"Sorry. You can't list a property as a tenant\"\n end\n\n\n\n end", "def subquery_accessible entity\r\n result = []\r\n if entity.accessible?\r\n entity.children.each { |c|\r\n result.push c\r\n result.concat subquery_accessible(c)\r\n }\r\n end\r\n result\r\n end", "def index\n skip_policy_scope\n @applications = current_user&.oauth_applications\n if @applications&.empty?\n skip_authorization\n else\n @applications&.each do |app|\n authorize app, policy_class: Oauth::ApplicationPolicy\n end\n end\n end", "def permissions\n Rails.cache.fetch(\"permissions_#{self.id}\", expire_in: 1.month) do\n self.roles.map(&:permissions).flatten\n end\n end", "def current_tenant\n ActsAsTenant.current_tenant\n end", "def current_tenant\n ActsAsTenant.current_tenant\n end", "def current_tenant\n ActsAsTenant.current_tenant\n end", "def requester_acls\n RBAC::ACLS.new.create(nil, OWNER_PERMISSIONS)\n end", "def requester_acls\n RBAC::ACLS.new.create(nil, OWNER_PERMISSIONS)\n end", "def current_tenant\n MultiTenant.current_tenant\n end", "def permissions\n if @permissions.nil?\n perm_array = []\n roles.each { |r| perm_array << r.permission_ids }\n @permissions = perm_array.flatten.uniq\n else\n @permissions\n end\n end", "def permissions_for(game)\n self.permissions.where(\"user_roles.game_id = ?\", game.id)\n end", "def get_permissions\n permissions.keys\n end", "def get_permissions\n permissions.keys\n end", "def index\n @tasks = policy_scope(Task)\n record.user == current_user\n end", "def grants_individual\n @users = Array.new()\n User.all.each do |u|\n if !u.admin?\n @users.push(u)\n end\n end\n end", "def get_permissions_by_resource resource_uuid\n resource_uuid = resource_uuid.uuid if resource_uuid.is_a?(Resource)\n \n @permissions.find_all{|per|per.resource_uuid == resource_uuid}\n end", "def get_current_permissions()\n\t\t\tkparams = {}\n\t\t\tclient.queue_service_action_call('permission', 'getCurrentPermissions', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend", "def grant_system_admin_privileges(user)\n can :manage, AccountPlan\n end", "def index\n @organization_profiles = policy_scope(OrganizationProfile).all\n authorize User\n end", "def access\n @user = User.find_by_user(params[:id])\n @datasetID, @fileID = params[:resource].split '/'\n\n is_restricted = AccessLevel.dataset_is_restricted(@datasetID)\n category = is_restricted ? :b : :a\n\n permissions = @user.permissions_for_dataset(category, @datasetID, @fileID)\n\n pv = permissions\n .reject { |e| e.permissionvalue == 0 }\n .inject(0) { |a, e| a == 0 ? e.permissionvalue : a * e.permissionvalue }\n\n # # General datasets have analyse and download permissions if browse access is granted\n # if !is_restricted\n # pv *= UserPermissionB::PERMISSION_VALUES[:analyse] * UserPermissionB::PERMISSION_VALUES[:download]\n # end\n\n # result = {:browse => pv > 0 && pv % UserPermissionB::PERMISSION_VALUES[:browse] == 0,\n # :analyse => pv > 0 && pv % UserPermissionB::PERMISSION_VALUES[:analyse] == 0,\n # :download => pv > 0 && pv % UserPermissionB::PERMISSION_VALUES[:download] == 0}\n\n if is_restricted\n result = {\n :browse => pv > 0 && pv % UserPermissionB::PERMISSION_VALUES[:browse] == 0,\n :analyse => pv > 0 && pv % UserPermissionB::PERMISSION_VALUES[:analyse] == 0,\n :download => pv > 0 && pv % UserPermissionB::PERMISSION_VALUES[:download] == 0 }\n else\n result = {\n :browse => true,\n :analyse => true,\n :download => pv > 0 }\n end\n\n render :json => result\n end", "def overall_permissions(thing)\n global_permissions.merge!(permissions_for(thing))\n end", "def api_perms\n ident = :api\n text = 'API Permissions'\n desc = 'All permissions that have to do with the API.'\n options = [:true, :false, :flow]\n def_option = :flow\n\n api_global = write_permission_group(ident, text, desc, options, def_option)\n\n ActiveRecord::Base.descendants.each do |m|\n next unless m.included_modules.include?(GraphQL::QLModel)\n root = write_permission_group(hashify(m), m.to_s, 'Actions corresponding to ' + m.to_s.pluralize, options, def_option)\n\n see = write_permission_group(:see, 'Viewable Fields', 'Regulate which fields of this model a user can see.', options, def_option)\n\n m.graph_fields.each do |f|\n g = write_permission(\"View #{f}\", \"Allow the user to see #{f}.\", hashify(f), options, def_option)\n g.add_to_group(see)\n end\n\n see.add_to_group(root)\n\n find_by = write_permission_group(:query, 'Query By', 'Regulate which fields of this model a user query by.', options, def_option)\n\n m.graph_finders.each do |f|\n finder = write_permission(\"Query by #{f}\", \"Allow the user to query by #{f}.\", hashify(f), options, def_option)\n finder.add_to_group(find_by)\n end\n\n find_by.add_to_group(root)\n\n root.add_to_group(api_global)\n end\n\n mutations = write_permission_group(:mutations, 'Mutations', 'Regulate which mutations a user can perform.', options, def_option)\n\n AvicusSchema.types.each do |f|\n f.each do |a|\n next unless a.is_a?(GraphQL::ObjectType) && a.name.include?('Payload')\n mut = a.name.gsub('Payload', '')\n write_permission(\"Execute #{mut}\", \"Allow the user to execute the #{mut} mutation.\", hashify(mut), options, def_option).add_to_group(mutations)\n end\n end\n\n mutations.add_to_group(api_global)\n\n global_options = {\n text: text,\n desc: desc,\n options: options,\n def_option: def_option\n }\n\n PermissionsGenerator.new('API', true, global_options, api_global, [])\nend", "def apps_permissions_scopes_list\n return {} unless is_app_token?\n semaphore.synchronize {\n @apps_permissions_scopes_list ||= (\n r = get('/api/apps.permissions.scopes.list').parsed\n r['scopes'] || {}\n )\n }\n end", "def all_permitted_tasks\n ( self.restricted? ) ? self.tasks.scoped : Task.scoped\n end", "def allowed_accounts\n return @allowed_accounts\n end" ]
[ "0.678953", "0.6761816", "0.67237586", "0.665139", "0.6650796", "0.65495807", "0.64620364", "0.64181876", "0.63737065", "0.63718957", "0.6366822", "0.6157869", "0.6147857", "0.6081552", "0.607618", "0.60743785", "0.60458297", "0.6045226", "0.6023286", "0.601517", "0.59624994", "0.5953583", "0.59444", "0.5930861", "0.5922859", "0.59121865", "0.5895311", "0.58882165", "0.58831495", "0.5880823", "0.5878898", "0.58743066", "0.5870559", "0.5853603", "0.5837692", "0.5830154", "0.5816677", "0.5815041", "0.58125544", "0.58080316", "0.5805312", "0.57981956", "0.5797022", "0.57898295", "0.57897127", "0.57890326", "0.57832825", "0.5777536", "0.5770763", "0.5761763", "0.5754947", "0.57507765", "0.5750631", "0.57417953", "0.57410425", "0.5734652", "0.57309127", "0.57195616", "0.57140696", "0.5702274", "0.5699982", "0.56955576", "0.5684169", "0.5682069", "0.5673571", "0.5672085", "0.5671065", "0.5637385", "0.56360054", "0.5629387", "0.56289554", "0.56253487", "0.5617861", "0.5617861", "0.5600917", "0.5600831", "0.56007665", "0.5593852", "0.5593591", "0.5593591", "0.5593591", "0.55930996", "0.55930996", "0.55836725", "0.55834717", "0.5581683", "0.55765", "0.55765", "0.55750984", "0.55730176", "0.55705047", "0.556669", "0.5548592", "0.5548309", "0.55410975", "0.554064", "0.55349964", "0.5531467", "0.5531387", "0.552447" ]
0.78868496
0
returns primary (base) tenant permission for user
def primary_tenant_permission if current_or_guest_user current_or_guest_user.tenant_ids.first else nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_tenant_permissions\n if current_or_guest_user\n current_or_guest_user.tenant_ids\n else\n nil\n end\n end", "def current_tenant\n Tenant.find_by_domain! current_user.email_domain\n end", "def current_tenant\n MultiTenant.current_tenant\n end", "def current_tenant\n ActsAsTenant.current_tenant\n end", "def current_tenant\n ActsAsTenant.current_tenant\n end", "def current_tenant\n ActsAsTenant.current_tenant\n end", "def current_tenant\n if params[:tenant_id].present?\n tenant = Tenant.find(params[:tenant_id])\n else\n Tenant.last\n end\n end", "def from?(some_user)\n tenant == some_user\n end", "def tenant_id\n return @tenant_id\n end", "def tenant_id\n return @tenant_id\n end", "def tenant_id\n return @tenant_id\n end", "def tenant_id\n return @tenant_id\n end", "def current_tenant_id\n self.class.current_tenant_id\n end", "def mapping_tenant\n @tenants = Tenant.where(:client_id => current_user.id, :is_active => true)\n @users = current_user.corporate_user\n end", "def super_admin\n User.where(id: memberships.super_admin.pluck(:user_id)).first\n end", "def get_user_type(user)\n userExists = User.find_by_id(user.id)\n if userExists && user.permission_level == 1\n return \"Admin\"\n elsif userExists && user.permission_level == 0\n return \"Standard\"\n end\n end", "def user_permission\n has_controller_permission?('user')\n end", "def current_tenant\n\t\t@current_tenant ||= Tenant.find_by(id: session[:tenant_id])\n \tend", "def pundit_user\n current_admin\n end", "def show\n\n @tenant = Tenant.find(params[:id])\n # @tenant.apartment works!\n authorize @tenant\n end", "def pundit_user\n current_identity\n end", "def get_user_for_tenant(args = {}) \n get(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend", "def primary_user\n primary_order_user = order_users.where(primary: true).first || order_users.first\n primary_order_user ? primary_order_user.user : nil\n end", "def tenant\n TenantView.new(space.tenant)\n end", "def permission_grants\n return @permission_grants\n end", "def primary_role\n return nil if user.person_role.blank?\n user.person_role\n end", "def user?\n permissions == 'user'\n end", "def show\n if (current_user.tenant?)\n @tenant = current_user.tenant\n if (@tenant == nil)\n @tenant=Tenant.first\n params[:notice]=\"No user could be found with that email.\"\n end\n end\n end", "def current_user\n current_admin_user\n end", "def current_user\n current_admin_user\n end", "def pundit_user\n current_account\n end", "def pundit_user\n current_account\n end", "def effective_user\n current_user || demo_user\n end", "def scope_current_tenant &block\n if current_user\n current_user.create_tenant # make sure there is a tenant\n \n current_tenant.scope_schema &block\n else\n yield\n end\n end", "def owner\n vals = Role.access_values_for(:creator)\n User.joins(:roles).where('roles.plan_id = ? AND roles.access IN (?)', self.id, vals).first\n end", "def your_project_access_type policy = nil, resource = nil\n unless policy.nil? or resource.nil? or !(policy.sharing_scope == Policy::ALL_SYSMO_USERS)\n unless policy.permissions.empty?\n my_project_ids = if resource.class == Project then [resource.id] else resource.project_ids end\n my_project_perms = policy.permissions.select {|p| p.contributor_type == 'Project' and my_project_ids.include? p.contributor_id}\n access_types = my_project_perms.map(&:access_type)\n return access_types.first if access_types.all?{|acc| acc == access_types.first}\n else\n policy.access_type\n end\n end\n end", "def allowed?(action,user)\n\n if user.tenant?\n flash[:notice] = \"Sorry. You are not allowed to perform this action as a tenant\"\n return redirect_to action, notice:\"Sorry. You can't list a property as a tenant\"\n end\n\n\n\n end", "def tenant\n return options.tenant if options.tenant\n fail StandardError, 'No tenant specified in AzureAD configuration.'\n end", "def current_tenant\n @current_tenant ||= Roomer.tenant_model.find_by_url_identifier(url_identifier)\n end", "def pundit_user\n current_trainer\n end", "def authorized_by(user)\n user.id == self.id\n end", "def scoped_to_tenant?\n !!scoped_to_tenant_id\n end", "def pundit_user\n CurrentAuthority.new(current_user, current_right)\n end", "def pundit_user\n @current_user\n end", "def get_read_access( u)\n \n return (u == self.user) || (self.public)\n \n \n end", "def get_min_permission_to_child_tree_nodes_by_user()\n if AuthenticationModel.current_user_is_admin?\n return 4 #\"Administrating\"\n end\n result = ac_type\n\n #optimization (if it already minimal value)\n if result == 0 #\"Forbidden\"\n return result \n end\n\n children = TreeNode.old_find_by_sql(\"SELECT get_max_user_permission(#{AuthenticationModel.current_user}, tree_nodes.id) as max_user_permission_2, *\n from tree_nodes where parent_id =#{id}\")\n children.each{ |tn|\n #get current node permission\n if tn.ac_type < result\n result = tn.ac_type\n end\n\n #optimization (if it already minimal value)\n if result == 0 #\"Forbidden\"\n return result \n end\n #get child permission\n tmp_res = tn.get_min_permission_to_child_tree_nodes_by_user()\n if tmp_res < result\n result = tmp_res\n end\n }\n result\n end", "def pundit_user\n current_staff\n end", "def user\n access_code.user\n end", "def get_current_tenant \n get(\"/tenants.json/current\")\nend", "def current_user\n current_admin\n end", "def set_tenant\n if current_user\n current_account = Account.where(id: current_user.current_tenant_id).first\n set_current_tenant(current_account)\n end\n end", "def is_super_user?\n @super_user\n end", "def pundit_user\n \t\tcurrent_admin # current_user to Pundit\n \tend", "def set_tenant_of\n @tenant_of = TenantOf.find_by(id: params[:id])\n @tenant = @tenant_of.user\n end", "def phi_allowed_by\n phi_context[:user_id]\n end", "def allow_access_by_any_user\n @attributes[:allow_access_by_any_user]\n end", "def pundit_user\n current_person\n end", "def get_permissions_for_user(user)\n get_filtered_policy(0, user)\n end", "def allowed_to_create_tenants\n return @allowed_to_create_tenants\n end", "def pp_tenant( tenant, do_flat=true )\n \tloc.pp_tenant( tenant, do_flat );\n end", "def manage_brandreach?\n user.admin? || user.super_admin?\n end", "def is_super_admin?\n user_type == 'super_admin'\n end", "def user_permission(instance,current_user)\n\t\tcase instance\n\t\twhen User #IF THAT THING IS A USER, ONLY A USER OR AN ADMIN CAN CHANGE\n\t\t\ttrue if self.admin || instance == current_user\n\t\telse\n\t\t\t#IF THAT THING IS SOMETHING BESIDES A USER, ONLY AN ADMIN OR THE USER THAT THE THING BELONGS TO CAN CHANGE IT\n\t\t\ttrue if self.admin || instance.user == current_user\n\t\tend\n\tend", "def forem_user\n current_user\n end", "def current_user_or_admin\n if current_user \n return current_user\n elsif current_admin \n return current_admin\n end \n end", "def pundit_user\n # if action_name == \"new\"\n # current_user\n # else\n current_user || current_company\n # end\n end", "def primary_account\n subclass_must_define\n end", "def grant_permission\n @attributes[:grant_permission]\n end", "def role\n permission_type\n end", "def show\n @tenant=Tenant.find(params[:tenant_id])\n end", "def permission_grants()\n return MicrosoftGraph::PermissionGrants::PermissionGrantsRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def tenant_path\n @tenant_path ||= '/api/v2/tenants/settings'\n end", "def tenant_class\n @tenant_class ||= if self.model.respond_to?(:call)\n self.model.call\n elsif self.model.respond_to?(:constantize)\n self.model.constantize\n else\n self.model\n end\n end", "def show?\n @current_user.permission('Bid', :guest)\n end", "def owner\n permission = self.permissions(level: 'owner')[0]\n if permission\n permission.user\n else\n nil\n end\n end", "def user\n if user_id\n super\n else\n billable_to.owner # always a User\n end\n end", "def super_user? \n current_user.role.role == \"Super\" \n end", "def get_organization_and_check_permission\n @organization = current_user.is_cesia? ? ::Organization.find(params[:id]) : current_organization\n authorize @organization\n end", "def can_access?(user)\n user == self.user\n end", "def quota_viewable\n return Quotum.none if @force_empty\n if @user.present?\n if @user.tenant_ids\n Quotum.where(tenant_id: @user.tenant_ids).or(Quotum.where(tenant_id: nil))\n else\n Quotum.where(tenant_id: nil)\n end\n else\n Quotum.where(tenant_id: nil)\n end\n end", "def owner_perm privilege, klass, owner\n Permission.new( :privilege => privilege,\n :class_name => klass.name,\n :is_grant => false,\n :has_grant_option => false,\n :target_owned_by_self => false,\n :target_owner => owner\n )\n \n end", "def find_first_admin\n self.where(:admin => true).order(:created_at).first\n end", "def get_active_permissions\n set_access_token\n if @access_token && !@permissions && set_uid\n # if we don't have permissions set but have an access token\n # grab the user's info\n @rest = Facebook::RestAPI.new(@access_token) \n result = @rest.fql_query(\"select #{all_permissions.join(\",\")} from permissions where uid = #{@uid.to_s}\")\n result.first\n end \n end", "def user_permission(paid, cancelled, signed_in, admin)\n\tif paid == \"no\" or cancelled == \"yes\"\n\treturn \"Go away!\"\n\telsif signed_in == \"yes\" and admin == \"yes\"\n\treturn \"You can see and change all the pages!\"\n\telsif signed_in == \"yes\" and admin == \"no\"\n\treturn \"You can see all the pages!\"\n\telsif signed_in == \"no\"\n\treturn \"You can't see any of the pages, please sign in!\"\n\tend\nend", "def user\n project.user\n end", "def is_super_admin\n return self.role == :super_admin.to_s\n end", "def campus_patron_permissions\n anonymous_permissions\n end", "def campus_patron_permissions\n anonymous_permissions\n end", "def swpmanager_getCollaboratorAdminSuperuserPermission\n return SWPMANAGER_COLLABORATORADMINSUPERUSERPERMISSION if defined? SWPMANAGER_COLLABORATORADMINSUPERUSERPERMISSION\n permission = 2\n if File.exist? \"#{Rails.root}/config/lato/swpmanager.yml\"\n config = YAML.load(\n File.read(File.expand_path(\"#{Rails.root}/config/lato/swpmanager.yml\", __FILE__))\n )\n if config && config['collaborator_admin_superuser_permission']\n permission = config['collaborator_admin_superuser_permission']\n end\n end\n # return result\n return permission\n end", "def accessible\n accessible_for(Aurita.user)\n end", "def permission_classification\n return @permission_classification\n end", "def show \n #if current_user.company_id == @user.company_id \n authorize @user \n end", "def has_user_permission?(object)\n object and object.user and current_user and object.user == current_user\n end", "def restapi_permission\n @attributes[:restapi_permission]\n end", "def create_tenant\n \t#password = Base64.encode64(Digest::SHA1.digest(\"#{rand(1<<64)}/#{Time.now.to_f}/#{Process.pid}/#{userid}\"))[0..7]\n \tPgTools.create_tenant(userid, db_password)\n end", "def system_user\n User.find_by_name(\"DanbooruBot\") || User.admins.first\n end", "def quota_view_only\n return Quotum.none if @force_empty\n if @user.present?\n if @user.tenant_ids\n Quotum.where.not(tenant_id: @user.tenant_ids).or(Quotum.where(tenant_id: nil))\n else\n Quotum.all\n end\n else\n Quotum.all\n end\n end", "def current_user\n current_admin || current_nonprofit\n end", "def set_current_tenant_if_necessary\n if !self.user.current_tenant\n self.user.current_tenant = self.tenant\n self.user.save\n end\n end", "def project_permissions\n user.project_permissions(rule.project)\n end" ]
[ "0.73966545", "0.6493027", "0.64182276", "0.6390949", "0.6390949", "0.6390949", "0.6390889", "0.638754", "0.6242775", "0.6242775", "0.6242775", "0.6242775", "0.61415726", "0.6112098", "0.6027526", "0.59923315", "0.5970421", "0.59339327", "0.5917308", "0.589589", "0.58301973", "0.58250123", "0.5800842", "0.577839", "0.57741636", "0.5764068", "0.57590646", "0.575132", "0.57268107", "0.57268107", "0.5717275", "0.5717275", "0.57018894", "0.5699899", "0.56913483", "0.56822807", "0.5674417", "0.56571764", "0.5648667", "0.5645374", "0.56451863", "0.5634139", "0.56287396", "0.56261206", "0.56120646", "0.56101197", "0.5601366", "0.55826044", "0.5579296", "0.5578842", "0.55659777", "0.5564501", "0.55542237", "0.55497414", "0.5547235", "0.5543032", "0.55414575", "0.554056", "0.55339557", "0.5531953", "0.55313665", "0.55292976", "0.552598", "0.551868", "0.5511141", "0.5505915", "0.5505756", "0.54984254", "0.5493819", "0.54860693", "0.54741377", "0.5473854", "0.54610574", "0.54599977", "0.5449836", "0.5433382", "0.54317695", "0.5420477", "0.5411807", "0.5411511", "0.5408038", "0.5400978", "0.53971547", "0.53917766", "0.53915554", "0.5384929", "0.5383718", "0.5383718", "0.53817415", "0.53716767", "0.5371588", "0.53616714", "0.53611374", "0.5359312", "0.53585917", "0.535708", "0.5345809", "0.5343145", "0.53425896", "0.5338114" ]
0.8528185
0
Use callbacks to share common setup or constraints between actions.
def set_collection @collection = current_user.collections.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Only allow a trusted parameter "white list" through.
def collection_params params.require(:collection).permit(:name, :user_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def filtered_parameters; end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n [:rating, :review]\n end", "def valid_params?; end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def filter_parameters; end", "def filter_parameters; end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def check_params; true; end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def list_params\n params.permit(:name)\n end", "def check_params\n true\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def additional_permitted_params\n []\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end", "def allow_params_authentication!; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end", "def quote_params\n params.permit!\n end", "def list_params\n params.permit(:list_name)\n end", "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def all_params; end", "def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end", "def source_params\n params.require(:source).permit(all_allowed_params)\n end", "def user_params\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 get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end", "def permitted_params\n @wfd_edit_parameters\n end", "def user_params\r\n end", "def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def params_permit\n params.permit(:id)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def filter_params\n params.permit(*resource_filter_permitted_params)\n end", "def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end", "def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend", "def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end", "def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def argument_params\n params.require(:argument).permit(:name)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def parameters\n nil\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end", "def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end", "def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end" ]
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.63804525", "0.6373396", "0.6360051", "0.6355191", "0.62856233", "0.627813", "0.62451434", "0.6228103", "0.6224965", "0.6222941", "0.6210244", "0.62077755", "0.61762565", "0.61711127", "0.6168448", "0.6160164", "0.61446255", "0.6134175", "0.6120522", "0.6106709", "0.60981655", "0.6076113", "0.60534036", "0.60410434", "0.6034582", "0.6029977", "0.6019861", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.60184896", "0.60157263", "0.6005857", "0.6003803", "0.60012573", "0.59955895", "0.5994598", "0.5993604", "0.5983824", "0.5983166", "0.5977431", "0.597591", "0.5968824", "0.5965953", "0.59647584", "0.59647584", "0.59566855", "0.59506303", "0.5950375", "0.59485626", "0.59440875", "0.5930872", "0.5930206", "0.5925668", "0.59235454", "0.5917905", "0.59164816", "0.5913821", "0.59128743", "0.5906617", "0.59053683", "0.59052664", "0.5901591", "0.58987755", "0.5897456", "0.58970183", "0.58942604" ]
0.0
-1
Parses the given stream and returns a node tree
def load(stream, root_class = nil) root_class ||= PrisonParser::Node line_num = 0 nodes = [] @tokens = [] current_node = root_class.new while !stream.eof? do line = stream.readline.strip line_num += 1 tokenize(line) next if tokens.size == 0 # start a new node if "BEGIN" == tokens[0] nodes.push(current_node) label = tokens[1] current_node = current_node.create_node(label) if tokens.size > 2 # inline node if tokens.size % 2 != 1 raise UnevenTokenError.new("Unexpected number of tokens in an inline node definition on line #{line_num}") end unless "END" == tokens[tokens.size - 1] raise UnexpectedEndOfLineError.new("Unexpected end of inline node definition on line #{line_num}") end # Don't iterate the 'BEGIN', label, 'END' tokens[2..-2].each_slice(2) do |parts| current_node.add_property(parts[0], parts[1]) end upper_node = nodes.pop upper_node.finished_reading_node(current_node) current_node = upper_node else current_node.prevent_inlining! end elsif "END" == tokens[0] # end of multi-line section upper_node = nodes.pop upper_node.finished_reading_node(current_node) current_node = upper_node else # inside a multi-line section current_node.add_property(tokens[0], tokens[1]) end end if nodes.size != 0 raise UnexpectedEndOfFileError.new("Unexpected end of file!") end current_node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(stream, encoding=nil)\n _parse(stream, false, encoding)\n @tree.get_document\n end", "def decode( inputstream)\n #Helper method on inputstream to read single bits\n class << inputstream\n def init\n @byte = 0\n @bit_count = 0\n end\n def read_bit\n if 0 == @bit_count\n @byte = read( 1)[0]\n @bit_count = 8\n end\n bit = @byte & 0b10000000 == 0 ? 0 : 1\n @bit_count -= 1\n @byte <<= 1\n return bit\n end\n end\n \n inputstream.init\n node = @root_node\n tokens = []\n loop do\n bit = inputstream.read_bit\n branch = node.branches[bit]\n if branch.is_a?( Node)\n node = branch\n else\n token = branch\n break if TERMINATOR == token\n tokens << token\n node = @root_node\n end\n end\n tokens\n end", "def parse stream\n @stack = []\n @iv = 0\n @repeat_range = [] \n @range_rules = [] \n @gram = Grammar.new \n state = :start\n \n stream.each do |token|\n trans = @transitions.fetch state\n action = trans.fetch( token.type, nil )\n raise \"Parser: unexpected token '#{token.type}' when in #{state}\" if action.nil?\n state = action.call( self, token )\n end\n @gram\n end", "def parse_stream()\r\n #puts \"parse_stream\"\r\n REXML::Document.parse_stream(@pipe, self)\r\n end", "def match(ptr, depth = 0)\n children = []\n loop do\n ptr.skip(/\\s+/)\n break if ptr.eos?\n ptr.unscan if ptr.matched?\n if ast = @root.match(ptr, depth + 1)\n children << ast\n else\n raise ParserJam.new(ptr, \"StreamParser[#{depth}]\")\n end\n end\n AST.new(:root, children: children, pos: 0)\n end", "def process(input_stream)\n debug 'Beginning tokenization of input'\n\n @stream = input_stream\n @stream_char = 1\n\n @output = [] if @state == :root\n\n until @stream.strip.empty?\n tk = tokenize\n @output.append(tk) if tk.instance_of? Token\n end\n\n @output\n end", "def parse(stream)\n pages = JSON.load(stream)\nend", "def parse(content)\n $Log.info('Start Parsing')\n lines = content.strip.split(/\\r?\\n/)\n root = @root_type.new(@metadata)\n root.build(@metadata, lines)\n root.post_process\n root\n end", "def parse(data)\n @children.clear\n data = StringIO.new(data)\n while !data.eof?\n mode = Util.read_bytes_until(data, ' ').to_i(8)\n name = repository.set_encoding Util.read_bytes_until(data, \"\\0\")\n id = repository.set_encoding data.read(20).unpack(\"H*\").first\n @children[name] = Reference.new(:repository => repository, :id => id, :mode => mode)\n end\n end", "def parse( input_stream, input_descriptor = nil )\n \n #\n # Initialize the Parser and Lexer for the coming work.\n \n @lexer = %%GRAMMAR_CLASS_NAME%%Lexer.new( input_stream, input_descriptor )\n @state_stack = [ @@states[0] ]\n @node_stack = []\n action = nil\n \n \n #\n # Do the work.\n \n while true\n \n state = state_stack[-1]\n set_lexer_state( state )\n \n #\n # Determine our next action, based on lookahead.\n \n next_token = la(1)\n token_type = (next_token.nil? ? nil : next_token.type)\n action = state.actions[token_type]\n \n #\n # Process the action.\n \n if action.nil? then\n nyi( \"error handling for bad lookahead: [#{next_token.text}]:#{next_token.type}\" )\n elsif action.accept? then\n break\n else\n action.perform( self )\n end\n end\n \n \n return node_stack[-1]\n end", "def parse\n @started = false\n begin\n parser = REXML::Parsers::SAX2Parser.new @stream \n parser.listen( :start_element ) do |uri, localname, qname, attributes|\n if @current.nil?\n @current = REXML::Element::new(qname)\n else\n e = REXML::Element::new(qname)\n @current = @current.add_element(e)\n end\n @current.add_attributes attributes\n if @current.name == 'stream'\n @listener.receive(@current)\n @started = true\n end\n end\n parser.listen( :end_element ) do |uri, localname, qname|\n case qname\n when \"stream:stream\"\n @started = false\n else\n @listener.receive(@current) if @current.parent.name == 'stream'\n @current = @current.parent\n end\n end\n parser.listen( :characters ) do | text |\n @current.text = (@current.text.nil? ? '' : @current.text) + text\n end\n parser.listen( :cdata ) do | text |\n raise \"Not implemented !\"\n end\n parser.parse\n rescue REXML::ParseException\n @listener.parse_failure\n end\n end", "def parse_tree\n File.open(html_file, 'r') do |file|\n current = nil\n file.each_line do |line|\n line.scan(%r{(<(.*?>.*?)<(\\/.*?)>|<(.*?)>(.*))}).each do |tag|\n if !tag[3].nil? && tag[3].start_with?('/') # ending tag\n current = current.parent\n else\n node = Node.new(tag)\n if @root.nil?\n @root = node\n else\n node.parent = current\n current.childs << node\n end\n @tags << node.tag\n current = node\n current = current.parent if !tag[2].nil? && tag[2].start_with?('/')\n end\n end\n end\n end\n end", "def parse(filename)\n file = File.open(filename, \"r\").readlines\n\n $root = Node.new('root')\n $context = $root\n\n file.each_with_index do |line, index|\n process_line(line, index) if line.match(/\\S/)\n end\n\n return $root\n\nend", "def parse\n @started = false\n\n parser = XMLParser.new(\"UTF-8\")\n def parser.unknownEncoding(e)\n raise \"Unknown encoding #{e.to_s}\"\n end\n def parser.default\n end\n\n begin\n parser.parse(@stream) do |type, name, data|\n begin\n case type\n when XMLParser::START_ELEM\n case name\n when \"stream:stream\"\n openstream = ParsedXMLElement.new(name)\n data.each {|key, value| openstream.add_attribute(key, value)}\n @listener.receive(openstream)\n @started = true\n else\n if @current.nil?\n @current = ParsedXMLElement.new(name.clone)\n else\n @current = @current.add_child(name.clone)\n end\n data.each {|key, value| @current.add_attribute(key.clone, value.clone)}\n end\n when XMLParser::CDATA\n @current.append_data(data.clone) if @current\n when XMLParser::END_ELEM\n case name\n when \"stream:stream\"\n @started = false\n else\n @listener.receive(@current) unless @current.element_parent\n @current = @current.element_parent\n end\n end\n rescue\n puts \"Error #{$!}\"\n end\n end\n rescue XMLParserError\n line = parser.line\n print \"XML Parsing error(#{line}): #{$!}\\n\"\n end\n end", "def parse_tree\n id = attribute( 'id' )\n label = attribute( 'label' )\n\n type = attribute( 'xsi:type' )[4..-1]\n klass = NeXML.const_get( type )\n tree = klass.new( id, :label => label )\n\n #a 'tree' element *will* have child nodes.\n while next_node\n case local_name\n when \"node\"\n #parse child 'node' element\n node = parse_node\n\n #and add it to the 'tree'\n tree.add_node node\n\n #root?\n tree.roots << node if node.root?\n when \"rootedge\"\n #parse child 'edge' element\n rootedge = parse_rootedge\n\n #and add it to the 'tree'\n # tree.add_rootedge rootedge # XXX it looks like the super class(es)\n # can only deal with edges that have source and target\n when \"edge\"\n #parse child 'edge' element\n edge = parse_edge( type )\n\n #and add it to the 'tree'\n tree.add_edge edge\n when \"tree\"\n #end of current 'tree' element has been reached\n break\n end\n end\n\n #return the 'tree' object\n tree\n end", "def set_tree_node_stream(input)\n @input = input\n end", "def parse\n case node.name\n when 'document'\n Plex::Parser.new(parent, node.root).parse\n when 'MediaContainer'\n parse_media_container\n when 'Video'\n parse_video\n when 'Directory'\n parse_directory\n when 'text'\n nil\n else\n end\n end", "def parse_tree(records)\n\n # build tree, should return a file_header node\n first, *records = *records\n unless first.code == :file_header\n raise ParseError.new('Expecting file header record (01).')\n end\n root = ParseNode.new(first)\n stack = [root]\n\n records.each do |record|\n raise ParseError.new('Unexpected record.') if stack.empty?\n\n case record.code\n\n # handling headers\n when :group_header, :account_identifier\n\n parent = {group_header: :file_header,\n account_identifier: :group_header}[record.code]\n unless stack.last.code == parent\n raise ParseError.new(\"Parsing #{record.code}, expecting #{parent} parent.\")\n end\n\n n = ParseNode.new(record)\n stack.last.children << n\n stack << n\n\n # handling trailers\n when :account_trailer, :group_trailer, :file_trailer\n\n parent = {account_trailer: :account_identifier,\n group_trailer: :group_header,\n file_trailer: :file_header}[record.code]\n unless stack.last.code == parent\n raise ParseError.new(\"Parsing #{record.code}, expecting #{parent} parent.\")\n end\n\n stack.last.records << record\n stack.pop\n\n # handling continuations\n when :continuation\n\n n = (stack.last.children.last || stack.last)\n n.records << record\n\n # handling transactions\n when :transaction_detail\n\n unless stack.last.code == :account_identifier\n raise ParseError.new(\"Parsing #{record.code}, expecting account_identifier parent.\")\n end\n\n stack.last.children << ParseNode.new(record)\n\n # handling special known errors\n else # nil\n raise ParseError.new('Unknown or unexpected record code.')\n end\n end\n\n unless stack == []\n raise ParseError.new('Reached unexpected end of input (EOF).')\n end\n\n # root now contains our parsed tree\n root\n end", "def evaluate(stream) \n @stack = []\n @stream = stream \n @i = 0\n @error = false\n return parse \n end", "def parse_sibling(scanner)\n parse(scanner)\n end", "def build_tree(s)\n bytes = s.bytes\n uniq_b = bytes.uniq\n nodes = uniq_b.map { |byte| Leaf.new(byte, bytes.count(byte)) }\n until nodes.length == 1\n node1 = nodes.delete(nodes.min_by(&:count))\n node2 = nodes.delete(nodes.min_by(&:count))\n nodes << Node.new(node1, node2, node1.count + node2.count)\n end\n nodes.fetch(0)\nend", "def parse_stream(instream)\n unless(instream.respond_to?(:gets))\n puts \"Unable to use the specified input stream: not responding to #gets\"\n return nil\n end\n a = nil\n lines_parsed = 0\n while(!@stop)\n begin\n s=instream.gets\n \n next if (s.nil? || s.strip.length == 0)\n a = Parser.parse_line(s, a)\n if ($DEBUG)\n puts \" * #{s}\"\n puts \" -> #{a.to_s}\"\n end\n\t\t\n next if (a.nil?) # No action detected\n lines_parsed += 1\n if (a.complete?)\n # Action detected or completed (in the case of a two-line action)\n # Save the action, and reset the pointer to nil so that the \n # parse_line method does not attempt further processing on it.\n @actions.unshift(a)\n a = nil\n end\n rescue StandardError => e\n LOGGER.e {\"Error while parsing, halting: #{e}\"}\n @stop = true\n end\n end\n\t\n\t# indicate successful completion\n\treturn lines_parsed\n end", "def parse(data)\n @tree = instance.parse(data)\n raise Error, instance unless @tree\n \n @tree\n end", "def parsed_tree; end", "def parse_fragment(stream, container='div', encoding=nil)\n _parse(stream, true, encoding, container)\n @tree.get_fragment\n end", "def parse_trees\n otus = cache[ attribute( 'otus' ) ]\n\n id = attribute( 'id' )\n label = attribute( 'label' )\n\n trees = NeXML::Trees.new( id, :otus => otus, :label => label )\n\n #a 'trees' element *will* have child nodes.\n while next_node\n case local_name\n when \"tree\"\n #parse child 'tree' element\n trees << parse_tree\n when \"network\"\n trees << parse_network\n when \"trees\"\n #end of current 'trees' element has been reached\n break\n end\n end\n\n #return the 'trees' object\n trees\n end", "def parse!\n return if @parsed\n \n # the parents\n log_data = `git log -1 #{node}^ 2> /dev/null`\n \n # DETERMINING PARENTS\n dad = log_data[/^commit (.+)$/, 1]\n dad = dad ? dad[0..6] : nil\n mom = nil\n \n if log_data =~ /^Merge: (.+)\\.\\.\\. (.+)\\.\\.\\.$/ # Merge: 1c002dd... 35cfb2b...\n dad = $1 # just have them both use the short name, nbd\n mom = $2\n end\n \n @parents = [dad, mom].compact.map {|r| Changeset.new repo, r }\n \n # the actual changeset\n log_data = `git log -1 #{node} 2> /dev/null`\n \n # DETERMINING DATE\n @date = Time.parse log_data[/^Date:\\s+(.+)$/, 1]\n \n # DETERMINING USER\n @user = log_data[/^Author:\\s+(.+)$/, 1]\n \n # DETERMINING DESCRIPTION\n @description = log_data.split(\"\\n\")[4..-1].map {|l| l.strip }.join \"\\n\"\n \n # ALTERED FILES\n @altered_files = `git log -1 #{node} --pretty=oneline --name-only 2> /dev/null`.split(\"\\n\")[1..-1]\n \n # ALL FILES\n # @all_files is also sorted. Hooray!\n @all_files = `git ls-tree -r #{node}`.split(\"\\n\").map do |line|\n # 100644 blob cdbeb2a42b714a4db49293c87fec4e180d07d44f .autotest\n line[/^\\d+ \\w+ \\w+\\s+(.+)$/, 1]\n end\n \n @parsed = true\n end", "def parse sgf, strict_parsing = true\n @strict_parsing = strict_parsing\n @stream = streamably_stringify sgf\n @collection = Collection.new\n @root = @collection.root\n @current_node = @root\n @branches = []\n until @stream.eof?\n case next_character\n when \"(\" then open_branch\n when \";\" then\n create_new_node\n parse_node_data\n add_properties_to_current_node\n when \")\" then close_branch\n else next\n end\n end\n @collection\n end", "def from_node(node); end", "def parse(source); end", "def parse_chunk_LPAV stream\n stream.read\n end", "def parse\n #puts \"PARSE\"\n @started = false\n begin\n parser = REXML::Parsers::SAX2Parser.new @stream\n\n parser.listen(:end_document) do\n raise Jabber::ConnectionForceCloseError\n end\n\n parser.listen( :start_element ) do |uri, localname, qname, attributes|\n case qname\n when \"stream:stream\"\n openstream = ParsedXMLElement.new(qname)\n attributes.each { |attr, value| openstream.add_attribute(attr, value) }\n @listener.receive(openstream)\n @started = true\n else\n if @current.nil?\n @current = ParsedXMLElement.new(qname)\n else\n @current = @current.add_child(qname)\n end\n attributes.each { |attr, value| @current.add_attribute(attr, value) }\n end\n end\n parser.listen( :end_element ) do |uri, localname, qname|\n case qname\n when \"stream:stream\"\n @started = false\n else\n @listener.receive(@current) unless @current.element_parent\n @current = @current.element_parent\n end\n end\n parser.listen( :characters ) do | text |\n @current.append_data(text) if @current\n end\n parser.listen( :cdata ) do | text |\n @current.append_data(text) if @current\n end\n parser.parse\n rescue REXML::ParseException => e\n @listener.parse_failure\n rescue Jabber::ConnectionForceCloseError => e\n @listener.parse_failure(e)\n end\n end", "def parse(content)\n TOMLP::Parser.new(content).parse\n end", "def build_tree(tree_size, input)\n nodes = Array.new(tree_size) { Node.new(nil, nil, nil) }\n\n tree_size.times do |i|\n line = input.next\n val, left, right = line.chomp.split.map(&:to_i)\n nodes[i].val = val\n nodes[i].left = nodes[left] unless left == -1\n nodes[i].right = nodes[right] unless right == -1\n end\n \n nodes.first\nend", "def parse_item stream, encoding = nil\n decode read_item(stream)[:payload], encoding\n end", "def print_tree(stream, indent=0)\n\t\t\tstream.puts summary(\"\\t\"*indent)\n\t\t\t@children.sort_by { |child_status|\n\t\t\t\tchild_status.get_rss_total\n\t\t\t}.each { |child_status|\n\t\t\t\t# recursively print trees for child statuses\n\t\t\t\tchild_status.print_tree(stream, indent+1)\n\t\t\t}\n\t\tend", "def parse(source)\n @root = Document.new(tokenize(source))\n self\n end", "def parse\n #return a cached version if it exists\n return @nexml if @nexml\n\n #start at the root element\n skip_leader\n\n #start with a new Nexml object\n version = attribute( 'version' )\n generator = attribute( 'generator' )\n @nexml = NeXML::Nexml.new( version, generator )\n\n #perhaps a namespace api as well\n \n #start parsing other elements\n while next_node\n case local_name\n when \"otus\"\n @nexml.add_otus( parse_otus )\n when \"trees\"\n @nexml.add_trees( parse_trees )\n when \"characters\"\n @nexml.add_characters( parse_characters )\n end\n end\n\n #close the libxml parser object\n #close\n\n #return the Nexml object\n @nexml\n end", "def parse\n level = @reader.level\n while @reader.level && @reader.level == level\n lev, tag, data = @reader.info\n @reader.advance\n\n # The default arguments to the XML builder will use the tag\n # value as the XML tag.\n xml_tag = tag.downcase\n attrs = {}\n\n # Concatendate any lower level continued data.\n while data && @reader.level && continued?(level)\n data << (@reader.data || \"\") << \"\\n\"\n @reader.advance\n end\n\n # If there are children, we will parse them in a block passed to\n # the builder.\n block = children?(level) ? lambda { parse } : nil\n\n # if the tag is a @xx@ reference, then the data becomes the tag\n # and the reference is passed as an 'id' attributes.\n if ref?(tag)\n xml_tag = data.downcase\n data = nil\n attrs['id'] = tag\n end\n\n # If the data is a @xx@ reference, then pass it as a 'ref'\n # attribute rather than a data value.\n if ref?(data)\n attrs['ref'] = data\n data = nil\n end\n\n # if there are children, then pass the data as a value attribute.\n if children?(level)\n attrs['value'] = data if exist?(data)\n data = nil\n end\n\n # Construct the arguments to the XML builder and call it.\n args = [xml_tag]\n args << data if exist?(data)\n args << attrs if exist?(attrs)\n @builder.tag!(*args, &block)\n end\n end", "def parse_root\n @scanner << \"\\n\" unless @scanner.string.end_with?(\"\\n\")\n\n s0 = @scanner.pos\n s1 = []\n s2 = parse_skipline\n while s2 != :failed\n s1 << s2\n s2 = parse_skipline\n end\n\n s2 = []\n s3 = parse_header\n while s3 != :failed\n s2 << s3\n s3 = parse_header\n end\n s3 = parse_initialboard\n s3 = nil if s3 == :failed\n s4 = []\n s5 = parse_header\n while s5 != :failed\n s4 << s5\n s5 = parse_header\n end\n parse_split\n s6 = parse_moves\n if s6 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s7 = []\n s8 = parse_fork\n while s8 != :failed\n s7 << s8\n s8 = parse_fork\n end\n parse_nl\n @reported_pos = s0\n s0 = transform_root(s2, s3, s4, s6, s7)\n end\n\n s0\n end", "def initialize(stream, listener)\n @stream = stream\n\n # this hack fixes REXML version \"2.7.3\" and \"2.7.4\"\n if REXML::Version==\"2.7.3\" || REXML::Version==\"2.7.4\"\n def @stream.read(len=nil)\n len = 100 unless len\n super(len)\n end\n def @stream.gets(char=nil)\n super(\">\")\n end\n def @stream.readline(char=nil)\n super(\">\")\n end\n def @stream.readlines(char=nil)\n super(\">\")\n end\n end\n\n @listener = listener\n @current = nil\n end", "def parse_json(stream)\n ::JSON.parse(stream)\n end", "def parse_new_node(node, options = {})\n content = \"\"\n parser = nil\n\n case node.type\n # Any function call\n when :send\n parser = CallParser.new(node, options)\n\n # Function args\n when :args\n parser = ArgsParser.new(node)\n\n # Class declaration\n when :class\n parser = ClassParser.new(node)\n\n # Assign var\n when :lvasgn, :ivasgn, :cvasgn\n parser = VarParser.new(node, options)\n\n when :lvar, :ivar\n return unless node.children.length > 0\n return node.children[0].to_s\n\n # Function declaration\n when :def, :defs\n parser = FunctionParser.new(node, options)\n\n # Basic types\n when :str, :int, :float, :true, :false, :nil\n parser = BaseTypeParser.new(node, node.type)\n\n # Blocks\n when :begin\n node.children.each do |child|\n parser = MasterParser.new\n content << parser.parse_new_node(child, options).to_s << \"\\n\"\n end\n\n return content\n\n # Else, error\n else\n raise \"Unsupported type \" + node.type.to_s\n end\n\n parser.parse\n parser\n end", "def decode_stream(stream)\n stream.each_line{|l|\n toks = l.split(/[ \\t\\r]/)\n next unless toks.length >= 2\n\n addrtok, optok = toks\n next unless is_addr(addrtok) && is_hexword(optok)\n\n address = hex_to_u32(addrtok)\n opcode = hex_to_u32(optok)\n\n out = decode(address, opcode)\n printf(\"%08x:\\t%08x\\t%s\\n\", address, opcode, out)\n }\nend", "def _parse_\n\t\t\tout = []\n\t\t\tstr = ''\n\t\t\tfresh = true\n\t\t\twhile @scanner.rest? do\n\t\t\t\t# last ||= 0\n\t\t\t\t# out.last.tap do |o|\n\t\t\t\t# \tif o.is_a?(Hash)\n\t\t\t\t# \t\tputs \"[#{@scanner.pos}] Parser has a Dictionary (#{o.class.name}) with data:\"\n\t\t\t\t# \t\to.each do |k, v|\n\t\t\t\t# \t\t\tputs \" #{k}: is #{v.class.name} with data: #{v.to_s[0..4]}#{\"...\" if v.to_s.length > 5}\"\n\t\t\t\t# \t\tend\n\t\t\t\t# \telse\n\t\t\t\t# \t\tputs \"[#{@scanner.pos}] Parser has #{o.class.name} with data: #{o.to_s[0..4]}#{\"...\" if o.to_s.length > 5}\"\n\t\t\t\t# \tend\n\t\t\t\t# \tputs \"next is #{@scanner.peek 8}\"\n\t\t\t\t# end unless (last == out.count) || (-1 == (last = out.count))\n\t\t\t\tcase\n\t\t\t\t##########################################\n\t\t\t\t## parse an Array\n\t\t\t\t##########################################\n\t\t\t\twhen @scanner.scan(/\\[/)\n\t\t\t\t\tout << _parse_\n\t\t\t\t##########################################\n\t\t\t\t## parse a Dictionary\n\t\t\t\t##########################################\n\t\t\t\twhen @scanner.scan(/<</)\n\t\t\t\t\tdata = _parse_\n\t\t\t\t\tobj = {}\n\t\t\t\t\tobj[data.shift] = data.shift while data[0]\n\t\t\t\t\tout << obj\n\t\t\t\t##########################################\n\t\t\t\t## return content of array or dictionary\n\t\t\t\t##########################################\n\t\t\t\twhen @scanner.scan(/\\]/), @scanner.scan(/>>/)\n\t\t\t\t\treturn out\n\t\t\t\t##########################################\n\t\t\t\t## parse a Stream\n\t\t\t\t##########################################\n\t\t\t\twhen @scanner.scan(/stream[\\r\\n]/)\n\t\t\t\t\t@scanner.pos += 1 if @scanner.peek(1) == \"\\n\".freeze && @scanner.matched[-1] != \"\\n\".freeze\n\t\t\t\t\t# the following was dicarded because some PDF files didn't have an EOL marker as required\n\t\t\t\t\t# str = @scanner.scan_until(/(\\r\\n|\\r|\\n)endstream/)\n\t\t\t\t\t# instead, a non-strict RegExp is used:\n\t\t\t\t\tstr = @scanner.scan_until(/endstream/)\n\t\t\t\t\t# raise error if the stream doesn't end.\n\t\t\t\t\traise \"Parsing Error: PDF file error - a stream object wasn't properly colsed using 'endstream'!\" unless str\n\t\t\t\t\t# need to remove end of stream\n\t\t\t\t\tif out.last.is_a? Hash\n\t\t\t\t\t\t# out.last[:raw_stream_content] = str[0...-10] #cuts only one EON char (\\n or \\r)\n\t\t\t\t\t\tout.last[:raw_stream_content] = unify_string str.sub(/(\\r\\n|\\n|\\r)?endstream\\z/, \"\").force_encoding(Encoding::ASCII_8BIT)\n\t\t\t\t\telse\n\t\t\t\t\t\twarn \"Stream not attached to dictionary!\"\n\t\t\t\t\t\tout << str.sub(/(\\r\\n|\\n|\\r)?endstream\\z/, \"\").force_encoding(Encoding::ASCII_8BIT)\n\t\t\t\t\tend\n\t\t\t\t##########################################\n\t\t\t\t## parse an Object after finished\n\t\t\t\t##########################################\n\t\t\t\twhen str = @scanner.scan(/endobj/)\n\t\t\t\t\t#what to do when this is an object?\n\t\t\t\t\tif out.last.is_a? Hash\n\t\t\t\t\t\tout << out.pop.merge({indirect_generation_number: out.pop, indirect_reference_id: out.pop})\n\t\t\t\t\telse\n\t\t\t\t\t\tout << {indirect_without_dictionary: out.pop, indirect_generation_number: out.pop, indirect_reference_id: out.pop}\n\t\t\t\t\tend\n\t\t\t\t\tfresh = true\n\t\t\t\t\t# puts \"!!!!!!!!! Error with :indirect_reference_id\\n\\nObject #{out.last} :indirect_reference_id = #{out.last[:indirect_reference_id]}\" unless out.last[:indirect_reference_id].is_a?(Fixnum)\n\t\t\t\t##########################################\n\t\t\t\t## parse a Hex String\n\t\t\t\t##########################################\n\t\t\t\twhen str = @scanner.scan(/<[0-9a-fA-F]+>/)\n\t\t\t\t\t# warn \"Found a hex string\"\n\t\t\t\t\tout << unify_string([str[1..-2]].pack('H*').force_encoding(Encoding::ASCII_8BIT))\n\t\t\t\t##########################################\n\t\t\t\t## parse a Literal String\n\t\t\t\t##########################################\n\t\t\t\twhen @scanner.scan(/\\(/)\n\t\t\t\t\t# warn \"Found a literal string\"\n\t\t\t\t\tstr = ''.force_encoding(Encoding::ASCII_8BIT)\n\t\t\t\t\tcount = 1\n\t\t\t\t\twhile count > 0 && @scanner.rest? do\n\t\t\t\t\t\tscn = @scanner.scan_until(/[\\(\\)]/)\n\t\t\t\t\t\tunless scn\n\t\t\t\t\t\t\twarn \"Unknown error parsing string at #{@scanner.pos} for string: #{str}!\"\n\t\t\t\t\t\t\tcount = 0 # error\n\t\t\t\t\t\t\tnext\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tstr += scn.to_s\n\t\t\t\t\t\tseperator_count = 0\n\t\t\t\t\t\tseperator_count += 1 while str[-2-seperator_count] == \"\\\\\"\n\n\t\t\t\t\t\tcase str[-1]\n\t\t\t\t\t\twhen '('\n\t\t\t\t\t\t\t## The following solution might fail when (string ends with this sign: \\\\)\n\t\t\t\t\t\t\tcount += 1 unless seperator_count.odd?\n\t\t\t\t\t\twhen ')'\n\t\t\t\t\t\t\tcount -= 1 unless seperator_count.odd?\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\twarn \"Unknown error parsing string at #{@scanner.pos} for string: #{str}!\"\n\t\t\t\t\t\t\tcount = 0 # error\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\t# The PDF formatted string is: str[0..-2]\n\t\t\t\t\t# now starting to convert to regular string\n\t\t\t\t\tstr_bytes = str.force_encoding(Encoding::ASCII_8BIT)[0..-2].bytes.to_a\n\t\t\t\t\tstr = []\n\t\t\t\t\tuntil str_bytes.empty?\n\t\t\t\t\t\tcase str_bytes[0]\n\t\t\t\t\t\twhen 13 # eol - \\r\n\t\t\t\t\t\t\t# An end-of-line marker appearing within a literal string without a preceding REVERSE SOLIDUS\n\t\t\t\t\t\t\t# shall be treated as a byte value of (0Ah),\n\t\t\t\t\t\t\t# irrespective of whether the end-of-line marker was a CARRIAGE RETURN (0Dh), a LINE FEED (0Ah), or both.\n\t\t\t\t\t\t\tstr_bytes.shift\n\t\t\t\t\t\t\tstr_bytes.shift if str_bytes[0] == 10\n\t\t\t\t\t\t\tstr << 10\n\t\t\t\t\t\twhen 10 # eol - \\n\n\t\t\t\t\t\t\t# An end-of-line marker appearing within a literal string without a preceding REVERSE SOLIDUS\n\t\t\t\t\t\t\t# shall be treated as a byte value of (0Ah),\n\t\t\t\t\t\t\t# irrespective of whether the end-of-line marker was a CARRIAGE RETURN (0Dh), a LINE FEED (0Ah), or both.\n\t\t\t\t\t\t\tstr_bytes.shift\n\t\t\t\t\t\t\tstr_bytes.shift if str_bytes[0] == 13\n\t\t\t\t\t\t\tstr << 10\n\t\t\t\t\t\twhen 92 # \"\\\\\".ord == 92\n\t\t\t\t\t\t\tstr_bytes.shift\n\t\t\t\t\t\t\trep = str_bytes.shift\n\t\t\t\t\t\t\tcase rep\n\t\t\t\t\t\t\twhen 110 #n\n\t\t\t\t\t\t\t\tstr << 10 #new line\n\t\t\t\t\t\t\twhen 114 #r\n\t\t\t\t\t\t\t\tstr << 13 # CR\n\t\t\t\t\t\t\twhen 116 #t\n\t\t\t\t\t\t\t\tstr << 9 #tab\n\t\t\t\t\t\t\twhen 98 #b\n\t\t\t\t\t\t\t\tstr << 8\n\t\t\t\t\t\t\twhen 102 #f\n\t\t\t\t\t\t\t\tstr << 255\n\t\t\t\t\t\t\twhen 48..57 #octal notation for byte?\n\t\t\t\t\t\t\t\trep = rep.chr\n\t\t\t\t\t\t\t\trep += str_bytes.shift.chr if str_bytes[0].between?(48,57)\n\t\t\t\t\t\t\t\trep += str_bytes.shift.chr if str_bytes[0].between?(48,57) && ((rep + str_bytes[0].chr).to_i <= 255)\n\t\t\t\t\t\t\t\tstr << rep.to_i\n\t\t\t\t\t\t\twhen 10 # new line, ignore\n\t\t\t\t\t\t\t\tstr_bytes.shift if str_bytes[0] == 13\n\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\twhen 13 # new line (or double notation for new line), ignore\n\t\t\t\t\t\t\t\tstr_bytes.shift if str_bytes[0] == 10\n\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tstr << rep\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tstr << str_bytes.shift\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tout << unify_string(str.pack('C*').force_encoding(Encoding::ASCII_8BIT))\n\t\t\t\t##########################################\n\t\t\t\t## Parse a comment\n\t\t\t\t##########################################\n\t\t\t\twhen str = @scanner.scan(/\\%/)\n\t\t\t\t\t#is a comment, skip until new line\n\t\t\t\t\tloop do\n\t\t\t\t\t\t# break unless @scanner.scan(/[^\\d\\r\\n]+/)\n\t\t\t\t\t\tbreak if @scanner.scan(/[^\\d]+[\\r\\n]+/) || @scanner.check(/([\\d]+[\\s]+[\\d]+[\\s]+obj[\\n\\r\\s]+\\<\\<)|([\\n\\r]+)/) || @scanner.eos?\n\t\t\t\t\t\t@scanner.pos += 1\n\t\t\t\t\tend\n\t\t\t\t\t# puts \"AFTER COMMENT: #{@scanner.peek 8}\"\n\t\t\t\t##########################################\n\t\t\t\t## Parse a Name\n\t\t\t\t##########################################\n\t\t\t\t# old, probably working version: when str = @scanner.scan(/\\/[\\#\\w\\d\\.\\+\\-\\\\\\?\\,]+/)\n\t\t\t\t# I don't know how to write the /[\\x21-\\x7e___subtract_certain_hex_values_here____]+/\n\t\t\t\t# all allowed regular caracters between ! and ~ : /[\\x21-\\x24\\x26\\x27\\x2a-\\x2e\\x30-\\x3b\\x3d\\x3f-\\x5a\\x5c\\x5e-\\x7a\\x7c\\x7e]+\n\t\t\t\t# all characters that aren't white space or special: /[^\\x00\\x09\\x0a\\x0c\\x0d\\x20\\x28\\x29\\x3c\\x3e\\x5b\\x5d\\x7b\\x7d\\x2f\\x25]+\n\t\t\twhen str = @scanner.scan(/\\/[^\\x00\\x09\\x0a\\x0c\\x0d\\x20\\x28\\x29\\x3c\\x3e\\x5b\\x5d\\x7b\\x7d\\x2f\\x25]+/)\n\t\t\t\t\tout << ( str[1..-1].gsub(/\\#[0-9a-fA-F]{2}/) {|a| a[1..2].hex.chr } ).to_sym\n\t\t\t\t##########################################\n\t\t\t\t## Parse a Number\n\t\t\t\t##########################################\n\t\t\t\twhen str = @scanner.scan(/[\\+\\-\\.\\d]+/)\n\t\t\t\t\tstr.match(/\\./) ? (out << str.to_f) : (out << str.to_i)\n\t\t\t\t##########################################\n\t\t\t\t## Parse an Object Reference\n\t\t\t\t##########################################\n\t\t\t\twhen @scanner.scan(/R/)\n\t\t\t\t\tout << { is_reference_only: true, indirect_generation_number: out.pop, indirect_reference_id: out.pop}\n\t\t\t\t\t@references << out.last\n\t\t\t\t##########################################\n\t\t\t\t## Parse Bool - true and after false\n\t\t\t\t##########################################\n\t\t\t\twhen @scanner.scan(/true/)\n\t\t\t\t\tout << true\n\t\t\t\twhen @scanner.scan(/false/)\n\t\t\t\t\tout << false\n\t\t\t\t##########################################\n\t\t\t\t## Parse NULL - null\n\t\t\t\t##########################################\n\t\t\t\twhen @scanner.scan(/null/)\n\t\t\t\t\tout << nil\n\t\t\t\t##########################################\n\t\t\t\t## XREF - check for encryption... anything else?\n\t\t\t\t##########################################\n\t\t\t\twhen @scanner.scan(/xref/)\n\t\t\t\t\t##########\n\t\t\t\t\t## get root object to check for encryption\n\t\t\t\t\t@scanner.scan_until(/(trailer)|(\\%EOF)/)\n\t\t\t\t\tfresh = true\n\t\t\t\t\tif @scanner.matched[-1] == 'r'\n\t\t\t\t\t\tif @scanner.skip_until(/<</)\n\t\t\t\t\t\t\tdata = _parse_\n\t\t\t\t\t\t\t@root_object ||= {}\n\t\t\t\t\t\t\t@root_object[data.shift] = data.shift while data[0]\t\t\t\t\t\t\n\t\t\t\t\t\tend\n\t\t\t\t\t\t##########\n\t\t\t\t\t\t## skip untill end of segment, maked by %%EOF\n\t\t\t\t\t\t@scanner.skip_until(/\\%\\%EOF/)\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\twhen @scanner.scan(/[\\s]+/)\n\t\t\t\t\t# Generally, do nothing\n\t\t\t\t\tnil\n\t\t\t\twhen @scanner.scan(/obj[\\s]*/)\n\t\t\t\t\t# Fix wkhtmltopdf PDF authoring issue - missing 'endobj' keywords\n\t\t\t\t\tunless fresh || (out[-4].nil? || out[-4].is_a?(Hash))\n\t\t\t\t\t\tkeep = []\n\t\t\t\t\t\tkeep << out.pop # .tap {|i| puts \"#{i} is an ID\"} \n\t\t\t\t\t\tkeep << out.pop # .tap {|i| puts \"#{i} is a REF\"} \n\n\t\t\t\t\t\tif out.last.is_a? Hash\n\t\t\t\t\t\t\tout << out.pop.merge({indirect_generation_number: out.pop, indirect_reference_id: out.pop})\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tout << {indirect_without_dictionary: out.pop, indirect_generation_number: out.pop, indirect_reference_id: out.pop}\n\t\t\t\t\t\tend\n\t\t\t\t\t\twarn \"'endobj' keyword was missing for Object ID: #{out.last[:indirect_reference_id]}, trying to auto-fix issue, but might fail.\"\n\n\t\t\t\t\t\tout << keep.pop\n\t\t\t\t\t\tout << keep.pop\n\t\t\t\t\tend\n\t\t\t\t\tfresh = false\n\t\t\t\telse\n\t\t\t\t\t# always advance \n\t\t\t\t\t# warn \"Advnacing for unknown reason... #{@scanner.peek(4)}\" unless @scanner.peek(1) =~ /[\\s\\n]/\n\t\t\t\t\twarn \"Warning: parser advnacing for unknown reason. Potential data-loss.\"\n\t\t\t\t\t@scanner.pos = @scanner.pos + 1\n\t\t\t\tend\n\t\t\tend\n\t\t\tout\n\t\tend", "def parse\n parse_file\n self\n end", "def stream_node(bt, reds, pointer_info, acc, dir, start_key = nil, &fun)\n # pp :stream_node => {:bt => bt, :reds => reds, :pointer_info => pointer_info, :start_key => start_key, :dir => dir, :acc => acc}\n pointer, _reds = *pointer_info\n # p :stream_node => { :_reds => _reds, :pointer => pointer }\n\n return :ok, acc if pointer_info.nil?\n\n node_type, node_list = get_node(bt, pointer)\n # p :node_type => node_type, :node_list => node_list\n adjusted_list = adjust_dir(dir, node_list)\n # p :adjusted_list => adjusted_list\n\n if start_key\n case node_type\n when :kp_node; stream_kp_node(bt, reds, adjusted_list, acc, dir, start_key, &fun)\n when :kv_node; stream_kv_node(bt, reds, adjusted_list, acc, dir, start_key, &fun)\n else\n raise \"invalid start_key: %p\" % [start_key]\n end\n else\n case node_type\n when :kp_node; stream_kp_node(bt, reds, adjusted_list, acc, dir, &fun)\n when :kv_node; stream_kv_node2(bt, reds, [], adjusted_list, acc, dir, &fun)\n else\n raise \"No such node_type\"\n end\n end\n end", "def parse(source)\n Parser.parse(source)\n end", "def start\n REXML::Document.parse_stream(@source, self)\n end", "def parse(input)\n rownum = 0\n @header = nil if first_line_is_header\n lines = input.each_line.to_a\n lines.each do |line|\n line = line.encode('utf-8')\n rownum += 1\n\n next if rownum <= skip_initial_rows\n next if rownum > lines.size - skip_trailing_rows\n\n values = line.chomp.split(separator)\n\n if first_line_is_header and @header.nil?\n @header = values\n next\n end\n\n begin\n @entries << make_entry(values)\n rescue RuntimeError => e\n raise ParseStreamError.new(\"line #{rownum}: #{e.message}\", e, rownum, line)\n end\n end\n end", "def parse(source_buffer); end", "def parse(source_buffer); end", "def parse(source_buffer); end", "def parse(s)\n parser = Stupidedi::Builder::StateMachine.build(@config)\n machine, result = parser.read(Stupidedi::Reader.build(s))\n\n # Report fatal tokenizer failures\n if result.fatal?\n result.explain{ |reason| raise reason + \" at #{result.position.inspect}\" }\n end\n machine\n end", "def parse(source)\n @parser.parse(@scanner.scan(source))\n end", "def decode_first_from_stream(stream, schema_name: nil, namespace: @namespace)\n data = decode_all_from_stream(stream, schema_name: schema_name, namespace: namespace)\n data.first\n end", "def parse_node(node, relative_to)\n\t\traise '`relative_to\\' must be a pathname' unless relative_to.kind_of?(Pathname)\n\n\t\tif node.kind_of? Hash\n\t\t\treturn parse_hash(node, relative_to)\n\t\telsif node.kind_of? String\n\t\t\treturn parse_string(node)\n\t\telsif node.nil?\n\t\t\treturn YamlNopInstruction.new\n\t\telse\n\t\t\traise \"Unsupported YAML node \\'#{node}' of type \\'#{node.class}'\"\n\t\tend\n\tend", "def parse_tag_to_tree(html_str)\n node = Struct.new(:type, :classes, :id, :name, :text_content, :children, :parents)\n parser = node.new\n parser.type = html_str.scan(/<[a-z0-9]+/)[0][1..-1] if html_str[0] != \" \"\n parser.classes = html_str.scan(/class='(.*?)'/).join.split(\" \")\n parser.id = html_str.scan(/id='(.*?)'/).join\n parser.name = html_str.scan(/name='(.*?)'/).join\n parser.children = []\n parser.parents = nil\n parser\nend", "def parse(data); end", "def parse(io)\n source = Parslet::Source.new(io)\n context = Parslet::Atoms::Context.new\n \n result = nil\n value = apply(source, context)\n \n # If we didn't succeed the parse, raise an exception for the user. \n # Stack trace will be off, but the error tree should explain the reason\n # it failed.\n if value.error?\n parse_failed(value.message)\n end\n \n # assert: value is a success answer\n \n # If we haven't consumed the input, then the pattern doesn't match. Try\n # to provide a good error message (even asking down below)\n unless source.eof?\n # Do we know why we stopped matching input? If yes, that's a good\n # error to fail with. Otherwise just report that we cannot consume the\n # input.\n if cause \n # We're not using #parse_failed here, since it assigns to @last_cause.\n # Still: We'll raise this differently, since the real cause is different.\n raise Parslet::UnconsumedInput, \n \"Unconsumed input, maybe because of this: #{cause}\"\n else\n old_pos = source.pos\n parse_failed(\n format_cause(source, \n \"Don't know what to do with #{source.read(100)}\", old_pos), \n Parslet::UnconsumedInput)\n end\n end\n \n return flatten(value.result)\n end", "def read_trees(filename)\n log(\"Reading #{filename}...\")\n File.open(filename, \"r\") do |file|\n file.readlines.collect do |line|\n Tree.from_string(line)\n end\n end\nend", "def populate(array)\n @root = Node.new({type: :document}, [], nil, 0)\n @total_nodes += 1\n @max_depth = 0\n current_node = @root\n current_depth = 0\n array.each do |hash|\n # opening tag - create new node\n if NODE_DOWN.include? hash[:type]\n #if <> depth += 1\n new_node = Node.new(hash, [], current_node, current_node.depth + 1)\n current_node.children << new_node\n current_node = new_node\n current_depth += 1\n @total_nodes += 1\n else #hash[:type] == \"close\"\n #if </> depth -= 1\n new_node = Node.new(hash, [], current_node, current_node.depth)\n current_node.children << new_node\n current_node = current_node.parent\n current_depth -= 1\n @total_nodes += 1\n end\n\n if current_depth > @max_depth\n @max_depth = current_depth\n end\n\n if hash[:type] == :text && current_node.children.empty?\n current_depth -= 1\n current_node = current_node.parent\n end\n end\n self\n end", "def load_node(line)\n name, klass, parent = line.split(field_sep)\n [klass.constantize.new(name, nil), parent]\n end", "def parse\n parser = REXML::Parsers::SAX2Parser.new @stream \n parser.listen( :start_element ) do |uri, localname, qname, attributes|\n case qname\n when \"CougaarEvents\"\n @node = attributes['Node']\n @experiment = attributes['experiment']\n #puts \" Node: #{@node} Experiment: #{@experiment}\"\n @started = true\n when \"CougaarEvent\" \n @current = CougaarEvent.new\n @current.node = @node\n @current.data = \"\"\n @current.experiment = @experiment\n @current.event_type = attributes['type']\n @current.cluster_identifier = attributes['clusterIdentifier']\n @current.component = attributes['component']\n else\n @current.data << \"<#{qname}\"\n attributes.each do |key, value| \n @current.data << \" #{key} = \\\"#{value}\\\"\"\n end\n @current.data << \" >\"\n end\n end\n parser.listen( :end_element ) do |uri, localname, qname|\n case qname\n when \"CougaarEvents\"\n @node = nil\n @started = false\n when \"CougaarEvent\"\n @current.data = [@current.data].pack(\"m\")\n @listener.call(@current)\n @current = nil\n else\n @current.data << \"</#{qname}>\"\n end\n end\n parser.listen( :characters ) do | text |\n @current.data << text if @current\n end\n parser.listen( :cdata ) do | text |\n @current.data << text if @current\n end\n parser.parse\n end", "def parse_root\n s0 = @scanner.pos\n s1 = []\n s2 = parse_header\n while s2 != :failed\n s1 << s2\n s2 = parse_header\n end\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s2 = parse_initialboard\n s2 = nil if s2 == :failed\n s3 = []\n s4 = parse_header\n while s4 != :failed\n s3 << s4\n s4 = parse_header\n end\n s4 = parse_moves\n if s4 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s5 = []\n s6 = parse_fork\n while s6 != :failed\n s5 << s6\n s6 = parse_fork\n end\n @reported_pos = s0\n s0 = transform_root(s1, s2, s3, s4, s5)\n end\n end\n s0\n end", "def _parse_for_prot_groups(stream, with_peps=false, tp='axml')\n prtgrps = []\n case tp\n when 'axml'\n root = AXML.parse(stream)\n root.protein_group.each do |protein_group|\n pg = ProtGroup.new(protein_group.attrs) do \n protein_group.map do |protein|\n Prot.new(protein.attrs)\n end\n end\n prtgrps << pg \n end\n end\n prtgrps\n end", "def load( stream )\n Marhsal.load( stream )\n end", "def parse( x )\n cycle( xml( x ) )\n end", "def parse!(content)\n @children = []\n @content = ''\n\n # Parse all direct children and create new markdown objects\n sections = Section.generate_sections(content)\n\n # No children!\n if sections.empty?\n @content = content\n return\n end\n\n # Populate content prior to found headers\n @content = content[0..sections.first.header_location.begin - 1] if sections.first.header_location.begin > 0\n\n parse_children!(sections)\n end", "def parse(content, open_tags, prev_level, root_level)\n File.open(\"#{file.path}\", \"r\").each_line do |line|\n\n next if /^\\s*$/ === line\n\n line = line.chomp.split(/\\s+/, 3)\n \n level = line.shift.to_i\n \n if prev_level.nil?\n prev_level = root_level = level-1 # not assuming base level is 0\n end\n \n (level..prev_level).to_a.reverse.each do |i|\n content << \"\\t\" * (i - root_level) if content[-1] == ?\\n\n content << \"</#{open_tags.pop}>\\n\"\n end\n \n if line[0][0] == ?@\n xref_id, tag = line\n xref_id.gsub!(/^@(.*)@$/, '\\1')\n id_attr = ' id=\"' + xref_id + '\"'\n value = ''\n else\n tag, value = line\n id_attr = ''\n value ||= ''\n if /^@(\\w+)@$/ === value\n value = \"<xref>#{$1}</xref>\"\n else\n value.gsub!(/&/, '&amp;')\n value.gsub!(/</, '&lt;')\n value.gsub!(/>/, '&gt;')\n end\n end\n \n if tag == 'CONC' || tag == 'CONT'\n content << (tag == 'CONT' ? \"\\n\" : \" \")\n content << value\n level -= 1\n else\n content << \"\\n\" if level > prev_level\n tag.downcase!\n content << \"\\t\" * (level - root_level) + \"<#{tag}#{id_attr}>#{value}\"\n open_tags.push tag\n end\n \n prev_level = level\n end\n content\n end", "def parse(data)\n if !data.respond_to?(:read)\n data = StringIO.new(data || \"\")\n end\n\n if data.eof?\n {}\n else\n require_rexml unless defined?(REXML::Document)\n doc = REXML::Document.new(data)\n\n if doc.root\n merge_element!({}, doc.root, XmlMini.depth)\n else\n raise REXML::ParseException,\n \"The document #{doc.to_s.inspect} does not have a valid root\"\n end\n end\n end", "def build_parse_tree(exp)\n exp_arr = exp.split\n tree_stack = Stack.new\n tree = BinaryTree.new('')\n current_tree = tree\n exp_arr.each do |i|\n if i == '('\n current_tree.insert_left('')\n tree_stack.push(current_tree)\n current_tree = current_tree.left_child\n elsif i.match(/\\d/)\n current_tree.set_root_value(Integer(i))\n parent = tree_stack.pop\n current_tree = parent\n elsif ['+', '-', '*', '/'].include?(i)\n current_tree.set_root_value(i)\n current_tree.insert_right('')\n tree_stack.push(current_tree)\n current_tree = current_tree.right_child\n elsif i == ')'\n current_tree = tree_stack.pop\n else\n fail 'Invalid Argument'\n end\n end\n tree\nend", "def parse(io_or_str, &nuke_node_callback)\n raise LocalJumpError, \"NodeProcesssor#parse totally requires a block\" unless block_given?\n @node_handler = nuke_node_callback\n @parser.parse(io_or_str)\n end", "def parse(body)\n new Nokogiri body\n end", "def create_java_test_node\n File.open(@file_name, \"r\") do |f|\n f.each_with_index do |line, index|\n if index == 0\n @stack = []\n @stack.push(@root)\n parent = @root\n end\n line.chomp!\n next if line.empty? || line.nil?\n prelim_whitespace = 0\n line.each_byte do |byte|\n break if byte != 32\n prelim_whitespace += 1\n end\n\n stripped_line = line.strip\n next if stripped_line.nil? || stripped_line.empty?\n\n case stripped_line\n when /^package/\n node = Tree.new(format_java_description(line), prelim_whitespace)\n node.file_name = @file_name\n parent = fetch_parent(@stack, node)\n if parent\n parent.children << node\n node.parent = parent\n end\n node.structure_marker = 'package'\n @stack.push(node)\n when /^public class/\n node = Tree.new(format_java_description(line), prelim_whitespace)\n node.file_name = @file_name\n parent = fetch_parent(@stack, node)\n if parent\n parent.children << node\n node.parent = parent\n end\n node.structure_marker = 'java_class'\n @stack.push(node)\n when /^public void/\n node = Tree.new(format_java_description(line), prelim_whitespace)\n node.file_name = @file_name\n parent = fetch_parent(@stack, node)\n if parent\n parent.children << node\n node.parent = parent\n end\n node.structure_marker = 'test'\n else\n end\n end\n end\n @root\n end", "def create_java_test_node\n File.open(@file_name, \"r\") do |f|\n f.each_with_index do |line, index|\n if index == 0\n @stack = []\n @stack.push(@root)\n parent = @root\n end\n line.chomp!\n next if line.empty? || line.nil?\n prelim_whitespace = 0\n line.each_byte do |byte|\n break if byte != 32\n prelim_whitespace += 1\n end\n\n stripped_line = line.strip\n next if stripped_line.nil? || stripped_line.empty?\n\n case stripped_line\n when /^package/\n node = Tree.new(format_java_description(line), prelim_whitespace)\n node.file_name = @file_name\n parent = fetch_parent(@stack, node)\n if parent\n parent.children << node\n node.parent = parent\n end\n node.structure_marker = 'package'\n @stack.push(node)\n when /^public class/\n node = Tree.new(format_java_description(line), prelim_whitespace)\n node.file_name = @file_name\n parent = fetch_parent(@stack, node)\n if parent\n parent.children << node\n node.parent = parent\n end\n node.structure_marker = 'java_class'\n @stack.push(node)\n when /^public void/\n node = Tree.new(format_java_description(line), prelim_whitespace)\n node.file_name = @file_name\n parent = fetch_parent(@stack, node)\n if parent\n parent.children << node\n node.parent = parent\n end\n node.structure_marker = 'test'\n else\n end\n end\n end\n @root\n end", "def detect_format(stream)\n # Got to look into the file to see\n if stream.respond_to?(:rewind) && stream.respond_to?(:read)\n stream.rewind\n string = stream.read(1000)\n stream.rewind\n else\n string = stream.to_s\n end\n case string\n when /<html/i then RDF::RDFa::Reader\n when /\\{\\s*\\\"@\\\"/i then JSON::LD::Reader\n else RDF::Turtle::Reader\n end\nend", "def initialize(stream, listener)\n @stream = stream\n @listener = listener\n @current = nil\n @node=nil\n end", "def parse str\n self.ss = scanner_class.new str\n self.state ||= nil\n\n do_parse\n end", "def parse str\n self.ss = scanner_class.new str\n self.state ||= nil\n\n do_parse\n end", "def parse str\n self.ss = scanner_class.new str\n self.state ||= nil\n\n do_parse\n end", "def parse str\n self.ss = scanner_class.new str\n self.state ||= nil\n\n do_parse\n end", "def parsed\n return @parsed if instance_variable_defined? :@parsed\n\n if source =~ /^(---\\s*\\n.*?\\n?)^(---\\s*$\\n?)/m\n { metadata: YAML.load($1), content: $' }\n else\n { metadata: {}, content: source }\n end\n end", "def detect_format(stream)\n # Got to look into the file to see\n if stream.is_a?(IO) || stream.is_a?(StringIO)\n stream.rewind\n string = stream.read(1000)\n stream.rewind\n else\n string = stream.to_s\n end\n case string\n when /<(\\w+:)?RDF/ then RDF::RDFXML::Reader\n when /<html/i then RDF::RDFa::Reader\n when /@prefix/i then RDF::Turtle::Reader\n else RDF::NTriples::Reader\n end\nend", "def import_hierarchy(stream)\n uri = build_uri('import-hierarchy')\n req = Net::HTTP::Post.new(uri, DEFAULT_HEADERS)\n req['Transfer-Encoding'] = ['chunked']\n req.body_stream = stream\n resp = request(req)\n return true if resp.code == '204'\n raise_on_non_200(resp, 204)\n end", "def parse(parser,i=0,previous_level=0,parent=nil)\n if i < parser.headlines.count\n hl = parser.headlines[i]\n #str = hl.to_s.gsub('*','').gsub(' ','')\n str = hl.to_s\n level = hl.level\n if (level - previous_level == 1) && previous_level != 0\n parent = parser.headlines[i-1]\n $last_parent[level] = parent\n elsif level == previous_level || level < previous_level\n parent = $last_parent[level]\n else\n parent = nil\n end\n #TODO Fix order\n hl.body_lines.shift #remove title\n $headlines << {:id => Digest::MD5.hexdigest(hl.to_s), :title => str, :body => hl.body_lines.join(\"\\n\"), :level => hl.level, :parent => Digest::MD5.hexdigest(parent.to_s), :tags => hl.tags}\n if parent\n unless $children[Digest::MD5.hexdigest(parent.to_s)]\n $children[Digest::MD5.hexdigest(parent.to_s)] = []\n end\n $children[Digest::MD5.hexdigest(parent.to_s)] << {:title => str, :body => hl.body_lines.join(\"\\n\"), :parent => Digest::MD5.hexdigest(parent.to_s)}\n end\n parse(parser,i+1,level,parent)\n end\nend", "def initialize(stream, listener)\n @stream = stream\n # this hack fixes REXML version \"2.7.3\"\n if REXML::Version==\"2.7.3\"\n def @stream.read(len=nil)\n len = 100 unless len\n super(len)\n end\n end\n @listener = listener\n @current = nil\n end", "def parse! raw_xml_response, mediainfo_object\n # puts \"#{raw_xml_response}\"\n REXML::Document.new(raw_xml_response).elements.each(\"/Mediainfo/File/track\") { |track|\n # we create a \"Stream\" object, depending on the Stream type\n stream = StreamFactory.create track.attributes['type']\n\n # we get each tag about the stream\n track.children.select { |n| n.is_a? REXML::Element }.each do |c|\n # we convert the tag name to a ruby-attribute-compatible name\n tag_name = c.name.strip # remove whitespaces at the beginning and the end\n tag_name = tag_name.gsub(/ +/, \"_\") # we replace spaces by '_'\n # we replace characters forbidden in Ruby method names by '_':\n tag_name = tag_name.gsub(/[\\(\\)\\{\\}\\[\\]\\*\\/\\\\,;\\.:\\+=\\-\\^\\$\\!\\?\\|@#\\&\"'`]+/, '_')\n tag_name = tag_name.gsub(/^_+/, \"\") # remove '_' at the beginning\n tag_name = tag_name.gsub(/_+$/, \"\") # remove '_' at the end\n tag_name = tag_name.gsub(/_+/, \"_\") # we replace several '_' following by a single one\n tag_name = tag_name.downcase\n\n # if there is an attribute in the Stream class,\n # that has the same name as the tag name, we set it with the tag content\n if stream.class.method_defined? tag_name + \"=\"\n # we call the method which name is the content of the string tag_name\n stream.send tag_name + \"=\", c.text.strip\n else\n # to print the tag ignored, in case we want to support them\n # puts \"#{stream.class}: tag ignored: #{tag_name}, #{c.text.strip}\"\n end\n end\n \n # we add the Stream objects to the MediaInfo object\n mediainfo_object.streams << stream\n }\n end", "def parse!\n return if @parsed\n \n log_data = `git log -1 HEAD 2> /dev/null`\n \n unless log_data.empty?\n # DETERMINING PARENTS\n commit = log_data[/^commit (.+)$/, 1]\n dad = commit ? commit[0..6] : nil\n mom = nil\n \n if log_data =~ /^Merge: (.+)\\.\\.\\. (.+)\\.\\.\\.$/ # Merge: 1c002dd... 35cfb2b...\n dad = $1 # just have them both use the short name, nbd\n mom = $2\n end\n \n @parents = [dad, mom].compact.map {|p| Changeset.new @repo, p }\n else\n @parents = []\n end\n @parsed = true\n end", "def parse_file(path)\n if (!File.exists?(path))\n LOGGER.e {\"Unable to open specified file to parse: '#{path}'\"}\n return nil\n end\n \n File.open(path, 'r') do |f|\n parse_stream(f)\n end\n end", "def start(options={},&block)\n @stdout = options[:stdout] || $stdout\n @stderr = options[:stdout] || @stdout\n @stdin = options[:stdin] || $stdin\n while line = @stdin == $stdin ? Readline.readline(\"> \", true) : @stdin.gets \n line.strip!\n next if line.length==0\n parse_tree_node = parser.parse line\n if parse_tree_node\n evaluate parse_tree_node, &block\n else\n errputs parser.parser_failure_info :verbose => true\n end\n end\n end", "def detect_format(stream)\n # Got to look into the file to see\n if stream.is_a?(IO) || stream.is_a?(StringIO)\n stream.rewind\n string = stream.read(1000)\n stream.rewind\n else\n string = stream.to_s\n end\n case string\n when /<html/i then RDF::RDFa::Reader\n when /@prefix/i then RDF::Turtle::Reader\n else RDF::NTriples::Reader\n end\n end", "def parse; end", "def parse; end", "def parse; end", "def Graph(str)\n graph = Graph.new\n nodes = {}\n str.lines.each do |line|\n case line\n when /^\\s*(\\w+):(.*)$/\n name,code = $~[1,2]\n graph << (nodes[name] = eval(code))\n when /^\\s*(\\w+)\\s*->\\s*(\\w+)((\\s*->\\s*\\w+)*)\\s*(#.*)?$/\n name1,name2,others = $~[1,3]\n [name1,name2].each do |name|\n raise \"Undefined node: #{name} on line: #{line}\" if not nodes.key? name\n end\n nodes[name1].out << nodes[name2]\n \n if others != \"\"\n # repeat on the part of this line which we have not processed yet\n line = name2+others\n redo\n end\n when /^\\s*(#.*)?$/\n next\n else\n raise \"Couldn't parse this line: #{line}\"\n end\n end\n raise \"No start node defined! There should be a node called START.\" if not nodes.key? 'START'\n graph.start = nodes['START']\n graph\nend", "def initialize stream, value=nil, parent=nil, reference=false\n super(parent)\n @ndata = @pubid = @value = @external = nil\n if stream.kind_of? Array\n @name = stream[1]\n if stream[-1] == '%'\n @reference = true\n stream.pop\n else\n @reference = false\n end\n if stream[2] =~ /SYSTEM|PUBLIC/\n @external = stream[2]\n if @external == 'SYSTEM'\n @ref = stream[3]\n @ndata = stream[4] if stream.size == 5\n else\n @pubid = stream[3]\n @ref = stream[4]\n end\n else\n @value = stream[2]\n end\n else\n @reference = reference\n @external = nil\n @name = stream\n @value = value\n end\n end", "def parse(source)\n raise \"Attempt to continue parsing using finalized parser\" if @finished\n\n source.each_char() { |char|\n if @mode == :read_comment\n if char == \"\\n\"\n @mode = :find_name\n end\n elsif @in_escape == true\n buffer(case char\n when 'n' then \"\\n\"\n when 'r' then \"\\r\"\n when 'a' then \"\\a\"\n when 'b' then \"\\b\"\n when 'f' then \"\\f\"\n when 't' then \"\\t\"\n when '0' then \"\\0\"\n else char\n end, true)\n @in_escape = false\n else\n case char\n when ' ', \"\\t\"\n if @mode == :read_name\n parsedName(grab_and_reset_buffer())\n @mode = :find_value\n elsif ! ((@consume_whitespace && @last_char == char) || @mode == :find_name || @mode == :find_value)\n buffer char\n end\n\n when '{'\n case @mode\n when :read_name, :find_value\n parsedName(grab_and_reset_buffer()) if @mode == :read_name\n parsedNodeOpening()\n @depth += 1\n\n when :read_value, :find_name\n parsedValue(grab_and_reset_buffer()) if @mode == :read_value\n if @depth == 0 && @nameless_roots\n @depth += 1\n parsedName('')\n parsedNodeOpening()\n else\n raise error_string('Invalid character { - expected name.')\n end\n\n else\n raise error_string('Invalid character { - expected name.')\n end\n\n @mode = :find_name\n\n when '}'\n case @mode\n when :read_name, :find_value\n parsedName(grab_and_reset_buffer()) if @mode == :read_name\n parsedValue('')\n\n when :read_value\n parsedValue(grab_and_reset_buffer())\n end\n\n if @depth == 0\n raise error_string(\"Unexpected } - no matching {.\")\n end\n\n @depth -= 1\n @mode = :find_name\n\n parsedNodeClosing()\n\n when \"\\n\", '#', ';'\n case @mode\n when :read_name, :find_value\n parsedName(grab_and_reset_buffer()) if @mode == :read_name\n parsedValue('')\n when :read_value\n parsedValue(grab_and_reset_buffer())\n end\n\n @mode = char == '#' ? :read_comment : :find_name\n\n when \"\\\\\"\n @in_escape = true\n\n else\n if @mode == :find_name\n @mode = :read_name\n elsif @mode == :find_value\n @mode = :read_value\n end\n\n buffer(char)\n\n end\n end\n\n @last_char = char\n\n if char == \"\\n\"\n @line += 1\n @column = 1\n else\n @column += 1\n end\n }\n end", "def parse_content(content); end", "def test\n sentence = \"(S (NP (NNP John)) (VP (V runs)))\"\n test = Tree.new(sentence)\n end" ]
[ "0.7480541", "0.63556576", "0.63311917", "0.6061552", "0.6050684", "0.5991325", "0.5863618", "0.582962", "0.5777376", "0.5757155", "0.5756618", "0.56822157", "0.5677197", "0.56628925", "0.5604052", "0.5592924", "0.5585131", "0.55820906", "0.5558012", "0.55352855", "0.5532359", "0.5484673", "0.5481451", "0.54764175", "0.5447535", "0.5411115", "0.53770393", "0.5362698", "0.5354608", "0.53351384", "0.53332347", "0.5291086", "0.52892953", "0.5269775", "0.52215105", "0.520914", "0.5207036", "0.5194276", "0.5189669", "0.5181166", "0.51774114", "0.5170248", "0.51459175", "0.5142527", "0.5137016", "0.5136522", "0.5132796", "0.51305604", "0.51296", "0.5117104", "0.50918317", "0.50918317", "0.50918317", "0.5089267", "0.5088122", "0.5086238", "0.50815004", "0.50765634", "0.5073393", "0.5067", "0.50635266", "0.5062975", "0.50623345", "0.50543815", "0.50537467", "0.50499755", "0.5046987", "0.503729", "0.5015938", "0.50026625", "0.499298", "0.49918932", "0.49821383", "0.49798927", "0.49794406", "0.49794406", "0.49702966", "0.4968565", "0.49654558", "0.49654558", "0.49654558", "0.49654558", "0.4959709", "0.4958323", "0.4957502", "0.495126", "0.49472657", "0.49420848", "0.4938106", "0.49379808", "0.49375442", "0.49280608", "0.492772", "0.492772", "0.492772", "0.49248827", "0.49108183", "0.49105167", "0.49042508", "0.4901858" ]
0.6902235
1
Splits a line into a series of tokens
def tokenize(line) tokens.clear return if line.size == 0 line = line.tr("\t", ' ') token_start = 0 i = 0 chars = line.chars while i < line.size do c = chars[i] if c == ' ' # eat the spaces! if token_start != i tokens << line[token_start, i - token_start] end token_start = i + 1 elsif c == '"' # skip ahead to the next quote end_quotes = line.index('"', i + 1) raise UnmatchedQuoteError.new("Unmatched quote on '#{line}'") if end_quotes.nil? tokens << line[i + 1, end_quotes - i - 1] i = end_quotes token_start = i + 1 else # skip ahead to the next space next_space = line.index(' ', i) || -1 i = next_space - 1 break if i < 0 end i += 1 end if token_start < line.size # append the remainder of the string, after we ran out of spaces tokens << line[token_start, line.size - token_start] end return tokens end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tokenize_line(line)\n # Adding spaces around parens to make tokenization trivial.\n line = line.gsub(/\\(/, ' ( ')\n line = line.gsub(/\\)/, ' ) ')\n line.split\n end", "def process_line(line)\n line.split ' '\n end", "def split_line(line)\n tmpLine = line.clone\n chunks = []\n\n while tmpLine != ''\n tmpLine.sub!(/^\\s*/,\"\")\n tmpLine.sub!(/^([a-z0-9_\"]+)(\\((([^()]+|\\([^()]*\\))*)\\))?/i,\"\")\n break if $&.nil?\n chunks.push $& unless $& == ''\n end\n\n chunks\n end", "def split_line(line)\n raise ArgumentError, 'can not parse empty line' if line.empty?\n\n # Split the line by using a regex.\n # / / symbolises start and end of regex.\n # \\s+ means one or multiple whitespaces\n line = line.strip.split(/\\s+/)\n \n return line\nend", "def tokens_in_line(board, line)\n line_tokens = line.collect {|index| board.cells[index.to_i]}\n end", "def get_tokens(lines)\n tokens = []\n chunk = \"\"\n\n lines.each do |line|\n case line\n when /^[#\\+\\-]+.*$/ # Headers\n unless chunk == \"\"\n tokens += [chunk.strip]\n chunk = \"\"\n end\n\n tokens += [line.strip]\n when /^\\s*$/ # Ends or Starts of paragraphs\n unless chunk == \"\"\n tokens += [chunk.strip]\n chunk = \"\"\n end\n else #Paragraphs\n chunk += line.strip + \" \"\n end\n end\n\n tokens += [chunk.strip] unless chunk == \"\"\n tokens\nend", "def parse(lineno, line)\n tokens = GedLine.new *line.chomp.strip.split(/\\s/)\n parse_line(lineno, tokens)\n end", "def split_line(line)\n line.split(Mergeit::Config::FILE_FORMAT[:delimeter], Mergeit::Config::SUPPORTED_PARTS[:size])\n end", "def tokenize ln, line\r\n pure_line = line.gsub(/^#{regex_line_comment}/, '') # trim line comment marker\r\n\r\n indent_level = 0\r\n processor_name = '_raw'\r\n line_code = ''\r\n block_open = false\r\n if matches = /#{regex_proc_line}/.match(pure_line) \r\n processor_name = matches[\"processor_name_\"]\r\n indent_level = matches[\"leading_spaces_\"].size\r\n line_code = matches[\"line_code_\"]\r\n block_open = true if /#{regex_block_start}\\s*$/ =~ line_code\r\n line_code.gsub!(/\\s*(#{regex_block_start})?\\s*$/, '') \r\n elsif matches = /^#{regex_proc_head}[^\\s]/.match(pure_line) \r\n indent_level = matches[\"leading_spaces_\"].size\r\n end\r\n\r\n Token.new ln, line, indent_level, processor_name, line_code, block_open \r\n end", "def lex_line\n @chunks = @line.scan(/#{BRACKET_RE}|#{DATE_RE}|#{MOD_RE}|#{ATTR_REGEX}|#{OTHER_RE}/).chunk do |seg|\n case seg\n when BRACKET_RE then :bracket\n when MOD_RE then :modifier\n when DATE_RE then :date\n when ATTR_REGEX then :attr\n when OTHER_RE then :other\n else :error\n end\n end.to_a\n # it should be impossible to encounter errors, but cry if they happen\n check_for_errors\n @chunks\n end", "def shellsplit(line, rule_set=nil)\n (rule_set || @@default_rule_set).split(line)\n end", "def parse_line(line)\n return [] if line.nil? or line.empty?\n line.chomp(\"\\n\").split(\"\\t\")\n end", "def split_words(line)\n return line.scan(%r{[,;:]+|[^;: ,]+|(?=[ ]+)}).reject { |e| e.empty? }\n end", "def makeTokens(line)\n # print(line)\n tokens=line.split(/(\\W)/).select { |s| s != '' } #scan(/\\W|[\\w.]+/).select { |s| s != \" \" }\n # print(\"Tokens: \")\n # puts(tokens.length)\n \n #handle negative numbers \n i = 0 \n j = i+1\n length = tokens.length \n while i < length \n if ( tokens[i]==\"-\" or tokens[i]==\"(\" or tokens[i]==\"+\") and tokens[j]==\"-\" \n tokens[j+1]=\"-\"+tokens[j+1] #merge minus with the next token\n tokens[j]=nil #setup space \n end\n i+=1\n j+=1\n end\n tokens = tokens.compact #remove spaces \n # print(tokens)\n # puts\n return tokens\nend", "def tokenize\n return @value.split(/\\s+/)\n end", "def split_tags(line)\n md = line.scan(/\\.(\\w+)\\s*?/)\n md ? md.flatten : []\n end", "def tokenize input\n setup_scanner input\n\n until @s.eos? do\n pos = @s.pos\n\n # leading spaces will be reflected by the column of the next token\n # the only thing we loose are trailing spaces at the end of the file\n next if @s.scan(/ +/)\n\n # note: after BULLET, LABEL, etc.,\n # indent will be the column of the next non-newline token\n\n @tokens << case\n # [CR]LF => :NEWLINE\n when @s.scan(/\\r?\\n/) then\n token = [:NEWLINE, @s.matched, *pos]\n @s.newline!\n token\n # === text => :HEADER then :TEXT\n when @s.scan(/(=+)(\\s*)/) then\n level = @s[1].length\n header = [:HEADER, level, *pos]\n\n if @s[2] =~ /^\\r?\\n/ then\n @s.unscan(@s[2])\n header\n else\n pos = @s.pos\n @s.scan(/.*/)\n @tokens << header\n [:TEXT, @s.matched.sub(/\\r$/, ''), *pos]\n end\n # --- (at least 3) and nothing else on the line => :RULE\n when @s.scan(/(-{3,}) *\\r?$/) then\n [:RULE, @s[1].length - 2, *pos]\n # * or - followed by white space and text => :BULLET\n when @s.scan(/([*-]) +(\\S)/) then\n @s.unscan(@s[2])\n [:BULLET, @s[1], *pos]\n # A. text, a. text, 12. text => :UALPHA, :LALPHA, :NUMBER\n when @s.scan(/([a-z]|\\d+)\\. +(\\S)/i) then\n # FIXME if tab(s), the column will be wrong\n # either support tabs everywhere by first expanding them to\n # spaces, or assume that they will have been replaced\n # before (and provide a check for that at least in debug\n # mode)\n list_label = @s[1]\n @s.unscan(@s[2])\n list_type =\n case list_label\n when /[a-z]/ then :LALPHA\n when /[A-Z]/ then :UALPHA\n when /\\d/ then :NUMBER\n else\n raise ParseError, \"BUG token #{list_label}\"\n end\n [list_type, list_label, *pos]\n # [text] followed by spaces or end of line => :LABEL\n when @s.scan(/\\[(.*?)\\]( +|\\r?$)/) then\n [:LABEL, @s[1], *pos]\n # text:: followed by spaces or end of line => :NOTE\n when @s.scan(/(.*?)::( +|\\r?$)/) then\n [:NOTE, @s[1], *pos]\n # >>> followed by end of line => :BLOCKQUOTE\n when @s.scan(/>>> *(\\w+)?$/) then\n [:BLOCKQUOTE, @s[1], *pos]\n # anything else: :TEXT\n else\n @s.scan(/(.*?)( )?\\r?$/)\n token = [:TEXT, @s[1], *pos]\n\n if @s[2] then\n @tokens << token\n [:BREAK, @s[2], pos[0] + @s[1].length, pos[1]]\n else\n token\n end\n end\n end\n\n self\n end", "def parse( line )\r\n line.split(';')\r\nend", "def tokenize ; end", "def tokenize ; end", "def tokenize\n @s.reset\n\n tokens = []\n\n while token = consume\n tokens << token\n end\n\n tokens\n end", "def tokenize\n @s.reset\n\n tokens = []\n\n while token = consume\n tokens << token\n end\n\n tokens\n end", "def shellsplit(line)\n words = []\n field = ''\n line.scan(/\\G\\s*(?>([^\\s\\\\\\'\\\"]+)|'([^\\']*)'|\"((?:[^\\\"\\\\]|\\\\.)*)\"|(\\\\.?)|(\\S))(\\s|\\z)?/) do\n |word, sq, dq, esc, garbage, sep|\n raise ArgumentError, \"Unmatched double quote: #{line.inspect}\" if garbage\n field << (word || sq || (dq || esc))\n if sep\n words << field\n field = ''\n end\n end\n words\n end", "def key_splitter(lines)\n lines[0].split(\"\\t\")\n end", "def split_lines(input)\n return input.split(/[ ]*[\\.\\n]+[ ]*/)\n end", "def line_token\n return nil unless md = MULTI_DENT.match(@chunk)\n\n @tokens.last.last.push newLine: true\n token :Terminator, \"\\n\"\n\n indent = md.to_a[0]\n num_newlines = count(indent, \"\\n\")\n spaces = indent.length - num_newlines\n\n @line += num_newlines\n\n movement = spaces - @indent\n if movement > 0\n @indents.push movement\n token :Indent, movement\n elsif movement < 0\n outdent_token movement.abs, num_newlines\n end\n\n @indent += movement\n indent.length\n end", "def split_lines\n text.split(/\\n/)\n end", "def shellsplit(line)\n words = []\n field = ''\n line.scan(/\\G\\s*(?>([^\\s\\\\\\'\\\"]+)|'([^\\']*)'|\"((?:[^\\\"\\\\]|\\\\.)*)\"|(\\\\.?)|(\\S))(\\s|\\z)?/) do |word, sq, dq, esc, garbage, sep|\n raise ArgumentError, \"Unmatched double quote: #{line.inspect}\" if garbage\n token = (word || sq || (dq || esc))\n token.gsub!(/\\\\(.)/, '\\1') unless Vagrant::Util::Platform.windows?\n field << token\n if sep\n words << field\n field = ''\n end\n end\n words\n end", "def tokenize\n # Array to contain all tokens.\n tokenArray = []\n # While getChar returns anything other than \"\"\n while getChar\n # Loop to next character until not a space.\n while charIsWhitespace\n nextChar\n end\n # Breaks if it hits the dreaded empty string.\n if getChar.nil?\n break\n end\n # If character is a letter.\n if(charIsAlpha) \n # Initialize local variables for scope.\n m = \"\"\n line = @line\n column = @column \n # While character is letter or number or underscore,\n # add to string \"m\" current character.\n while(charIsAlpha or charIsDigit or getChar == '_')\n m += getChar\n nextChar\n end\n # If the keywords include \"m\" string in hash array,\n # add to tokenArray a new token with the keywords having \"m\" as an index key,\n # its column and line as well for future use and debugging.\n if(Tokens::KEYWORDS.include?(m))\n tokenArray.push Token.new(Tokens::KEYWORDS[m], m, column, line)\n # Must be identifier, add to array as identifier.\n else\n tokenArray.push Token.new(Tokens::IDENT, m, column, line)\n end\n # If the current character is a number.\n elsif(charIsDigit)\n # Initialize local variables for scope.\n m = \"\"\n line = @line\n column = @column\n # Bool is for exception checking on periods. Most likely will be removed,\n # have yet to decide on ranges.\n dot = false\n # While char is number or period,\n while(charIsDigit or getChar == '.')\n # if period\n if(getChar == '.')\n # if dot is true\n if(dot)\n # Create exception class message.\n TokenizerException.new(column, line, \"Number literal contains too many dots.\")\n end\n # Sets flag for second dot if it happens before leaving scope.\n dot = true\n end\n # String adds new character and increments\n m += getChar\n nextChar\n end\n # Token complete, push token as number into tokenArray\n tokenArray.push Token.new(Tokens::NUMBER, m, column, line)\n # Current character doesn't fit into letter or number parameters.\n else\n # More instance variables\n column = @column\n line = @line\n # Starts off by saying this is a character, then moving to the next to check.\n m = getChar\n nextChar\n # While the string is in the operators add and increment character.\n while(Tokens::OPERATORS.include?(m))\n m += getChar if !getChar.nil?\n m += \" \" if getChar.nil?\n nextChar\n end\n # Jump back to the last character\n prevChar()\n # Take of the last character.\n m = m.slice(0, m.size - 1)\n # Pushes another token into the array.\n tokenArray.push Token.new(Tokens::OPERATORS[m], m, column, line)\n end\n end\n return tokenArray\n end", "def line_splitter(tsv)\n tsv.split(\"\\n\")\n end", "def tokenize; end", "def tokenize; end", "def parse_line(delim , line)\n temp_array = Array.new #Array to hold data\n index = 0 #Position of array index\n token = \"\" #To hold the string\n grouping = false #Grouping characters flag\n\n #Parse line with delimeter\n line.each_char do |char|\n #Grouping Block \n if char == \"\\\"\" and !grouping\n token += char\n grouping = true\n elsif char == \"\\\"\" and grouping \n token += char\n grouping = false\n elsif char == delim and !grouping \n temp_array.push(clean(token)) \n token = \"\" \n else\n token += char\n end\n end \n \n #Store last token on line\n temp_array.push(clean(token))\n \n return temp_array\nend", "def parse_vocab(line)\n line.split(/[ \\t]+/)\nend", "def get_chunks(line)\n # split the line\n parts = line.strip.scan /\\w+|\\W/\n # build all combinations\n (1..(parts.size)).collect do |len|\n (0..(parts.size - len)).collect do |idx|\n parts[idx, len].join \"\"\n end\n end.flatten.reject do |el|\n el.length < @min_len || # to short\n # reject (nonalpha separated by) whitespace at beginning and end\n (el =~ /(^\\W?\\s)|(\\s\\W?$)/)\n end\n end", "def split_commands(cmd_line); end", "def recordize line\n line.split(\"\\t\")\n end", "def tokenize input\n s = StringScanner.new input\n\n @line = 0\n @line_pos = 0\n\n until s.eos? do\n pos = s.pos\n\n @tokens << case\n when s.scan(/\\r?\\n/) then\n token = [:NEWLINE, s.matched, *token_pos(pos)]\n @line_pos = s.pos\n @line += 1\n token\n when s.scan(/ +/) then\n [:INDENT, s.matched_size, *token_pos(pos)]\n when s.scan(/(=+)\\s*/) then\n level = s[1].length\n level = 6 if level > 6\n @tokens << [:HEADER, level, *token_pos(pos)]\n\n pos = s.pos\n s.scan(/.*/)\n [:TEXT, s.matched, *token_pos(pos)]\n when s.scan(/^(-{3,}) *$/) then\n [:RULE, s[1].length - 2, *token_pos(pos)]\n when s.scan(/([*-])\\s+/) then\n @tokens << [:BULLET, :BULLET, *token_pos(pos)]\n [:SPACE, s.matched_size, *token_pos(pos)]\n when s.scan(/([a-z]|\\d+)\\.[ \\t]+\\S/i) then\n list_label = s[1]\n width = s.matched_size - 1\n\n s.pos -= 1 # unget \\S\n\n list_type = case list_label\n when /[a-z]/ then :LALPHA\n when /[A-Z]/ then :UALPHA\n when /\\d/ then :NUMBER\n else\n raise ParseError, \"BUG token #{list_label}\"\n end\n\n @tokens << [list_type, list_label, *token_pos(pos)]\n [:SPACE, width, *token_pos(pos)]\n when s.scan(/\\[(.*?)\\]( +|$)/) then\n @tokens << [:LABEL, s[1], *token_pos(pos)]\n [:SPACE, s.matched_size, *token_pos(pos)]\n when s.scan(/(.*?)::( +|$)/) then\n @tokens << [:NOTE, s[1], *token_pos(pos)]\n [:SPACE, s.matched_size, *token_pos(pos)]\n else s.scan(/.*/)\n [:TEXT, s.matched, *token_pos(pos)]\n end\n end\n\n self\n end", "def tokenize\n \n end", "def token(line)\n\n if line.length > 160\n 8\n elsif line.length > 140\n 7\n elsif line.length > 120\n 6\n elsif line.length > 100\n 5\n elsif line.length > 80\n 4\n elsif line.length > 60\n 3\n elsif line.length > 40\n 2\n elsif line.length >= 20\n 1\n elsif line.length < 20\n 0\n else\n puts 'Some error occurred'\n end\n end", "def lines\n text.split(/(?<=[\\n\\f])/)\n end", "def parse_line( line )\n\tline.chomp!\n\tvalues = []\n\t#BEGIN_STUDENT\n\twords = line.split(',')\n words.each do |word|\n\t\tvalues += [word]\n end\n\treturn values\n\t#END_STUDENT\nend", "def tokenize (p_token, type, lineno, pos)\n\t\n\tif type == \"op\"\n\t\treturn op_tokenize(p_token, lineno, pos)\n\t\n\telsif type == \"character\"\n\t\treturn char_tokenize(p_token, lineno, pos)\n\t\n\telsif type == \"string\"\n\t\treturn string_tokenize(p_token, lineno, pos)\n\t\n\telsif type == \"digit\"\n\t\treturn digit_tokenize(p_token, lineno, pos)\n\t\n\telse\n\t\t# should create an error here, just for thoroughness\n\tend\nend", "def split_first_line(line)\n title, date, tags = line.split('|')\n tags = tags.strip.split(',')\n return title, date, tags\nend", "def recordize line\n line.split(\"\\t\") rescue nil\n end", "def segments_from_line(line, row)\n segs = []\n line.gsub(/\\s+$/,'').scan(/[AOXN10]-+[\\|@]/) do |match|\n segs << Segment.new(match, row, $`.length)\n end\n segs\n end", "def tokens\n @tokens ||= scanner.tokenize(input)\n end", "def tokenize(str)\n\t#gsub: substitute; split: converts string to array\n tokens = str.gsub('(', ' ( ').gsub(')',' ) ').split()\t\n return tokens\nend", "def segments(line)\n #return [] if line.nil? or line.blank?\n col = 0\n (line+' '*99).scan(/(\\s+|[-+]?\\d+\\.?\\d*|-+|\\w+|.)/).flatten.collect { |s| [s,col...(col+=s.length)] }\n end", "def tokenize\n\t\tout_tokens = Array.new\n\t\t\n\t\t@token_offset = 0\n\t\tuntil @token_offset >= (self.length - 1)\n\t\t\tout_tokens << next_token\n\t\tend\n\t\t\n\t\tout_tokens.reject {|token| token.empty? }\n\tend", "def parse(line)\n cmd, arg_string = line.downcase.split(' ')\n [cmd, *arg_string.to_s.split(',')]\n end", "def parse line\n normalize(@lexer.tokenize(line)).select { |t| t.is_a? String }\n end", "def set_token(lines)\n match = nil\n lines.find_index { |line| match = line.match(REGEX[:token]) }\n\n raise \"No Delimiter Token Set\" if match.nil?\n\n match.captures[0]\n end", "def tokenize\n for c in @code.split(\" \").map(&:to_s)\n $tokens << getToken\n @code = @code.strip\n end\n $tokens\n end", "def parse_line(line)\n ln, fn, mi, sex, fav_color, dob = line.split(' | ')\n LineParser.to_h(fn, ln, mi, sex, fav_color, parse_dob(dob))\n end", "def st_lex(raw)\n @tokens = raw.delete(' ').gsub(\"\\n\", '')\n end", "def parse_line_data(line)\n line.strip.gsub('\"', '').split ' = '\n end", "def split; end", "def split_commands(cmd_line)\n return [\"\"] if cmd_line.empty?\n\n cmd_line.split(/;/).each_with_object([]) do |v, m|\n if m.empty? || m.last[-1] != '\\\\'\n m << v.strip\n next\n end\n\n m.last[-1, 1] = \"\"\n m.last << \";\" << v\n end\n end", "def split(parts); end", "def split\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 38 )\n\n\n return_value = SplitReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __K_SPLIT197__ = nil\n __LPAR198__ = nil\n __RPAR200__ = nil\n __Identificador201__ = nil\n __EOL203__ = nil\n string199 = nil\n var_local202 = nil\n\n\n tree_for_K_SPLIT197 = nil\n tree_for_LPAR198 = nil\n tree_for_RPAR200 = nil\n tree_for_Identificador201 = nil\n tree_for_EOL203 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 184:4: K_SPLIT LPAR string RPAR ( Identificador | var_local ) EOL\n __K_SPLIT197__ = match( K_SPLIT, TOKENS_FOLLOWING_K_SPLIT_IN_split_872 )\n if @state.backtracking == 0\n tree_for_K_SPLIT197 = @adaptor.create_with_payload( __K_SPLIT197__ )\n @adaptor.add_child( root_0, tree_for_K_SPLIT197 )\n\n end\n\n __LPAR198__ = match( LPAR, TOKENS_FOLLOWING_LPAR_IN_split_874 )\n if @state.backtracking == 0\n tree_for_LPAR198 = @adaptor.create_with_payload( __LPAR198__ )\n @adaptor.add_child( root_0, tree_for_LPAR198 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_string_IN_split_876 )\n string199 = string\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, string199.tree )\n end\n\n __RPAR200__ = match( RPAR, TOKENS_FOLLOWING_RPAR_IN_split_878 )\n if @state.backtracking == 0\n tree_for_RPAR200 = @adaptor.create_with_payload( __RPAR200__ )\n @adaptor.add_child( root_0, tree_for_RPAR200 )\n\n end\n\n # at line 184:29: ( Identificador | var_local )\n alt_28 = 2\n look_28_0 = @input.peek( 1 )\n\n if ( look_28_0 == Identificador )\n alt_28 = 1\n elsif ( look_28_0 == DOUBLEDOT )\n alt_28 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n\n raise NoViableAlternative( \"\", 28, 0 )\n\n end\n case alt_28\n when 1\n # at line 184:30: Identificador\n __Identificador201__ = match( Identificador, TOKENS_FOLLOWING_Identificador_IN_split_881 )\n if @state.backtracking == 0\n tree_for_Identificador201 = @adaptor.create_with_payload( __Identificador201__ )\n @adaptor.add_child( root_0, tree_for_Identificador201 )\n\n end\n\n\n when 2\n # at line 184:44: var_local\n @state.following.push( TOKENS_FOLLOWING_var_local_IN_split_883 )\n var_local202 = var_local\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, var_local202.tree )\n end\n\n\n end\n __EOL203__ = match( EOL, TOKENS_FOLLOWING_EOL_IN_split_886 )\n if @state.backtracking == 0\n tree_for_EOL203 = @adaptor.create_with_payload( __EOL203__ )\n @adaptor.add_child( root_0, tree_for_EOL203 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 38 )\n\n\n end\n\n return return_value\n end", "def tokenize(str)\n str.gsub('(', ' ( ').gsub(')', ' ) ').split(' ')\nend", "def split_text( text )\n result =text.split(/[\\n,\\r]/)\n end", "def parse_line_tokens(line)\n return if line.nil? || line.empty? || !line.include?(';')\n\n tokens = line.split(';')\n id = tokens[0]\n letter = tokens[1]\n neighbors = tokens[2]\n\n # create mapping id to letter\n @nmap[id] = letter\n\n # if neighbors is empty, we reached a end node\n @ends << id if neighbors.strip.empty?\n\n # add neighbors if neighbors for that id exist\n @nnmap[id] = neighbors.strip.split(',')\n end", "def preprocess_line line\n line.split(/,/).collect { |l| l.strip }\n end", "def tokenize(source)\n source = source.source if source.respond_to?(:source)\n return [] if source.to_s.empty?\n tokens = source.split(TemplateParser)\n\n # removes the rogue empty element at the beginning of the array\n tokens.shift if tokens[0] and tokens[0].empty?\n\n tokens\n end", "def split(pattern=$;, limit=0) end", "def split(pattern=$;, limit=0) end", "def tokens\n @tokens ||= tokenize_input\n end", "def parse_line(line)\n matrix(line)\n .each_slice(3)\n .map(&:join)\n end", "def line_split str\n content = str.split(': ')[1] || ''\n if content.match /\\//\n content.split('/').map(&:strip).reject(&:empty?)\n else\n content\n end\n end", "def tokenize(str)\n #Se hace split para eliminar todos los espacios en blanco\n tokens = sanitize_input(str).split(WHITESPACE_BREAK) #Tokenizo algunos strings, los basicos\n return [''] if tokens.empty?\n #Se realiza la tabla de los separadores de caracteres\n splittables = PRE_SIGNO1 + POST_SIGNO1 + PRE_SIGNO2 + POST_SIGNO2 + PRE_N_POST #creo una tabla\n #Se indica cuales son las expresiones regulares a separar\n pattern = Regexp.new(\"[^#{Regexp.escape(splittables.join)}]+\") #Simbolos\n output = []\n #Para cada palabra sin espacio en blanco obtenida\n #se hace split si tiene los elementos de la tabla\n #splittables y se anade al array. \n tokens.each do |token|\n prefix, stem, suffix = token.partition(pattern)\n output << prefix.split('') unless prefix.empty?\n output << stem unless stem.empty?\n output << suffix.split('') unless suffix.empty?\n end\n output.flatten\n end", "def parse( line )\n info = line.split(',')\n return info\nend", "def tokens\n tok_sequence = []\n until @scanner.eos?\n token = _next_token\n tok_sequence << token unless token.nil?\n end\n\n tok_sequence\n end", "def parse(script)\n next_token_id = 0\n\n token_records = []\n\n # Maps token name to token entry\n @tokenNameMap = {}\n\n script_lines = script.split(\"\\n\")\n @original_line_numbers = []\n\n # Join lines that have been ended with '\\' to their following lines;\n # only do this if there's an odd number of '\\' at the end\n\n @lines = []\n accum = nil\n accum_start_line = nil\n\n script_lines.each_with_index do |line, original_line_number|\n\n trailing_backslash_count = 0\n while line.length > trailing_backslash_count && line[-1-trailing_backslash_count] == '\\\\'\n trailing_backslash_count += 1\n end\n\n if accum.nil?\n accum = \"\"\n accum_start_line = original_line_number\n end\n\n if (trailing_backslash_count % 2 == 1)\n accum << line[0...-1]\n else\n accum << line\n @lines << accum\n @original_line_numbers << accum_start_line\n accum = nil\n end\n end\n\n if !accum.nil?\n raise ParseException, \"Incomplete final line: #{script}\"\n end\n\n # Now that we've stitched together lines where there were trailing \\ characters,\n # process each line as a complete token definition\n\n @lines.each_with_index do |line, line_index|\n line_number = 1 + @original_line_numbers[line_index]\n\n # Strip whitespace only from the left side (which will strip all of\n # it, if the entire line is whitespace). We want to preserve any\n # special escaped whitespace on the right side.\n line.lstrip!\n\n # If line is empty, or starts with '#', it's a comment\n if line.length == 0 || line[0] == '#'\n next\n end\n\n if !(line =~ TOKENNAME_EXPR)\n raise ParseException.build(\"Syntax error\", line_number, line)\n end\n\n pos = line.index(\":\")\n\n tokenName = line[0,pos].strip()\n\n expr = line[pos+1..-1]\n\n rex = RegParse.new(expr, @tokenNameMap, line_number)\n\n # Give it the next available token id, if it's not an anonymous token; else -1\n\n token_id = -1\n if tokenName[0] != '_'\n token_id = next_token_id\n next_token_id += 1\n end\n\n entry = TokenEntry.new(tokenName, rex, token_id)\n\n if @tokenNameMap.has_key?(tokenName)\n raise ParseException.build(\"Duplicate token name\",line_number,line)\n end\n @tokenNameMap[entry.name] = entry\n\n next if entry.id < 0\n\n if accepts_zero_characters(rex.start_state, rex.endState)\n raise ParseException.build(\"Zero-length tokens accepted\",line_number,line)\n end\n\n token_records << entry\n end\n\n combined = combine_token_nfas(token_records)\n\n builder = NFAToDFA.new(combined)\n builder.generate_pdf = @generate_pdf\n dfa = builder.nfa_to_dfa\n\n apply_redundant_token_filter(token_records, dfa)\n\n Tokn::DFA.new(token_records.map{|x| x.name}, dfa)\n end", "def parse_input(line)\n pieces = line.split(' ')\n a = pieces[1]\n b = pieces[7]\n @step_map.add_node(a, b)\n end", "def parse_to_array(line_as_string)\n as_array = line_as_string.split(\" \")\nend", "def fields(text) \n p text.split(/[,\\s]+/)\nend", "def lists\n lines.inject([]){ |lists, line| lists << split(line) }\n end", "def split(pat, limit)\n end", "def split_string(string)\n string.each_line.with_index do |line, index|\n end\nend", "def parse(tokens)\n if tokens.length == 1\n tokens[0]\n elsif tokens.length > 2\n [\n tokens[1],\n [ tokens[0], parse(tokens[2..-1]) ]\n ]\n else\n raise RuntimeError, \"Fucked Tokens\"\n end\n end", "def start(raw)\n typ = Tokenizer::DEFAULT_TOKEN_TABLE\n letters = raw.dup.split(\"\")\n tokens = []\n\n while (ch = letters.shift) != nil\n tokens.push(typ[ch])\n end\n\n return tokens\n end", "def tokens; end", "def tokens; end", "def tokens; end", "def tokens; end", "def tokens; end", "def tokens; end", "def tokens; end", "def tokens; end", "def read_tokens()\n\n # By adding @ to tokens, we're saving it also in the instance. We're not\n # going to use that, but it might be useful later.\n @tokens = []\n\n File.open(@filename) do |input_file|\n input_file.each do |line|\n line.split.each do |word|\n word = normalize(word)\n @tokens << word unless word.empty?\n end\n end\n end\n\n @tokens\n end", "def tokenize str, terminates=false, &block\n if block_given?\n offset = 0\n while str.length > 0 do\n ostr = str\n str = ostr.sub /(^[ \\t\\r\\f\\v\\u00a0]*)([^\\]\\[)(}{,.?\\s\\u00a0]+|[()\\[\\]{},.?\\n])/i, '' # Pluck the next token\n spaces, token = $1, $2\n if token && ((str.length > 0) || terminates || token.match(/^[()\\[\\]{},.?\\n]/)) # This string really ends here (no continuation of non-delimiter)\n offset += spaces&.length || 0\n block.call token, offset unless token.empty?\n offset += token&.length || 0\n else\n return ostr # Return the unprocessed remainder of the string (which may be blank)\n end\n end\n ''\n else\n tokens = []\n while str.length > 0\n str = str.sub /(^[ \\t\\r\\f\\v\\u00a0]*)([^\\]\\[)(}{,.?\\s\\u00a0]+|[()\\[\\]{},.?\\n])/i, ''\n if $2\n tokens << $2\n else\n break\n end\n end\n tokens\n end\nend", "def tokenizer(str, token_size = 1)\n # Treat token_size of 0 as if it was a 1.\n if token_size <= 0\n token_size = 1\n end\n \n if token_size == 1\n token_array = str.split(\"\")\n else\n token_array = []\n ul = str.length - 1\n ll = 0\n ts = token_size - 1\n while ts <= ul\n token_array << str[ll..ts]\n ll += 1\n ts += 1\n end \n end\n \n return token_array\n end", "def parse_line(line)\n ln, fn, sex, fav_color, dob = line.split(', ')\n LineParser.to_h(fn, ln, nil, sex, fav_color, parse_dob(dob))\n end", "def parse_input(line)\n prefix, suffix = line.split '|'\n prefixes = unless prefix.nil? then prefix.split(';') else [] end\n suffixes = unless suffix.nil? then suffix.split(';') else [] end\n return prefixes, suffixes\nend", "def tokens(force = nil)\n data(force).map(&:token)\n end", "def each_token(&block)\n each_input_line do |line|\n each_token_in_line line, &block\n end\n\n alter_stack [], &block\n end", "def process_line(line)\n if (@custom_processor && @custom_processor.class.method_defined?(:process_line))\n @custom_processor.process_line line\n else\n line.split ' '\n end\n end", "def streams_for(line)\n line.split(/({{\\s*[^}]+\\s*}})/)\n end" ]
[ "0.7667002", "0.6967882", "0.69489825", "0.69461644", "0.6883082", "0.6859", "0.67830473", "0.67783755", "0.6654122", "0.6650294", "0.65709895", "0.6522022", "0.6449775", "0.6416128", "0.64105785", "0.6357944", "0.62834084", "0.62682664", "0.62504345", "0.62504345", "0.6187874", "0.6187874", "0.6173073", "0.61681336", "0.615204", "0.6132647", "0.6128315", "0.61136514", "0.6112132", "0.6079993", "0.60749334", "0.60749334", "0.6074164", "0.60379475", "0.6025528", "0.60063404", "0.60043496", "0.59811467", "0.5949288", "0.59488446", "0.5881057", "0.58734775", "0.58456206", "0.58443505", "0.58377284", "0.5825317", "0.5817963", "0.5803646", "0.57818115", "0.5766899", "0.57662666", "0.5763982", "0.5762196", "0.5718971", "0.57092917", "0.568882", "0.56837213", "0.5681333", "0.56732327", "0.56500506", "0.5636251", "0.5624011", "0.5604092", "0.5594993", "0.55701137", "0.55693215", "0.55590445", "0.55590445", "0.55519795", "0.55511683", "0.5549528", "0.5523386", "0.55233353", "0.55122995", "0.55071855", "0.54994726", "0.5488979", "0.5479744", "0.5476245", "0.5457518", "0.54564667", "0.5444649", "0.544252", "0.54403794", "0.54403794", "0.54403794", "0.54403794", "0.54403794", "0.54403794", "0.54403794", "0.54403794", "0.54384494", "0.5437859", "0.5433838", "0.5430722", "0.5405039", "0.537684", "0.53746986", "0.5374364", "0.537141" ]
0.6803158
6
Creates a new resource instance, resource should be specified by its name or identifier.
def get_resource(resource_type) Occi::Log.debug("Instantiating #{resource_type} ...") if @model.get_by_id resource_type # we got a resource type identifier Occi::Core::Resource.new resource_type elsif @model.kinds.select { |kind| kind.term == resource_type }.any? # we got a resource type name Occi::Core::Resource.new @model.kinds.select { |kind| kind.term == resource_type }.first.type_identifier else raise "Unknown resource type! [#{resource_type}]" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_resource(_params)\n resource_class.new(resource_params)\n end", "def create(resource, options = {}, format = nil)\n base_create(resource, options, format)\n end", "def create(resource,identifier,json)\n raise 'Not Yet Implemented'\n end", "def create_resource\n class_name.new(get_secure_params).tap do |model|\n model.save\n set_resource_ivar model\n end\n end", "def new_resource(*args)\n Freemle::Client::Resource.new(*args)\n end", "def create(attributes = {})\n resource = new(attributes)\n resource.__send__(:_create)\n resource\n end", "def create_resource(new_resource, attributes)\n new_resource.attributes = attributes\n new_resource.save\n new_resource\n end", "def create(resource, format=@default_format)\n options = { resource: resource.class, format: format }\n reply = post resource_url(options), resource, fhir_headers(options)\n if [200,201].include? reply.code\n type = reply.response[:headers][:content_type]\n if !type.nil?\n if type.include?('xml') && !reply.body.empty?\n reply.resource = resource.class.from_xml(reply.body)\n elsif type.include?('json') && !reply.body.empty?\n reply.resource = resource.class.from_fhir_json(reply.body)\n else\n reply.resource = resource # just send back the submitted resource\n end\n else\n reply.resource = resource # don't know the content type, so return the resource provided\n end\n else\n reply.resource = resource # just send back the submitted resource\n end\n reply.resource_class = resource.class\n reply\n end", "def create_resource object\n object.save\n end", "def create(repository, resource)\n raise NotImplementedError\n end", "def create(*args)\n raise NotImplementedError, 'Implement a method to create the resource.'\n end", "def create\n @resource = Resource.new(params[:resource])\n \n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render json: @resource, status: :created, location: @resource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(resource)\n resource.client = self\n resource.create\n end", "def new\n @resource = Resource.new\n end", "def create_resource(object)\n object.save\n end", "def create(resource_name)\n if ! advance? then return self end\n @@logger.debug \"Launching resource: #{resource_name}.\"\n resource = @resourcer.get resource_name\n deps = @resourcer.get_dep(resource_name)\n deps.each {|ref| create(ref)}\n created = @mutator.create(resource_name, resource)\n created.harp_script = @harp_script\n result = {:create => resource_name}\n args = {:action => :create}\n if created.output? (args)\n result[:output] = created.make_output_token(args)\n result[:line] = @current_line\n end\n @events.push(result)\n created.save\n return self\n end", "def create_resource id, url, hash\n # TODO\n page = resource_page id\n if is_url? url\n create_new_archive page, url, hash\n end\n content = 'TODO'\n write! page, content\n end", "def create\n Puppet.debug( \"#{self.resource.type}: CREATE #{resource[:name]}\" ) \n end", "def create\n resource = model_class.new(permitted_resource_params)\n ensure_current_store(resource)\n\n if resource.save\n render_serialized_payload(201) { serialize_resource(resource) }\n else\n render_error_payload(resource.errors)\n end\n end", "def new\n if clone_target = resource_class.find_by_id(params[:id])\n set_resource_ivar(clone_target.clone)\n end\n\n new!\n end", "def create(data)\n @create_resource_mixin.create(data)\n end", "def instantiate\n resource.new(data)\n end", "def create\n add_breadcrumb I18n.t('integral.navigation.create')\n @resource = resource_klass.new(resource_params)\n\n yield if block_given?\n\n if @resource.save\n respond_successfully(notification_message('creation_success'), edit_backend_resource_url(@resource))\n else\n respond_failure(notification_message('creation_failure'), :new)\n end\n end", "def new_resource\n controller_class.new(new_resource_params)\n end", "def build_resource\n self.resource = resource_class.new(resource_params)\n end", "def add(name, resource, attributes = {})\n resources[name] = resource\n resource.update_attributes(attributes) if attributes.any?\n resource\n end", "def new\n @entity = resource_class.new\n end", "def create(attributes = {})\n build(attributes).tap { |resource| resource.save }\n end", "def create\n self.resource = resource_class.new(params_for_create.to_hash.merge({created_by: current_user}))\n\n respond_to do |format|\n if resource.save\n format.html { redirect_to resource, notice: \"#{resource_class_name} was successfully created.\" }\n format.json { render :show, status: :created, location: resource }\n else\n format.html { render :new }\n format.json { render json: resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n validate_save_and_respond(change_set_class.new(resource_class.new), :new)\n end", "def create_resource(resource_descr, type_to_create, authorizer)\n raise InsufficientPrivilegesException unless authorizer.can_create_resource?(resource_descr, type_to_create)\n\n if resource_descr[:account_id].nil?\n resource = eval(\"OMF::SFA::Model::#{type_to_create.classify}\").create(resource_descr)\n resource = manage_resource(resource)\n else\n resource = @scheduler.create_child_resource(resource_descr, type_to_create, nil)\n end\n\n raise UnknownResourceException.new \"Resource '#{resource_descr.inspect}' cannot be created\" unless resource\n resource\n end", "def create\n created_resource = create_resource(new_resource, resource_params)\n if created_resource.errors.blank?\n render json: serialize(created_resource),\n status: :created\n else\n render json: serialize_invalid_attributes(created_resource.errors),\n status: :unprocessable_entity\n end\n end", "def create\n @resource = Resource.new(params[:resource])\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render json: @resource, status: :created, location: @resource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @resource = Resource.new(resource_params)\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n model = model_class.new\n action = action_class.new(model, current_user)\n\n respond_with(action.create(resource_attributes))\n end", "def base_create(resource, options, format = nil, additional_header = {})\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n headers = {content_type: \"#{format}\"}\n headers[:prefer] = @return_preference if @use_return_preference\n headers.merge!(additional_header)\n options = {} if options.nil?\n options[:resource] = resource.class\n options[:format] = format || @default_format\n reply = post resource_url(options), resource, fhir_headers(headers)\n if [200, 201].include? reply.code\n type = reply.response[:headers].detect{|x, _y| x.downcase=='content-type'}.try(:last)\n if !type.nil?\n reply.resource = if type.include?('xml') && !reply.body.empty?\n klass = self.versioned_resource_class(:Xml)\n klass.from_xml(reply.body)\n elsif type.include?('json') && !reply.body.empty?\n klass = self.versioned_resource_class(:Json)\n klass.from_json(reply.body)\n else\n resource # just send back the submitted resource\n end\n resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.self_link)\n else\n resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.self_link)\n reply.resource = resource # don't know the content type, so return the resource provided\n end\n else\n resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.self_link)\n reply.resource = resource # just send back the submitted resource\n end\n set_client_on_resource(reply.resource)\n reply.resource_class = resource.class\n reply\n end", "def new(*args)\n enclosing_resource ? enclosing_resource.send(\"build_#{resource_specification.source}\", *args) : super\n end", "def create\n params[:id] = resource.id if resource.save\n respond_with resource\n end", "def new(options = {}, &block)\n respond_with(build_resource, options, &block)\n end", "def create\n @resource = Resource.new(params[:resource])\n\n respond_to do |format|\n if @resource.save\n flash[:notice] = 'Resource was successfully created.'\n format.html { redirect_to(@resource) }\n format.xml { render :xml => @resource, :status => :created, :location => @resource }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @resource = Resource.new(params[:resource])\n\n if @resource.save\n flash[:notice] = 'Resource was successfully created.'\n redirect_to @resource\n else\n render :action => \"new\"\n end\n end", "def create_resource(type, title, parameters = {})\n parameters = parameters.merge(:name => title)\n resource = Puppet::Type.type(type.to_sym).new(parameters)\n catalog.add_resource(resource)\n resource\n end", "def build_resource(hash = {})\n self.resource = resource_class.new(hash)\n end", "def create_resource_for(resource_name)\n resource = self.class.const_set(resource_name, Class.new(Meli::Base))\n resource.prefix = self.class.prefix\n resource.site = self.class.site\n resource\n end", "def build_resource(hash=nil, student_id=nil)\n hash[:student_id] = student_id\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def resource\n @resource ||= resource_set.createResource(uri)\n end", "def resource\n resource_klass.new(attributes.symbolize_keys.merge(new_record: false))\n end", "def create(params={})\n raise '`create` method is not supported for this resource.'\n end", "def create(params={})\n raise '`create` method is not supported for this resource.'\n end", "def create(params={})\n raise '`create` method is not supported for this resource.'\n end", "def create(params={})\n raise '`create` method is not supported for this resource.'\n end", "def define_new_resource(resource_name)\n name = resource_name.singularize\n resource_klass_name = name.to_s.camelcase\n klass_name = \"#{resource_klass_name}Resource\"\n return if AssociationResource.const_defined? klass_name\n\n base_klass = AssociationResource::IncludedResource\n base_klass.sub_name = name\n AssociationResource.const_set(klass_name, Class.new(base_klass))\n end", "def define_new_resource(resource_name)\n name = resource_name.singularize\n resource_klass_name = name.to_s.camelcase\n klass_name = \"#{resource_klass_name}Resource\"\n return if AssociationResource.const_defined? klass_name\n\n base_klass = AssociationResource::IncludedResource\n base_klass.sub_name = name\n AssociationResource.const_set(klass_name, Class.new(base_klass))\n end", "def create\n existing_resource = Resource.find_by_url(params[:resource][:url])\n if existing_resource\n flash[:notice] = \"That resource has already been added, but please give it a review!\"\n redirect_to resource_path(existing_resource) and return\n end\n @resource = Resource.new(params[:resource])\n @resource.contributor = current_user\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to(@resource, :notice => 'Resource was successfully created.') }\n format.xml { render :xml => @resource, :status => :created, :location => @resource }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n self.resource = new_resource\n\n respond_to do |format|\n if resource.save\n flash[:notice] = \"#{resource_name.humanize} was successfully created.\"\n format.html { redirect_to resource_url }\n format.xml do\n header_attrs = {:location => resource_url}\n header_attrs.merge!(:key => resource.key) if resource.respond_to?(:key)\n head :created, header_attrs\n end\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => resource.errors.to_xml, :status => :unprocessable_entity }\n end\n end\n end", "def create!(name:, **config)\n new_resource = self.build(name: name, **config)\n\n new_resource.attr_map(config) do |config_key, config_value|\n new_resource.instance_attr_accessor new_resource.to_snake(config_key)\n config_value\n end\n\n new_resource.save!\n\n yield new_resource if block_given?\n new_resource\n end", "def create(context)\n context.request.body.rewind # in case someone already read it\n begin\n data = JSON.parse(context.request.body.read)\n rescue JSON::ParserError\n context.halt(406, { status: 'error', message: 'Not acceptable JSON payload' }.to_json)\n end\n\n permitted_params = resource_fields.map { |k| k[:name] }\n permitted_params = data.select { |k, _| permitted_params.include?(k) }\n\n begin\n instance_variable_set(:\"@#{resource_name}\", resource_name.classify.constantize.new(permitted_params))\n\n if instance_variable_get(:\"@#{resource_name}\").save\n instance_variable_get(:\"@#{resource_name}\").to_json\n else\n errors = instance_variable_get(:\"@#{resource_name}\").errors.map { |k, v| \"#{k}: #{v}\" }.join('; ')\n context.halt(406, { status: 'error', message: errors }.to_json)\n end\n rescue StandardError => e\n context.halt(500, { status: 'error', message: e.message }.to_json)\n end\n end", "def create\n add_breadcrumb I18n.t('integral.navigation.create'), \"new_backend_#{controller_name.singularize}_path\".to_sym\n @resource = resource_klass.new(resource_params)\n\n yield if block_given?\n\n if @resource.save\n respond_successfully(notification_message('creation_success'), send(\"edit_backend_#{controller_name.singularize}_path\", @resource.id))\n else\n respond_failure(notification_message('creation_failure'), :new)\n end\n end", "def new_from_resource(rsrc); self.class.new_from_resource(rsrc) end", "def create_resource(type, file, resource_name=nil, comment=nil)\n if type != 'table' and !file.instance_of? File\n file = File.open(file)\n end\n begin\n resource_name = resource_name || File.basename(file)\n res = ODPS.conn.post do |req|\n req.url \"projects/#{ODPS.current_project}/resources\"\n req.headers['x-odps-resource-type'] = type\n req.headers['x-odps-resource-name'] = resource_name\n req.headers['x-odps-comment'] = comment if comment\n req.headers['Content-Type'] = 'text/plain'\n if type == 'table'\n req.headers['x-odps-copy-table-source'] = file\n else\n req.body = file.read\n end\n end\n rescue Exception, e\n AliODPS::LOGGER.error \"Open file error!#{$!}@#{$@}\"\n ensure\n file.close unless type == 'table'\n end\n\n resource = Resource.new\n if res.status == 201\n resource.comment = comment\n resource.file_source = res['Location']\n resource.name = resource_name\n end\n resource\n end", "def create\n @resource = Resource.new(params[:resource])\n\n respond_to do |format|\n if @resource.save\n flash[:success] = 'Resource was successfully created.'\n format.html { redirect_to admin_resource_path(@resource.id) }\n format.json { render json: @resource, status: :created, location: @resource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resource.errors.full_messages.join(''), status: :unprocessable_entity }\n end\n end\n end", "def construct_new_resource(response)\n data = JSON.parse(response.body, symbolize_names: true)\n new(data)\n end", "def create_resource(resource, opts = {})\n data, _status_code, _headers = create_resource_with_http_info(resource, opts)\n data\n end", "def new_resource model = controller_model\n resource || set_resource(model.new.tap do |record|\n settings = params[model.name.underscore] || {}\n attributes = params_with_parents(model).merge(settings)\n record.assign_attributes attributes, as: current_role\n end)\n end", "def create\n @resource = current_user.resources.build(resource_params)\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def build_resource(hash = {})\n self.resource = resource_class.new_with_session(hash, session)\n end", "def build_resource(hash = {})\n self.resource = resource_class.new_with_session(hash, session)\n end", "def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def create\n authorize! :create, resource\n current_model_service.create resource, params\n yield if block_given? # after_create\n respond_with resource, location: helpers.show_path(resource)\n end", "def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def create(\n resource,\n deadline: nil\n )\n req = V1::ResourceCreateRequest.new()\n\n req.resource = Plumbing::convert_resource_to_plumbing(resource)\n tries = 0\n plumbing_response = nil\n loop do\n begin\n plumbing_response = @stub.create(req, metadata: @parent.get_metadata(\"Resources.Create\", req), deadline: deadline)\n rescue => exception\n if (@parent.shouldRetry(tries, exception))\n tries + +@parent.jitterSleep(tries)\n next\n end\n raise Plumbing::convert_error_to_porcelain(exception)\n end\n break\n end\n\n resp = ResourceCreateResponse.new()\n resp.meta = Plumbing::convert_create_response_metadata_to_porcelain(plumbing_response.meta)\n resp.rate_limit = Plumbing::convert_rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)\n resp.resource = Plumbing::convert_resource_to_porcelain(plumbing_response.resource)\n resp\n end", "def set_resource\n unless params[:id].blank?\n @resource = Resource.find(params[:id])\n end\n if @resource.nil?\n @resource = Resource.new(project: @project) \n end\n end", "def build_resource(hash = nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end", "def new(data={})\n self.spira_resource.new(data)\n end", "def resource\n @resource ||= begin\n resource_constant.new(attributes)\n end\n end", "def create\n instance_variable_set(resource, @model.new(resource_params))\n\n yield if block_given?\n\n respond_to do |format|\n if instance_variable_get(resource).save\n format.html { redirect_to action: :index, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: resource_location }\n after_create\n else\n format.html { render :new }\n format.json do\n render json: instance_variable_get(resource).errors.as_json(full_messages: true),\n status: :unprocessable_entity\n end\n end\n end\n end", "def create(type, opts = nil)\n proxy_info = OmfRc::ResourceFactory.proxy_list[type]\n if proxy_info && proxy_info.create_by && !proxy_info.create_by.include?(self.type.to_sym)\n raise StandardError, \"Resource #{type} is not designed to be created by #{self.type}\"\n end\n\n before_create(type, opts) if respond_to? :before_create\n new_resource = OmfRc::ResourceFactory.new(type.to_sym, opts, @comm)\n after_create(new_resource) if respond_to? :after_create\n children << new_resource\n new_resource\n end", "def create\n @api_v1_resource = Api::V1::Resource.new(api_v1_resource_params)\n\n respond_to do |format|\n if @api_v1_resource.save\n format.html { redirect_to @api_v1_resource, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_resource }\n else\n format.html { render :new }\n format.json { render json: @api_v1_resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def find_or_create_resource_for(name)\n resource_name = name.to_s.camelize\n resource_name.constantize\n rescue NameError\n resource = self.class.const_set(resource_name, Class.new(ActiveResource::Base))\n resource.prefix = self.class.prefix\n resource.site = self.class.site\n resource\n end", "def find_or_create_resource_for(name)\r\n resource_name = name.to_s.camelize\r\n resource_name.constantize\r\n rescue NameError\r\n resource = self.class.const_set(resource_name, Class.new(ActiveTamino::Base))\r\n resource.collection = self.class.collection\r\n resource.credentials = self.class.credentials\r\n resource.doctype = self.class.doctype\r\n resource\r\n end", "def create\n @resource = current_admin.resources.new(resource_params)\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render action: 'show', status: :created, location: @resource }\n else\n format.html { render action: 'new' }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @resource = Resource.new(params[:resource])\n if current_user\n @resource.resourceable_type = current_user.class.name\n @resource.resourceable_id = current_user.id\n else\n @resource.resourceable_type = current_instructor.class.name\n @resource.resourceable_id = current_instructor.id\n end\n \n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render json: @resource, status: :created, location: @resource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(name, type, options = {})\n Utils.stringify_keys!(options)\n path = \"/projects/#{project.name}/resources/\"\n\n headers = build_create_base_headers(name, type, options)\n body = build_create_base_body(options)\n\n location = client.post(path, headers: headers, body: body).headers['Location']\n Resource.new(name: name, resource_type: type, comment: options['comment'], location: location)\n end", "def create\n @resource = Resource.new(resource_params)\n @resource.active = true\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_resource_for(resource_name)\n resource = self.class.const_set(resource_name, Class.new(Docusigner::Base))\n resource.prefix = self.class.prefix\n resource.site = self.class.site\n resource\n end", "def create\n @property_hash = {\n name: @resource[:name],\n ensure: :present,\n primitive: @resource[:primitive],\n clone_max: @resource[:clone_max],\n clone_node_max: @resource[:clone_node_max],\n notify_clones: @resource[:notify_clones],\n globally_unique: @resource[:globally_unique],\n ordered: @resource[:ordered],\n interleave: @resource[:interleave],\n cib: @resource[:cib],\n existing_resource: :false\n }\n end", "def create\n @resource = Resource.new(params[:resource])\n @resource.campaign_id = session[:campaign_id]\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, :notice => 'Resource was successfully created.' }\n format.json { render :json => @resource, :status => :created, :location => @resource }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Resource.new(resource_params)\n \n if @asset.save\n redirect_to admin_resource_path(@asset), notice: 'Resource was successfully created.'\n else\n render action: 'new'\n end\n end", "def create\n @resource = Resource.new(resource_params)\n\n handle_extra_data\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to edit_project_path(@resource.project), notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(attributes = {})\n resource = build(attributes)\n @parent.attributes[@name] = resource if resource.save\n resource\n end", "def create(type, opts = {}, creation_opts = {}, &creation_callback)\n proxy_info = OmfRc::ResourceFactory.proxy_list[type]\n if proxy_info && proxy_info.create_by && !proxy_info.create_by.include?(self.type.to_sym)\n raise StandardError, \"Resource #{type} is not designed to be created by #{self.type}\"\n end\n\n before_create(type, opts) if respond_to? :before_create\n new_resource = OmfRc::ResourceFactory.create(type.to_sym, opts, creation_opts, &creation_callback)\n after_create(new_resource) if respond_to? :after_create\n\n self.synchronize do\n children << new_resource\n end\n new_resource\n end" ]
[ "0.8225565", "0.74735874", "0.74709904", "0.7435916", "0.73996377", "0.736391", "0.7345037", "0.7329278", "0.7280913", "0.7243268", "0.72429705", "0.72133404", "0.7175528", "0.71637857", "0.71165985", "0.70752156", "0.7043156", "0.70320654", "0.7031223", "0.69984424", "0.6984145", "0.69648033", "0.6962752", "0.69592917", "0.6946224", "0.69116974", "0.6904633", "0.6891175", "0.688223", "0.6881278", "0.6878539", "0.6847982", "0.6828661", "0.6827336", "0.68260217", "0.6774587", "0.6739916", "0.6734271", "0.67270505", "0.67253214", "0.67095965", "0.6687066", "0.668084", "0.66487813", "0.6630227", "0.6618315", "0.66116947", "0.65992665", "0.65992665", "0.65992665", "0.65992665", "0.65951145", "0.65951145", "0.658055", "0.65630484", "0.65578073", "0.6556224", "0.6551909", "0.65452695", "0.6543765", "0.654244", "0.6535555", "0.652985", "0.65283257", "0.6490878", "0.6476553", "0.6476553", "0.6468066", "0.6458893", "0.6458893", "0.6458893", "0.6458893", "0.6458893", "0.6458893", "0.6458893", "0.6458893", "0.6458893", "0.6458893", "0.64584476", "0.64574987", "0.6455698", "0.64393747", "0.6424851", "0.6394806", "0.63867354", "0.6368925", "0.6361048", "0.6358581", "0.6358317", "0.6348567", "0.6345315", "0.63431054", "0.6342903", "0.63384557", "0.6327613", "0.632018", "0.63178253", "0.631605", "0.6314541", "0.6308944", "0.6307214" ]
0.0
-1
Retrieves all entity type identifiers related to a given type identifier
def get_entity_types_related_to(type_identifier) Occi::Log.debug("Getting entity type identifiers related to #{type_identifier}") collection = @model.get type_identifier collection.kinds.collect { |kind| kind.type_identifier } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_entity_type_identifiers\n get_entity_types_related_to Occi::Core::Entity.kind.type_identifier\n end", "def get_entity_type_identifiers\n get_kind_type_identifiers_related_to Occi::Core::Entity.kind.type_identifier\n end", "def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n\n end", "def get_entities(type)\n @entities[type.name]\n end", "def id_types\n identifiers.map(&:type).uniq\n end", "def get_entity_types\n get_types(Occi::Core::Entity.kind)\n end", "def get_entity_types\n Occi::Log.debug(\"Getting entity types ...\")\n @model.kinds.collect { |kind| kind.term }\n end", "def entity_types\n @entity_types ||= metadata.xpath('//EntityType').collect {|entity| entity.attributes['Name'].value}\n end", "def entities_of_type(type)\n @entities.select { |entity| entity['type'] == type }.map { |entity| Entity.new entity }\n end", "def entity_types\n @entity_types ||= schemas.map do |namespace, schema|\n schema.entity_types.map do |entity_type|\n \"#{namespace}.#{entity_type}\"\n end\n end.flatten\n end", "def entity_types\n @entity_types ||= schemas.map do |namespace, schema|\n schema.entity_types.map do |entity_type|\n \"#{namespace}.#{entity_type}\"\n end\n end.flatten\n end", "def index\n @identifier_types = IdentifierType.all\n end", "def get_link_type_identifiers\n get_entity_types_related_to Occi::Core::Link.kind.type_identifier\n end", "def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end", "def get_entity_type_identifier(type)\n get_type_identifier(type, Occi::Core::Entity.kind)\n end", "def entity_types\n @entity_types ||= parent_tokenizer.class.all_entity_types\n end", "def index\n @entity_types = EntityType.all\n end", "def list_entities project_id:, entity_type_id:\n # [START dialogflow_list_entities]\n # project_id = \"Your Google Cloud project ID\"\n # entity_type_id = \"Existing Entity Type ID\"\n\n require \"google/cloud/dialogflow\"\n\n entity_types_client = Google::Cloud::Dialogflow::EntityTypes.new\n parent = entity_types_client.class.entity_type_path project_id, entity_type_id\n\n entities = entity_types_client.get_entity_type(parent).entities\n\n entities.each do |entity|\n puts \"Entity value: #{entity.value}\"\n puts \"Entity synonyms: #{entity.synonyms}\"\n end\n # [END dialogflow_list_entities]\nend", "def get_resource_type_identifiers\n get_kind_type_identifiers_related_to Occi::Core::Resource.kind.type_identifier\n end", "def patient_identifiers(patient, identifier_type)\n PatientIdentifier.where(patient: patient, type: identifier_type)\n end", "def list_possible_type_ids\n\tissuetypes = @client.Issuetype.all\n\tissuetypes.each do |issue|\n\t\tputs \"#{issue.id}\\t#{issue.name}\"\n\tend\nend", "def asset_type_ids\n assets.scope.uniq.pluck(:asset_type_id)\n end", "def ids(type)\n Document.where(:typ => type).select(:ide).collect { |d| d[:ide] }.uniq.sort\n end", "def show\n @h_identifier_types = {}\n IdentifierType.all.map{|it| @h_identifier_types[it.id] = it}\n end", "def get_tags(tenant_id, entity_type_id,entity_id)\n return @instance.get_tags(tenant_id, entity_type_id,entity_id)\n end", "def index\n @identification_types = IdentificationType.all\n end", "def ids\n @@enums_by_id.keys\n end", "def get_workspace_entities_by_type(workspace_namespace, workspace_name, entity_type)\n path = self.api_root + \"/api/workspaces/#{uri_encode(workspace_namespace)}/#{uri_encode(workspace_name)}/entities/#{entity_type}\"\n process_firecloud_request(:get, path)\n end", "def relations_by_type\n relations = {}\n for i in 0..(self.relations.count-1)\n type = self.relations(i).type.first\n relations[type] ||= []\n relations[type] += self.relations(i).id\n end\n relations\n end", "def index\n @type_identifications = TypeIdentification.all\n end", "def collected_entities entity_type, viewer=nil\n entity_type = entity_type.to_s\n if viewer == self\n assoc = entity_type.to_s\n scope = self.method(assoc).call\n scope = scope.where.not(owner_id: id) if entity_type == \"List\"\n scope\n else\n arr = collection_pointers.where(entity_type: entity_type, private: false).map(&:entity)\n arr = arr.keep_if { |l| l.owner != self } if entity_type == \"List\"\n arr\n end\n end", "def entity_ids(domain)\n @providers[domain].map do |block|\n block.call(domain)\n end.flatten.compact\n end", "def get_workspace_entity_types(workspace_namespace, workspace_name)\n path = self.api_root + \"/api/workspaces/#{uri_encode(workspace_namespace)}/#{uri_encode(workspace_name)}/entities\"\n process_firecloud_request(:get, path)\n end", "def find_entity_ids(*query)\n query = create_query(*query)\n path = \"entities/#{query.type}\"\n data = { where: query.constraints, offset: query.offset,\n limit: query.limit, orderBy: query.order_by }\n service.post(path, data).map {|e| e[:id]}\n end", "def type_names\n\t\ttypes_names = DATABASE.execute(\"SELECT name FROM types WHERE id='#{self.type_id[0]}' OR id='#{self.type_id[1]}';\") \t\n\t\treturn types_names\n\tend", "def reading_incidence_type_ids\n reading_incidences.pluck(:reading_incidence_type_id)\n end", "def find_all(klass)\n ds = @model_class.where(:class_type=>klass.to_s)\n ds.all.map {|r| r[:id] }\n end", "def id_mapping_types\n @id_mapping_types ||= extract_classes_with_true(:track_imported_ids, configuration)\n end", "def index\n @identity_types = IdentityType.all\n end", "def get_mixin_type_identifiers\n identifiers = []\n\n get_mixin_types.each do |mixin_type|\n identifiers << 'http://schemas.ogf.org/occi/infrastructure#' + mixin_type\n end\n\n identifiers\n end", "def type\n entity_type.name\n end", "def identifiers(filter = Set.new)\n list(filter).entities.map { |ent| ent['occi.core.id'] }\n end", "def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end", "def ingested_ids\n ingested_ids_by_type.flatten\n end", "def ingested_ids\n ingested_ids_by_type.flatten\n end", "def tags_for type\n tag_ids = ActsAsTaggableOn::Tagging\n .where(taggable_type: type.camelize, context: :tags)\n .collect(&:tag_id)\n .uniq\n ActsAsTaggableOn::Tag\n .where(id: tag_ids)\n end", "def get_link_type_identifiers\n get_kind_type_identifiers_related_to Occi::Core::Link.kind.type_identifier\n end", "def find_by_tags_in_entity_type(tenant_id,entity_type_id,tags,strict=true)\n return @instance.find_by_tags_in_entity_type(tenant_id,entity_type_id,tags,strict)\n end", "def items_for_type(type)\n all_ids = []\n valid_ids = []\n AllItems.get.each do |item_code, values|\n _item_name, item_type, item_valid = values\n next unless item_type == type\n all_ids << item_code\n valid_ids << item_code if item_valid\n end\n\n [all_ids, valid_ids]\n end", "def identifiers\n return [] if __getobj__.blank?\n\n __getobj__.identifier if __getobj__.respond_to?(:identifier)\n end", "def entities viewerid=nil\n tagging_query(viewerid).to_a.map(&:entity)\n end", "def intervention_types_index\n index = {}\n InterventionType.all.each do |intervention_type|\n index[intervention_type.id] = intervention_type\n end\n index\n end", "def default_entity_types(*args)\n Epiphany::Tokenizer::Cache.all_entity_types\n end", "def default_entity_types(*args)\n Epiphany::Tokenizer::Cache.all_entity_types\n end", "def find_many(entity_type, uuids, params)\n uuids.map do |uuid|\n find_one(entity_type, uuid, params)\n end\n end", "def entities_used\n entities_arr = Array.new\n @entities.each do |entity|\n entities_arr << entity.id unless entities_arr.include?(entity.id)\n end\n return entities_arr\n end", "def all(id, type, scope = Amico.default_scope_key)\n validate_relationship_type(type)\n count = self.send(\"#{type.to_s}_count\".to_sym, id, scope)\n count > 0 ? self.send(\"#{type}\", id, {:page_size => count}, scope) : []\n end", "def all_ids\n @all_ids ||= @ids_fenotypes.keys\n @all_ids\n end", "def get_issue_types(project_id_or_key)\n get(\"projects/#{project_id_or_key}/issueTypes\")\n end", "def index\n @entity_types = EntityType.order('id').page(params[:page])\n \n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def index\n @identifier_types = IdentifierType.order(:position).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @identifier_types }\n end\n end", "def find_entities(*query)\n query = create_query(*query)\n ids = find_entity_ids(query)\n load_resources \"entities/#{query.type}\", ids do |id, data|\n create_entity(query.type, id, data)\n end\n end", "def details_by_type_and_id(type, id)\n get(resource_path_for_entity_type(type) + \"/#{id}\")\n end", "def fetch_related_oids( oid )\n\t\toid = normalize_oid( oid )\n\t\tself.log.debug \"Fetching OIDs of resources related to %s\" % [ oid ]\n\t\treturn self.search( :criteria => {:relation => oid}, :include_related => true )\n\tend", "def allowed_types\n [ Entities::SearchString, \n Entities::Organization, \n Entities::Domain, \n Entities::Host,\n Entities::Person, \n Entities::Username, \n Entities::Account]\nend", "def types\n get_metadata unless @types\n return @types\n end", "def include_by entity_type, entity_id, user_id\n if entity = entity_type.singularize.camelize.constantize.find(entity_id)\n include entity, user_id\n end\n end", "def dbpedia_types\n _response_entity.fetch(\"type\", [])\n end", "def allowed_types\n [ Entities::Domain, \n Entities::Host, \n Entities::Organization, \n Entities::SearchString, \n Entities::Person]\nend", "def get_all_org_units_by_type_id(outype_id)\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/6606/children/?ouTypeId=#{outype_id}\"\n _get(path)\nend", "def joined_by_type(type)\n\t\tArray(self.joined.find_all_by_joinable_type(type))\n\tend", "def service_types_index\n index = {}\n ServiceType.all.each do |service_type|\n index[service_type.id] = service_type\n end\n index\n end", "def custom_entity_types\n @_custom_entity_types ||= {}\n end", "def custom_entity_types\n @_custom_entity_types ||= {}\n end", "def get_relationships_of_type(type)\n g_command = get_command(type)\n relationships = self.send(g_command.to_sym)\n end", "def find_by_type(types); end", "def find_by_type(types); end", "def allowed_types\n [ Entities::SearchString, \n Entities::Organization, \n Entities::DnsRecord, \n Entities::Host,\n Entities::EmailAddress,\n Entities::Person, \n Entities::Username, \n Entities::Account]\nend", "def type_id\n\t\ttypes_id = [self.type1, self.type2]\n\t\treturn types_id\n\tend", "def return_sub_types\n main_type = type_status\n if main_type\n return self.beer_subtypes.map{|type| {id: type.id, name: type.name}}\n else\n return types_for_subtype\n end\n end", "def list_orphans(type_id = nil)\n call(:get, orphan_path(type_id))\n end", "def has_many_polymorphic_association(key)\n send(\"#{key}_type\").constantize.where(\"#{key}_id\": id)\n end", "def find_entities\n []\n end", "def ref_types\n response = request(:eve, :ref_types)\n result = {}\n response.ref_types.each do |row|\n result[row.ref_type_id] = row.ref_type_name\n end\n result\n end", "def get_related_event_types(category, id, quantity)\n all_events = KeventerReader.instance.catalog_events()\n\n all_events.select{|e| e.event_type.categories.any?{|c| c == category}}\n .select{|e| e.event_type.id != id}\n .uniq{ |e| e.event_type.id}\n .first(quantity)\nend", "def find_entity_and_tag_count_in_entity_type(tenant_id,entity_type_id,tags,strict=true)\n return @instance.find_entity_and_tag_count_in_entity_type(tenant_id,entity_type_id,tags,strict)\n end", "def merchant_types\n MerchantType.find merchant_type_ids\n end", "def get_types(type)\n result = []\n types = TYPE_CONVERSION_TREE[type]\n if types\n result += types\n types.each do |t|\n result |= get_types(t)\n end\n end\n result\n end", "def all\n all_by_type.values.flatten\n end", "def lookup( *ids )\n cache = attribute_cache( :id )\n matching = ids.map do |id|\n entity = cache.fetch( id ) do\n entities.find { |e| e.id == id }\n end\n\n entity || missing_entity_class.new\n end\n\n List.new matching\n end", "def loaded_instances(type)\n @instances[type].keys\n end", "def entity_scope type, viewer\n # type.constantize.tagged_by list.name_tag, [ list.owner_id, viewer.id ]\n type.constantize.joins(:taggings).merge(Tagging.list_scope @list, viewer.id)\n end", "def entity_classes\n @entity_classes ||= []\n end", "def entity_values(kind)\n self.entities.kind(kind.to_s).pluck('value')\n end", "def find_concept_ids(concept_type, concept_search_term)\n if concept_type.blank? and concept_search_term.blank?\n raise ArgumentError, \"Please provide either a concept type or a concept search term\"\n end\n concept_ids = []\n \n #This is the concept type case\n if concept_search_term.blank?\n concept_ids = Concept.find(:all, :conditions => [\"concept_type_id = ?\", concept_type.concept_type_id])\n elsif concent_type.blank?\n \n else\n \n end\n end", "def native_entities\r\n entities = []\r\n for type, type_entities in @types\r\n if type == QuadFace\r\n entities.concat( type_entities.keys.map { |quad| quad.faces } )\r\n else\r\n entities.concat( type_entities.keys )\r\n end\r\n end\r\n entities\r\n end", "def event_types\n meeting_events.includes(:event_type).map(&:event_type)\n end", "def accounts(type=AbstractAccount)\n # See http://stackoverflow.com/questions/3371518/in-ruby-is-there-an-array-method-that-combines-select-and-map/17703276#17703276\n # for why reduce was used here\n self.class.reflect_on_all_associations(:has_one).reduce([]) do |result, association|\n result.push self.send association.name if association.klass < type\n result\n end\n end", "def getObjects(iTypeName)\n return getType(iTypeName).getObjects\n end", "def types\n list = Array.new\n\n if @db != nil\n is_ok = false\n\n begin\n stm = @db.prepare( 'SELECT qType FROM qryResults GROUP BY qType ORDER BY qType')\n rs = stm.execute\n\n rs.each do |row|\n list.push row['qType']\n end\n\n stm.close\n is_ok = true\n rescue ::SQLite3::Exception => e\n Maadi::post_message(:Warn, \"Repository (#{@type}:#{@instance_name}) encountered an SELECT Types error (#{e.message}).\")\n end\n end\n\n return list\n end" ]
[ "0.7796788", "0.74293005", "0.69550896", "0.68346107", "0.6783869", "0.67296726", "0.67119765", "0.6372826", "0.6372268", "0.6317861", "0.6317861", "0.6285354", "0.62398446", "0.6012297", "0.5992851", "0.59634304", "0.5936028", "0.5860965", "0.5858274", "0.57935256", "0.57421315", "0.56829786", "0.56615055", "0.56589544", "0.5563262", "0.5542533", "0.5530776", "0.5508669", "0.55059034", "0.5469174", "0.54602236", "0.5444835", "0.543883", "0.5423524", "0.541388", "0.5377064", "0.53653127", "0.53508085", "0.53258264", "0.5294939", "0.52844477", "0.5259283", "0.5232159", "0.52285767", "0.52285767", "0.5226784", "0.51717913", "0.5153505", "0.51456606", "0.5139777", "0.5123909", "0.51142323", "0.50657856", "0.50657856", "0.5048398", "0.5046798", "0.5042192", "0.5032332", "0.50183", "0.49914527", "0.4987136", "0.49729586", "0.49620023", "0.49610424", "0.49259824", "0.49242228", "0.4922901", "0.4916569", "0.49058074", "0.49007306", "0.49002886", "0.49001554", "0.48913833", "0.48913833", "0.48849535", "0.48810616", "0.48810616", "0.48807988", "0.487039", "0.4865697", "0.48638415", "0.48549676", "0.48539045", "0.485345", "0.48527378", "0.48508364", "0.48398623", "0.48340982", "0.4832018", "0.48294228", "0.48205087", "0.4816602", "0.48165157", "0.48084828", "0.4807406", "0.4805596", "0.48045388", "0.48027724", "0.47978628", "0.4795637" ]
0.8358175
0
Retrieves all available entity types.
def get_entity_types Occi::Log.debug("Getting entity types ...") @model.kinds.collect { |kind| kind.term } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_entity_types\n get_types(Occi::Core::Entity.kind)\n end", "def entity_types\n @entity_types ||= metadata.xpath('//EntityType').collect {|entity| entity.attributes['Name'].value}\n end", "def index\n @entity_types = EntityType.all\n end", "def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end", "def entity_types\n @entity_types ||= parent_tokenizer.class.all_entity_types\n end", "def get_entity_type_identifiers\n get_entity_types_related_to Occi::Core::Entity.kind.type_identifier\n end", "def entity_types\n @entity_types ||= schemas.map do |namespace, schema|\n schema.entity_types.map do |entity_type|\n \"#{namespace}.#{entity_type}\"\n end\n end.flatten\n end", "def entity_types\n @entity_types ||= schemas.map do |namespace, schema|\n schema.entity_types.map do |entity_type|\n \"#{namespace}.#{entity_type}\"\n end\n end.flatten\n end", "def default_entity_types(*args)\n Epiphany::Tokenizer::Cache.all_entity_types\n end", "def default_entity_types(*args)\n Epiphany::Tokenizer::Cache.all_entity_types\n end", "def get_entities(type)\n @entities[type.name]\n end", "def get_workspace_entity_types(workspace_namespace, workspace_name)\n path = self.api_root + \"/api/workspaces/#{uri_encode(workspace_namespace)}/#{uri_encode(workspace_name)}/entities\"\n process_firecloud_request(:get, path)\n end", "def available_types\n gather do |c|\n c.respond_to?(:model_types) ? c.model_types : []\n end\n end", "def get_entity_type_identifiers\n get_kind_type_identifiers_related_to Occi::Core::Entity.kind.type_identifier\n end", "def retrieve_all_entities\n response = self.execute(\"RetrieveAllEntities\", {\n EntityFilters: \"Entity\",\n RetrieveAsIfPublished: true\n },\n Metadata::RetrieveAllEntitiesResponse)\n end", "def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end", "def index\n @entity_types = EntityType.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entity_types }\n end\n end", "def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n\n end", "def types\n get_metadata unless @types\n return @types\n end", "def entities_of_type(type)\n @entities.select { |entity| entity['type'] == type }.map { |entity| Entity.new entity }\n end", "def allowed_types\n [ Entities::Domain, \n Entities::Host, \n Entities::Organization, \n Entities::SearchString, \n Entities::Person]\nend", "def allowed_types\n [ Entities::SearchString, \n Entities::Organization, \n Entities::Domain, \n Entities::Host,\n Entities::Person, \n Entities::Username, \n Entities::Account]\nend", "def index\n breadcrumb_for_collections(@collection)\n semantic_breadcrumb @collection.name, @collection\n semantic_breadcrumb \"Entity Types\"\n @entity_types = @collection.entity_types\n end", "def index\n @entity_types = EntityType.order('id').page(params[:page])\n \n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def entity_classes\n @entity_classes ||= []\n end", "def api_v11_timeseries_entity_types_get(opts = {})\n api_v11_timeseries_entity_types_get_with_http_info(opts)\n return nil\n end", "def get_entity_types_related_to(type_identifier)\n Occi::Log.debug(\"Getting entity type identifiers related to #{type_identifier}\")\n collection = @model.get type_identifier\n collection.kinds.collect { |kind| kind.type_identifier }\n end", "def allowed_entity_types\n [\n GlobalConstant::EntityGroupDraft.theme_entity_type,\n GlobalConstant::EntityGroupDraft.registration_entity_type,\n GlobalConstant::EntityGroupDraft.kyc_entity_type,\n GlobalConstant::EntityGroupDraft.dashboard_entity_type\n ]\n end", "def allowed_types\n [ Entities::SearchString, \n Entities::Organization, \n Entities::DnsRecord, \n Entities::Host,\n Entities::EmailAddress,\n Entities::Person, \n Entities::Username, \n Entities::Account]\nend", "def custom_entity_types\n @_custom_entity_types ||= {}\n end", "def custom_entity_types\n @_custom_entity_types ||= {}\n end", "def get_workspace_entities_by_type(workspace_namespace, workspace_name, entity_type)\n path = self.api_root + \"/api/workspaces/#{uri_encode(workspace_namespace)}/#{uri_encode(workspace_name)}/entities/#{entity_type}\"\n process_firecloud_request(:get, path)\n end", "def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end", "def get_available_types()\n\t\t\tkparams = {}\n\t\t\tclient.queue_service_action_call('uiconf', 'getAvailableTypes', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend", "def list_entities project_id:, entity_type_id:\n # [START dialogflow_list_entities]\n # project_id = \"Your Google Cloud project ID\"\n # entity_type_id = \"Existing Entity Type ID\"\n\n require \"google/cloud/dialogflow\"\n\n entity_types_client = Google::Cloud::Dialogflow::EntityTypes.new\n parent = entity_types_client.class.entity_type_path project_id, entity_type_id\n\n entities = entity_types_client.get_entity_type(parent).entities\n\n entities.each do |entity|\n puts \"Entity value: #{entity.value}\"\n puts \"Entity synonyms: #{entity.synonyms}\"\n end\n # [END dialogflow_list_entities]\nend", "def freebase_types\n _response_entity.fetch(\"freebaseTypes\", [])\n end", "def list\n \n @product_types = ProductType.find(:all, :order => \"name\")\n end", "def types\n load_schema! unless schema_loaded?\n @types\n end", "def type\n entity_type.name\n end", "def dbpedia_types\n _response_entity.fetch(\"type\", [])\n end", "def index\n @types = ItemType.all\n end", "def allowed_types\n [ Entities::Account,\n Entities::DnsRecord, \n Entities::DnsServer, \n Entities::DocFile,\n Entities::EmailAddress,\n Entities::FacebookAccount,\n Entities::Finding,\n Entities::Host, \n Entities::LocalImage,\n Entities::RemoteImage,\n Entities::KloutAccount,\n Entities::NetBlock,\n Entities::NetSvc,\n Entities::Organization,\n Entities::ParsableFile,\n Entities::ParsableText,\n Entities::PdfFile,\n Entities::Person,\n Entities::PhysicalLocation, \n Entities::SearchString, \n Entities::TwitterAccount,\n Entities::Username,\n Entities::WebApplication,\n Entities::WebForm,\n Entities::WebPage,\n Entities::XlsFile ]\n end", "def index\n @egc_server_types = EgcServerType.all\n end", "def types\n @types ||= Types.new(@client)\n end", "def entities_list\n raise 'Not implemented'\n end", "def types\n if @@types.nil? || (@@last_type_check + (4 * 60 * 60)) < Time.now\n @@last_type_check = Time.now\n @@types = _make_request(:types)['results']\n end\n @@types\n end", "def entities\n @entities ||= []\n end", "def get_all\n Rutodo::Database::Todo.map(&:as_entity)\n end", "def find_entities\n []\n end", "def index\n @article_types = ArticleType.all\n end", "def index\n @types = Type.all\n end", "def get_list_service_types\n ServiceType.get_list_service_types\n end", "def all\n all_by_type.values.flatten\n end", "def show\n @entity_types = EntityType.where(project_id: @document.project_id)\n @document.adjust_offset(true)\n end", "def index\n @entities = Entity.all\n end", "def index\n @entities = Entity.all\n end", "def show\n @entity_types = EntityType.where(collection_id: @document.collection_id)\n @document.adjust_offset(true)\n end", "def all\n Ribs.with_handle(self.database) do |h|\n h.all(self.metadata.persistent_class.entity_name)\n end\n end", "def all_of_type\n Resource::AllOfType.new(type)\n end", "def entities\n @entities ||= begin\n acc = {}\n @api.routes.filter_map(&:entity).each do |entity|\n collect_entities(acc, entity)\n end\n acc.keys.sort_by(&:name)\n end\n end", "def allowed_types\n [ Entities::DnsRecord, \n Entities::Host, \n Entities::Organization, \n Entities::User]\nend", "def available_related_content_types\n available_related_content.map{|hash| hash['Type'] }\n end", "def index\n @platform_account_types = PlatformAccountType.all\n end", "def index\n @vendor_item_types = VendorItemType.all\n end", "def entities\n @entities\n end", "def index\n @entities = Entity::Repo.roots\n end", "def all\n list = []\n page = 1\n fetch_all = true\n\n if @query.has_key?(:page)\n page = @query[:page]\n fetch_all = false\n end\n \n while true\n response = RestClient.get(@type.Resource, @query)\n data = response['data'] \n if !data.nil? && data.any?\n data.each {|item| list << @type.from_json(item)}\n \n if !fetch_all\n break\n else\n @query.merge!(page: page += 1)\n end\n else\n break\n end\n end\n\n return list\n end", "def allowed_types\n [ Entities::SearchString,\n Entities::Organization ]\nend", "def resources\n typed_set(entities, Occi::Core::Resource)\n end", "def show\n @breadcrumb = 'read'\n @entity_type = EntityType.find(params[:id])\n @entities = @entity_type.entities.paginate(:page => params[:page], :per_page => per_page).order('fiscal_id')\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entity_type }\n end\n end", "def entities\n @entities ||= Entity.from_models(self, @models)\n end", "def entities\n _entities\n end", "def entities\n _entities\n end", "def index\n @engagement_types = EngagementType.all\n end", "def index\n @class_types = ClassType.all\n end", "def index\n @author_site_types = SiteType.fetch_data(current_user)\n end", "def index\n @tipo_entidades = TipoEntidade.all\n end", "def service_types_generated \n types = [ ServiceTypeValue[:fulltext], ServiceTypeValue[:holding], ServiceTypeValue[:table_of_contents], ServiceTypeValue[:relevant_link] ]\n \n return types\n end", "def all\n raise ArgumentError, \"No type specified for query\" if @type.nil?\n\n @store.load_from_url(uri_builder.resources_uri(@type, to_query))\n end", "def types\n respond_to?(:articleType) ? articleType : []\n end", "def entity_type\n return @entity_type\n end", "def types\n @types ||= []\n end", "def index\n @competence_types = CompetenceType.all\n end", "def index\n @epargne_types = EpargneType.all\n end", "def index\n @entity_statuses = EntityStatus.all\n end", "def get_workspace_entities(workspace_namespace, workspace_name)\n path = self.api_root + \"/api/workspaces/#{uri_encode(workspace_namespace)}/#{uri_encode(workspace_name)}/entities_with_type\"\n process_firecloud_request(:get, path)\n end", "def get_entity_list(entity_type, ns=Model::NS_MMD_1)\n # Search for the first occuring node of type entity which is a child node\n # of the metadata element.\n entity_list = @document.elements[\n \"//[local-name()='metadata' and namespace-uri()='%s']/[local-name()='%s-list' and namespace-uri()='%s'][1]\" %\n [Model::NS_MMD_1, entity_type, ns]]\n \n unless entity_list.nil? or entity_list.is_a? REXML::Text\n collection = Model::ScoredCollection.new(entity_list.attributes['count'],\n entity_list.attributes['offset'])\n # Select the method to use for reading the list.\n read_list_method = method('read_' + entity_list.name.gsub('-', '_'))\n \n # Read the entity list and store the entities in the collection.\n read_list_method.call(entity_list, collection, true) if read_list_method\n \n return collection\n else\n return Model::ScoredCollection.new\n end\n end", "def index\n @event_types = EventType.all\n respond_with @event_types\n end", "def entity_sets\n entity_container.entity_sets\n end", "def entity_sets\n entity_container.entity_sets\n end", "def entity_sets\n entity_container.entity_sets\n end", "def get_activites_supportedtypes()\n @restv9.get_activites_supportedobjecttypes()\n end", "def collected_entities entity_type, viewer=nil\n entity_type = entity_type.to_s\n if viewer == self\n assoc = entity_type.to_s\n scope = self.method(assoc).call\n scope = scope.where.not(owner_id: id) if entity_type == \"List\"\n scope\n else\n arr = collection_pointers.where(entity_type: entity_type, private: false).map(&:entity)\n arr = arr.keep_if { |l| l.owner != self } if entity_type == \"List\"\n arr\n end\n end", "def index\n @expense_types = ExpenseType.all\n end", "def org_types\n organizations.map(&:organization_type)\n end", "def get_report_types\n \n LOGGER.info \"list all report types\"\n Reports::ReportFactory::REPORT_TYPES.collect{ |t| get_uri(t) }.join(\"\\n\")\n end", "def service_types\n get_info :service_types\n end", "def index\n @attendence_types = AttendenceType.all\n end", "def item_types(refresh: false)\n cname = \"#{name}.item_types\"\n Rails.cache.delete(cname) if refresh\n\n Rails.cache.fetch(cname) do\n list = []\n implementation_classes.each do |imp_class|\n list += imp_class.attribute_names\n .select { |a| Classification::GeneralSelection.use_with_attribute?(a) }\n .map do |a|\n mn = imp_class.model_name.to_s.ns_underscore\n mn = mn.pluralize unless imp_class.respond_to?(:is_activity_log)\n \"#{mn}_#{a}\".to_sym\n end\n end\n\n list\n end\n end", "def index\n @instance_types = InstanceType.all\n end" ]
[ "0.82866675", "0.7752563", "0.75918645", "0.7248464", "0.7244958", "0.7227515", "0.72221315", "0.72221315", "0.7029091", "0.7029091", "0.6950121", "0.68591714", "0.6712268", "0.6696491", "0.6655576", "0.6602504", "0.6525311", "0.64333314", "0.6367737", "0.63387257", "0.6275062", "0.6272941", "0.62449896", "0.62423307", "0.6216905", "0.61877376", "0.6176852", "0.6176107", "0.6173128", "0.6135612", "0.6135612", "0.6121399", "0.6068783", "0.6054574", "0.60510623", "0.59608185", "0.5946732", "0.5937348", "0.591743", "0.59160376", "0.5882015", "0.5880578", "0.58671564", "0.5862159", "0.5850606", "0.5847761", "0.5800407", "0.5785744", "0.57776904", "0.5768224", "0.57643956", "0.5763587", "0.57192034", "0.5694575", "0.56857646", "0.56857646", "0.568192", "0.5675008", "0.5671244", "0.5644988", "0.56433934", "0.56413776", "0.56401044", "0.5631816", "0.56304246", "0.5628991", "0.5628041", "0.56132865", "0.5608646", "0.56037617", "0.55925435", "0.55828875", "0.55828875", "0.5576508", "0.5570298", "0.5567791", "0.5567558", "0.55647475", "0.55504465", "0.55486524", "0.55477625", "0.5539032", "0.55320406", "0.5524959", "0.55216336", "0.5516997", "0.55129766", "0.5511147", "0.5504893", "0.5504893", "0.5504893", "0.5500046", "0.5496744", "0.54949677", "0.5484571", "0.54801863", "0.5479392", "0.54659826", "0.5463687", "0.5458688" ]
0.82484925
1