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
Called when a message is received, receiving ReceiverHandlercount messages
def on_message(delivery, message) # Print received message if @log_msgs == "body" Formatters::BasicFormatter.new(message).print elsif @log_msgs == "dict" Formatters::DictFormatter.new(message).print end # If process reply to if @process_reply_to and !message.reply_to.nil? self.do_process_reply_to(message) end # Increase number of received messages @received = @received + 1 # If all messages are received if @received == @count # Close receiver delivery.receiver.close # Close connection delivery.receiver.connection.close end # if end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def message_received(message)\n @message_handlers.each do |block|\n block.call(message)\n end\n end", "def on_receive(message)\n end", "def received\n end", "def receive_msg msg\n # stub, overwrite this in your handler\n end", "def receives_messages\n Messenger.resolve(@@default_messenger).add_message_handler do |message|\n new.received(message)\n end\n end", "def on_message(message)\n if Integer === message\n @count += message\n end\n end", "def on_message(message)\n if Integer === message\n @count += message\n end\n end", "def receive_message(message)\n end", "def on_receive(message)\n update\n end", "def on_message_call handler\n @@handler_symbol = handler\n end", "def received message, headers={}\n end", "def on_message_data_receiving_event(ctx) end", "def handle_messages!\n self.logger.debug { \"Starting message handler.\" }\n \n loop do\n message = nil\n\n # reads data\n self.logger.debug { \"Waiting for messages.\" }\n message = self.protocol.wait_interaction!\n \n # if nil data arrived, it means termination\n if message.nil?\n break\n end\n \n self.logger.debug { \"Message of type '#{message.type}' received.\" }\n\n # calls processing method according to incoming message\n case message.type.to_sym\n when :order\n self.handle_order(message)\n end\n \n end\n \n self.logger.debug { \"Message handler terminated.\" }\n end", "def on_incoming_message(msg)\n type = msg.operation\n debug \"(#{id}) Deliver message '#{type}': #{msg.inspect}\"\n htypes = [type, :message]\n if type == :inform\n # TODO keep converting itype is painful, need to solve this.\n if (it = msg.itype(:ruby)) # format itype as lower case string\n case it\n when \"creation_ok\"\n htypes << :create_succeeded\n when 'status'\n htypes << :inform_status\n end\n\n htypes << it.to_sym\n end\n end\n\n debug \"(#{id}) Message type '#{htypes.inspect}' (#{msg.class}:#{msg.cid})\"\n hs = htypes.map { |ht| (@handlers[ht] || {}).values }.compact.flatten\n debug \"(#{id}) Distributing message to '#{hs.inspect}'\"\n hs.each do |block|\n block.call msg\n end\n if cbk = @context2cbk[msg.cid.to_s]\n debug \"(#{id}) Distributing message to '#{cbk.inspect}'\"\n cbk[:last_used] = Time.now\n cbk[:block].call(msg)\n end\n end", "def handle_message(message)\n if @response_wait_list.waiting_for?(message)\n @response_wait_list.received(message)\n else\n @listener.receive_message(message)\n end\n end", "def process_msgs\n end", "def msg_received(notification)\n data = notification.userInfo.objectForKey(NSFileHandleNotificationDataItem)\n if data.length > 0\n NSLog(\"msg_received\")\n @on_read.call(data)\n end\n @handle.readInBackgroundAndNotify\n end", "def handle_message(event)\n sender = @users[event['sender']]\n timestamp = event['origin_server_ts'] || Time.now.to_i\n content = event['content']\n message = Message.new sender, timestamp, content\n broadcast(:message, @room, message)\n Events.processed event\n end", "def on_message(&handler)\n @on_message_handler = handler\n end", "def on_receive_message(\n subscriber_klass,\n delivery_info,\n metadata,\n payload\n )\n logger.debug '**************************'\n logger.debug subscriber_klass.inspect\n logger.debug delivery_info.inspect\n logger.debug metadata.inspect\n logger.debug payload.inspect\n\n if delivery_info.routing_key\n routing_key = [app_name, delivery_info.routing_key].join(delimiter)\n executable = subscriber_klass.executable_for(routing_key)\n end\n\n unless executable\n routing_key = [app_name, exchange_name].join(delimiter)\n executable = subscriber_klass.executable_for(routing_key)\n end\n\n logger.debug \"routing_key: #{routing_key}\"\n return unless executable\n\n subscriber = subscriber_klass.new\n subscriber.channel = @subject.channel\n\n subscription_handler =\n EventSource::Protocols::Amqp::BunnyConsumerHandler.new(\n subscriber,\n delivery_info,\n metadata,\n payload,\n &executable\n )\n\n subscription_handler.run\n rescue Bunny::Exception => e\n logger.error \"Bunny Consumer Error \\n message: #{e.message} \\n backtrace: #{e.backtrace.join(\"\\n\")}\"\n ensure\n subscriber = nil\n end", "def received\n @received ||= message.received\n end", "def message_received(&callback)\n if block_given?\n @message_received_callbacks << callback\n else\n @message_received_callbacks.each { |c| c.call }\n if @check_interval > 0\n now = Time.now\n if (now - @last_received) > MIN_RESTART_INACTIVITY_TIMER_INTERVAL\n @last_received = now\n restart_inactivity_timer\n end\n end\n end\n true\n end", "def receive_and_handle_messages(max_count = 10)\n logger.debug(\"Receiving messages from queue (max: #{max_count})\")\n\n msg_count = 0\n msg = nil\n \n while (msg = @receive_queue.pop) && (msg_count <= max_count)\n Watchy::Message.handle(msg)\n msg_count += 1\n end\n\n logger.info(\"Received #{msg_count} messages\")\n end", "def did_receive_channel_message(stem, sender, channel, msg)\n end", "def listen_for_messages\n @queue.subscribe do |_delivery_info, _metad5ata, payload|\n data = JSON.parse(payload)\n display_message(data['user'], data['message'])\n end\n end", "def message_received(client, msg)\n content = JSON.parse msg.data\n\n kind = content['type'] || 'empty message'\n\n OutputLogger.logger.info \"Received a message of the #{kind} type.\"\n OutputLogger.logger.debug content\n\n method = \"on_#{content['type']}\"\n\n send(method, content, client) if respond_to?(method)\n end", "def handle_message(request, message)\n #\n end", "def _receive_message state\n state.message_payload = _read(state.in_stream, state)\n end", "def receiving(data); end", "def receiving(data); end", "def message_received(type, from, text, time = nil)\n msg = message_db.add(\n type: type,\n to: type == :message ? username : nil,\n from: from,\n text: text,\n time: time\n )\n signal_change(type, msg)\n end", "def subscribe &handler\n input = \"\"\n response = 0\n #wait for message from pull socket\n while true\n response = @pull.recv_string(input)\n if !error?(response)\n input.chomp!\n\n #Message received\n yield input if block_given?\n Communicator::get_logger.info \"Message received: #{input}\"\n end\n end\n end", "def receive_data(data)\n handle(data)\n end", "def on_message(m)\n end", "def on_message_data_event(ctx); end", "def set_message_handler(&block); end", "def on_message(&block)\n @@message_callback = block\n end", "def received(message)\n if message.respond_to?(:encoding) && message.encoding != 'UTF-8'\n message.force_encoding 'UTF-8'\n end\n data = JSON.parse message, :symbolize_names => true\n\n case data[:type]\n when 'text'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n room.message @user, data[:text], name_color, data[:client_ts]\n when 'av-invite', 'av-accept', 'av-close'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n av_message data\n when 'sync'\n @last_event_id = data[:last_event_id].to_i\n sync_events\n when 'ping'\n respond pong: { nonce: data[:nonce], client_ts: data[:client_ts] }\n when 'relay'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n room.relay @user, data[:to], data[:body], data[:client_ts]\n end\n end", "def on_message(pattern, event, message)\n _, message = event.split(\":\")\n unless message == self.identity\n @logger.debug({context: :monitor, pattern: pattern, event: event, message: message}.to_json)\n data = @client.hgetall(fnamespace)\n self.set(namespace, value)\n end\n end", "def on_message_data_event(ctx) end", "def process_messages\n # Check status for all streams, reopen as necessary\n @streams.each { |_, stream| try { stream.keep_alive } }\n\n # Actual processing of incoming messages happens in event callbacks\n # Oбрабатываем пришедшее сообщение в интерфейсах обратного вызова\n @conn.ProcessMessage2(100)\n end", "def handle_messages\n messages = *disque.fetch(from: queue_name,timeout: 100,count: batch_size)\n messages.each do |queue,id,data|\n Chore.logger.debug \"Received #{id.inspect} from #{queue.inspect} with #{data.inspect}\"\n yield(id, queue, nil, data, 0)\n Chore.run_hooks_for(:on_fetch, id, data)\n end\n messages\n end", "def receive_data(data)\n end", "def received(data)\n RequestsChannel.broadcast_to(@request, {request: @request, users: @request.users, messages: @request.messages})\n end", "def on_message(&processor_block)\n raise \"Message processor already registered\" if @message_processor\n @message_processor = processor_block\n end", "def onmessage(&block)\n super( &proc do |msg|\n msg = JSON.parse(msg)\n Hammer.logger.debug \"Websocket recieved: #{msg}\" if config[:logger][:show_traffic]\n block.call msg\n end)\n end", "def receive\n # Process msg_descriptor\n Subscriber.execute_from_descriptor(msg_descriptor)\n head :no_content\n rescue InvalidSubscriberError\n # 404: Message delivery will be retried\n head :not_found\n rescue StandardError\n # 422: Message delivery will be retried\n head :unprocessable_entity\n end", "def message_callbacks\n @messagecbs\n end", "def receive_message\n true\n end", "def receive(data); end", "def actual_received_count\n actual_messages.size\n end", "def listen_for_messages\n queue = @channel.queue(\"\")\n\n queue.bind(@exchange).subscribe do |delivery_info, metadata, payload|\n data = JSON.parse(payload)\n display_message(data['user'], data['message'])\n end\n end", "def receive_data &block\n self.on_data_received = block\n end", "def did_receive_private_message(stem, sender, msg)\n end", "def on_message(event)\n message = JSON.parse(event.data)\n\n if message['id']\n message['command'] = 'response_received'\n elsif message['message']\n command, *args = *message['message']\n message = {'command' => command, 'args' => args}\n end\n\n logger.debug \"Message received: #{message.inspect}\"\n dispatch(message)\n end", "def message_received(&callback)\n @connectivity_checker.message_received(&callback)\n end", "def receive_data(data)\n @buffer.extract(data).each do |line|\n payload = { :uuid => @uuid, \n :message => line,\n :host => @host,\n :user => @user }\n @global_history_fanout.publish(payload.to_json)\n end\n end", "def receive(message)\n info(\"[Smartfocus] Receive -> #{message}\")\n end", "def process_messages\n @messages.pop do |channel, message|\n Fiber.new do\n on_message(channel, message)\n process_messages\n end.resume\n end\n end", "def on_connection_listener_fetch_loop_received(event)\n listener = event[:caller]\n time = event[:time]\n messages_count = event[:messages_buffer].size\n\n message = \"[#{listener.id}] Polled #{messages_count} messages in #{time}ms\"\n\n # We don't want the \"polled 0\" in dev as it would spam the log\n # Instead we publish only info when there was anything we could poll and fail over to the\n # zero notifications when in debug mode\n messages_count.zero? ? debug(message) : info(message)\n end", "def on_newmessage(time, userid, username, msg)\n end", "def message_count\n 0\n end", "def process\n logger.info \"Beetle: received message #{message.inspect}\"\n end", "def receive_msg(msg)\n if msg.command == \"CONNECTED\"\n @log.debug(\"#{self} received CONNECTED : #{msg.inspect}\")\n @connected = true\n else\n @log.debug(\"got a message: #{msg.inspect}\")\n @log.debug(\"#{self} got a message\")\n @data_received << msg # accumulate messages\n end\n end", "def process_message(message)\n end", "def receive(message)\n self.class.listeners.map do |matcher, block|\n match = matcher.match(message)\n block.call(match) if match\n end.compact\n end", "def on_message(env, msg)\n log(\"received\", msg)\n Message.new(@connection, msg).dispath\n end", "def did_receive_notice(stem, sender, recipient, msg)\n end", "def onmessage(msg)\n Slanger::Statsd.increment(\"messages\")\n Slanger::Statsd.gauge(\"message_size\", msg.bytesize)\n\n msg = Oj.load(msg)\n\n msg[\"data\"] = Oj.load(msg[\"data\"]) if msg[\"data\"].is_a? String\n\n case msg[\"event\"]\n when /\\Aclient-/\n msg[\"socket_id\"] = socket_id\n Channel.send_client_message(msg)\n when \"pusher:ping\"\n pusher_ping(msg)\n when \"pusher:pong\"\n pusher_pong(msg)\n when \"pusher:subscribe\"\n pusher_subscribe(msg)\n when \"pusher:unsubscribe\"\n pusher_unsubscribe(msg)\n end\n rescue JSON::ParserError, Oj::ParseError\n send_error({ code: 5001, message: \"Invalid JSON\" })\n rescue Exception => e\n puts \"Error: #{e.class.name}: #{e.message}\\n#{e.backtrace.join(\"\\n\")}\"\n send_error({ code: 500, message: \"Internal Error\" })\n end", "def process_messages\n\t\t\tloop do\n\t\t\t\tchan, message = @redis_listener.blpop(\"#{PREFIX}.network:#{@network}.messages\", 0)\n\t\t\t\[email protected](\"A client sent the message : #{message}\")\n\t\t\t\tmsgid, command, args = parse(message)\n\t\t\t\tunless command\n\t\t\t\t\[email protected](\"A client sent an invalid message.\")\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif msgid && @failed_cmds.include?(msgid) # Every daemon tried to contact the multi (blpop act as first waiting, first served)\n\t\t\t\t\tanswer(msgid, false, \"No daemon could contact the multiplexer\")\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tans, info = case command\n\t\t\t\t\twhen \"add_sensor\"\n\t\t\t\t\t\tregister_device :sensor, args\n\t\t\t\t\twhen \"add_actuator\"\n\t\t\t\t\t\tregister_device :actuator, args\n\t\t\t\t\twhen \"delete_sensor\"\n\t\t\t\t\t\tunregister_device :sensor, args\n\t\t\t\t\twhen \"delete_actuator\"\n\t\t\t\t\t\tunregister_device :actuator, args\n\t\t\t\t\twhen \"take\"\n\t\t\t\t\t\ttake_callback args\n\t\t\t\t\twhen \"actuator_state\"\n\t\t\t\t\t\tactuator_state_callback args\n\t\t\t\t\telse\n\t\t\t\t\t\[email protected](\"A client sent an unknown command : \\\"#{command}\\\"\")\n\t\t\t\t\t\t[false, \"Unknown command \\\"#{command}\\\"\"]\n\t\t\t\tend\n\t\t\t\tcase ans\n\t\t\t\t\twhen true # Success\n\t\t\t\t\t\tanswer(msgid, true)\n\t\t\t\t\twhen false # Failure\n\t\t\t\t\t\tanswer(msgid, false, info)\n\t\t\t\t\telse # Timeout error, transmit to another daemon\n\t\t\t\t\t\tif not msgid\t\t\t # Generate an id only for daemons\n\t\t\t\t\t\t\tmsgid = rand.hash.abs\n\t\t\t\t\t\t\tmessage = \"#{msgid}:#{message}\"\n\t\t\t\t\t\tend\n\t\t\t\t\t\t@failed_cmds.push(msgid).unshift\n\t\t\t\t\t\t#answer(msgid, false, \"wait\") # TODO utile ?\n\t\t\t\t\t\t@redis_listener.lpush(\"#{PREFIX}.network:#@network.messages\", message) #TODO generate with path?\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def receive(websocket_message); end", "def receive_message\n #$>.puts \"Received complete message\"\n true\n end", "def received\n @messages = Message.sent_to current_user\n end", "def hbrecv_count\n @connection.hbrecv_count\n end", "def handle_messages(&handler)\n raise NotImplementedError\n end", "def receive_data(data)\n # a large json-rpc message may be split over multiple packets\n # (invocations of receive_data)\n # and multiple messages may be concatinated into one packet\n @data += data\n while extracted = JSONParser.extract_json_from(@data)\n msg, @data = *extracted\n @rjr_node.send(:handle_message, msg, self) # XXX private method\n end\n end", "def handle_incoming_message(data)\n message = parse(data)\n text = message[:text].downcase\n\n if text.include?(\"now playing\") || text.include?(\"coming next\")\n @logger.debug(\"Discarding message #{message}\")\n else\n @logger.debug(\"Keeping message #{message}\")\n # fire on_message callbacks\n notify(:on_message, message)\n # if the is_new? is true then fire on_programme_changed callbacks\n notify(:on_programme_changed, message) if is_new?(message)\n # store the message in the cache\n cache_store(message[:station_id], message)\n end\n end", "def handle_message(metadata, payload)\n @consumer_channel.push payload\n end", "def receive(message)\n info(\"[Emailvision] Receive -> #{message}\")\n end", "def handle_message(message, ip, transport)\n payload = message.payload\n\n @message_hooks[payload.class].each do |hook|\n hook.call(payload)\n end\n @message_signal.broadcast\n end", "def on_receive(&block)\n self.on_receive = block if block\n @on_receive\n end", "def message_handler(&message_proc)\n @message_proc = message_proc\n end", "def receive_data(data)\n self.received_data += data\n process_data if data.end_with?(\"\\n\")\n end", "def on_message(message)\n search_for = message.event.split(\"/\")\n raise InvalidBackendEvent(message.event) if search_for.size < 2\n klass = @handlers[search_for[0]] and handler = klass.method(search_for[1])\n raise UndefinedHandler.new(message.event) unless handler\n logger.info(\"#{message.event}, #{message.inspect}\")\n handler.call(message)\n end", "def receive_data(data)\n data.chomp!\n @@count = @@count + 1\n puts(\"Count : #{@@count} - Data : #{data}\")\n end", "def receive(message, &callback)\n lock = $_LOCK_ # get a reference to the receiver's lock\n # and use it to synchronize the callback with any other input that may be happening at that receiver\n synchronized_callback = lambda do |*args|\n lock.synchronize do\n callback.call(*args)\n end\n end\n # It seems that if we are going to use the global variable store, then the key (the message)\n # needs to be converted to a String (identical symbols are apparently not equal across Ruby evaluators.)\n SendReceive.registry[message.to_s] << [synchronized_callback, $max_object] # and records the binding for the current $max_object.\n end", "def handle_message(message)\n maybe_print(message)\n msg = MessageHandlerMessage.new(message, self)\n route_message(msg)\n rescue => e\n sender = msg.try(:sender) || \"UNKNOWN-SENDER\"\n send_error(sender, e)\n end", "def process_when_ready(msg)\n # Dropped messages will be redelivered as we reconnect\n # when calling worker.pump.start\n return unless self.redis\n\n bump_message_counter!\n\n return process_message!(msg) unless msg.has_dependencies?\n\n # We wait for each link/read versions to be equal to what we received.\n # For write versions, since they represent the value of the corresponding\n # counters after all the increments, we have to figure out the version that\n # they would be before all the increments.\n read_increments = count_dependencies(msg.dependencies[:read])\n deps = []\n deps += msg.dependencies[:write].map do |dep|\n dep.dup.tap { |d| d.version -= 1 + read_increments[d.key(:sub).for(:redis)].to_i }\n end\n deps += msg.dependencies[:read]\n deps << msg.dependencies[:link] if msg.dependencies[:link]\n\n deps.reduce(proc { process_message!(msg) }) do |chain, dep|\n proc { on_version(dep.key(:sub).for(:redis), dep.version) { chain.call } }\n end.call\n end", "def run(&blk)\n consumer.each{|i| item_received(message_to_item(i), &blk)}\n end", "def recv_callback\n @recv_callback ||= Proc.new {|message|}\n end", "def onmessage(&blk); super; end", "def receive_object message\n transition_on_recv message_name(message), message\n end", "def on_server_response(connection, message)\n end", "def on_message client, data\n controller(client).on_message(data)\n end", "def handle_message(message,sock)\n if message.nil? or !message.respond_to?(:type)\n Routing.log {|logger| logger.error(self.class) {\"Not a correct message: #{message.to_s}.\"}}\n return\n end\n\n case message.type\n when Protocol::MessageType::PING\n on_ping(message,sock)\n when Protocol::MessageType::PONG\n on_pong(message,sock)\n when Protocol::MessageType::REQUEST_SUPERNODES\n on_request_supernodes(message,sock)\n when Protocol::MessageType::RESPONSE_SUPERNODES\n on_response_supernodes(message,sock)\n when Protocol::MessageType::PROMOTION_ADS\n on_supernode_promotion(message,sock)\n else\n Routing.log{|logger| logger.error(self.class) {\"Unknown message type: #{message.to_s}.\"}}\n end\n end", "def do_recv()\n data = super()\n message = Hurricane::Message.new()\n message.type = data.data[0].name\n message.destination = data.data[1]\n message.tag = data.data[2]\n message.data = data.data[3]\n message\n end", "def receive_data(data)\n #@logger.trace { \">>> #{data.inspect}\" }\n @buffer.receive(data) do |message_type_char, raw_message|\n @message = MosesPG::Message.create(message_type_char, raw_message)\n @logger.trace { \">>> #{@message}\" }\n @message.events.each { |event| send(event) }\n end\n self\n end", "def set_message_handler &block\n @message_handler = block\n end", "def on_message_complete\n @currently_reading.finish_reading! if @currently_reading.is_a?(Request)\n\n if @currently_responding\n @pending_responses << @currently_reading\n else\n @currently_responding = @currently_reading\n end\n\n @currently_reading = @pending_reads.shift\n end", "def handler\r\n\t loop do \r\n\t socket = @rqueue.pop\r\n\t req = Request.new socket \r\n\t if req.broadcast == true\r\n\t handle_broadcast req \r\n\t else\r\n\t handle_listen req\r\n\t end\r\n\t \r\n\t end\r\n \tend" ]
[ "0.6887329", "0.6765397", "0.6757999", "0.6747996", "0.66874695", "0.665105", "0.665105", "0.65329725", "0.6487146", "0.64148605", "0.6400146", "0.6390028", "0.6385803", "0.63106287", "0.63036394", "0.6216118", "0.6165126", "0.61249256", "0.61115146", "0.60898244", "0.6086603", "0.6038203", "0.60149646", "0.60014665", "0.59975773", "0.5997549", "0.5966184", "0.5952721", "0.5946798", "0.5946798", "0.59319097", "0.59265006", "0.5921696", "0.5916774", "0.5891132", "0.58830976", "0.5875804", "0.5866712", "0.58650213", "0.5846713", "0.58448106", "0.5826898", "0.579607", "0.5793339", "0.5783193", "0.57805634", "0.57742536", "0.5767437", "0.57640487", "0.5761612", "0.575899", "0.57539284", "0.574355", "0.5742835", "0.5727032", "0.5726647", "0.5724511", "0.5720863", "0.57067114", "0.5679051", "0.5676183", "0.5669827", "0.5665695", "0.5656005", "0.56507105", "0.564083", "0.5640745", "0.56352806", "0.56315416", "0.56031525", "0.55991673", "0.5585555", "0.5579094", "0.5574444", "0.55739874", "0.5568231", "0.5550377", "0.55501366", "0.5527976", "0.5521611", "0.5518153", "0.5510388", "0.5505079", "0.550374", "0.5503512", "0.55013484", "0.5500732", "0.5496489", "0.5493998", "0.5486294", "0.54835576", "0.5475272", "0.5471087", "0.546594", "0.54529953", "0.54469824", "0.5443318", "0.5440453", "0.5432075", "0.5429828" ]
0.6549731
7
default value is nil
def value nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default\n nil\n end", "def default\n nil\n end", "def set_default\n end", "def default; end", "def default; end", "def default=(_); end", "def default\n end", "def default=(value); end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults; end", "def defaults!; end", "def defaults!; end", "def default_value(value); value; end", "def default=(_arg0); end", "def default value = nil\n @default = value if value\n @default\n end", "def default\n igetset(:default) { nil }\n end", "def default\n @default\n end", "def default!\n @value = default\n end", "def set_default\n (!default || value?) ? self : add_value(default)\n end", "def default\n return nil unless default_value\n default_value.respond_to?(:call) ? default_value.call : default_value.dup\n end", "def default(options = T.unsafe(nil)); end", "def default\n ''\n end", "def default\n @default = true\n end", "def required_defaults; end", "def default_value \n self[:value] ||= {}\n self[:value][:default_value] ||= []\n self[:value][:default_value].delete('-1')\n self[:value][:default_value]\n end", "def default\n self['default']\n end", "def default_data\n end", "def default_entry\n nil\n end", "def default\n return @default\n end", "def default?\n @default\n end", "def default=(p0) end", "def default\n @what = :default\n self\n end", "def default\n options[:default]\n end", "def default\n @type = :default\n end", "def null\n end", "def default(key) end", "def default_value(val); @@next_default_value = val; end", "def default\r\n @opts[:default]\r\n end", "def default_values\n \t self.status ||= '0'\n \tend", "def default\n #----------\n \n # the default field value; retrieve from the options\n default = options[ :default ]\n \n # is there are default value?\n unless default.nil?\n self.value_from( default.respond_to?( :call ) ? default.call : default )\n end\n \n end", "def default_value\n return @default_value\n end", "def set_defaults\n end", "def set_defaults\n end", "def default_values\n\t\tself.done ||= 'false'\n\t\tself.flag ||= 'false'\n\tend", "def get_default_value\n raise 'get_default_value must be implemented'\n end", "def default_values\n self.deleted ||= '0'\n end", "def default_value\n self['default']\n end", "def set_defaults\n\n end", "def set_defaults\n\n end", "def set_defaults\n\n end", "def set_defaults\n\n end", "def set_defaults\n\n end", "def set_defaults\n\n end", "def default?\n @default\n end", "def default_values\n self.subtype ||= \"registered\"\n self.status ||= \"NEW\"\n end", "def default?\n [email protected]?\n end", "def null?; false end", "def default(id = T.unsafe(nil)); end", "def safe_by_default; end", "def default?; return !explicit?; end", "def recommended_value; nil; end", "def setDefault\n self.monthlyCost ||= 0.0 # will set the default value only if it's nil\n self.annualCost ||= 0.0\n end", "def optional; end", "def is_default?\n return self.name == '_default'\n end", "def default_if_not_specified(opt,default_opt)\n opt ? opt : default_opt\nend", "def param_default( param, value )\n param = value unless ( param && param.length > 0 )\n end", "def set_default(value)\r\n\t\t\tself.default_value = value\r\n\t\tend", "def default_value(val); @next_default_value = val; end", "def default_value(val); @next_default_value = val; end", "def default_value\n default_db_value ? default_db_value.to_s : \"null\"\n end", "def default_value\n\t\t# This bizarre construct is done in order to not be reliant\n\t\t# on the inherent assignment-order when using Property.new({...})\n\t\t# since that hash can be ordered anywhich way .daniel\n\t\tif value_id\n\t\t\tvalue_object.default_value\n\t\telse\t\t\t\n\t\t\t@default_value\n\t\tend\n\tend", "def default_values\n self.communication_email ||= self.email\n end", "def default_values\n\t\tself.max_student ||= 0\n\t\tself.backup_student ||= 0\n\tend", "def default\n attributes.default\n end", "def method_missing(*args)\n default\n end", "def default\n @default || atlas_default\n end", "def defaults\n super\n end", "def default_value\n return unless default?\n\n node_parts[1]\n end", "def default_options; {} end", "def default_value\n self[:value] ||= {}\n self[:value][:default_value] ||= ''\n self[:value][:default_value].to_f unless self[:value][:default_value].empty?\n end", "def defaults(defaults = T.unsafe(nil)); end", "def default?\n @id == :default\n end", "def default_values\n self.trash ||= false\n end", "def value\n nil\n end", "def value\n nil\n end", "def default_value\n { 'value' => '', 'other' => '' }\n end", "def defaults\n {}\n end", "def default_value\n match = if definition =~ /timestamp|datetime/i\n /default '?(.+[^'])'?/i.match(definition)\n else\n /default '?(\\w+)'?/i.match(definition)\n end\n\n return unless match\n\n match[1].downcase != 'null' ? match[1] : nil\n end", "def defaults\n {}\n end", "def defaults\n {}\n end", "def default_options; end" ]
[ "0.80734533", "0.80734533", "0.78648186", "0.78594214", "0.78594214", "0.7794627", "0.7660349", "0.7625772", "0.7573737", "0.7573737", "0.7573737", "0.7573737", "0.7573737", "0.7573737", "0.7573737", "0.7573737", "0.7573737", "0.7573737", "0.7526293", "0.7526293", "0.7503683", "0.74725294", "0.74529463", "0.7424886", "0.7414528", "0.7275165", "0.72350866", "0.72224545", "0.71769947", "0.7164157", "0.7116932", "0.71118796", "0.7108768", "0.7094999", "0.7078771", "0.70710176", "0.7062535", "0.7033295", "0.70217454", "0.7003568", "0.69824564", "0.6978665", "0.6973163", "0.69488", "0.69471365", "0.6938562", "0.6936775", "0.69342434", "0.692478", "0.6917226", "0.6917226", "0.6912857", "0.69033307", "0.69028", "0.6900077", "0.6897971", "0.6897971", "0.6897971", "0.6897971", "0.6897971", "0.6897971", "0.68932086", "0.6882929", "0.6867232", "0.68435454", "0.6820381", "0.68050116", "0.678846", "0.67833227", "0.67691684", "0.6761085", "0.67585254", "0.67371106", "0.67327493", "0.67316645", "0.67304236", "0.67304236", "0.6726673", "0.6724921", "0.6723075", "0.6712806", "0.67116106", "0.6711514", "0.670877", "0.66989756", "0.6697346", "0.6688779", "0.6681579", "0.6674393", "0.6672313", "0.6665726", "0.6652544", "0.6652544", "0.66459846", "0.66198117", "0.66141427", "0.6611704", "0.66108584", "0.6604627" ]
0.6708905
84
convenience for collecting lists for example a list of things might be specified by the rule first:thing rest:(delimiter item:thing) this returns a list of those things, provided first, rest, and item are so defined
def items (rest.elements || []).inject([first]) { |list, el| list << el.item } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_list; end", "def parse_list; end", "def saw_begin_list(list); end", "def parse_lists_from_subject(subject)\n # extract part between '[...]'\n subject.to_s.match(/\\[(.*)\\]/)\n if $1\n # and create array by valid separators: \\s , |\n subject_array = $1.split(/[\\s,|]/)\n else\n return []\n end\n lists = []\n List.all.each do |list|\n subject_array.each do |pot_list|\n if pot_list.casecmp(list.name) == 0\n lists << list\n end\n end\n end\n return lists\n end", "def process_item_list(item)\n aux_item = item.strip\n\n # remove start [\n if aux_item.start_with?('[')\n aux_item = aux_item[1..aux_item.length]\n end\n\n # remove end ]\n if aux_item.end_with?(']')\n aux_item = aux_item[0..aux_item.length-2]\n end\n\n aux_item\n end", "def process(items) \n out = []\n \n if items.is_a?(Array)\n items.each do |item|\n out << item.scan(@regex).flatten\n end\n \n elsif items.is_a?(String)\n out = items.scan(@regex).flatten#{|m| m.to_s}\n \n else\n out = items\n end\n \n out.flatten\n end", "def wp_parse_list(list)\n return list if list.kind_of?(Array)\n list.split(/[\\s,]+/)\n end", "def format_list(items); end", "def accept_list_item_start list_item\n case @list_type.last\n when :NOTE, :LABEL then\n Array(list_item.label).map do |label|\n tt_sections label\n end.flatten\n end\n end", "def accept_list_item_start list_item\n @res << list_item_start(list_item, @list.last)\n end", "def create_list(items)\n\n\tgrocery_list = {}\n\n\tlist_items = items.split(\" \")\n\n\t#best practice...\n\tlist_items.each do |item_name|\n\t\tgrocery_list = add_item(grocery_list, item_name)\n\tend\n\n\treturn grocery_list\nend", "def transform_list_items( str, rs )\n\t\t\[email protected] \" Transforming list items\"\n\n\t\t\t# Trim trailing blank lines\n\t\t\tstr = str.sub( /\\n{2,}\\z/, \"\\n\" )\n\t\t\tstr.gsub( ListItemRegexp ) {|line|\n\t\t\t\[email protected] \" Found item line %p\" % line\n\t\t\t\tleading_line, item = $1, $4\n\t\t\t\tseparating_lines = $5\n\n\t\t\t\tif leading_line or /\\n{2,}/.match(item) or not separating_lines.empty? then\n\t\t\t\t\[email protected] \" Found leading line or item has a blank\"\n\t\t\t\t\titem = apply_block_transforms( outdent(item), rs )\n\t\t\t\telse\n\t\t\t\t\t# Recursion for sub-lists\n\t\t\t\t\[email protected] \" Recursing for sublist\"\n\t\t\t\t\titem = transform_lists( outdent(item), rs ).chomp\n\t\t\t\t\titem = apply_span_transforms( item, rs )\n\t\t\t\tend\n\n\t\t\t\t%{<li>%s</li>\\n} % item\n\t\t\t}\n\t\tend", "def makelist(list)\n case list\n when String\n list = list.split(/[:;]/)\n else\n list = Array(list).map{ |path| path.to_s }\n end\n list.reject{ |path| path.strip.empty? }\n end", "def makelist(list)\n case list\n when String\n list = list.split(/[:;]/)\n else\n list = Array(list).map{ |path| path.to_s }\n end\n list.reject{ |path| path.strip.empty? }\n end", "def makelist(list)\n case list\n when String\n list = list.split(/[:;]/)\n else\n list = Array(list).map{ |path| path.to_s }\n end\n list.reject{ |path| path.strip.empty? }\n end", "def create_list(items)\r\n\r\n\tgrocery_list = {}\r\n\r\n\tlist_items = items.split(\" \")\r\n\r\n\t#best practice...\r\n\tlist_items.each do |item_name|\r\n\t\tgrocery_list = add_item(grocery_list, item_name)\r\n\tend\r\n\r\n\treturn grocery_list\r\nend", "def saw_end_list(list); end", "def accept_list_item_start(list_item)\n if tag = @in_list_entry.last\n @res << tag\n end\n\n @res << list_item_start(list_item, @list.last)\n end", "def extract_matched_items(items)\n []\n end", "def parse_first_list_line(indentation, content); end", "def shopping_list(ingredients)\n\t\tlist = ingredients.split(/\\n/)\n\tend", "def group_selectors(seq)\n newseq = []\n tail = seq.dup\n until tail.empty?\n head = []\n begin\n head << tail.shift\n end while !tail.empty? && head.last.is_a?(String) || tail.first.is_a?(String)\n newseq << head\n end\n newseq\n end", "def create_list(items)\n\tnew_list = {}\n\titem_arr = items.split\n\titem_arr.each do |item|\n\t\tadd_item(new_list, item)\n\tend\n\tprint_list(new_list)\n\t\nend", "def get_items\n @fdata.scan(SUB_ITEM_REGEXP)\n end", "def list_item_from unparsed\n parsed = inner_parse unparsed.join\n RDoc::Markup::ListItem.new nil, *parsed\n end", "def partition(&block) # :nodoc:\n resolve\n result = @items.partition(&block)\n [\n PropertyGroup::PathList.new.import(result[0]),\n PropertyGroup::PathList.new.import(result[1]),\n ]\n end", "def create_items items\n list = RDoc::Markup::List.new :NOTE\n\n items.each do |item|\n item =~ /\\A(.*?(?:\\([^)]+\\))?):\\s*/\n\n title = $1\n body = $'\n\n paragraph = RDoc::Markup::Paragraph.new body\n list_item = RDoc::Markup::ListItem.new title, paragraph\n list << list_item\n end\n\n list\n end", "def create_items items\n list = RDoc::Markup::List.new :NOTE\n\n items.each do |item|\n item =~ /\\A(.*?(?:\\([^)]+\\))?):\\s*/\n\n title = $1\n body = $'\n\n paragraph = RDoc::Markup::Paragraph.new body\n list_item = RDoc::Markup::ListItem.new title, paragraph\n list << list_item\n end\n\n list\n end", "def flatten_repetition(list, named); end", "def apply_one_rule!(rule, input)\n output = []\n while first = input.shift\n if first.kind_of?(String)\n rule.doc = @doc\n rule.apply(first, input, output)\n else\n output << first\n end\n end\n output\n end", "def _consume_rule seq\n # rule = rulename defined-as elements c-nl\n\n rulename = seq.shift\n raise \"BUG: bad rulename #{rulename.inspect}\" if rulename.nil? || rulename.type != :name\n\n raise \"truncated rule for #{rulename.value}\" if seq.empty?\n\n defined_as = nil\n case (op = seq.shift).type\n when :EQ, :EQ_ALT\n defined_as = op\n else\n raise \"unexpected #{op.type.inspect}, expected :EQ or :EQ_ALT\"\n end\n\n definition = _alternation(seq)\n raise \"unexpected #{seq.first.type.inspect} after rule\" unless seq.empty? || seq.first.type == :endline\n [rulename, defined_as, definition]\n end", "def list(**options)\n result = []\n\n search = options[:pattern].to_s.downcase\n group = options[:group].to_s.downcase\n\n @data.each do |item|\n next if item.empty?\n next unless group.empty? || group.eql?(item.group.to_s.downcase)\n\n host = item.host.to_s.downcase\n comment = item.comment.to_s.downcase\n\n next unless host =~ /^.*#{search}.*$/ || comment =~ /^.*#{search}.*$/\n\n result.push(item)\n end\n\n result\n end", "def each\n items = {}\n subject = []\n source.each_line do |line|\n parsed_line = Line.parse(line)\n if parsed_line.is_a?(Line::ChecklistItem)\n raise DuplicateItemNames if items.key?(parsed_line.to_s)\n\n items.merge!(parsed_line.to_s => parsed_line.checked?)\n elsif parsed_line.is_a?(Line::Header)\n raise DuplicateSubjectNames if subject.include?(parsed_line.to_s)\n\n unless items.empty?\n yield subject, items\n items.clear\n end\n if parsed_line.nesting > subject.count + 1\n subject << parsed_line.to_s\n elsif parsed_line.nesting == subject.count + 1\n subject.pop if subject.count.positive?\n subject.push(parsed_line.to_s)\n else\n (subject.count - parsed_line.nesting + 2).times do\n subject.pop\n end\n subject.push(parsed_line.to_s)\n end\n end\n end\n\n unless items.empty?\n yield subject, items\n items.clear\n end\n end", "def extended_grammar(sets)\n rules = []\n sets.each do |set|\n set.items.each do |item|\n if item.dot == 0\n rule = [item]\n next_item = item.next_item\n while next_item != nil\n rule << next_item\n next_item = next_item.next_item\n end\n rules << rule\n end\n end\n end\n rules\n end", "def parse(list)\n list.gsub(/[^\\w\\ ,]+/, '').squeeze(\" \").downcase.split(\",\").map(&:strip).reject { |s| s.blank? }.uniq\n end", "def extract_argument_lists(args, splittable_args); end", "def list(*) end", "def quotelist( *args )\n\t\t\treturn args.flatten.collect {|part| part =~ /\\s/ ? part.inspect : part}\n\t\tend", "def _ItemsList\n\n _save = self.pos\n while true # choice\n _tmp = apply_with_args(:_UnorderedList, 1)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_OrderedList)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_DefinitionList)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_LongDefinitionList)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_ItemsList unless _tmp\n return _tmp\n end", "def list(names)\n if names.size == 0 ; return ''\n elsif names.size == 1 ; return \"#{names[0][:name]}\"\n else ; first_elements = names[0..-2].map {|element| element[:name]}\n return \"#{first_elements.join(\", \")} & #{names[-1][:name]}\"\n end\nend", "def items\n lineitems.each_with_object([]) {|lineitem,arr| arr << lineitem.item}\n end", "def list_of_items(string_of_items)\n items = string_of_items.split(\", \")\n bays = \"\"\n for x in items\n bays += bay_for_item(x) + \", \"\n end\n return bays[0...-2]\nend", "def process_items(items)\n if items\n\n # We begin here with no IPs set. This is used to determin if we are\n # setting the primary address, or simply providing an alias to an\n # already existing interface.\n ipset = false\n ip6set = false\n\n # Process each one of the line items\n items.each do |i|\n # Return the dynamic address assignemnt if found\n if i =~ %r{^(dhcp|inet6 autoconf)$}\n yield i\n # yield up/down if found\n elsif i =~ %r{^(up|down)$}\n yield i\n # Yield the command string in full\n elsif i =~ %r{^!}\n yield i\n else\n begin\n ip = IPAddress i\n if ip.ipv6?\n line = ['inet6']\n line << 'alias' if ip6set\n line << ip.compressed\n line << ip.prefix\n ip6set = true\n elsif ip.ipv4?\n line = ['inet']\n line << 'alias' if ipset\n line << ip.address\n line << ip.netmask\n line << 'NONE'\n ipset = true\n end\n if line\n yield line.join(' ')\n else\n puts line\n puts 'line not found'\n end\n rescue ArgumentError\n # In the case we have received something we don't know how to\n # handle, and is not an IP address as caught here in the else, then\n # we just send it back unmodified.\n yield i\n end\n end\n end\n end\n end", "def make_list_from_item(item, flatten = false)\n res = []\n if item.respond_to?('each')\n item.each do |e|\n if flatten\n res << make_list_from_item(e)\n else\n res << e\n end\n end\n else\n res << item\n end\n return res\n end", "def parse_matching_rules( needles, haystack, include_wildcard = true )\n needles = [*needles]\n\n needles.push( WILDCARD_KEY ) if include_wildcard\n\n matched_values = []\n\n needles.each do | needle |\n matched_values += haystack[needle].split( /\\s*,\\s*/ ) if haystack.key?( needle )\n end\n\n return matched_values\n end", "def extract_passages( keys, passage_list = 'null' )\n passages = []\n if passage_list && passage_list != 'null'\n passage_list.split(',').each do |passages_data|\n passages << extract_passage( keys, passages_data )\n end\n end\n passages\n end", "def extract_ingredients_structured\n # NOTE manish 9/17/12 This is for food52 http://www.food52.com/recipes/4175_gin_spritz\n # Interestingly it has to be evaluated before li[contains(@itemprop]!)]\n ingredients = @doc.xpath(\"//p[contains(@itemprop, 'ingredients')]\").collect { |s| clean_text(s.text)}\n\n ingredients = @doc.xpath(\"//div[contains(@class, 'ingredients')]//li\").collect { |s| clean_text(s.text)\n } if ingredients.empty?\n ingredients = @doc.xpath(\"//div[contains(@id, 'ingredients')]//li\").collect { |s| clean_text(s.text)} if ingredients.empty?\n\n # READ READ READ READ: a lot of these patterns have no test. You can remove two or three of these\n # patterns and the test will still pass. In the future if you add a pattern, document the website\n # or page for which you are adding the pattern\n\n ingredients = @doc.xpath(\"//li[contains(@class,'ingredient')]\").collect { |s| clean_text(s.text)} if ingredients.empty?\n ingredients = @doc.xpath(\"//li[contains(@itemprop,'ingredient')]\").collect { |s| clean_text(s.text)} if ingredients.empty?\n ingredients = @doc.xpath(\"//span[contains(@class, 'ingredient')]\").collect { |s| clean_text(s.text)} if ingredients.empty?\n ingredients = @doc.css(\"div.ingredients-section li\").collect { |s| clean_text(s.text)} if ingredients.empty?\n ingredients\n end", "def start_special_list(list_type)\n end", "def separated_by1(sep, sym, &block)\n _defmetasyntax(\"separated_by1\", _intern(sym), block) {|target|\n seq(sym) {|x| [x] }\\\n | seq(target, sep, sym) {|list, _, x| list.push x; list }\n }\n end", "def find_arrangements(prefix, start, items, last)\n\tif items != [] then\n\t\tr = items.map { |item|\n\t\t\tif item - start <= 3 then\n\t\t\t\trest = items.select { |elem| elem > item }\n\t\t\t\tfind_arrangements(prefix + [start], item, rest, last)\n\t\t\telse\n\t\t\t\t[]\n\t\t\tend\n\t\t}.flatten 1\n\t\tr\n\telse\n\t\tif last - start <= 3 then\n\t\t\t[prefix + [start, last]]\n\t\telse\n\t\t\t[]\n\t\tend\n\tend\nend", "def lists\n lines.inject([]){ |lists, line| lists << split(line) }\n end", "def multi\n first.is_a?(::Symbol) || first.is_a?(::String) ? [ self ] : self\n end", "def apply_first_and_last\n return if ordered_list.to_a.empty?\n graph << RDF::Statement.new(value.subject, ::RDF::Vocab::IANA.first, ordered_list.head.next.rdf_subject)\n graph << RDF::Statement.new(value.subject, ::RDF::Vocab::IANA.last, ordered_list.tail.prev.rdf_subject)\n end", "def start_dotted_items()\n start_symbol = grammar.start_symbol\n start_items = dotted_items.select do |anItem|\n (anItem.lhs == start_symbol) && anItem.at_start?\n end\n \n return start_items\n end", "def list_of(things,opts={})\n raise ArgumentError, 'got nil list of things' if things.nil?\n if !opts.delete(:force_list) && things.empty?\n content_tag(:span,'none',opts)\n else\n kind = things.first.table_name rescue 'items'\n add_class_to_html_options(opts, kind)\n add_class_to_html_options(opts, 'records') if things.first.andand.is_a?(ActiveRecord::Base)\n add_class_to_html_options(opts, 'list')\n add_class_to_html_options(opts, 'empty') if things.blank?\n content_tag(\n :ul,\n things.andand.collect do |thing|\n list_item(thing, opts)\n end.andand.join(' '),\n opts\n )\n end\n end", "def list names\n names = names.map { |name| name[:name] }\n p names\n case\n when names.count == 0\n \"\"\n when names.count == 1\n names[0]\n when names.count == 2\n names[0] + \" & \" + names[1]\n when names.count > 2\n last = names.pop\n names.join(\", \") + \" & \" + last\n end\nend", "def parse_definition_list; end", "def create_list_of(string_of_items)\n\tary_of_items = string_of_items.split(' ')\n\titem_list = {}\n\tary_of_items.each {|x| item_list[x] = 1}\n\tprint_list(item_list)\nend", "def create_grocery_list(list, item_list)\n items = item_list.split\n items.each do |item|\n list.store(item, 1)\n end\n return list\n print_list(grocery_list)\nend", "def new_list(item_String, quantity = 1)\n $list = []\n array_strings = item_String.split\n array_strings.each do |element|\n \tlist_item = {\n \t\tquantity: quantity,\n \t\titem: element\n \t}\n \t $list.push(list_item) \n \tend\nend", "def rulelist(ruleset, ctx)\r\n\r\n outlist = \"\"\r\n\r\n ruleset.rules.each do |ralias|\r\n rname = ctx.rules[ralias].name\r\n outlist += reference(\"rule\", rname)\r\n\r\n end # rules.each\r\n\r\n return outlist\r\n\r\n end", "def sub_elements\n r = @value.split(@sub_element_separator)\n if block_given?\n r.each {|se| yield se}\n return nil\n end\n return r\n end", "def parse_items(items)\n hash = Hash.new\n items.split(',').each { |x| hash[x.split(' ')[1]] = x.split(' ')[0] }\n hash\n end", "def gather_prefixes(tlds)\n prefixes = []\n while tlds.length > 0\n prefix = tlds.first[0]\n i = tlds.index {|tld| tld[0] != prefix} || tlds.length\n group = tlds[0...i].map {|tld| tld[1..-1]}\n if (j = group.index(''))\n group.delete_at(j)\n group << ''\n end\n r = (group.length == 1) ? group.first : gather_prefixes(group)\n prefixes << \"#{prefix}#{r}\"\n tlds = tlds[i..-1]\n end\n \"(?:#{prefixes.join('|')})\"\nend", "def get_multiple(list)\n list.map{ |x| x.nil? ? nil : get(x) }\n end", "def split(parts); end", "def split_definition(raw_def)\n # TODO: your implementation here\n\n #breaks down the non-terminal and the elements for the non-terminal\n raw_def = raw_def.map {|x| x.sub(/>/, '>;')}\n raw_def = raw_def.map{|x| x.strip}\n raw_def = raw_def.map{|x| x.split(/;/).flatten.map{|y| y.strip}}\n raw_def = raw_def.map{|x| x.map{|x| x.strip}}\n\nend", "def names\n\n get_list['list'].collect { |re, pa| re }\n end", "def join_list(delim, list) { :'Fn::Join' => [ delim, list ] } end", "def items\n @lists.collect(&:items).flatten\n end", "def chain_rule\n output = []\n variables.each_with_index do |variable, i|\n j = i - 1\n given = j < 0 ? [] : variables[0..i - 1]\n output << {variable => given}\n end\n output\n end", "def closed_begin_list(list); end", "def human_list(list)\n case list.length\n when 0\n \"\"\n when 1\n list[0]\n when 2\n \"#{list[0]} and #{list[1]}\"\n else\n \"#{list[0...-1].join(', ')}, and #{list[-1]}\"\n end\nend", "def list_values(bn, lists)\n raise \"no list\" unless lists.has_key?(bn)\n first, rest = lists[bn][RDF.first], lists[bn][RDF.rest]\n (rest == RDF.nil ? [] : list_values(rest, lists)).unshift(first)\n rescue\n lists.delete(bn)\n raise $!\n end", "def list_style(item); end", "def extract_listname(object)\n extract_list(object).list\n end", "def split(pattern=$;, limit=0) end", "def split(pattern=$;, limit=0) end", "def accept visitor\n visitor.accept_list_item_start self\n\n @parts.each do |part|\n part.accept visitor\n end\n\n visitor.accept_list_item_end self\n end", "def items\n res = []\n each_element('item') { |item|\n res << item\n }\n res\n end", "def many\n ->string, position {\n pos = position\n rets = []\n loop do\n case ret = parse(string, pos)\n when Pass\n rets << ret.matched\n pos = ret.position\n else\n return Pass.new(rets, pos)\n end\n end\n \n }.extend Parsable\n end", "def custom_delimiters\r\n\t\toutput = []\r\n\t\toutput << input.split(\"]\\n\").first[3..-1].split(\"][\") if input.start_with?('//')\r\n\t\toutput.flatten\r\n\tend", "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 list_thing(thing)\n next_marker = nil\n things = []\n loop do\n response = waf.send(\"list_#{thing}\", next_marker: next_marker, limit: 10)\n things += response.send(thing)\n next_marker = response.next_marker\n break unless next_marker\n end\n things\n end", "def parse_items(feed)\n items = ExtractData.list_same_tag_data(feed, 'item').map { |item| \"<item>#{item}</item>\"}\n parsed_items = []\n\n items.each do |item|\n parsed_item = parse_tag('item', RssSpecification::ITEM_TAGS, item)\n parsed_items << parsed_item unless parsed_item.empty?\n end\n\n parsed_items\n end", "def process_pair_list list, hash\n list = list[1..-2] # Remove square brackets\n if list.class == NilClass\n list = \"\"\n end\n array = list.split /\\s*,\\s*\\(/\n array.each do |pair|\n pair.delete! \"(\"\n pair.delete! \")\"\n components = pair.split /\\s*,\\s*/\n hash[components[0]] = components[1]\n end\n end", "def visit_rule(node)\n rules = node.rule[0].split(',')\n\n rules.each do |rule|\n append_child_rules(node, rule.strip)\n end\n end", "def create_list(items)\n list = {}\n arr = items.split(' ')#split string into indivdual strings\n arr.each do |item| list[item] = 1 end #iterate over arr in order to pass each string into the list\n \tlist \nend", "def list_items\r\n list = \"\"\r\n items.each{ |item| list = list + item.name + \"\\n\"}\r\n list\r\n end", "def _separate args, pattern=nil #/^[a-zA-Z]/ \n tag = nil\n items = []\n args.each do |arg| \n if arg =~ /^[0-9\\.]+$/\n items << arg\n else\n tag = arg\n if pattern\n die \"#{@action}: #{arg} appears invalid.\" if arg !~ pattern\n end\n end\n end\n items = nil if items.empty?\n return tag, items\n end", "def accept_list_item_start list_item\n type = @list_type.last\n\n case type\n when :NOTE, :LABEL then\n bullets = Array(list_item.label).map do |label|\n attributes(label).strip\n end.join \"\\n\"\n\n bullets << \"\\n:\"\n\n @prefix = ' ' * @indent\n @indent += 4\n @prefix << bullets + (' ' * (@indent - 1))\n else\n bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'\n @prefix = (' ' * @indent) + bullet.ljust(4)\n\n @indent += 4\n end\n end", "def seplist(list, sep = nil, iter_method = :each)\n first = true\n list.__send__(iter_method) do |*v|\n if first\n first = false\n elsif sep\n sep.call(self)\n else\n comma_breakable\n end\n yield(*v)\n end\n end", "def parse_list(user, listfile)\n #match only first found line, there should be no duplicates; also, case insensitive SHOULD be ok.\n line=File.readlines(listfile).select { |line| line =~ /#{user}/i }[0]\n val=line.split(':')\n return val[6].strip, val[1], val[2].strip, home \nend", "def items\n items, iter = [], @obj.items\n while (i = iter.next) do\n items << i\n end\n items\n end", "def accept_list_item_start list_item\n type = @list_type.last\n\n case type\n when :NOTE, :LABEL then\n bullets = Array(list_item.label).map do |label|\n attributes(label).strip\n end.join \"\\n\"\n\n bullets << \":\\n\" unless bullets.empty?\n\n @prefix = ' ' * @indent\n @indent += 2\n @prefix << bullets + (' ' * @indent)\n else\n bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'\n @prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)\n width = bullet.length + 1\n @indent += width\n end\n end", "def all(params = {})\n begin\n parse get nil, params\n rescue Exception => e\n []\n end\n end", "def all(params = {})\n begin\n parse get nil, params\n rescue Exception => e\n []\n end\n end", "def all(params = {})\n begin\n parse get nil, params\n rescue Exception => e\n []\n end\n end", "def all(params = {})\n begin\n parse get nil, params\n rescue Exception => e\n []\n end\n end", "def all(params = {})\n begin\n parse get nil, params\n rescue Exception => e\n []\n end\n end" ]
[ "0.5873925", "0.5873925", "0.567244", "0.55718756", "0.5546085", "0.5470776", "0.5439933", "0.5363642", "0.5322854", "0.52626806", "0.5224208", "0.52098763", "0.5199561", "0.5199561", "0.5199561", "0.5196001", "0.51937634", "0.51921177", "0.5191041", "0.5183084", "0.51798224", "0.5132195", "0.5119981", "0.5090297", "0.5077347", "0.50609565", "0.5060923", "0.5060923", "0.50202566", "0.50159127", "0.5013313", "0.50119054", "0.5006539", "0.49973902", "0.49799407", "0.49793553", "0.4971271", "0.49624863", "0.49606273", "0.49604347", "0.49277094", "0.4915913", "0.4904388", "0.49026343", "0.48870483", "0.48816916", "0.48612642", "0.48610166", "0.48523566", "0.48388532", "0.48337713", "0.48305035", "0.48200002", "0.48119476", "0.48048022", "0.48031968", "0.47930697", "0.47828946", "0.47815695", "0.4781439", "0.47761795", "0.4770244", "0.47700393", "0.4765071", "0.47633561", "0.47626367", "0.4761886", "0.47589543", "0.4753067", "0.4752448", "0.47479662", "0.4740491", "0.47403136", "0.47389477", "0.47366145", "0.47109514", "0.47067302", "0.47067302", "0.4686193", "0.4682457", "0.4667185", "0.46662784", "0.4664422", "0.46493906", "0.46485746", "0.46485305", "0.4647073", "0.46418995", "0.46393588", "0.46327433", "0.46323195", "0.46291706", "0.46291298", "0.46252653", "0.4623277", "0.46213448", "0.46213448", "0.46213448", "0.46213448", "0.46213448" ]
0.5606278
3
returns the ABCNodes that are immediate descendants of this node (immediate descendant meaning there may be intervening SyntaxNodes, but they are not ABCNodes) or select from among these children by passing subclasses of ABCNode
def children(*types) if types.count > 0 children.select { |el| el.is_one_of? *types } else next_descendants(ABCNode) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ascendants(*of_type, &block)\n if root?\n []\n else\n __filter_node_list([parent] + parent.ascendants, *of_type, &block)\n end\n end", "def descendants(*args, &blk)\n res = []\n each{|c|\n res += c.descendants(*args, &blk) if c.is_a? XML\n }\n res\n end", "def descendants(*of_type, &block)\n if leaf?\n []\n else\n __filter_node_list(children + children.collect_concat {|child| child.descendants}, *of_type, &block)\n end\n end", "def descendants\n model_base_class.where(descendant_conditions)\n end", "def all_nodes\n [self] + descendants\n end", "def descendants\n tree.tap(&:shift)\n end", "def descendants\n node, nodes = self, []\n node.children.each { |child|\n # Check for circular dependencies\n if !nodes.include?(child)\n nodes += [child]\n nodes += child.descendants\n end\n } unless node.children.empty?\n nodes\n end", "def descendants\n self.class.hierarchy_descendants(self)\n end", "def descendants\n children + children.map(&:children).flatten\n end", "def descendants(pat=nil, *rest, &blk)\n res = []\n @contents.each{|c|\n if pat.nil? or pat === c\n if rest == []\n res << c\n yield c if block_given?\n else\n res += c.children(*rest, &blk)\n end\n end\n if c.is_a? XML\n res += c.descendants(pat, *rest, &blk)\n end\n }\n res\n end", "def descendants\n self.class.descendants_of(self)\n end", "def descendants\n _descendants = children(true)\n children.each do |child|\n _descendants = _descendants + child.descendants\n end\n _descendants\n end", "def descendants\n node, nodes = self, []\n node.children.each { |child|\n # Check for circular dependenciess\n if !nodes.include?(child)\n nodes += [child]\n nodes += child.descendants\n end\n } unless node.children.empty?\n nodes\n end", "def descendants\n children + children.map(&:descendants).flatten\n end", "def descendants_to(*node_types)\n elements.map{|e|\n if node_types.include? e.class\n e\n elsif e.elements\n e.descendants_to *node_types\n else\n []\n end\n }.flatten\n end", "def descendants\n Base.descendants\n end", "def descendants\n children.inject([]) { |m,child|\n m << child\n m += child.descendants\n }\n end", "def children\n list = NodeSet.new(document)\n document.decorate(list)\n\n first = self.child\n return list unless first # Empty list\n\n list << first unless first.blank?\n while first = first.next\n list << first unless first.blank?\n end\n list\n end", "def descendants\n desc = []\n children.each do |tc|\n desc << tc\n desc += tc.descendants if tc.parent?\n end\n desc\n end", "def descendants\n without_self self_and_descendants\n end", "def onlychildren_list\n if matches.length == 1\n [self] + matches[0].onlychildren_list\n else\n [self]\n end\n end", "def find_direct_superclasses\n return @superclasses unless @superclasses.nil?\n query = \"SELECT ?s WHERE{ #{@term.to_ntriples} <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?s }\"\n selection = Jekyll::JekyllRdf::Helper::RdfHelper::sparql.\n query(query).map{ |solution| solution.s.to_s}\n @superclasses = selection\n return selection\n end", "def descendants_r(*args)\n pending = [self]\n des = []\n while !pending.empty?\n e = pending.pop\n e.children(*args).each do |c|\n if !des.include?(c)\n des << c\n pending.push(c)\n end\n end\n end\n des\n end", "def descendants\n return [] if new_record?\n tree_search_class.where(tree_path_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def on_axis_descendant(ast_node, context)\n nodes = XML::NodeSet.new\n\n context.each do |context_node|\n context_node.each_node do |node|\n nodes.concat(process(ast_node, XML::NodeSet.new([node])))\n end\n end\n\n return nodes\n end", "def descendants\n without_self self_and_descendants\n end", "def on_axis_ancestor_or_self(ast_node, context)\n nodes = XML::NodeSet.new\n\n context.each do |xml_node|\n while has_parent?(xml_node)\n if node_matches?(xml_node, ast_node)\n nodes << xml_node\n break\n end\n\n xml_node = xml_node.parent\n end\n end\n\n return nodes\n end", "def children_until_node_not_ancestor_of(klass)\n\t\t\tif !self.node.class.ancestors.include?(klass)\n\t\t\t\treturn []\n\t\t\tend\n\n\t\t\t[self] + self.children.collect { |i|\n\t\t\t\ti.children_until_node_not_ancestor_of(klass)\n\t\t\t}\n\t\tend", "def descendants\n @descendants ||= Set.new\n end", "def children\n\t\treturn self.search( :one, '(objectClass=*)' )\n\tend", "def children\n self.node.children.collect(&:content)\n end", "def flatten_hierarchy c=self\n result = [c]\n c.subclasses.each do |s|\n result += flatten_hierarchy(s)\n end\n result\n end", "def child_nodes(nodes)\n children = XML::NodeSet.new\n\n nodes.each do |xml_node|\n children.concat(xml_node.children)\n end\n\n return children\n end", "def descendents\n ObjectSpace.each_object(Class).select do |object|\n object < self\n end\n end", "def children\n self.class.required_attrs\n .map { |attr| send(attr) }\n .flatten\n .select { |val| val.is_a?(GraphQL::Language::Nodes::AbstractNode) }\n end", "def descendants\n records = fetch_self_and_descendants - [self]\n\n ActsAsOrderedTree::Relation::Preloaded.new(self.class).\n where(:id => records.map(&:id).compact).\n extending(Arrangeable).\n records(records)\n end", "def descendants\n \t\tres=children\n \t\tchildren.each {|c| res += c.descendants}\n \t\treturn res.uniq\n \tend", "def descendants\n \t descendants = []\n \t self.children.each { |child|\n \t descendants += [child] if child.permitted?\n \t descendants += child.descendants\n \t } unless self.children.empty?\n \t descendants \n \tend", "def descendants\n base_and_descendants.where.not(id: descendants_base.select(:id))\n end", "def descendants\n @descendants\n end", "def superclasses(c)\n result = [c]\n while s = c.superclass #rubocop:disable Lint/AssignmentInCondition\n result << s\n c = s\n end\n result\n end", "def subclasses\n if block_given?\n ::Class.all do |c|\n yield c if c < self\n end\n else\n enum_for :subclasses\n end\n end", "def valid_children\n allowed_children_and_descendants.select {|child| child.allowed_parent?(self)}\n end", "def descendants\n _descendants.flatten.uniq\n end", "def subclasses\n @subclasses\n end", "def descendant(n, *ns)\n cursor = self\n\n n.cons(ns).each do |n_|\n cursor = cursor.child(n_)\n end\n\n cursor\n end", "def descendants\n list = []\n children.each do |child|\n list << child\n list.concat(child.descendants)\n end\n list\n end", "def descendants\n list = []\n children.each do |child|\n list << child\n list.concat(child.descendants)\n end\n list\n end", "def each_inheritance(&block)\n @nodes.values.sort.each do |node|\n if node.super_class_node\n block.call node, node.super_class_node\n end\n end\n end", "def descendant_conditions\n column = \"#{self.base_class.table_name}.#{self.base_class.ancestry_column}\"\n lookup = if has_parent? then\n \"%/#{id}\"\n else\n \"#{id}\"\n end\n [\"#{column} like ?\n or #{column} like ?\n or #{column} like ?\n or #{column} like ?\n or #{column} = ?\", \"#{lookup}\", \"#{lookup}/%\", \"#{lookup},%\", \",#{id}\", \"#{id}\"]\n end", "def all_children(special=nil)\n if special && special[:exclude]\n transaction do\n # exclude some items and all their children\n special[:exclude] = [special[:exclude]] if !special[:exclude].is_a?(Array)\n # get objects for ids\n special[:exclude].collect! {|s| s.is_a?(self.class) ? s : self.class.find(s)}\n # get all subtrees and flatten the list\n exclude_list = special[:exclude].map{|e| e.full_set.map{|ee| ee.id}}.flatten.uniq.join(',')\n if exclude_list.blank?\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:left_column]} > #{self[acts_as_nested_set_options[:left_column]]}) and (#{acts_as_nested_set_options[:right_column]} < #{self[acts_as_nested_set_options[:right_column]]})\", :order => acts_as_nested_set_options[:left_column])\n else\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND id NOT IN (#{exclude_list}) AND (#{acts_as_nested_set_options[:left_column]} > #{self[acts_as_nested_set_options[:left_column]]}) and (#{acts_as_nested_set_options[:right_column]} < #{self[acts_as_nested_set_options[:right_column]]})\", :order => acts_as_nested_set_options[:left_column])\n end\n end\n else\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:left_column]} > #{self[acts_as_nested_set_options[:left_column]]}) and (#{acts_as_nested_set_options[:right_column]} < #{self[acts_as_nested_set_options[:right_column]]})\", :order => acts_as_nested_set_options[:left_column])\n end\n end", "def css *args\n if children.any?\n children.css(*args)\n else\n NodeSet.new(document)\n end\n end", "def superclasses(access_type = nil)\n QueryResult.new(\n [\n NodeCache.find_children_of_type(self, \"Base\").select do |base|\n access_type.nil? ? true : base.send(\"#{access_type}?\")\n end\n ].flatten.map {|base| base.cpp_type }\n )\n end", "def subtypes(allow_caching = true)\n my_node(allow_caching).subclasses.collect { |st| SourceClass.new(st.uri) }\n end", "def children\n base_set_class.find(:all, :conditions => \"#{scope_condition} AND #{parent_col_name} = #{self.id}\", :order => left_col_name)\n end", "def flatten_hierarchy_with_suggested_types c=self\n result = [c]\n c.children.each do |s|\n result += flatten_hierarchy_with_suggested_types(s)\n end\n result\n end", "def descendants_and_self\r\n result = [self]\r\n children.each { |child| result << child.descendants_and_self }\r\n result.flatten!\r\n return result\r\n end", "def on_axis_ancestor(ast_node, context)\n nodes = XML::NodeSet.new\n\n context.each do |xml_node|\n while has_parent?(xml_node)\n xml_node = xml_node.parent\n\n if node_matches?(xml_node, ast_node)\n nodes << xml_node\n break\n end\n end\n end\n\n return nodes\n end", "def children\n node.children\n end", "def descendants\n without_self(self_and_descendants)\n end", "def intend_children\n children.select { |child| !child.has_class :hidden }\n end", "def intend_children\n children.select { |child| !child.has_class :hidden }\n end", "def roots\n acts_as_nested_set_options[:class].find(:all, :conditions => \"(#{acts_as_nested_set_options[:parent_column]} IS NULL OR #{acts_as_nested_set_options[:parent_column]} = 0)\", :order => \"#{acts_as_nested_set_options[:left_column]}\")\n end", "def on_axis_descendant_or_self(ast_node, context)\n nodes = on_test(ast_node, context)\n\n nodes.concat(on_axis_descendant(ast_node, context))\n\n return nodes\n end", "def parents(*classes)\n result = []\n ancestor = self.parent\n until ancestor.nil?\n # Filter ancestors by class\n if classes.nil? || classes.empty? || classes.include?(ancestor.class)\n # If a block is given, it must return true for the ancestor to be included\n result.push(ancestor) unless block_given? && !yield(ancestor)\n end\n ancestor = ancestor.parent\n end\n result\n end", "def all_children(options = {})\n conditions = \"(#{nested_set_left} > #{self[nested_set_left]}) and (#{nested_set_right} < #{self[nested_set_right]})\"\n if options[:exclude]\n transaction do\n # exclude some items and all their children\n options[:exclude] = [options[:exclude]] if !options[:exclude].is_a?(Array)\n # get objects for ids\n options[:exclude].collect! {|s| s.is_a?(nested_set_class) ? s : nested_set_class.find(s)}\n # get all subtrees and flatten the list\n exclude_list = options[:exclude].map{|e| e.full_set.map{|ee| ee.id}}.flatten.uniq\n conditions += \" AND id NOT IN (#{exclude_list.join(',')})\" unless exclude_list.empty?\n end\n end\n nested_set_class.find_with_nested_set_scope(:all, :conditions => conditions, :order => nested_set_left)\n end", "def with_children\n [self].tap do |self_with_children|\n if children\n self_with_children.concat(child_nodes)\n end\n end\n end", "def children(pat=nil, *rest, &blk)\n return descendants(*rest, &blk) if pat == :*\n res = []\n @contents.each{|c|\n if pat.nil? or pat === c\n if rest == []\n res << c\n yield c if block_given?\n else\n res += c.children(*rest, &blk)\n end\n end\n }\n res\n end", "def children\n raise NotImplementedError.new(\"All subclasses of Sass::Script::Node must override #children.\")\n end", "def subclasses\n @subclasses ||= Set.new\n end", "def descendants(label = nil)\n Pipeline.dsl(self).descendants(label)\n end", "def set_children\n @nodes_xml.element_children.filter 'node'\n end", "def children\n @root.children & @initial_contents\n end", "def subclasses; end", "def subclasses; end", "def descendants\n model_base_class.scoped(:conditions => descendant_conditions)\n end", "def children\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} = #{self.id}\", :order => acts_as_nested_set_options[:left_column])\n end", "def ancestors_until_node_not_ancestor_of(klass)\n\t\t\tif !self.parent || !self.node.class.ancestors.include?(klass)\n\t\t\t\treturn []\n\t\t\tend\n\n\t\t\t[self] + self.parent.ancestors_until_node_not_ancestor_of(klass)\n\t\tend", "def nodes()\n self.root.nodes()\n end", "def descendant_links\n out = \"\"\n Agency.where('ancestry REGEXP ?', \"[[:<:]]#{self.id}[[:>:]]\").order(name: :asc).each do |a|\n out << \"<a class='agency-ancestry' href='/admin/agencies/#{a.id}'>#{a.name}</a>\"\n end\n return out\n end", "def find_all_nodes(*args)\n raise NotImplementedError\n nodes = @database.all_nodes\n # TODO: design node finder syntax\n nodes\n end", "def getAllChildren\n children = Tree.where(\"tree_type_id = ? AND version_id = ? AND subject_id = ? AND grade_band_id = ? AND code like ?\", tree_type_id, version_id, subject_id, grade_band_id, code+'.%')\n Rails.logger.debug(\"*** tree children: #{children.inspect}\")\n return children\n end", "def all_descendants_sql_by_node(node)\n column_names_initial_select = column_names.join(',')\n column_names_recursive_select = column_names.map { |c| 't.'+ c }.join(',')\n\n sql = \"\n WITH RECURSIVE walk_tree_to_deep(#{column_names_initial_select}) AS\n (\n SELECT #{column_names_initial_select} FROM nodes WHERE parent_id = #{node.id}\n UNION ALL\n SELECT #{column_names_recursive_select}\n FROM nodes t, walk_tree_to_deep ft WHERE t.parent_id = ft.id\n )\n SELECT * FROM walk_tree_to_deep ORDER BY id\n \"\n\n find_by_sql(sql)\n end", "def superclasses(c)\n result = [c]\n while s = c.superclass\n result << s\n c = s\n end\n result\n end", "def descendants(*args)\n return call_ancestry_method(:descendants) if use_ancestry?\n\n Relationship.resources(descendant_rels(*args))\n end", "def generate_ancestor_list(c)\n c.ancestors.find_all { |a| a != c }\n end", "def category_tree\n cats = []\n categories.each do |cat|\n cats << cat\n cats = cats + cat.ancestors\n end\n return cats\n end", "def visit_all(&block)\n visit &block\n children.each {|c| c.visit_all &block}\n end", "def descendants\n if elements\n elements.map{|e| [e] + e.descendants}.flatten\n else\n []\n end\n end", "def children\n\t\treturn children_of @current_node\n\tend", "def ret_matching_nodes(parent_idh)\n if parent_idh[:model_name] == :node\n return [parent_idh]\n end\n filter = [:eq, :assembly_id, parent_idh.get_id()]\n if node_filter = ret_filter(pattern, :node)\n filter = [:and, filter, node_filter]\n end\n sp_hash = {\n cols: [:id, :group_id, :display_name],\n filter: filter\n }\n Model.get_objs(parent_idh.createMH(:node), sp_hash)\n end", "def get_all_children(catalog)\n catalog.descendant_catalogs\n end", "def children\n [] if leaf?\n self.class.where('forestify_left_position > ?', self.forestify_left_position).where('forestify_right_position < ?', self.forestify_right_position)\n end", "def subclasses\n @subclasses ||= []\n end", "def descendants\n Especie.where(\"#{Especie.attribute_alias(:ancestry_ascendente_directo)} LIKE '%,?,%'\", id).where.not(id: id)\n end", "def self_and_descendants\n nested_set_scope.where(\"#{self.class.table_name}.lft >= ? AND #{self.class.table_name}.rgt <= ?\", lft, rgt)\n end", "def leaves\n descendants.where(\"#{self.class.table_name}.rgt - #{self.class.table_name}.lft = ?\", 1)\n end", "def cti_all_descendants\n result = []\n block = Proc.new do |klass, descendants|\n result << klass\n descendants.each(&block)\n end\n @cti_descendants ||= {}\n @cti_descendants.each(&block)\n result\n end", "def find_leaf_nodes\n find(:all, :conditions => ['property_types.id NOT IN (SELECT DISTINCT parent_id FROM property_types WHERE parent_id != 1) AND property_types.id != 1'])\n end", "def self_and_siblings\n parent ? parent.children : Category.roots\n end" ]
[ "0.6157988", "0.609773", "0.597885", "0.5921023", "0.59028864", "0.58992827", "0.5869371", "0.5858752", "0.5817827", "0.5807498", "0.57820797", "0.57800174", "0.5725877", "0.5652421", "0.56303775", "0.56216675", "0.55670446", "0.5550273", "0.5541383", "0.553973", "0.55339015", "0.55273485", "0.55145335", "0.55145097", "0.5510041", "0.5495429", "0.5494057", "0.5494015", "0.54732436", "0.5453175", "0.54371214", "0.5423292", "0.5401736", "0.5388221", "0.5386345", "0.5368105", "0.5342237", "0.53234065", "0.5322161", "0.5318671", "0.5317875", "0.5316269", "0.5312836", "0.5311509", "0.53000486", "0.52991545", "0.52940595", "0.52940595", "0.52937835", "0.5286727", "0.5283833", "0.5282956", "0.5280833", "0.5248945", "0.5226634", "0.52234435", "0.5220667", "0.5208285", "0.52052647", "0.5196056", "0.518702", "0.518702", "0.51822996", "0.5181264", "0.51763827", "0.51731014", "0.5168546", "0.51624256", "0.51557845", "0.51501894", "0.51480937", "0.5134978", "0.5133236", "0.5122489", "0.5122489", "0.51222533", "0.51122284", "0.50954604", "0.5078894", "0.50622255", "0.50616765", "0.50525093", "0.50506455", "0.5040824", "0.5036603", "0.50305355", "0.5029859", "0.5028506", "0.50270414", "0.50264895", "0.5023093", "0.5016113", "0.49822035", "0.49780098", "0.49761462", "0.497446", "0.49708188", "0.49535325", "0.49527833", "0.4944932" ]
0.7292915
0
returns the first child (of type, optionally) or nil if no children
def child(type=nil) c = children(type)[0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_child!(children)\n children[1] || children\n end", "def first\n @children[0]\n end", "def first_child\n child 0\n end", "def child\n children[0]\n end", "def first_child\n children.min_by { |x| x.position}\n end", "def name\n return nil unless children?\n return nil unless first_child.children?\n first_child.first_child\n end", "def child_get(name)\n child = @children.select{ |elem| name.eql?(elem.name) }\n return nil unless child\n child\n end", "def function\n children[0]\n end", "def first_item\n @children[@items.first]\n end", "def first_element_child\n n = self.first_child\n while n do\n if n.node_type == ELEMENT_NODE then\n break\n end\n n = n.next_sibling\n end\n return n\n end", "def get_child(line)\n @children.each do |child|\n return child if child.line == line\n end\n nil\n end", "def child(pat=nil, *rest)\n children(pat, *rest) {|c|\n return c\n }\n return nil\n end", "def [](key)\n selected_child = children.select {|child| child.name == key }\n selected_child.size.eql?(1) ? selected_child.first : selected_child\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 depth_first(value_to_find)\r\n @children.each do |child|\r\n found_node = child.depth_first(value_to_find)\r\n if found_node != nil\r\n return found_node\r\n end\r\n end\r\n\r\n if payload == value_to_find\r\n return self\r\n else\r\n return nil\r\n end\r\n end", "def object\n object? ? children[2] : nil\n end", "def first_public_child\n children.published.first\n end", "def first *a; self.child(*a) + ':first-child' end", "def leftChild\r\n children.first\r\n end", "def child_for_name(name)\n child = child_with_exact_name(name)\n if child\n child\n else\n fallback_child\n end\n end", "def fetch(key)\n if key.empty?\n return @value\n end\n child = @children[key.shift]\n if child\n child.fetch(key)\n else\n return nil\n end\n end", "def first_sibling_in_list\n self.class.asc(:position).first\n end", "def has_one_child\n if self.left_child.nil? && !self.right_child.nil?\n self.right_child\n elsif !self.left_child.nil? && self.right_child.nil?\n self.left_child\n else\n nil\n end\n end", "def find_first_ancestor(type)\n ancestors.find{|a| a.is_a?(type) }\n end", "def first\n @elements.empty? ? nil : @elements[0]\n end", "def first()\n @tiers.each do |tier|\n unless tier.empty?()\n return tier[0]\n end\n end\n \n return nil\n end", "def get_child(path)\n children.find { |child| child.name == path } || OneDrive404.new\n end", "def type_check(type = nil)\n children {|child| type = child.type_check(nil)}\n return type\n end", "def doctype\n @children.each do |child|\n if child.nodeType == DOCUMENT_TYPE_NODE\n return child\n end\n end if @children\n nil\n end", "def child\n\t\tif is_child?\n\t\t\tself\n\t\telse\n\t\t\tif !familyid.blank?\n\t\t\t\tStudySubject.children.with_subjectid(familyid).first\n\t\t\telse\n\t\t\t\tnil\n\t\t\tend\n\t\tend\n\tend", "def value\n @children[0]\n end", "def build_has_one_child_if_nil(parent, child_name)\n child_obj = parent.send(child_name) # equivalent to calling something like @foster.home\n build_attribute_name_template = \"build_#{child_name}\" # e.g. \"build_personal_preference\"\n\n if child_obj.nil?\n # run the dynamic rails method to build a has_one child of the parent model instance\n # e.g. @foster.build_dog_preference\n child_obj = parent.send(build_attribute_name_template)\n end\n\n return child_obj\n end", "def get_child(node, name)\n a = nil\n node.children.each { |child|\n if child.name == name\n a = child\n break\n end\n }\n return a\nend", "def default\n children.where(:is_default => true).order(:position_value).first\n end", "def self_or_first_descendant\n block = self\n while block.descendant; block = block.descendant; end\n block\n end", "def get_child(section, line)\n section.children.each do |child|\n return child if child.line == line\n end\n nil\nend", "def get_first\n return head ? head.data : nil\n end", "def [](name)\n return super(name) if name.is_a?(Fixnum)\n\n if name == 'children'\n fail 'Starting sabre/vobject 4.0 the children property is now protected. You should use the children method instead'\n end\n\n matches = select(name)\n\n if matches.empty?\n return nil\n else\n first_match = matches.first\n # @return [first_match] Property\n first_match.iterator = ElementList.new(matches.to_a)\n return first_match\n end\n end", "def first\n if @prv\n @prv.first\n else\n self\n end\n end", "def first_stream_of( type )\n streams.each do |stream| return stream if stream.type == type end\n return nil\n end", "def find(key)\n return self if @name == key\n @children.each do |child|\n next unless child.respond_to?(:find)\n match = child.find(key)\n return match unless match.nil?\n end\n nil\n end", "def first_child?\n if mother = participant.try(:mother)\n if mother.participant?\n return mother.children.first == self\n end\n end\n false\n end", "def term\n children[0]\n end", "def child(name)\n children.select { |child| child.name == name }.first || NonexistentFSObject.new(name, self)\n end", "def second_child\n child 1\n end", "def find_first(selector, data)\n data = @data unless data\n results = (data/selector)\n if results and results.first\n results.first.inner_html.strip\n else\n nil\n end\n end", "def get(label)\n return self if @label == label\n @children.each do |child|\n return child.get(label) if child.get(label)\n end\n nil\n end", "def child( path )\n\t\tp = path.reverse\n\t\tn = p.pop\n\t\tif (n<0) | (n>content.length)\n\t\t\tnil\n\t\telsif p.length == 0\n\t\t\t@content[ n ] \n\t\telse\n\t\t\t@content[ n ].child( p.reverse )\n\t\tend;\n\tend", "def find( tag = nil )\n tag = Tag.new( tag, Tag.WILDCARD_NS ) unless tag.nil? || tag.is_a?( Tag )\n if block_given?\n children.find do |c|\n c.element? && ( tag.nil? || c.tag == tag ) && yield( c )\n end\n else\n first_element( tag )\n end\n end", "def get_first\n return nil if head.nil?\n return head.data\n end", "def find_leaf\n if first_question.descendants.length > 0\n leaves = first_question.descendants.select {|q| q.leaf?}\n\n raise StandardError, \"Multiple leaves found!\" if leaves.length > 1\n raise StandardError, \"No leaf found!\" if leaves.length == 0\n\n leaves.first\n else\n # Only one question!\n first_question\n end\n\n end", "def peek_first_item\n stack = []\n node, stack = *first_below(@root, stack)\n return nil unless node\n return node, stack\n end", "def default_child_purpose\n labware.plate_purpose.children.first\n end", "def root\n acts_as_nested_set_options[:class].find(:first, :conditions => \"(#{acts_as_nested_set_options[:parent_column]} IS NULL OR #{acts_as_nested_set_options[:parent_column]} = 0)\")\n end", "def get_first\n if @head == nil\n return nil\n else\n return @head.data\n end\n end", "def get_first\n @head == nil ? nil : @head.data\n end", "def child_by_id(id, scope = {})\n children_by_id(id, scope).first\n end", "def first_or_nil(lst)\n return nil if lst.nil?\n lst.first\nend", "def get_first\n @head.nil? ? nil : @head.data\n end", "def first\n # return value if head node is set\n if [email protected]?\n @head.value\n else\n # otherwise raise an exception\n raise \"List is empty\"\n end\n end", "def get_first\n return @head ? @head.data : nil\n end", "def child_from_position(_position)\n value_from_parent_and_position(self, _position)\n end", "def get_first\r\n return @head ? @head.data : nil\r\n end", "def typechild(name)\n child = domain(name) if respond_to? :domain\n child = struct(name) if not child and respond_to? :struct\n child = type_(name) if not child and respond_to? :type_\n child\n end", "def get_child(index)\n @children[index]\n end", "def rightChild\r\n children[1]\r\n end", "def descendant(pat=nil, *rest)\n descendants(pat, *rest) {|c|\n return c\n }\n return nil\n end", "def name\n children[0]\n end", "def name\n children[0]\n end", "def first(*args)\n find_first_or_last(:first, *args)\n end", "def first(*args)\n find(:first, *args)\n end", "def first(*args)\n find(:first, *args)\n end", "def child\n return @links[:child]\n end", "def closest_parent(type, this_view = nil)\n this_view ||= view_or_self.superview\n while this_view != nil do\n return this_view if this_view.is_a? type\n this_view = this_view.superview\n end\n nil\n end", "def get_first\n current = @head\n return nil if current.nil?\n \n return @head.data\n end", "def first(*args)\n find(:first, *args)\n end", "def get_first\n return @head.nil? ? nil : @head.data\n end", "def get_first\n return @head.nil? ? nil : @head.data\n end", "def first_object(query, kwargs = {})\n objs = objects(query, kwargs)\n return objs.length > 0 ? objs[0] : nil\n end", "def first\n self.take(1)[0]\n end", "def effective_root\n if empty? and children.size == 1\n children.first.effective_root\n else\n self\n end\n end", "def find_first_parent model = controller_model\n defined?(@first_parent) ? @first_parent : @first_parent = begin\n if parents = PARENTS[type_of(model)]\n parents.any? do |parent|\n id = params[:\"#{parent.name.underscore}_id\"]\n if id && parent.reflect_on_association(type_of(model))\n return parent.find(id)\n end\n end\n end\n end\n end", "def parent_object\n if has_parent?\n actual_class = parent_class_name.camelize.constantize\n actual_class.find(parent_id)\n else\n nil\n end\n end", "def get_first\r\n # if the list is empty, head is nil\r\n if @head.nil?\r\n return nil\r\n else \r\n value = @head.data\r\n return value\r\n end\r\n end", "def brother\n Item.where(name: self.name, level: self.level, parent_id: self.parent_id, s_type: self.s_type, has_value: !self.has_value).first\n # brothers = Item.where(name: self.name, level: self.level, parent_id: self.parent_id, s_type: self.s_type, has_value: !self.has_value)\n # raise 'There should be only one brother' if brother.size > 1\n # return brothers.first\n end", "def get_first\n \n return nil if @head.nil?\n return @head.data\n \n end", "def first_node_name\n first_child = @fragment.children.first\n (first_child && first_child.respond_to?(:name)) ? first_child.name : nil\n end", "def first_expression_child\n\n @raw_representation[2].find { |c| c.is_a?(Array) }\n end", "def first(*args)\n if args.any?\n if args.first.kind_of?(Integer) ||\n (loaded? && !args.first.kind_of?(Hash))\n to_a.first(*args)\n else\n apply_finder_options(args.first).first\n end\n else\n find_first\n end\nend", "def children(*types)\n if types.count > 0\n children.select { |el| el.is_one_of? *types } \n else\n next_descendants(ABCNode)\n end\n end", "def get_child(name)\n Vidalia::checkvar(name,String,self.class.ancestors,\"name\")\n @children[name]\n end", "def get_first\n return nil if @head.nil?\n return @head.data\n end", "def first\n @current = self.head if self.head\n @current.value rescue nil\n end", "def first\n self[0]\n end", "def first\n self[0]\n end", "def get_first\n return @head if @head.nil?\n\n return @head.data\n end", "def get_first\r\n if @head \r\n return @head.data\r\n else \r\n return nil\r\n end\r\n end", "def root\n return nodes.first if nodes.size == 1\n nodes.find { |node| root?(node) }\n end", "def child_with_exact_name(name)\n normal_children.find{|n| n.name == name}\n end", "def first_sibling\n node = self\n while node.previous_sibling\n node = node.previous_sibling\n end\n return node\n end" ]
[ "0.7283955", "0.7242061", "0.7073357", "0.6911435", "0.6763153", "0.6690597", "0.66373146", "0.6504628", "0.64523125", "0.6451528", "0.64393693", "0.6392268", "0.6280359", "0.6269426", "0.62675345", "0.6226695", "0.62112206", "0.61193734", "0.61129856", "0.6089946", "0.59947145", "0.59617764", "0.5938764", "0.59370947", "0.5920625", "0.5910055", "0.58883667", "0.5856253", "0.5812972", "0.5812054", "0.57573223", "0.5755361", "0.5753107", "0.57397753", "0.5698191", "0.5689253", "0.5666511", "0.5652088", "0.5647436", "0.56456006", "0.5643114", "0.56313694", "0.56249034", "0.5624789", "0.5622564", "0.561059", "0.56064254", "0.55741715", "0.556327", "0.5555633", "0.5536346", "0.5536044", "0.5535226", "0.55188084", "0.5497901", "0.5484478", "0.5481519", "0.54805636", "0.5476084", "0.5471524", "0.54714024", "0.5470667", "0.54664207", "0.5444604", "0.5443928", "0.5437127", "0.54361683", "0.54350734", "0.54350734", "0.54337865", "0.54308623", "0.54308623", "0.54286605", "0.5427708", "0.54162264", "0.5414383", "0.539326", "0.539326", "0.53924423", "0.5380469", "0.5374842", "0.53727585", "0.5369273", "0.5365187", "0.53624743", "0.53581077", "0.53565234", "0.53423023", "0.5338837", "0.5338523", "0.53372306", "0.5334817", "0.53282124", "0.53248924", "0.53248924", "0.53239286", "0.53198886", "0.5319047", "0.5309713", "0.5307973" ]
0.8050874
0
Use callbacks to share common setup or constraints between actions.
def set_advertisement @advertisement = current_user.company.advertisements.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 advertisement_params params.require(:advertisement).permit(:advertisement_id, :title, :body, :image1, :delivery_date) 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 user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n 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 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 user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\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 ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\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 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 url_whitelist; 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 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 permit_request_params\n params.permit(:address)\n end", "def sensitive_params=(params)\n @sensitive_params = params\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 backend_user_params\n params.permit!\n end", "def url_params\n params[:url].permit(:full)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "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 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.6981273", "0.6783789", "0.67460483", "0.6742222", "0.67354137", "0.65934366", "0.65028495", "0.6497783", "0.64826745", "0.6479415", "0.6456823", "0.6440081", "0.63800216", "0.6376521", "0.636652", "0.6319898", "0.6300256", "0.62994003", "0.6293621", "0.6292629", "0.6291586", "0.629103", "0.6282451", "0.6243152", "0.62413", "0.6219024", "0.6213724", "0.62103724", "0.61945", "0.61786324", "0.61755824", "0.6173267", "0.6163613", "0.6153058", "0.61521065", "0.6147508", "0.61234015", "0.61168665", "0.6107466", "0.6106177", "0.6091159", "0.60817343", "0.6071238", "0.6062299", "0.6021663", "0.60182893", "0.6014239", "0.6011563", "0.60080767", "0.60080767", "0.60028875", "0.60005623", "0.59964156", "0.5993086", "0.5992319", "0.5992299", "0.59801805", "0.59676576", "0.59606016", "0.595966", "0.59591126", "0.59589803", "0.5954058", "0.5953234", "0.5944434", "0.5940526", "0.59376484", "0.59376484", "0.5935253", "0.5930846", "0.5926387", "0.59256274", "0.5917907", "0.5910841", "0.590886", "0.59086543", "0.59060425", "0.58981544", "0.5898102", "0.5896809", "0.5895416", "0.58947027", "0.58923644", "0.5887903", "0.58830196", "0.5880581", "0.5873854", "0.58697754", "0.5869004", "0.58669055", "0.5866886", "0.58664906", "0.5864619", "0.58630043", "0.5862495", "0.5861368", "0.5859712", "0.5855544", "0.58551925", "0.5851284", "0.5850602" ]
0.0
-1
GET /recipes GET /recipes.json
def index @recipes = Recipe.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end", "def index\n @recipes = Recipe.all\n render json: @recipes\n end", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end", "def show\n response = Aws.list_recipe(params[:id])\n render :json => response\n end", "def index\n @recipes = Recipe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end", "def show(id) \n response = request(:get, \"/recipes/#{id}.json\")\n response.first[1]\n end", "def list\n \n recipes = Recipe.all\n render :json => recipes.to_json\n\n end", "def ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end", "def index\n recipes = current_user.recipes\n render json: { recipes: recipes}.to_json, status: :ok\n end", "def get_recipes(section)\n # Example: https://terraria.gamepedia.com/index.php?title=Recipes/Iron_Anvil&action=raw\n @connection.get '/index.php', {\n 'title' => \"Recipes/#{section}\",\n 'action' => 'raw'\n }\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def show\n recipe = Recipe.find(params[:id])\n # recipes = Recipe.find_by(params[:id])\n # render json: recipe\n render json: recipe\n end", "def show\n\n recipe = Recipe.find(params[:id])\n render :json => recipe.to_json\n\n end", "def index\n render json: Recipe.all\n end", "def show\n render json: @recipe\n end", "def show\n @data = @recipe.read(params[:id])\n render json: @data\n end", "def show\n @ingredient = Ingredient.find_by_url_slug(params[:id])\n @ingredient = Ingredient.find(params[:id]) if @ingredient.nil?\n @recipes = @ingredient.recipes.order('created_at DESC')\n logger.debug @recipes.inspect\n respond_to do |format|\n format.html {render :layout => 'wall'}\n format.json { render json: @ingredient }\n end\n end", "def index\n\t\t@recipes = Recipe.where(user_id: session[:user_id])\n\t\tif @recipes\n\t\t\trender json: @recipes.to_json(:include => [:inventories])\n\t\telse\n\t\t\tflash[:error] = \"You haven't saved any recipes yet! Search now :)\"\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend", "def show\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def index\n # @recipes = Recipe.all\n end", "def get_json\n recipe_json = File.read('./recipes.json')\n @json_recipes = JSON.parse(recipe_json)\n end", "def show\n\t\t@recipe = Recipe.find(params[:id])\n\t\tif @recipe \n\t\t\trender json: @recipe.to_json(:include => [:inventories])\n\t\telse\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend", "def index\n @recipes = RecipeCacheService.list(per_page: per_page_param, page: page_param)\n end", "def show\n @recipe = current_user.recipes.find(params[:id])\n @instructions = @recipe.instructions\n @ingredients = @recipe.ingredients\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def show\n respond_to do |format|\n format.html {}\n format.json { render json: @recipe }\n end\n end", "def index\n recipe_items = current_user.recipes.includes(recipe_items: :ingredient).find(params[:recipe_id]).recipe_items\n render json: { recipe_items: recipe_items}.to_json(include: :ingredient), status: :ok\n end", "def recipes\n @recipes ||= []\n end", "def show\n # accept the params\n # go to the db and get the correct recipe for that param\n p params[:id]\n @recipe = Recipe.find_by(id: params[:id])\n @ingredients = @recipe.ingredients.split(\", \").map {|ingredient| ingredient.capitalize}\n # send this to the view\n # show that data to the user\n render 'show.json.jb'\n end", "def get_from_npr(user_ingredients)\n raw_response=RestClient.get('http://api.npr.org/query?id=1139&fields=title,teaser,storyDate,byline,text&date&searchTerm=' + user_ingredients + '&dateType=story&output=JSON&apiKey=MDE5MDExNzc1MDE0MzA0MDE1NTViZDViOQ001')\n response = JSON.load(raw_response)\n\n if response[\"list\"][\"story\"] == nil\n puts \"Your search did not find any recipes...\"\n else\n recipes = response[\"list\"][\"story\"].map do |recipe|\n Recipe.new(\n title = recipe[\"title\"][\"$text\"],\n teaser = recipe[\"teaser\"][\"$text\"],\n link = recipe[\"link\"].first[\"$text\"],\n storyDate = recipe[\"storyDate\"][\"$text\"]\n )\n end\n end\n\nend", "def show\r\n\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] # hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n @recipe = JSON.parse response.read_body # gets the recipe\r\n\r\n p url_ingredients = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/ingredientWidget.json\")\r\n\r\n http_ingredients = Net::HTTP.new(url_ingredients.host, url_ingredients.port)\r\n http_ingredients.use_ssl = true\r\n http_ingredients.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request_ingredients = Net::HTTP::Get.new(url_ingredients)\r\n request_ingredients[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"]\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response_ingredients = http.request(request_ingredients)\r\n # puts response_ingredients.read_body\r\n @ingredients = JSON.parse # data is a string (which looks like a hash -> convert to hash) response_ingredients.read_body\r\n p \"RECIPES\"\r\n # p @recipe\r\n p \"INGREDIENTS\"\r\n p @ingredients\r\n\r\n end", "def index\n @recipes = (!params[:recipe].blank?)? Recipe.where(\"id in (\" + params[:recipe] + \")\") : Recipe.all\n @recipes_json = Recipe.where(\"title ilike ?\", \"%#{params[:q]}%\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: custom_json_for(@recipes_json)}\n end\n end", "def findrecipes\n\t\t@hide_menu = true\n puts \"In Find Recipes\"\n #this is where the data for the searching of recipes gets routed into\n input = params['query'].inspect\n\n ingreds = input.split(',')\n\n input = ingreds.join(\"%2C\")\n #this is the api \n url = \"https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/findByIngredients?fillIngredients=false&ingredients=\" + input + \"&limitLicense=false&number=5&ranking=1\"\n\n res = Unirest.get url,\n headers:{\n \"X-Mashape-Key\" => \"UpZLcnOR83mshtXvuIOPFXBkfhn5p1UWi1ejsnsTLWoVXrOppm\",\n \"Accept\" => \"application/json\"\n }\n\n recipes = res.body\n #for each recipe that gets returned, the following information is routed into the recipe results page\n recipes.each do |recipe|\n url2 = url2 = \"https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/\" + recipe['id'].to_s + \"/information?includeNutrition=false\"\n\n res2 = Unirest.get url2,\n headers:{\n \"X-Mashape-Key\" => \"UpZLcnOR83mshtXvuIOPFXBkfhn5p1UWi1ejsnsTLWoVXrOppm\",\n \"Accept\" => \"application/json\"\n }\n\n price = (\"$\" + (0.01 * res2.body['pricePerServing']).to_s)[0..5]\n\n recipe['price'] = price\n #this is the price of a recipe per serving\n\n end\n\n @recipeData = recipes\n render template: \"recipes/data\"\n end", "def recipe_info_for(id)\n response = Faraday.get(\"https://api.spoonacular.com/recipes/#{id}/information?includeNutrition=true&apiKey=#{spoonacular_key}\")\n JSON.parse response.body\n end", "def show\n if recipe\n render json: recipe\n else \n render json: {message: 'Recipe not found'}\n end\n end", "def all\n # returns all recipes\n @recipes\n end", "def show\n @food_recipe = FoodRecipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food_recipe }\n end\n end", "def show\n respond_with Recipe.find(params[\"id\"])\n end", "def recipes\n @ingredient = Ingredient.find(params[:id])\n \n respond_to do |format|\n format.html do\n @recipes = @ingredient.recipes.paginate(:page => params[:page], :order => 'name', :per_page => 5)\n end # recipes.html.haml\n format.xml do\n @recipes = @ingredient.recipes\n render :xml => @recipes\n end\n end\n end", "def user\n\t\t@recipes = Recipe.find_by_user_id(params[:id])\n\t\trespond_with @recipes\n\tend", "def show\n @recipe = Recipe.find(params[:id])\n @recipeIngredients = RecipeIngredient.where(:recipeId => params[:id])\n @ingredients = Ingredient.where(:id => @recipeIngredients.select(:ingredientId))\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def list\n display_recipes\n end", "def index\n @recipes = Recipe.render_all\n end", "def show\n @recipe = EdemamApiWrapper.show_recipe(params[:uri])\n end", "def get_recipe_titles(user_ingredients)\n \n search_params = 'http://www.recipepuppy.com/api/?i=' + user_ingredients.join(\",\")\n \n\n recipes = []\n search_string = RestClient.get(search_params)\n search_hash = JSON.parse(search_string)\n relevant_recipes = search_hash[\"results\"]\n relevant_recipes.collect do |recipe|\n recipes << recipe[\"title\"].strip\n end\n \n recipes\nend", "def by_ingredient\n # If ingredient exists, find recipes that use it\n if Ingredient.exists?(params[:id])\n ingredient = Ingredient.find(params[:id])\n recipes = Recipe.recipes_of_ingredient(params[:id])\n else\n recipes = Recipe.all\n end\n\n # Render json\n render json: {recipes: recipes}, status: 200 \n end", "def index\n @recipe_list = Recipe.where(category_id: params[:category_id])\n # Looks in recipe where the key, category_id is equal to the endpoint\n\n if @recipe_list.empty?\n render :json => {\n :error => 'Oops, no recipes yet! Add some now.'\n }\n else\n render :json => {\n :response => \"successful\",\n :data => @recipe_list\n }\n end\n end", "def index\n @ingredient_recipes = IngredientRecipe.all\n end", "def list_ingredients\n rid = params[:id]\n items = Aws.get_ingredients_from_db(rid)\n render :json => items\n end", "def get_recipe(id)\n recipe = Recipe.find(id)\n url = \"https://api2.bigoven.com/recipe/steps/#{recipe.id}?&api_key=#{ENV['API_KEY']}\"\n uri = URI(url)\n response = Net::HTTP.get(uri)\n # puts response\n\n JSON.parse(response)[\"Ingredients\"].each do |ingredient|\n # recipe.ingredients.create!(\n if (!Ingredient.exists?(ingredient[\"IngredientID\"])) \n Ingredient.create!(\n id: ingredient[\"IngredientID\"],\n name: ingredient[\"Name\"],\n html_name: ingredient[\"HTMLName\"]\n )\n end\n end\n\n if (recipe.recipe_ingredients.count > 0)\n recipe.recipe_ingredients.destroy_all\n recipe.save\n recipe.reload\n end\n\n JSON.parse(response)[\"Ingredients\"].each do |ingredient|\n \n # if (!recipe.recipe_ingredients.find_by(ingredient_id: ingredient[\"IngredientID\"]))\n recipe.recipe_ingredients.create!(\n ingredient_id: ingredient[\"IngredientID\"],\n quantity: ingredient[\"Quantity\"],\n display_quantity: ingredient[\"DisplayQuantity\"],\n unit: ingredient[\"Unit\"],\n metric_quantity: ingredient[\"MetricQuantity\"],\n metric_display_quantity: ingredient[\"MetricDisplayQuantity\"],\n metric_unit: ingredient[\"MetricUnit\"],\n preparation_notes: ingredient[\"PreparationNotes\"]\n )\n # end\n end\n \n recipe.steps = ''\n steps = JSON.parse(response)[\"Steps\"]\n steps.each do |step|\n step != steps.last ? recipe.steps += step[\"Text\"] + '$' : recipe.steps += step[\"Text\"]\n # recipe.steps += step[\"Text\"] + ','\n end\n \n recipe.save\n end", "def all\n @recipes\n end", "def all\n @recipes\n end", "def all\n @recipes\n end", "def show\n @recipe_all = RecipeAll.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_all }\n end\n end", "def create\n recipe = Recipe.create(recipe_params)\n render json: recipe\n end", "def read_json\n recipes_json = File.read('JSON/recipes.json')\n recipe_hash = JSON.parse(recipes_json)\n return recipe_hash\nend", "def userRecipe\n @user_id = params[:id]\n @user = User.find_by(id: @user_id)\n @recipes = Recipe.where(user_id: @user_id)\n end", "def getRecipeByTag\n begin\n @recipe = Recipe.where('tags ILIKE ?', '%'+params[:tag]+'%').all\n\n if [email protected]?\n render json: { status: 'SUCCESS', message: 'Loaded recipe!', data: @recipe }, status: :ok\n else\n render json: { status: 'SUCCESS', message: 'No recipe found', data: {} }, status: :not_found\n end\n rescue\n render json: { status: 'ERROR', message: 'Error loading recipe', data: {} }, status: :not_found\n end\n end", "def show\n @recipe_ingredient = Recipe_ingredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end", "def index\n per_page = params[:per_page]&.to_i || DEFAULT_PER_PAGE\n page = params[:page]&.to_i || DEFAULT_PAGE\n query = params[:query] || \"\"\n\n queries = query.split(\",\").map { |q| \"%#{q.downcase.strip}%\" }\n recipe_ids = []\n \n if queries.present?\n queries.each do |q|\n tmp_recipe_ids = Ingredient.where('UNACCENT(LOWER(name)) ILIKE UNACCENT(?)', q)\n .pluck(:recipe_id)\n .uniq\n\n excluded_ids = []\n excluded_ids = recipe_ids - tmp_recipe_ids | tmp_recipe_ids - recipe_ids unless recipe_ids.empty?\n \n recipe_ids = (recipe_ids + tmp_recipe_ids) - excluded_ids\n end\n end\n \n recipes = Recipe.where(id: recipe_ids).order('rate DESC NULLS LAST').order(id: :asc)\n .page(page)\n .per(per_page)\n \n render json: {\n meta: {\n total_recipes: recipes.total_count,\n total_pages: recipes.total_pages,\n per_page: per_page,\n query: query,\n page: page\n }, \n recipes: recipes.map { |recipe| ::RecipeJson.new(recipe: recipe).to_h }\n }\n end", "def show\n @recipe = Recipe.find(params[:id])\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def index\n\n @recipes = Recipe.all\n @recipe = current_user.recipes.new if can? :new, Recipe\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end", "def index\n @recipes = Recipe.all\n @recipe = Recipe.new \n end", "def index\n unless params[:tag].blank?\n @recipes = current_user.recipes.tagged_with(params[:tag]).order(\"created_at desc\").page(params[:page]).per(10)\n else\n @recipes = current_user.recipes.order(\"created_at desc\").page(params[:page]).per(10) \n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end", "def show\n @recipe_ingredient = RecipeIngredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end", "def show\n @meal = Meal.find(params[:meal_id]) if params[:meal_id]\n @recipe = @meal.recipes.find(params[:id]) if @meal\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def scrape_recipe(ingredient)\n @recipes_array = []\n @ingredient = ingredient\n url = \"https://www.allrecipes.com/search/results/?search=#{@ingredient}\"\n html_file = URI.open(url).read\n html_doc = Nokogiri::HTML(html_file)\n html_doc.search('.card__detailsContainer').each do |element|\n title = element.search('.card__title').first.text.strip\n description = element.search('.card__summary').first.text.strip\n rating = element.search('.review-star-text').text.strip.slice(/(\\d.?\\d*)/)\n url = element.search('.card__titleLink').first.attribute('href').value\n\n @recipes_array << {\n title: title,\n description: description,\n rating: rating,\n url: url\n }\n end\n @recipes_array\n end", "def show\n\t\t@recipe = Recipe.find(params[:id])\n\tend", "def find_recipe\n @recipe = Recipe.find(params[:id])\n end", "def index\n @recipe = Recipe.new\n @recipes = current_user.recipes.page(params[:page]).per(15)\n end", "def show\n @recipe = Recipe.find(params[:id])\n @nutrition_info = NutritionInfo.where( \"recipe_id = ?\", @recipe.id ).first\n @inventory_items = []\n @recipe.inventory_items.each do |inventory_item|\n @inventory_items << inventory_item\n end\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def getRecipeByIngredientsList\n begin\n ingredientsList = params[:ingredients].split(\",\")\n\n @recipe = []\n ingredientsList.each do |ingredient|\n @recipe.push(Recipe.where('ingredients ILIKE ?', '%'+ingredient+'%').all)\n end\n \n if [email protected]?\n render json: { status: 'SUCCESS', message: 'Loaded recipe!', data: @recipe }, status: :ok\n else\n render json: { status: 'SUCCESS', message: 'No recipe found', data: {} }, status: :not_found\n end\n rescue\n render json: { status: 'ERROR', message: 'Error loading recipe', data: {} }, status: :not_found\n end\n end", "def index\n @recipes = Recipe.where(nil)\n if params[:recipe].present?\n filtering_params(params).each do |key, value|\n @recipes = @recipes.public_send(key, value) if value.present?\n end\n end\n end", "def getRecipeByName\n begin\n @recipe = Recipe.find_by(name: params[:name])\n\n if @recipe.present?\n render json: { status: 'SUCCESS', message: 'Loaded recipe!', data: @recipe }, status: :ok\n else\n render json: { status: 'SUCCESS', message: 'No recipe found', data: {} }, status: :not_found\n end\n rescue\n render json: { status: 'ERROR', message: 'Error loading recipe', data: {} }, status: :not_found\n end\n end", "def index \n recipes = Recipe.all\n #render will return the object back in json format so that it can be used by the frontend\n render json: recipes, except: [:created_at, :updated_at]\n end", "def show\n @title = 'Categories'\n @recipes = @category.recipes.each{|c| [c.name, c.id] }\n end", "def index \n recipeIngredients = RecipeIngredient.all\n #render will return the object back in json format so that it can be used by the frontend\n render json: recipeIngredients\n end", "def index\n @page_title = \"All Recipes\"\n @recipes = Recipe.all\n end", "def index\n @meal_recipes = MealRecipe.all\n end", "def show\n @recipe_category = RecipeCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_category }\n end\n end", "def index\n @recipes = Recipe.search(params[:search])\n @ingredients = Ingredient.all\n end" ]
[ "0.8315941", "0.76739687", "0.76456314", "0.75547504", "0.7492078", "0.7476003", "0.74459517", "0.7393438", "0.7300475", "0.7273354", "0.72657275", "0.7214473", "0.7162102", "0.71540695", "0.7122386", "0.71124816", "0.7101849", "0.70503086", "0.69963014", "0.6985436", "0.6985171", "0.69701636", "0.69150996", "0.6897325", "0.68297285", "0.681682", "0.67840844", "0.6779935", "0.6757738", "0.67491", "0.6737886", "0.6731784", "0.672209", "0.67178035", "0.669967", "0.6644709", "0.6636941", "0.6590566", "0.65848976", "0.65803665", "0.65395725", "0.6525429", "0.6517328", "0.6506425", "0.65063167", "0.65016615", "0.64833033", "0.6473663", "0.6472108", "0.6465809", "0.6462389", "0.6462389", "0.6462389", "0.6460808", "0.6459485", "0.6450219", "0.64471495", "0.64408576", "0.6421248", "0.6404808", "0.6397196", "0.63956076", "0.63956076", "0.63956076", "0.63956076", "0.63956076", "0.6394012", "0.6390857", "0.6387274", "0.63818216", "0.63596964", "0.6352204", "0.6340071", "0.63337255", "0.6330549", "0.63175994", "0.62997496", "0.62933815", "0.62865657", "0.6285007", "0.628193", "0.62812424", "0.6272897", "0.62586695", "0.62569636", "0.62539816" ]
0.7057095
30
GET /recipes/1 GET /recipes/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end", "def show(id) \n response = request(:get, \"/recipes/#{id}.json\")\n response.first[1]\n end", "def show\n response = Aws.list_recipe(params[:id])\n render :json => response\n end", "def show\n recipe = Recipe.find(params[:id])\n # recipes = Recipe.find_by(params[:id])\n # render json: recipe\n render json: recipe\n end", "def show\n\n recipe = Recipe.find(params[:id])\n render :json => recipe.to_json\n\n end", "def index\n @recipes = Recipe.all\n render json: @recipes\n end", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def show\n @data = @recipe.read(params[:id])\n render json: @data\n end", "def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end", "def index\n @recipes = Recipe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end", "def ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end", "def show\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def show\n @ingredient = Ingredient.find_by_url_slug(params[:id])\n @ingredient = Ingredient.find(params[:id]) if @ingredient.nil?\n @recipes = @ingredient.recipes.order('created_at DESC')\n logger.debug @recipes.inspect\n respond_to do |format|\n format.html {render :layout => 'wall'}\n format.json { render json: @ingredient }\n end\n end", "def show\n render json: @recipe\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def show\n # accept the params\n # go to the db and get the correct recipe for that param\n p params[:id]\n @recipe = Recipe.find_by(id: params[:id])\n @ingredients = @recipe.ingredients.split(\", \").map {|ingredient| ingredient.capitalize}\n # send this to the view\n # show that data to the user\n render 'show.json.jb'\n end", "def show\n\t\t@recipe = Recipe.find(params[:id])\n\t\tif @recipe \n\t\t\trender json: @recipe.to_json(:include => [:inventories])\n\t\telse\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend", "def index\n recipes = current_user.recipes\n render json: { recipes: recipes}.to_json, status: :ok\n end", "def show\n respond_with Recipe.find(params[\"id\"])\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n @recipes = Recipe.all\n end", "def index\n render json: Recipe.all\n end", "def show\n respond_to do |format|\n format.html {}\n format.json { render json: @recipe }\n end\n end", "def show\n @recipe = Recipe.find(params[:id])\n end", "def list\n \n recipes = Recipe.all\n render :json => recipes.to_json\n\n end", "def index\n # @recipes = Recipe.all\n end", "def get_recipes(section)\n # Example: https://terraria.gamepedia.com/index.php?title=Recipes/Iron_Anvil&action=raw\n @connection.get '/index.php', {\n 'title' => \"Recipes/#{section}\",\n 'action' => 'raw'\n }\n end", "def show\n recipe_id = params[:id].to_i\n @recipe = Recipe.find(recipe_id)\n end", "def show\n @food_recipe = FoodRecipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food_recipe }\n end\n end", "def show\n @recipe = current_user.recipes.find(params[:id])\n @instructions = @recipe.instructions\n @ingredients = @recipe.ingredients\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def show\n if recipe\n render json: recipe\n else \n render json: {message: 'Recipe not found'}\n end\n end", "def show\r\n\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] # hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n @recipe = JSON.parse response.read_body # gets the recipe\r\n\r\n p url_ingredients = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/ingredientWidget.json\")\r\n\r\n http_ingredients = Net::HTTP.new(url_ingredients.host, url_ingredients.port)\r\n http_ingredients.use_ssl = true\r\n http_ingredients.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request_ingredients = Net::HTTP::Get.new(url_ingredients)\r\n request_ingredients[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"]\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response_ingredients = http.request(request_ingredients)\r\n # puts response_ingredients.read_body\r\n @ingredients = JSON.parse # data is a string (which looks like a hash -> convert to hash) response_ingredients.read_body\r\n p \"RECIPES\"\r\n # p @recipe\r\n p \"INGREDIENTS\"\r\n p @ingredients\r\n\r\n end", "def show\n\t\t@recipe = Recipe.find(params[:id])\n\tend", "def find_recipe\n @recipe = Recipe.find(params[:id])\n end", "def show\n @recipe = Recipe.find(params[:id])\n @recipeIngredients = RecipeIngredient.where(:recipeId => params[:id])\n @ingredients = Ingredient.where(:id => @recipeIngredients.select(:ingredientId))\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def recipe_info_for(id)\n response = Faraday.get(\"https://api.spoonacular.com/recipes/#{id}/information?includeNutrition=true&apiKey=#{spoonacular_key}\")\n JSON.parse response.body\n end", "def set_recipe\n @recipe = RecipeApi.find(params[:id])\n end", "def show\n @recipe_ingredient = Recipe_ingredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end", "def by_ingredient\n # If ingredient exists, find recipes that use it\n if Ingredient.exists?(params[:id])\n ingredient = Ingredient.find(params[:id])\n recipes = Recipe.recipes_of_ingredient(params[:id])\n else\n recipes = Recipe.all\n end\n\n # Render json\n render json: {recipes: recipes}, status: 200 \n end", "def find_recipe\n @recipe = Recipe.find(params[:id])\n end", "def show\n @meal = Meal.find(params[:meal_id]) if params[:meal_id]\n @recipe = @meal.recipes.find(params[:id]) if @meal\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def get_json\n recipe_json = File.read('./recipes.json')\n @json_recipes = JSON.parse(recipe_json)\n end", "def show\n @recipe_ingredient = RecipeIngredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end", "def show\n @recipe = EdemamApiWrapper.show_recipe(params[:uri])\n end", "def getRecipeByName\n begin\n @recipe = Recipe.find_by(name: params[:name])\n\n if @recipe.present?\n render json: { status: 'SUCCESS', message: 'Loaded recipe!', data: @recipe }, status: :ok\n else\n render json: { status: 'SUCCESS', message: 'No recipe found', data: {} }, status: :not_found\n end\n rescue\n render json: { status: 'ERROR', message: 'Error loading recipe', data: {} }, status: :not_found\n end\n end", "def index\n @recipes = RecipeCacheService.list(per_page: per_page_param, page: page_param)\n end", "def index\n\t\t@recipes = Recipe.where(user_id: session[:user_id])\n\t\tif @recipes\n\t\t\trender json: @recipes.to_json(:include => [:inventories])\n\t\telse\n\t\t\tflash[:error] = \"You haven't saved any recipes yet! Search now :)\"\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend", "def show\n @recipe_all = RecipeAll.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_all }\n end\n end", "def get_recipe(id)\n recipe = Recipe.find(id)\n url = \"https://api2.bigoven.com/recipe/steps/#{recipe.id}?&api_key=#{ENV['API_KEY']}\"\n uri = URI(url)\n response = Net::HTTP.get(uri)\n # puts response\n\n JSON.parse(response)[\"Ingredients\"].each do |ingredient|\n # recipe.ingredients.create!(\n if (!Ingredient.exists?(ingredient[\"IngredientID\"])) \n Ingredient.create!(\n id: ingredient[\"IngredientID\"],\n name: ingredient[\"Name\"],\n html_name: ingredient[\"HTMLName\"]\n )\n end\n end\n\n if (recipe.recipe_ingredients.count > 0)\n recipe.recipe_ingredients.destroy_all\n recipe.save\n recipe.reload\n end\n\n JSON.parse(response)[\"Ingredients\"].each do |ingredient|\n \n # if (!recipe.recipe_ingredients.find_by(ingredient_id: ingredient[\"IngredientID\"]))\n recipe.recipe_ingredients.create!(\n ingredient_id: ingredient[\"IngredientID\"],\n quantity: ingredient[\"Quantity\"],\n display_quantity: ingredient[\"DisplayQuantity\"],\n unit: ingredient[\"Unit\"],\n metric_quantity: ingredient[\"MetricQuantity\"],\n metric_display_quantity: ingredient[\"MetricDisplayQuantity\"],\n metric_unit: ingredient[\"MetricUnit\"],\n preparation_notes: ingredient[\"PreparationNotes\"]\n )\n # end\n end\n \n recipe.steps = ''\n steps = JSON.parse(response)[\"Steps\"]\n steps.each do |step|\n step != steps.last ? recipe.steps += step[\"Text\"] + '$' : recipe.steps += step[\"Text\"]\n # recipe.steps += step[\"Text\"] + ','\n end\n \n recipe.save\n end", "def index\n recipe_items = current_user.recipes.includes(recipe_items: :ingredient).find(params[:recipe_id]).recipe_items\n render json: { recipe_items: recipe_items}.to_json(include: :ingredient), status: :ok\n end", "def user\n\t\t@recipes = Recipe.find_by_user_id(params[:id])\n\t\trespond_with @recipes\n\tend", "def userRecipe\n @user_id = params[:id]\n @user = User.find_by(id: @user_id)\n @recipes = Recipe.where(user_id: @user_id)\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def index\n @recipes = (!params[:recipe].blank?)? Recipe.where(\"id in (\" + params[:recipe] + \")\") : Recipe.all\n @recipes_json = Recipe.where(\"title ilike ?\", \"%#{params[:q]}%\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: custom_json_for(@recipes_json)}\n end\n end", "def index\n @recipes = Recipe.all\n @recipe = Recipe.new \n end", "def create\n recipe = Recipe.create(recipe_params)\n render json: recipe\n end", "def index\n @recipe_list = Recipe.where(category_id: params[:category_id])\n # Looks in recipe where the key, category_id is equal to the endpoint\n\n if @recipe_list.empty?\n render :json => {\n :error => 'Oops, no recipes yet! Add some now.'\n }\n else\n render :json => {\n :response => \"successful\",\n :data => @recipe_list\n }\n end\n end", "def show\n recipe = EdamamApiWrapper.show_recipe(params[:id])\n if recipe == nil\n flash[:error] = \"Recipe does not exist. Please do a new recipes search.\"\n redirect_to root_path\n else\n @recipe = recipe\n end\n end", "def show\n @recipe_category = RecipeCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_category }\n end\n end", "def index\n render 'recipes/index'\n end", "def findrecipes\n\t\t@hide_menu = true\n puts \"In Find Recipes\"\n #this is where the data for the searching of recipes gets routed into\n input = params['query'].inspect\n\n ingreds = input.split(',')\n\n input = ingreds.join(\"%2C\")\n #this is the api \n url = \"https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/findByIngredients?fillIngredients=false&ingredients=\" + input + \"&limitLicense=false&number=5&ranking=1\"\n\n res = Unirest.get url,\n headers:{\n \"X-Mashape-Key\" => \"UpZLcnOR83mshtXvuIOPFXBkfhn5p1UWi1ejsnsTLWoVXrOppm\",\n \"Accept\" => \"application/json\"\n }\n\n recipes = res.body\n #for each recipe that gets returned, the following information is routed into the recipe results page\n recipes.each do |recipe|\n url2 = url2 = \"https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/\" + recipe['id'].to_s + \"/information?includeNutrition=false\"\n\n res2 = Unirest.get url2,\n headers:{\n \"X-Mashape-Key\" => \"UpZLcnOR83mshtXvuIOPFXBkfhn5p1UWi1ejsnsTLWoVXrOppm\",\n \"Accept\" => \"application/json\"\n }\n\n price = (\"$\" + (0.01 * res2.body['pricePerServing']).to_s)[0..5]\n\n recipe['price'] = price\n #this is the price of a recipe per serving\n\n end\n\n @recipeData = recipes\n render template: \"recipes/data\"\n end", "def recipes\n @ingredient = Ingredient.find(params[:id])\n \n respond_to do |format|\n format.html do\n @recipes = @ingredient.recipes.paginate(:page => params[:page], :order => 'name', :per_page => 5)\n end # recipes.html.haml\n format.xml do\n @recipes = @ingredient.recipes\n render :xml => @recipes\n end\n end\n end", "def get_from_npr(user_ingredients)\n raw_response=RestClient.get('http://api.npr.org/query?id=1139&fields=title,teaser,storyDate,byline,text&date&searchTerm=' + user_ingredients + '&dateType=story&output=JSON&apiKey=MDE5MDExNzc1MDE0MzA0MDE1NTViZDViOQ001')\n response = JSON.load(raw_response)\n\n if response[\"list\"][\"story\"] == nil\n puts \"Your search did not find any recipes...\"\n else\n recipes = response[\"list\"][\"story\"].map do |recipe|\n Recipe.new(\n title = recipe[\"title\"][\"$text\"],\n teaser = recipe[\"teaser\"][\"$text\"],\n link = recipe[\"link\"].first[\"$text\"],\n storyDate = recipe[\"storyDate\"][\"$text\"]\n )\n end\n end\n\nend", "def find_recipe\n \t\t@recipe = Recipe.friendly.find(params[:id])\n \tend", "def show\n @recipe = RecipeCacheService.find(params[:id])\n end", "def index\n @recipes = Recipe.render_all\n end", "def index\n @ingredient_recipes = IngredientRecipe.all\n end", "def show\n @recipe = Recipe.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @recipe }\n end\n end", "def set_recipe\n @recipe = Recipe.where(id: params[:id]).first\n render_404 unless @recipe\n end", "def read_json\n recipes_json = File.read('JSON/recipes.json')\n recipe_hash = JSON.parse(recipes_json)\n return recipe_hash\nend", "def show\n @recipe = Recipe.find(params[:id])\n @nutrition_info = NutritionInfo.where( \"recipe_id = ?\", @recipe.id ).first\n @inventory_items = []\n @recipe.inventory_items.each do |inventory_item|\n @inventory_items << inventory_item\n end\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end", "def show\n @recipe = Recipe.find(params[:id])\n @ingredients = @recipe.ingredients\n @instructions_domain = @recipe.instruction_url_split\n @nutrition_info = @recipe.nutrition_informations\n @health_labels = @recipe.health_labels\n end", "def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end", "def new\n @recipeingredient = Recipe_ingredient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end", "def list\n display_recipes\n end", "def list_ingredients\n rid = params[:id]\n items = Aws.get_ingredients_from_db(rid)\n render :json => items\n end", "def set_recipe\n @recipe = Recipe.find(params[:id])\n end", "def set_recipe\n @recipe = Recipe.find(params[:id])\n end", "def set_recipe\n @recipe = Recipe.find(params[:id])\n end", "def set_recipe\n @recipe = Recipe.find(params[:id])\n end", "def set_recipe\n @recipe = Recipe.find(params[:id])\n end", "def getRecipeByTag\n begin\n @recipe = Recipe.where('tags ILIKE ?', '%'+params[:tag]+'%').all\n\n if [email protected]?\n render json: { status: 'SUCCESS', message: 'Loaded recipe!', data: @recipe }, status: :ok\n else\n render json: { status: 'SUCCESS', message: 'No recipe found', data: {} }, status: :not_found\n end\n rescue\n render json: { status: 'ERROR', message: 'Error loading recipe', data: {} }, status: :not_found\n end\n end", "def set_recipe\n @recipe = Recipe.find(params[:id])\n end", "def set_recipe\n @recipe = Recipe.find(params[:id])\n end" ]
[ "0.79414284", "0.790214", "0.75844485", "0.756833", "0.7435937", "0.7432573", "0.7403042", "0.7356558", "0.7325271", "0.7305129", "0.72860897", "0.726182", "0.723712", "0.71111596", "0.70902306", "0.7004932", "0.70041907", "0.69779086", "0.69637275", "0.6949757", "0.6949757", "0.6949757", "0.6949757", "0.6949757", "0.6949757", "0.6949757", "0.6949757", "0.6949757", "0.6949757", "0.6949757", "0.6949757", "0.6949757", "0.6949757", "0.6949757", "0.69176924", "0.69135606", "0.69094366", "0.6907028", "0.69053125", "0.6894083", "0.6890568", "0.6852517", "0.6852079", "0.68328756", "0.68323183", "0.6799322", "0.6785318", "0.67711586", "0.6744038", "0.6737561", "0.67170906", "0.67065144", "0.67006236", "0.6694845", "0.6687984", "0.6682677", "0.66545105", "0.6632911", "0.66269714", "0.661954", "0.66153836", "0.6578738", "0.6575574", "0.6566427", "0.65469056", "0.6544494", "0.6544494", "0.6544494", "0.6544494", "0.6544494", "0.6543405", "0.65417534", "0.65059304", "0.6497512", "0.64965665", "0.64904445", "0.64779025", "0.64619064", "0.6451941", "0.6442731", "0.6437238", "0.64339733", "0.63870364", "0.6384307", "0.6346829", "0.63446105", "0.634192", "0.6331833", "0.6329156", "0.632741", "0.6316732", "0.6297295", "0.6285973", "0.6285182", "0.6285182", "0.6285182", "0.6285182", "0.6285182", "0.6279891", "0.6278118", "0.6276886" ]
0.0
-1
POST /recipes POST /recipes.json
def create @recipe = Recipe.new(recipe_params) respond_to do |format| if @recipe.save format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' } format.json { render :show, status: :created, location: @recipe } else format.html { render :new } format.json { render json: @recipe.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n recipe = Recipe.create(recipe_params)\n render json: recipe\n end", "def create\n user = current_user\n if params[:id]\n @recipe = Recipe.new(name: params[:name],\n description: params[:description],\n ingredients: params[:indredients],\n instructions: params[:instructions],\n servings: params[:servings],\n original_id: params[:id])\n else\n @recipe = Recipe.new(recipe_params)\n end\n user.recipes << @recipe\n if user.save\n render json: @recipe, status: :created\n else\n render json: {message: \"something went wrong\"}\n end\n end", "def create\n\t\t\t\trecipe = Recipe.new(recipe_params)\n\t\t\t\tingredients = params[:ingredients]\n\t\t\t\ttags = params[:tags]\n\t\t\t\t\n\t\t\t\tif recipe.save\n\t\t\t\t\tif !ingredients.blank?\n\t\t\t\t\t\tredirect_to api_v1_recipe_ingredients_url(recipe_id: recipe.id, ingredients: ingredients, tags: tags)\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\trender json: {status: 'ERROR', message: 'Recipe not saved', data: recipe.errors}, status: :unprocessable_entity\n\t\t\t\tend\n\t\t\tend", "def create\n @recipe = Recipe.new(params[:recipe])\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to recipes_path, notice: 'Recipe successfully created!!' }\n format.json { render json: @recipe }\n else\n format.html { render action: :new }\n format.json { render json: @recipe.errors }\n end\n end\n end", "def create\n @recipe = Recipe.new(recipe_params)\n # if params[:add_ingredient]\n # @recipe.ingredients.build\n # end\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = Recipe.new(params[:recipe])\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = Recipe.new(params[:recipe])\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n puts recipe_params[:ingredients], recipe_params[:recipe], recipe_params[:user_id]\n recipe = Recipe.create(recipe_params[:recipe])\n if(recipe.valid?)\n Ingredient.create_and_assign(recipe_params[:ingredients], recipe.id)\n newUR = UserRecipe.create(recipe_id: recipe.id, user_id: recipe_params[:user_id])\n render json: UserRecipeSerializer.new(newUR).to_serialized_json\n else\n render json: recipe.errors.full_messages\n end\n end", "def create\n @recipe = Recipe.new(params[:recipe])\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to edit_recipe_path(@recipe), notice: 'Recipe was successfully created.' }\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n @recipe = Recipe.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = Recipe.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = Recipe.new(recipe_params)\n\n \n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render action: 'show', status: :created, location: @recipe }\n else\n format.html { render action: 'new' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(options = {})\n optional = [:description,\n \t\t\t :compatible_with,\n \t\t\t :script_type\n ]\n params.required(:label).accepts(optional).validate!(options)\n response = request(:post, \"/recipes.json\", default_params(options))\n response['recipe']\n end", "def create\n @recipe = Recipe.new(params[:recipe])\n\n respond_to do |format|\n if @recipe.save \n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = Recipe.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: \"Recipe was successfully created.\" }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = Recipe.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: \"Recipe was successfully created.\" }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n recipeIngredient = rRcipeIngredient.create(recipeIngredient_params)\n render json: recipeIngredient\n end", "def create\n @recipe = Recipe.new(recipe_params)\n if params['ingredients']\n params['ingredients'].each do |ingredient_name|\n @recipe.ingredients << Ingredient.find_by(name: ingredient_name)\n end\n end\n\n @recipe.save \n redirect_to recipes_path\n end", "def create\n @recipe = Recipe.new(recipe_params)\n params[:recipe][:ingredients].each do |ingredient_id|\n next if ingredient_id.to_i == 0\n ingredient = Ingredient.find(ingredient_id.to_i)\n @recipe.ingredients << ingredient\n end\n params[:recipe][:gadgets].each do |gadget_id|\n next if gadget_id.to_i == 0\n gadget = Gadget.find(gadget_id.to_i)\n @recipe.gadgets << gadget\n end\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render action: 'show', status: :created, location: @recipe }\n else\n format.html { render action: 'new' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = current_user.recipes.build(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = Recipe.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully created.' }\n format.json { render action: 'show', status: :created, location: @recipe }\n else\n format.html { render action: 'new' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = Recipe.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render action: 'show', status: :created, location: @recipe }\n else\n format.html { render action: 'new' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = Recipe.new(recipe_params)\n\n \n end", "def add\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:recipe_id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] #hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n recipe_data = JSON.parse response.read_body\r\n recipe = Recipe.create :title => recipe_data[\"title\"], :image => recipe_data[\"image\"]\r\n @current_user.recipes << recipe # add recipe to My Recipes\r\n\r\n redirect_to my_recipes_path\r\n end", "def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end", "def create\n @recipe = current_user.recipes.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n if params[:lista].present?\n params[:lista].each do |(c,ingrediente)|\n Ingredient.create(name: ingrediente, recipe_id:@recipe.id) if ingrediente != \"\"\n end\n end\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n format.js {flash.now[:notice] = 'La receta se ha creado de forma exitosa.'} #ajax\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n format.js {flash.now[:alert] = 'Error al crear la receta.'} #ajax\n end\n end\n end", "def create\n @recipe = Recipe.new(params[:recipe])\n\n respond_to do |format|\n if @recipe.save\n Instruction.multi_save(params[:instructions], @recipe)\n Ingredient.multi_save(params[:ingredients], @recipe)\n current_user.recipes << @recipe\n current_user.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @food_recipe = FoodRecipe.new(params[:food_recipe])\n\n respond_to do |format|\n if @food_recipe.save\n format.html { redirect_to @food_recipe, notice: 'Food recipe was successfully created.' }\n format.json { render json: @food_recipe, status: :created, location: @food_recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @food_recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tif Recipe.find_by({api_id: params[:api_id]})\n\t\t\tflash[:error] = \"Recipe '#{params[:name]}' already exists in your saved recipes.\"\n\t\telse\n\t\t\t@recipe = Recipe.new(recipe_params)\n\t\t\tif @recipe.save\n\t\t\t\tids = params[:inventories].split(\",\")\n\t\t\t\tfor index in 0...ids.length\n\t\t\t\t\[email protected] << Inventory.where({id: ids[index].to_i})\n\t\t\t\tend\n\n\t\t\t\trender json: @recipe\n\t\t\telse\n\t\t\t\trender status: 400, nothing: true\n\t\t\tend\n\t\tend\n\tend", "def create\n @ingredient_recipe = IngredientRecipe.new(ingredient_recipe_params)\n\n respond_to do |format|\n if @ingredient_recipe.save\n format.html { redirect_to @ingredient_recipe, notice: 'Ingredient recipe was successfully created.' }\n format.json { render :show, status: :created, location: @ingredient_recipe }\n else\n format.html { render :new }\n format.json { render json: @ingredient_recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = Recipe.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n @recipes = ordered_recipes\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n format.js { render :create }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n format.js { render :new }\n end\n end\n end", "def recipe_params\n params.require(:recipe).permit(:name, :servings, :description, :instructions, :url, :tags => [])\n end", "def create\n @recipe = Recipe.new(recipe_params)\n @recipe.uuid = SecureRandom.uuid\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe.objective}\n format.json { render :show, status: :created, location: @recipe.objective }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meal = Meal.find(params[:meal_id]) if params[:meal_id]\n @recipe = @meal ? @meal.recipes.create(params[:recipe]) : Recipe.new(params[:recipe])\n\n #@recipe.ingredients = params[:ingredients].map {|i| \n #Ingredient.new(:item => Food.find(i.delete(:item_id)), :quantity => i[:quantity]) unless i[:item_id].blank? \n #}.compact if params[:ingredients]\n\n @recipe.tags = params[:tags].split(/,/).map { |t|\n Tag.find_or_create_by_name(t.strip.downcase)\n }.compact if params[:tags]\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe}\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n if params[\"donor\"]\n @recipe = Recipe.find(params[\"donor\"]).clone_with_ingredients(params[\"recipe\"])\n @recipe.user = current_user\n\n else\n @recipe = Recipe.new(params[\"recipe\"])\n end\n\n @recipe.user = current_user\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n new_recipe = Recipe.create(recipe_params)\n redirect_to user_recipes_path(new_recipe.user)\n end", "def create\n @recipe = current_user.recipes.build(recipe_params)\n \n if @recipe.save\n redirect_to @recipe, notice: \"Successfully created new recipe\"\n else\n render 'new'\n end\n end", "def create_recipe_request(version, auth_headers, data = {})\n post \"/api/recipes\", params: data, headers: {'Content-Type' => \"application/json\", 'Accept' => \"application/vnd.ink.#{version}\" }.merge(auth_headers)\nend", "def index\n @recipes = Recipe.all\n render json: @recipes\n end", "def createRecipeFromAPI(randRecipe)\n # make a recipe obj to create for our DB\n recipe = Recipe.create(title: randRecipe[\"title\"], cookbook: Cookbook.all.sample, instructions: randRecipe[\"instructions\"])\n photo = Photo.create(recipe: recipe, img_url: randRecipe[\"image\"], description: \"test photo\")\n ingredients = randRecipe[\"extendedIngredients\"].map do |ing| \n ingredient = Ingredient.find_or_create_by(name: ing[\"name\"].titlecase)\n ri = RecipeIngredient.create(recipe: recipe, ingredient: ingredient, quantity: \"#{ing[\"amount\"]} #{ing[\"unit\"]}\")\n end\nend", "def create\n @recipe = Recipe.new(recipe_params)\n @recipe.user_id = current_user.id\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @recipe = Recipe.new(recipe_params)\n @recipe.recipe_creator_id = current_user.id\n @recipe.allergies = get_allergies_from_params\n @recipe.ingredients = get_selected_ingredients\n\n #Shows an example on how to automatically check whether a recipe is suitable for a person with an intolerance\n laktoseintoleranz = Allergy.where(name: 'Laktoseintoleranz').first\n unless @recipe.allergies.include?(laktoseintoleranz)\n neo = Neography::Rest.new({:username => \"user\", :password => \"user\"})\n includes_laktose_ingredient = false\n\n @recipe.ingredients.each do |ingredient|\n node = neo.execute_query(\"MATCH (n)-[]->(i) WHERE n.name = 'Laktoseintoleranz' AND i.name = '#{ingredient.name}' RETURN i\")\n if node[\"data\"].present?\n includes_laktose_ingredient = true\n end\n end\n unless includes_laktose_ingredient\n @recipe.allergies << laktoseintoleranz\n end\n end\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n name = params['name']\n description = params['description']\n instructions = params['instructions']\n cook_time = params['cook_time']\n quantity = params['quantity']\n serving_size = params['serving_size']\n uid = params['user_id']\n aws_params = Hash.new\n aws_params[:custom_fields] = {\n 'name' => name,\n 'description' => description,\n 'instructions' => instructions,\n 'cook_time' => cook_time,\n 'quantity' => quantity,\n 'serving_size' => serving_size,\n 'user_id' => uid\n }\n if Aws.save_recipe_to_db(aws_params)\n msg = {:notice => \"Recipe created!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while save to DynamoDB!\"}\n render :json => msg\n end\n end", "def create\n @recipe = Recipe.new(recipe_params)\n if @recipe.save\n redirect_to recipes_path\n else\n render :new\n end\n end", "def create\n @recipes_food = RecipesFood.new(recipes_food_params)\n\n respond_to do |format|\n if @recipes_food.save\n format.html { redirect_to @recipes_food, notice: 'Recipes food was successfully created.' }\n format.json { render :show, status: :created, location: @recipes_food }\n else\n format.html { render :new }\n format.json { render json: @recipes_food.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @one_recipe_for_category = Recipe.new(recipe_params)\n if Category.exists?(@one_recipe_for_category.category_id)\n if @one_recipe_for_category.save\n render :json => {\n :response => \"Success! Created your new recipe.\",\n :data => @one_recipe_for_category\n }\n else\n render :json => {\n :error => \"Cannot save data.\"\n }\n end\n end\n end", "def create\n recipe_name = @view.ask_name\n recipe_description = @view.ask_description\n recipe = Recipe.new(recipe_name, recipe_description)\n @cookbook.add_recipe(recipe)\n @view.listing\n end", "def create\n @recipe = Recipe.new(params[:recipe])\n\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render json: @recipe, status: :created, location: @recipe }\n format.xml { render :xml => @recipes}\n\n else\n @categories=RecipeCategory.all\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n format.xml { render :xml => @recipe.errors}\n end\n end\n end", "def recipe_params\n params.require(:recipe).permit(:title, :ingredients, :instructions, :category_id, :image)\n end", "def create\n @recipe = Recipe.new(recipe_params)\n @states = State.all\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @recipe = Recipe.new(params[:recipe])\n #\n create! do |success, failure|\n # if @recipe.save # Not needed!\n # success.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n # success.json { render json: @recipe, status: :created, location: @recipe }\n # else\n # failure.html { render action: \"new\" }\n # failure.json { render json: @recipe.errors, status: :unprocessable_entity }\n # end\n end\n end", "def create\n @potluck_recipe = PotluckRecipe.new(potluck_recipe_params)\n if @potluck_recipe.save\n render json: {result: @potluck_recipe}\n else\n render json: { result: @potluck_recipe.errors, status: :unprocessable_entity }\n end\n end", "def create\n @recipe_item = RecipeItem.new(recipe_item_params)\n\n respond_to do |format|\n if @recipe_item.save\n format.html { redirect_to @recipe_item.recipe, notice: 'Recipe item was successfully created.' }\n format.json { render :show, status: :created, location: @recipe_item }\n else\n format.html { render :new }\n format.json { render json: @recipe_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def recipe_params\n params.require(:recipe).permit(:title, :description)\n end", "def create\n @recipe = Recipe.new(params[:recipe])\n \n respond_to do |format|\n if @recipe.save\n flash[:notice] = 'Recipe was successfully created.'\n format.html { redirect_to(@recipe) }\n format.xml { render :xml => @recipe, :status => :created, :location => @recipe }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @recipe.errors, :status => :unprocessable_entity }\n end\n end\n end", "def recipe_params\n params.require(:recipe).permit(:title, :servings)\n end", "def create\n @recipe = Recipe.new(recipe_params)\n @recipe.chef = Chef.find(2)\n \n if @recipe.save\n # shows a message when saved \n flash[:success] = \"Your recipe was created successfully!\"\n # redirect - index page\n redirect_to recipes_path\n else\n render :new\n end\n end", "def create\n @recipe = new_recipe\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n @render_final_form = true\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = Recipe.new(params[:recipe])\n #@recipe.ingrediences = Ingredience.find(@params[:ingredience_ids]) if @params[:ingredience_ids]\n respond_to do |format|\n if @recipe.save\n flash[:notice] = 'Recipe was successfully created.'\n format.html { redirect_to(@recipe) }\n format.xml { render :xml => @recipe, :status => :created, :location => @recipe }\n else\n format.html { render :action => \"new\" }\n @ingrediences = Ingredience.find(:all, :order => 'title')\n @categories = Category.find(:all, :conditions => [\"food = ?\", true])\n format.xml { render :xml => @recipe.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 ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end", "def create\n @recipe = Recipe.new(params[:recipe])\n\n respond_to do |format|\n if @current_user.recipes << @recipe\n flash[:notice] = 'Recipe was successfully created.'\n format.html { redirect_to recipe_url(@recipe) }\n format.xml { head :created, :location => recipe_url(@recipe) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @recipe.errors.to_xml }\n end\n end\n end", "def create\n @recipe = Recipe.new(recipe_params)\n @recipe.user_id=current_user.id\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def recipe_params\n params.require(:recipe).permit(:title, :author, :ingredients, :instructions, :image)\n end", "def recipe_params\n params.require(:recipe).permit(:title, :summary, :instructions)\n end", "def create\n name = @view.ask_user_for_info(\"name\")\n description = @view.ask_user_for_info(\"description\")\n prep_time = @view.ask_user_for_attribute(\"prep_time\")\n difficulty = @view.ask_user_for_attribute(\"difficulty\")\n recipe = Recipe.new(name: name, description: description, prep_time: prep_time, difficulty: difficulty)\n @cookbook.add_recipe(recipe)\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def create\n @recipe = Recipe.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n count = 1\n complete_directions = \"\"\n params[\"directions\"].each do |direction|\n complete_directions += direction + \"\\n\"\n count += 1\n end\n @recipe.directions = complete_directions\n params[\"ingredients\"].each_with_index do |ingredient, index|\n found = false\n Ingredient.all.each do |db_ingredient|\n if db_ingredient.name == ingredient\n @ingredient = db_ingredient\n Recipeingredient.create({:ingredient_id => @ingredient.id, :recipe_id => @recipe.id, :amount => params[\"amounts\"][index]})\n found = true\n end\n end\n if found == false\n @ingredient = Ingredient.create({:name => ingredient})\n Recipeingredient.create({:ingredient_id => @ingredient.id, :recipe_id => @recipe.id, :amount => params[\"amounts\"][index]})\n end\n end\n Userrecipe.create({:contribution_id => @recipe.id, :user_id => current_user.id})\n if params[\"tags\"] != nil\n params[\"tags\"].each do |tag|\n @tag = Tag.find_by_name(tag)\n Recipetag.create({:recipe_id => @recipe.id,:tag_id => @tag.id})\n end\n end\n @recipe.serves = params[\"serves\"]\n @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipeingredient = Recipeingredient.new(recipeingredient_params)\n\n respond_to do |format|\n if @recipeingredient.save\n format.html { redirect_to @recipeingredient, notice: 'Recipeingredient was successfully created.' }\n format.json { render :show, status: :created, location: @recipeingredient }\n else\n format.html { render :new }\n format.json { render json: @recipeingredient.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = current_user.recipes.build(recipe_params)\n @recipe.user = current_user\n @recipe.save\n @measurs = Array.new\n @ingrs = Array.new\n @tgs = Array.new\n #ovo bi trebalo unutar sebe prikupiti sastojke i mjere\n parse_ingredients\n parse_tags\n @recipe.measurements = @measurs\n @recipe.ingredients = @ingrs\n @recipe.recipe_tags = @tgs\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def recipe_params\n params.require(:recipe).permit(:name, :description, :intructions, :ingredients, :image, :prep, :cooking, \n\t\t\t\t\t\t\t\t\t :level, :serves, :tips, :additional_info, :meta_title, :meta_description, :meta_keywords)\n end", "def create\n @recipe_ingredient = RecipeIngredient.new(params[:recipe_ingredient])\n\n respond_to do |format|\n if @recipe_ingredient.save\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe ingredient was successfully created.' }\n format.json { render json: @recipe_ingredient, status: :created, location: @recipe_ingredient }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = Recipe.new(params[:recipe])\n\n respond_to do |format|\n if @current_user.recipes << @recipe\n flash[:notice] = 'Recipe was successfully created.'\n format.html { redirect_to edit_recipe_url(@recipe) }\n format.xml { head :created, :location => recipe_url(@recipe) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @recipe.errors.to_xml }\n end\n end\n end", "def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end", "def create\n @recipe = Recipe.new(recipe_params)\n @recipe.user_id = current_user.id\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'レシピが登録されました。' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def recipe_params\r\n params.require(:recipe).permit(:title, :subtitle, :body, :featured, :ingredients, :main_image, :thumb_image)\r\n end", "def recipe_params\n params.require(:recipe).permit(:name, :serves, :cooking_time, :difficulty, :ingredients, :procedure, :food_preference_id, :food_type_id, :cuisine_id, :photo)\n end", "def recipe_params\n params.require(:recipe).permit(:content, :quantity_upstairs, :quantity_downstairs, :food_type, :ann_safe, :checkbox_value, :id)\n end", "def recipe_params\n params.require(:recipe).permit(:user_id, :title, :image_url, :description, :cuisine_id, :category_id, :cook_time, :serving_num, :instruction, :ingredients_attributes => [:id, :recipe_id, :quantity, :unit, :item_id, :_destroy, :item_attributes => [:name]])\n end", "def recipe_params\n params.require(:recipe).permit(:name, :photo, :source_url, :serving_size, :ingredients, :instructions, :health_labels)\n end", "def recipe_params\n params.require(:recipe).permit(:name, :instructions, :recipe_image)\n end", "def recipe_params\n\n params.require(:recipe).permit(:title, :description)\n\n end", "def recipe_params\n params.require(:recipe).permit(:title, :description)\n end", "def create\n @recipe_ingredient = RecipeIngredient.new(recipe_ingredient_params)\n\n respond_to do |format|\n if @recipe_ingredient.save\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe ingredient was successfully created.' }\n format.json { render :show, status: :created, location: @recipe_ingredient }\n else\n format.html { render :new }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_recipe(recipe)\n @recipes.push(recipe)\n save\n end", "def recipe_params\n params.require(:recipe).permit(:title, :description, properties: [:preparation_time, :rest_time, :calories, :difficulty], ingredients: [], categories: [])\n end", "def create_new_recipe3 user, params\n recipe = Recipe.new(name: params[\"recipe_name\"], create_time: Time.now.to_i, user_id: user.id, user_name: user.name)\n recipe.picture = params[\"recipe_url\"] if params[\"recipe_url\"] != nil\n raise Error::RecipeError, recipe.errors.messages.values[0][0] unless recipe.save\n\n ingredients = params[\"ingredients\"]\n ingredients.each { |ingredient| Ingredient.create(name: ingredient[\"name\"], amount: ingredient[\"amount\"], recipe_id: recipe.id)}\n\n steps = params[\"steps\"]\n steps.length.times { |i| Step.create(index: i+1, content: steps[i], recipe_id: recipe.id)}\n\n recipe\n end", "def index\n @recipes = Recipe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end", "def create\n @recipe_ingredient = Recipe_ingredient.new(params[:recipe_ingredient])\n\n respond_to do |format|\n if @recipe_ingredient.save\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe_ingredient was successfully created.' }\n format.json { render json: @recipe_ingredient, status: :created, location: @recipe_ingredient }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recipe = Recipe.find params[:recipe_id]\n review = Review.new review_params\n review.recipe = @recipe\n review.user = current_user\n if review.save\n render json:{id: review.id}\n else \n render(json: {status: 422},\n status: 422 )\n end\n end", "def create\n @recipe = create_recipes\n\n respond_to do |format|\n if @recipe.present? && @recipe.persisted?\n send_new_recipe_email(@recipe)\n format.html { redirect_to redirect_path, notice: I18n.t(:'recipes.create.successful') }\n format.json { render :show, status: :created }\n else\n format.html {\n if @recipe.present?\n flash[:error] = @recipe.errors.full_messages.to_sentence\n else\n flash[:error] = I18n.t(:'recipes.create.failed')\n end\n redirect_to new_recipe_path\n }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def recipe_params\n params.require(:recipe).permit(:name, :url, :instructions, :picture_url, :menu_type, allergy_ids: [], ingredient_ids: [])\n end" ]
[ "0.7513961", "0.7252413", "0.71854967", "0.7043643", "0.69464684", "0.69280976", "0.69280976", "0.6921548", "0.6838844", "0.6824818", "0.68215215", "0.681211", "0.6806326", "0.680137", "0.67922544", "0.67922544", "0.6773201", "0.677275", "0.6763137", "0.6756849", "0.67557687", "0.6737752", "0.6726562", "0.67062205", "0.6620947", "0.66185737", "0.66119117", "0.6607107", "0.6596976", "0.6556449", "0.6550552", "0.65274197", "0.65172076", "0.6505409", "0.648949", "0.6486617", "0.6485578", "0.64660835", "0.6455028", "0.6431329", "0.64213747", "0.641404", "0.6409871", "0.64040107", "0.639946", "0.6391104", "0.6384966", "0.63783526", "0.6373009", "0.63557744", "0.63465995", "0.63215625", "0.63051635", "0.62961364", "0.62940055", "0.6286886", "0.6286488", "0.6273654", "0.62613964", "0.62595093", "0.625856", "0.6257782", "0.6251998", "0.6251504", "0.6249476", "0.6242118", "0.62367815", "0.62367815", "0.62367815", "0.62367815", "0.62367815", "0.62355894", "0.62339747", "0.62297916", "0.622521", "0.6223257", "0.6217662", "0.6215211", "0.6214794", "0.6213426", "0.62111735", "0.62086254", "0.62078243", "0.62037516", "0.6203167", "0.6185899", "0.6182454", "0.6174368", "0.61727536", "0.61704755", "0.61663455", "0.6164732", "0.61611927", "0.61598605", "0.615552", "0.61472136" ]
0.6830795
13
PATCH/PUT /recipes/1 PATCH/PUT /recipes/1.json
def update respond_to do |format| if @recipe.update(recipe_params) format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' } format.json { render :show, status: :ok, location: @recipe } else format.html { render :edit } format.json { render json: @recipe.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n recipe.update(recipe_params)\n render json: recipe\n end", "def update\n begin\n recipe = Recipe.find(params[:id])\n\n if recipe.update_attributes(recipe_params)\n render json: { status: 'SUCCESS', message: 'Recipe updated!', data: recipe }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Error updating recipe', data: recipe.errors }, status: :unprocessable_entity\n end\n rescue\n render json: { status: 'ERROR', message: 'Error finding recipe', data: {} }, status: :not_found\n end\n end", "def edit(id, options = {})\n optional = [:label,\n :description,\n :compatible_with,\n :script_type\n ]\n params.accepts(optional).validate! options\n request(:put, \"/recipes/#{id}.json\", default_params(options))\n end", "def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end", "def update\n @recipe = current_user.recipes.find(params[:id])\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n \n unless params[:instructions].nil?\n @recipe.instructions.delete_all\n Instruction.multi_save(params[:instructions], @recipe)\n end\n \n unless params[:ingredients].nil?\n @recipe.ingredients.delete_all\n Ingredient.multi_save(params[:ingredients], @recipe)\n end\n\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render json: {:recipe => @recipe, :tags => @recipe.tag_list} }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params[:recipe][:ingredient_ids] ||= []\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n params[:recipe][:ingredients].each do |ingredient_id|\n next if ingredient_id.to_i == 0\n ingredient = Ingredient.find(ingredient_id.to_i)\n @recipe.ingredients << ingredient\n end\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t\t\trecipe = Recipe.find(params[:id])\n\t\t\t\tingredients = params[:ingredients]\n\t\t\t\ttags = params[:tags]\n\n\t\t\t\tif recipe.update_attributes(recipe_params)\n\t\t\t\t\tif !ingredients.blank?\n\t\t\t\t\t\tcreate_ingredient(recipe.id, ingredients)\n\t\t\t\t\tend\n\n\t\t\t\t\tif !tags.blank?\n\t\t\t\t\t\tcreate_tag(recipe.id, tags)\n\t\t\t\t\tend\n\n\t\t\t\t\trender json: {status: 'SUCCESS', message: 'Updated recipe', data: get_recipe_by_id(recipe.id)}, status: :ok\n\t\t\t\telse\n\t\t\t\t\trender json: {status: 'ERROR', message: 'Recipe not updated', data: recipe.errors}, status: :unprocessable_entity\n\t\t\t\tend\n\t\t\tend", "def update\n recipe = Recipe.find(params[:id])\n\n if recipe.user == current_user\n recipe.update(recipe_params)\n render json: { recipe: params[:id], deleted: true }\n else\n render json: { recipe: params[:id], deleted: false }\n end\n end", "def update\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to edit_recipe_path(@recipe), notice: 'Recipe was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n save_relations\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(attributes: {})\n attributes = attributes.with_indifferent_access\n clean_attributes(attributes)\n titleize(attributes)\n sync_tags(attributes)\n parse_ingredients(attributes)\n recipe.update(attributes)\n recipe_response\n rescue StandardError => e\n error_response(e)\n end", "def update\n # @recipe = Recipe.find(params[:id])\n #\n update! do |success, failure|\n # success.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n # success.json { head :ok }\n # failure.html { render action: \"edit\" }\n # failure.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end", "def update\n respond_to do |format|\n update_recipe_line_items\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n #@recipe.ingredients = params[:recipe_ingredients].map {|k, v|\n #ingredient = @recipe.ingredients.find(k) || @recipe.ingredients.build\n #ingredient.update_attributes(:item => Food.find(v[:item_id]), :quantity => v[:quantity]) unless v[:item_id].blank?\n #ingredient\n #}.compact if params[:ingredients]\n\n @recipe.tags = params[:tags].split(/,/).map { |t|\n Tag.find_or_create_by_name(t.strip.downcase)\n }.compact if params[:tags]\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to recipes_path, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @food_recipe = FoodRecipe.find(params[:id])\n\n respond_to do |format|\n if @food_recipe.update_attributes(params[:food_recipe])\n format.html { redirect_to @food_recipe, notice: 'Food recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @food_recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: \"Recipe was successfully updated.\" }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: \"Recipe was successfully updated.\" }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: \"Recipe was successfully updated.\" }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to recipes_path, notice: 'Recipe successfully changed!!' }\n format.json { render json: @recipe }\n else\n #flash[:notice] = 'Recipe has not been changed!'\n format.html { render action: :edit }\n format.json { render json: @recipe.errors }\n end\n end\n end", "def update\n #if you query the Recipe db by the id, and the id is present then...\n if (@single_recipe_to_update = Recipe.find_by_id(params[:id])).present?\n # ... run the recipe_params function within the update function. it takes the input values from recipe_params and\n # updates that information the db\n @single_recipe_to_update.update(recipe_params)\n render :json => {\n :response => \"Successfully updated recipe.\",\n :data => @single_recipe_to_update # return the recipe with updated info\n }\n else\n render :json => {\n :response => \"Cannot find this record.\"\n }\n end\n end", "def update\n authorize @ingredient.recipe\n respond_to do |format|\n if @ingredient.update(ingredient_params)\n format.html { redirect_to @ingredient}\n format.json { render :show, status: :ok, location: @ingredient }\n else\n format.html { render :edit }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe.ingredients.clear\n params['ingredients'].each do |ingredient_name|\n @recipe.ingredients << Ingredient.find_by(name: ingredient_name)\n end\n\n @recipe.update(recipe_params)\n redirect_to @recipe\n end", "def update\n @recipe = Recipe.find(params[:id])\n \n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n flash[:notice] = 'Recipe was successfully updated.'\n format.html { redirect_to(@recipe) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @recipe.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize @recipe\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe = Recipe.find(params[:id])\n\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n @categories=RecipeCategory.all\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe_ingredient = RecipeIngredient.find(params[:id])\n\n respond_to do |format|\n if @recipe_ingredient.update_attributes(params[:recipe_ingredient])\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe ingredient was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n calculate_nutrients \n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe_ingredient = Recipe_ingredient.find(params[:id])\n\n respond_to do |format|\n if @recipe_ingredient.update_attributes(params[:recipe_ingredient])\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe_ingredient was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_recipe\n @recipe = RecipeApi.find(params[:id])\n end", "def update\n respond_to do |format|\n if @ingredient_recipe.update(ingredient_recipe_params)\n format.html { redirect_to @ingredient_recipe, notice: 'Ingredient recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @ingredient_recipe }\n else\n format.html { render :edit }\n format.json { render json: @ingredient_recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @recipe\n\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n rid = params['id']\n name = params['name']\n description = params['description']\n instructions = params['instructions']\n cook_time = params['cook_time']\n quantity = params['quantity']\n serving_size = params['serving_size']\n uid = params['user_id']\n aws_params = Hash.new\n aws_params[:custom_fields] = {\n 'recipe_id' => rid,\n 'name' => name,\n 'description' => description,\n 'instructions' => instructions,\n 'cook_time' => cook_time,\n 'quantity' => quantity,\n 'serving_size' => serving_size,\n 'user_id' => uid\n }\n if Aws.update_recipe(aws_params)\n msg = {:notice => \"Recipe updated!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while save to DynamoDB!\"}\n render :json => msg\n end\n end", "def update\n p = recipe_params\n @recipe.properties = RecipeProperties.new(p.delete(:properties))\n respond_to do |format|\n if @recipe.update(p)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe = Recipe.find(params[:id])\n @recipe.update(recipe_params)\n redirect_to new_ingredient_path\n end", "def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end", "def update\n authorize! :update, @recipe\n \n @recipe.modifier = current_user\n \n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: t('.success') }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @potluck_recipe.update(potluck_recipe_params)\n format.html { redirect_to @potluck_recipe, notice: 'Potluck recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @potluck_recipe }\n else\n format.html { render :edit }\n format.json { render json: @potluck_recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipes_food.update(recipes_food_params)\n format.html { redirect_to @recipes_food, notice: 'Recipes food was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipes_food }\n else\n format.html { render :edit }\n format.json { render json: @recipes_food.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@recipe = Recipe.find(params[:id])\n\n \tif @recipe.update(recipe_params)\n \t\tredirect_to recipe_path\n\t end\t\t\n\tend", "def update\n respond_to do |format|\n if @recipe.update(update_recipe_params)\n #if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'レシピが更新されました。' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe = Recipe.find(params[:id])\n @recipe.ingrediences = Ingredience.find(params[:ingredience_ids]) if params[:ingredience_ids] \n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n flash[:notice] = 'Recipe was successfully updated.'\n format.html { redirect_to(@recipe) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @recipe.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n #@recipe = Recipe.find(params[:id])\n \n if @recipe.update(recipe_params)\n flash[:success] = \"Your recipe was updated successfully!\"\n redirect_to recipe_path(@recipe)\n \n else\n render :edit\n \n end\n \n end", "def update\n respond_to do |format|\n save_relations\n if @ingredient.update(ingredient_params)\n format.html { redirect_to @ingredient.recipe, notice: 'Ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @ingredient }\n else\n format.html { render :edit }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe = current_user.recipes.find(params[:id])\n @obj = @recipe\n if(@recipe.update(recipe_params))\n flash.alert = \"Recipe updated\"\n redirect_to current_user\n else\n flash.now.alert = \"Error\"\n render 'shared/form'\n end\n end", "def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n @recipe = Recipe.find(params[:id])\n if @recipe.update(recipe_params)\n redirect_to recipe_url(@recipe)\n else\n render 'edit'\n end\n end", "def update\n @cooking_recipe = CookingRecipe.find(params[:id])\n\n respond_to do |format|\n if @cooking_recipe.update_attributes(params[:cooking_recipe])\n format.html { redirect_to(@cooking_recipe, :notice => 'CookingRecipe was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cooking_recipe.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(recipe)\n return false unless recipe.valid?\n\n @service.update(recipe)\n end", "def update\n @recipe = current_user.recipes.find(params[:id])\n @obj = @recipe\n if(@recipe.update(recipe_params))\n flash.alert = \"Recipe updated\"\n redirect_to current_user\n return\n else\n flash.now.alert = \"Error\"\n render 'shared/form'\n end\n end", "def update\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n flash[:notice] = 'Recipe was successfully updated.'\n format.html { redirect_to edit_recipe_url(@recipe) }\n format.js\n format.xml { head :ok }\n else\n format.html { render :action => \"edit_basics\" }\n format.js\n format.xml { render :xml => @recipe.errors.to_xml }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipeingredient.update(recipeingredient_params)\n format.html { redirect_to @recipeingredient, notice: 'Recipeingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipeingredient }\n else\n format.html { render :edit }\n format.json { render json: @recipeingredient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe_ingredient.update(recipe_ingredient_params)\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_ingredient }\n else\n format.html { render :edit }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @recipe.update(recipe_params)\n redirect_to @recipe, notice: \"Recipe was successfully updated.\"\n else\n render :edit, status: :unprocessable_entity\n end\n end", "def update\n @recipe_all = RecipeAll.find(params[:id])\n\n respond_to do |format|\n if @recipe_all.update_attributes(params[:recipe_all])\n format.html { redirect_to @recipe_all, notice: 'Recipe all was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe_all.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # recipe_params[:ingredient_lists_attributes].each do |list|\n # list.each do |item|\n # item[:ingredient_attributes] = Ingredient.where(name: item[:ingredient_attributes].name).first_or_create\n # end\n # end\n \n # category_ids = params[:recipe][:categories_attributes].map { |k,v| v[:id] }\n # #pry.debugger\n \n # recipe_params.merge({ category_ids: category_ids })\n \n\n respond_to do |format|\n \n if @recipe.update(recipe_params)\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cookbook.update(cookbook_params)\n format.html { redirect_to cookbook_path(@cookbook), notice: 'Cookbook was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cookbook = Cookbook.find(params[:id])\n\n respond_to do |format|\n if @cookbook.update_attributes(params[:cookbook])\n format.html { redirect_to @cookbook, notice: 'Cookbook was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @recipe = Recipe.find(params[:id])\n end", "def patch!\n request! :patch\n end", "def edit\n #@recipe = Recipe.find(params[:id])\n \n \n end", "def edit_basics\n @recipe = Recipe.find(params[:id])\n end", "def update\n respond_to do |format|\n if @recipe_input.update(recipe_input_params)\n format.html { redirect_to @recipe_input, notice: 'Recipe input was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_input }\n else\n format.html { render :edit }\n format.json { render json: @recipe_input.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ingredient = Ingredient.find(params[:id])\n\n respond_to do |format|\n if @ingredient.update_attributes(params[:ingredient])\n format.html { redirect_to @ingredient, notice: 'Ingredient was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @favorite_recipe.update(favorite_recipe_params)\n format.html { redirect_to @favorite_recipe, notice: 'Favorite recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @favorite_recipe }\n else\n format.html { render :edit }\n format.json { render json: @favorite_recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe = Recipe.find(current_recipe)\n @recipe_ingredient = current_recipe.recipe_ingredients.find(params[:id])\n @obj = @recipe_ingredient\n if(@recipe_ingredient.update(ri_params))\n #flash.alert = \"Record Updated\"\n respond_to do |f|\n f.html {redirect_to current_recipe}\n f.js {@recipe}\n end\n else\n #flash.now.alert = \"Error\"\n respond_to do |f|\n f.html {render 'shared/form'}\n f.js {@recipe}\n end\n end\n end", "def update_recipe(db,id,description)\n # your code here\nend", "def set_recipe\n @recipe = Recipe.find(params[:id])\n \n end", "def update\n @beverage = Beverage.find(params[:id])\n @beverage.ingredients.clear\n params[:ingredient].each{|ingr|\n @beverage.ingredients << Ingredient.find_by_name(ingr)\n } unless params[:ingredient].blank?\n\n respond_to do |format|\n if @beverage.update_attributes(params[:beverage])\n format.html { redirect_to @beverage, notice: 'Beverage was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @beverage.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @recipe = Recipe.find(params[:id])\nend", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n respond_to do |format|\n if @recipe_item.update(recipe_item_params)\n format.html { redirect_to @recipe_item, notice: 'Recipe item was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_item }\n else\n format.html { render :edit }\n format.json { render json: @recipe_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n\n if params[:lista].present?\n params[:lista].each do |(c,ingrediente)|\n Ingredient.create(name: ingrediente, recipe_id:@recipe.id) if ingrediente != \"\"\n end\n end\n\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n format.js {flash.now[:notice] = 'La receta se ha actualizado de forma exitosa.'} \n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n format.js {flash.now[:alert] = 'Error al actuar la receta.'} \n end\n end\n end", "def set_recipe\n @recipe = Recipe.find params[:id]\n end", "def update\n respond_to do |format|\n if @cookbook.update(cookbook_params)\n format.html { redirect_to @cookbook, notice: 'Cookbook was successfully updated.' }\n format.json { render :show, status: :ok, location: @cookbook }\n else\n format.html { render :edit }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #before action\n #Also in update we need to include the whitelisted fields\n if @recipe.update(recipe_params)\n flash[:success] = \"Your recipe was updated successfully\"\n #We want to redirect the user to the updated recipe. So we have to provide the object @recipe in the path method\n redirect_to recipe_path(@recipe)\n else\n render :edit\n end\n end", "def set_recipe\n @recipe = Recipe.find(params[:id]) # Find the recipe\n end", "def edit\n\t\t@recipe = Recipe.find(params[:id])\n\tend", "def set_recipe\n @recipe = Recipe.find(params[:id])\n end", "def set_recipe\n @recipe = Recipe.find(params[:id])\n end", "def set_recipe\n @recipe = Recipe.find(params[:id])\n end" ]
[ "0.7412457", "0.7212625", "0.7132887", "0.7110579", "0.707984", "0.70403636", "0.6898505", "0.6888944", "0.6888944", "0.6888944", "0.6888944", "0.6887258", "0.6844805", "0.6808558", "0.6766614", "0.67402714", "0.6716237", "0.66892487", "0.66645557", "0.66595244", "0.66223663", "0.6601799", "0.6591347", "0.6591347", "0.6591347", "0.6584351", "0.6573086", "0.6534769", "0.6530078", "0.65145105", "0.64855593", "0.64847803", "0.64650196", "0.6440537", "0.640971", "0.63889056", "0.6381204", "0.6369964", "0.6368034", "0.63657445", "0.6359717", "0.6345758", "0.6338658", "0.6331527", "0.6314524", "0.6306233", "0.63029957", "0.62902135", "0.62839913", "0.628187", "0.62770694", "0.62526083", "0.6241775", "0.6233243", "0.6231339", "0.6210555", "0.6208473", "0.62023395", "0.61998695", "0.61599433", "0.6148719", "0.61461675", "0.61297154", "0.61280924", "0.6124265", "0.60766315", "0.60760874", "0.6062716", "0.606211", "0.6051055", "0.6042371", "0.60419446", "0.60408807", "0.6033242", "0.60143477", "0.60053515", "0.59840256", "0.5977991", "0.59753263", "0.5967737", "0.59629714", "0.5959465", "0.59404916", "0.59274185", "0.5924822", "0.592402", "0.592402", "0.592402" ]
0.6611246
30
DELETE /recipes/1 DELETE /recipes/1.json
def destroy @recipe.destroy respond_to do |format| format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end", "def recipe_delete # /v1/user/:id/recipes/:recipe_id (DELETE)\n params[:recipes] = params[:recipe_id]\n recipes_delete\n end", "def destroy\n rid = params['id']\n if Aws.delete_recipe(rid) && Aws.delete_all_ingredients(rid)\n msg = {:notice => \"Recipe deleted!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while deleting from DynamoDB!\"}\n render :json => msg\n end\n end", "def destroy\n recipe = Recipe.find(params[:id])\n recipe.destroy()\n render json: {message:\"Recipe deleted.\"}\n end", "def destroy\n begin\n recipe = Recipe.find(params[:id])\n\n recipe.destroy\n render json: { status: 'SUCCESS', message: 'Recipe deleted!', data: recipe }, status: :ok\n rescue\n render json: { status: 'ERROR', message: 'Error finding recipe', data: {} }, status: :not_found\n end\n end", "def destroy\n @data = @recipe.delete(params[:id])\n render json: @data\n end", "def destroy\n\t\t\t\trecipe = get_recipe_by_id(params[:id])\n\t\t\t\trecipe.destroy\n\t\t\t\trender json: {status: 'SUCCESS', message: 'Deleted recipe', data: recipe}, status: :ok\n\t\t\tend", "def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@recipe = Recipe.find(params[:id])\n\t\tif @recipe.destroy\n\t\t\trender json: {}\n\t\telse\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend", "def destroy\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :ok }\n end\n end", "def destroy\n # @recipe = Recipe.find(params[:id])\n # @recipe.destroy\n #\n destroy! do |format|\n # format.html { redirect_to recipes_url }\n # format.json { head :ok }\n end\n end", "def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe = current_user.recipes.find(params[:id])\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n \n respond_to do |format|\n format.html { redirect_to(recipes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to(recipes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to(recipes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @food_recipe = FoodRecipe.find(params[:id])\n @food_recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to food_recipes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n current_user.recipes.find(params[:id]).destroy\n redirect_to current_user\n end", "def destroy\n current_user.recipes.find(params[:id]).destroy\n redirect_to current_user\n end", "def destroy\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: I18n.t(:'recipes.destroy.successful') }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @recipe_ingredient = RecipeIngredient.find(params[:id])\n @recipe_ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_ingredients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if (@single_recipe_delete = Recipe.find_by_id(params[:id])).present?\n @single_recipe_delete.destroy\n render :json => {\n :response => 'Successfully deleted record.'\n }\n else\n render :json => {\n :response => 'record not found'\n }\n end\n end", "def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :destroy, @recipe\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: t('.success') }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe_ingredient = Recipe_ingredient.find(params[:id])\n @recipe_ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_ingredients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: \"Recipe was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: \"Recipe was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: \"Recipe was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete_recipe(db,id)\n q = \"DELETE FROM recipes WHERE id=#{id};\"\n return db.execute(q)\nend", "def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'レシピが削除されました。' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @recipe\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url}\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe_all = RecipeAll.find(params[:id])\n @recipe_all.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_alls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe.destroy\n \n end", "def destroy\n @cooking_recipe = CookingRecipe.find(params[:id])\n @cooking_recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to(cooking_recipes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ingredient_recipe.destroy\n respond_to do |format|\n format.html { redirect_to ingredient_recipes_url, notice: 'Ingredient recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n recipe = @ingredient.recipe\n @ingredient.destroy\n respond_to do |format|\n if recipe.save\n format.html { redirect_to recipe, notice: 'Ingredient was successfully removed.' }\n format.json { head :no_content }\n else\n format.html { redirect_to recipe, notice: 'An error occured while removing the ingredient.' }\n format.json { head :no_content }\n end\n end\n end", "def destroy\n @recipe.destroy\n head :no_content\n end", "def destroy\n authorize @ingredient.recipe\n @ingredient.destroy\n respond_to do |format|\n format.html { redirect_to @ingredient.recipe }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n format.js { render action: \"index\" }\n end\n end", "def destroy\n #1st you retrieve the product thanks to params[:product_id]\n product = Product.find(params[:product_id])\n #2nd you retrieve the recipe thanks to params[:id]\n @recipes = product.recipes.find(params[:id])\n @recipes.destroy\n \n respond_to do |format|\n #1st argument reference the path /posts/:post_id/comments/\n format.html { redirect_to action: \"index\", notice: 'Recipe step was successfully deleted.' }\n format.xml { head :ok }\n end\n end", "def destroy\n\t\t@recipe = Recipe.find(params[:id])\n\t @recipe.destroy\n\t redirect_to recipes_path\n\tend", "def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to user_path(current_user), notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe_item.destroy\n respond_to do |format|\n format.html { redirect_to @recipe_item.recipe, notice: 'Recipe item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n recipe_index = @view.index_delete\n @cookbook.remove_recipe(recipe_index)\n @view.listing\n end", "def delete_recipe(db,id)\n # your code here\nend", "def destroy\n @recipes_food.destroy\n respond_to do |format|\n format.html { redirect_to recipes_foods_url, notice: 'Recipes food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @potluck_recipe.destroy\n respond_to do |format|\n format.html { redirect_to potluck_recipes_url, notice: 'Potluck recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe.destroy\n redirect_to recipes_path, notice: 'Recipe successfully deleted!!'\n end", "def destroy\n @ingredient = Ingredient.find(params[:id])\n @ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to ingredients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe_ingredient.destroy\n respond_to do |format|\n format.html { redirect_to recipe_ingredients_url, notice: 'Recipe ingredient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe.destroy\n redirect_to root_path, notice: \"Successfully deleted recipe\"\n end", "def destroy\n @recipeingredient.destroy\n respond_to do |format|\n format.html { redirect_to recipeingredients_url, notice: 'Recipeingredient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'La recette a été supprimée.' }\n end\n end", "def original_destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to(recipes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ingredient.destroy\n redirect_to @recipe\n end", "def destroy\n @favorite_recipe.destroy\n respond_to do |format|\n format.html { redirect_to favorite_recipes_url, notice: 'Favorite recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @favourites_recipe.destroy\n respond_to do |format|\n format.html { redirect_to favourites_recipes_url, notice: 'Favourites recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @batch = Batch.find(params[:id])\n @batch.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_path(@batch.recipe_id)}\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @recipe\n\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cooking_ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to(cooking_ingredients_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @recipe.destroy\n redirect_to recipes_url, notice: \"Recipe was successfully destroyed.\"\n end", "def destroy\n @recipe_category = RecipeCategory.find(params[:id])\n @recipe_category.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meals_recipe = MealsRecipe.find(params[:id])\n @meals_recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to(meals_recipes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ingredients_nutrient.destroy\n respond_to do |format|\n format.html { redirect_to ingredients_nutrients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe_list.destroy\n respond_to do |format|\n format.html { redirect_to recipe_lists_url, notice: 'Recipe list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n Ingredient.find(params[:id]).destroy\n redirect_to ingredients_path\n end" ]
[ "0.82631564", "0.8203384", "0.7745981", "0.7638722", "0.76314753", "0.76168", "0.7602991", "0.7566857", "0.75504524", "0.75504524", "0.75504524", "0.75504524", "0.75504524", "0.7474456", "0.74714565", "0.7446406", "0.74406594", "0.74406594", "0.74406594", "0.74406594", "0.74406594", "0.74210465", "0.741352", "0.73338306", "0.73338306", "0.73170274", "0.7267196", "0.7267196", "0.7259213", "0.7216318", "0.72152823", "0.719028", "0.718472", "0.71759975", "0.7164896", "0.7136078", "0.7130241", "0.7130241", "0.7130241", "0.7108639", "0.7089652", "0.7083104", "0.7074207", "0.7071318", "0.7066233", "0.70592964", "0.70479804", "0.7026674", "0.7025104", "0.70212424", "0.6993792", "0.6981974", "0.6981433", "0.69430566", "0.6924475", "0.69153935", "0.69039005", "0.6902774", "0.6902346", "0.68742454", "0.6835877", "0.68337435", "0.68336225", "0.68327445", "0.68158", "0.67599016", "0.6745616", "0.67428267", "0.67384464", "0.6731477", "0.6729182", "0.6723054", "0.6705825", "0.66937953", "0.66878885", "0.66730917", "0.66341025", "0.659505", "0.65908974" ]
0.7137432
51
Use callbacks to share common setup or constraints between actions.
def set_recipe @recipe = Recipe.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 recipe_params params.require(:recipe).permit(:content, :quantity_upstairs, :quantity_downstairs, :food_type, :ann_safe, :checkbox_value, :id) 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
has_one :codeml_result, dependent: :destroy has_one :fast_result, dependent: :destroy after_create :execute_pipeline
def execute_pipeline PipelineJob.perform_async(id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute_convert_stock_one_on_one( employee, quantity) \n source = self.one_to_one_source \n source_item = source.item \n \n new_convert_stock = ConvertStock.new \n new_convert_stock.source_quantity = quantity \n new_convert_stock.creator_id = employee.id \n new_convert_stock.stock_conversion_id = self.id \n today_datetime = DateTime.now \n new_convert_stock.year = today_datetime.year \n new_convert_stock.month = today_datetime.year \n \n \n \n if not quantity.present? or quantity <= 0 or quantity > source_item.ready # if it is not one to one -> quantity*source.quantity > source_item.ready \n new_convert_stock.errors.add(:source_quantity , \n \"Jumlah Konversi harus setidaknya 1, dan tidak boleh lebih dari #{source_item.ready}\" ) \n return new_convert_stock \n end\n \n new_convert_stock.save \n \n # create stock entry\n new_convert_stock.execute_conversion_one_on_one(employee) \n # create stock mutation \n end", "def create_line_code\n production_run = ProductionRun.find(:first, :conditions=>['production_run_code = ?', self.production_run_code])\n if production_run != nil\n self.line_code = production_run.line_code\n else\n self.line_code = \"\"\n end\nend", "def before_create()\n end\n \n def before_update()\n end\n \n def before_destroy()\n end\n \n ##################################################################\n # execute the rule\n # this rule does nothing\n def process(process_id, plan, data)\n RulesEngine::Process.auditor.audit(process_id, \"Inside Rule #{title}\", RulesEngine::Process::AUDIT_INFO) \n # RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::STOP_SUCCESS)\n # RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::STOP_FAILURE)\n # RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::START_WORKFLOW, 'next_workflow')\n RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::NEXT)\n end \n end", "def build_callback_to_depender_model\n first_association_chain = @quickery_builder.association_chains.first\n first_association_chain.model.quickery_association_chain_dependers ||= []\n first_association_chain.model.quickery_association_chain_dependers << first_association_chain\n end", "def after_create; end", "def has_one?; false; end", "def has_one?; false; end", "def dependent; end", "def dependent; end", "def make_and_model; end", "def create_result\n race = Race.find(params[:id])\n @result = race.create_result_before(params[:before_result_id])\n expire_cache\n end", "def prepare_result; end", "def create\n @register_execution = RegisterExecution.new(register_execution_params)\n\n respond_to do |format|\n if @register_execution.save\n\n root = Root.new\n root.size = register_execution_params['root_size']\n root.onion_id = register_execution_params['onion_id']\n if root.save\n root_register_execution = RootRegisterExecution.new\n root_register_execution.register_execution_id = @register_execution.id\n root_register_execution.root_id = root.id\n root_register_execution.save\n end\n\n format.html { redirect_to @register_execution, notice: 'Register execution was successfully created.' }\n format.json { render action: 'show', status: :created, location: @register_execution }\n else\n\n register_execution = params[:register_execution]\n analysis_execution = AnalysisExecution.find_by_id(register_execution['analysis_execution_id'])\n #analysis = Analysis.find_by_id(analysis_execution.analysis.id)\n analysis = Analysis.find_by_id(register_execution[:analysis_id])\n\n @analysis_execution_id = analysis_execution.id\n @analysis_id = analysis.id\n @analysis_name = analysis.name\n @groups = OnionGroup.where(:analysis_id => analysis.id)\n @onions = [] #Onion.find_all_by_analysis_id()\n\n format.html { render action: 'new' }\n format.json { render json: @register_execution.errors, status: :unprocessable_entity }\n end\n end\n end", "def after_create(obj); end", "def after_build\n end", "def initialise_process\n self.state = \"Initiated\"\n self.save!\n self.init_process\n end", "def create\n @hq_proc = HqProc.new(params[:hq_proc])\n \n params[:hq_proc][:new_hq_rsrc_usage_attributes] ||= {}\n params[:hq_proc][:existing_hq_rsrc_usage_attributes] ||= {}\n params[:hq_proc][:assigned_hq_rsrc] ||= {}\n respond_to do |format|\n if @hq_proc.save\n flash[:notice] = 'Process was successfully created.'\n format.html { redirect_to :action => :index }\n format.xml { render :xml => @hq_proc, :status => :created, :location => @hq_proc }\n else\n messages = '<ul>Error:'\n @hq_proc.errors.full_messages.each {|msg| messages += '<li>'+msg+'</li>'}\n messages += '</ul>'\n flash[:notice] = messages\n format.html { redirect_to :action => \"new\", :template => 'reflected/new' }\n format.xml { render :xml => @hq_proc.errors, :status => :unprocessable_entity }\n end\n end\n end", "def after_create\n self.cim_id\n end", "def after_processing\n end", "def create\n @project = Project.find_by_id(params[:project_id])\n @execution = Execution.new(execution_params)\n @execution.project = @project\n @execution.status = \"Pending\"\n @execution.timespent = DateTime.now.to_i\n dataset = MlMethods.new.open_dataset(@execution.project.attachment_url)\n attribute = dataset.attribute(@execution.class_name)\n save = true\n if(!attribute.nil?)\n dataset.setClass(attribute)\n else\n save = false\n end\n respond_to do |format|\n if save\n if @execution.save\n Notification.create(user_id: current_user.id, execution_id: @execution.id, checked: false)\n MlMethods.new.create_thread @execution\n flash[:notice] = 'Execution was successfully created.'\n format.html { redirect_to [@project,@execution]}\n format.json { render :show, status: :created, location: @execution }\n else\n flash[:warning] = 'Houveram erros durante a criação da execução.'\n format.html { render :new }\n format.json { render json: @execution.errors, status: :unprocessable_entity }\n end\n else\n flash[:warning] = 'Houveram erros durante a criação da execução.'\n @execution.errors.add(:class_name, \"Classe não encontrada.\")\n format.html { @description = Utils.get_description @execution.method\n @method = @execution.method\n render :new }\n format.json { render json: @execution.errors, status: :unprocessable_entity }\n end\n end\n end", "def have_one(model)\n HasOneReflection.new model\nend", "def set_one_to_one_associated_object(opts, o)\n if opts.dataset_need_primary_key? && new?\n delay_validate_associated_object(opts, o)\n after_create_hook { super(opts, o) }\n o\n else\n super\n end\n end", "def after_create_save(record); end", "def create\n # @script = Script.new(script_params)\n @automatic = Automatic.find(params[:automatic_id])\n @script = @automatic.scripts.build(script_params)\n @script.user_id = current_user.id\n unless @automatic.auto_type == 'cito'\n @script.who_code = Diagcode.where(pss_code: @script.pss_code).first.who_code\n end\n\n if @script.script_type == \"rec\"\n @script.organ = \"\"\n end\n\n if @script.save\n redirect_to automatic_path(@automatic), notice: 'Script creado exitosamente!'\n else\n render :new\n end\n end", "def execute; end", "def execute; end", "def create_dependancies\n create_course_plan()\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_result\n TestResult.new\n end", "def set_pipeline\n @pipeline = Pipeline.find(params[:id])\n end", "def execute()\n\n end", "def execute()\n\n end", "def has_one(association, **options, &block)\n create_association(:has_one, association, options, &block)\n end", "def create\n params[:operation][\"inputs\"] = filter_distribution_ids(params[:operation][\"inputs\"])\n @operation = Operation.new(params[:operation])\n @model = Model.find(params[:model_id])\n respond_to do |format|\n if @operation.save\n if @model\n @operation.dependent.models << @model\n format.html { redirect_to user_model_path(@model.user, @model), notice: 'Operation was successfully created.' }\n else\n format.html { redirect_to root_path, notice: 'Operation was successfully created.' }\n end \n else\n format.html { render action: \"new\" }\n format.json { render json: @operation.errors, status: :unprocessable_entity }\n end\n end\n end", "def has_one(*args)\n require \"og/relation/has_one\"\n relations! << Og::HasOne.new(args, :owner_class => self)\n end", "def run\n super\n\n x = Ear::Client::Corpwatch::CorpwatchService.new\n corps = x.search @object.name\n\n # Attach to the first object\n @object.physical_locations << create_object(PhysicalLocation, {\n :address => corps.first.address, \n :state => corps.first.state, \n :country => corps.first.country })\n\n # Save off our raw data\n #@task_run.save_raw_result corps.join(\" \")\n\nend", "def post_process; end", "def prepare; self; end", "def domain_create_result(proc_id)\n result = parse_attributes(result_retrieve(proc_id)[:body].split(\"\\n\\n\", 1)[0])\n puts result\n return nil unless result.has_key? :completion_status\n case result[:completion_status]\n when 'ack' then\n result_delete proc_id\n result[:object_name]\n when 'nack' then\n raise_response result\n else\n nil\n end\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 execute\n end", "def execute\n\n end", "def set_three_result\n @three_result = ThreeResult.find(params[:id])\n end", "def create\n @process_lt = ProcessLt.new(process_lt_params)\n\n respond_to do |format|\n if @process_lt.save\n update_related_ids_and_reverse()\n format.html { redirect_to @process_lt, notice: 'Process was successfully created.' }\n format.json { render :show, status: :created, location: @process_lt }\n else\n format.html { render :new }\n format.json { render json: @process_lt.errors, status: :unprocessable_entity }\n end\n end\n end", "def process!\n self.status = 'Generado'\n save\n end", "def save_success_sequence(aa_sequence, nt_sequence, header, accession_no, organism, group, reference, uploader_name, uploader_email)\n\n new_sequence = CustomizedProteinSequence.new\n new_sequence.header = header\n new_sequence.uploader = \"USER\"\n new_sequence.uploader_name = uploader_name\n new_sequence.uploader_email = uploader_email\n new_sequence.group = group\n new_sequence.accession_no = accession_no # result[:header] should be accession no OR manually extract accession number from local blast db\n new_sequence.chain = aa_sequence\n new_sequence.reference = reference\n new_sequence.save!\n\n\n # don't ask user for nt sequence yet. probably ask later through email\n new_nt_sequence = CustomizedNucleotideSequence.new\n new_nt_sequence.header = header\n new_nt_sequence.uploader = \"USER\"\n new_nt_sequence.uploader_name = uploader_name\n new_nt_sequence.uploader_email = uploader_email\n new_nt_sequence.group = group\n new_nt_sequence.accession_no = accession_no\n new_nt_sequence.chain = nt_sequence\n new_sequence.reference = reference\n new_nt_sequence.save!\n\n\n end", "def execute\n return false unless super\n ActiveRecord::Base.transaction do\n # Location Create\n location_params = @recipient_location.merge({name: @parcel_details[:recipient_name] })\n recipient_loc = create_parcel_destination_location(location_params)\n\n # Parcel Create\n parcel_params = @parcel_details.merge({destination_location_id: recipient_loc.id })\n parcel_object = create_parcel(parcel_params) if valid?\n if valid?\n # Mission Create\n mission_params = {\n drone_id: @drone.id,\n warehouse_id: @warehouse.id,\n parcel_id: parcel_object.id\n }\n @result = create_mission(mission_params)\n end\n raise ActiveRecord::Rollback unless valid?\n end\n valid?\n end", "def perform_some_actions\n # It is to be called while destroying a Child record\n # But must not be called while destroying the parent record\n unless self.parent.destroyed?\n\n end\n end", "def _process_on_create(entity)\n end", "def procession\n @procession ||= fetch_procession\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n floorplan_path = runner.getStringArgumentValue('floorplan_path', user_arguments)\n\n # check the floorplan_path for reasonableness\n if floorplan_path.empty?\n runner.registerError('Empty floorplan path was entered.')\n return false\n end\n\n path = runner.workflow.findFile(floorplan_path)\n if path.empty?\n runner.registerError(\"Cannot find floorplan path '#{floorplan_path}'.\")\n return false\n end\n\n json = nil\n File.open(path.get.to_s, 'r') do |file|\n json = file.read\n end\n\n floorplan = OpenStudio::FloorplanJS.load(json)\n if floorplan.empty?\n runner.registerError(\"Cannot load floorplan from '#{floorplan_path}'.\")\n return false\n end\n\n # scene = floorplan.get.toThreeScene(true)\n # rt = OpenStudio::Model::ThreeJSReverseTranslator.new\n # new_model = rt.modelFromThreeJS(scene\n\n rt = OpenStudio::Model::FloorspaceReverseTranslator.new\n new_model = rt.modelFromFloorspace(json)\n\n unless new_model.is_initialized\n runner.registerError('Cannot convert floorplan to model.')\n return false\n end\n new_model = new_model.get\n runner.registerInfo(\"Model from FloorSpaceJS has #{new_model.getPlanarSurfaceGroups.size} planar surface groups.\")\n puts \"hello\"\n puts new_model\n\n runner.registerInitialCondition(\"Initial model has #{model.getPlanarSurfaceGroups.size} planar surface groups.\")\n\n mm = OpenStudio::Model::ModelMerger.new\n mm.mergeModels(model, new_model, rt.handleMapping)\n\n mm.warnings.each do |warnings|\n runner.registerWarning(warnings.logMessage)\n end\n\n # put all of the spaces in the model into a vector\n spaces = OpenStudio::Model::SpaceVector.new\n model.getSpaces.each do |space|\n spaces << space\n end\n\n # intersect and match surfaces for each space in the vector\n # todo - add in diagnostic intersect as option\n # OpenStudio::Model.intersectSurfaces(spaces)\n # OpenStudio::Model.matchSurfaces(spaces)\n\n # removing duplicate points in a surface\n model.getPlanarSurfaces.each do |surface|\n array = []\n vertices = surface.vertices\n fixed = false\n vertices.each do |vertex|\n next if fixed\n\n if array.include?(vertex)\n # create a new set of vertices\n new_vertices = OpenStudio::Point3dVector.new\n array_b = []\n surface.vertices.each do |vertex_b|\n next if array_b.include?(vertex_b)\n\n new_vertices << vertex_b\n array_b << vertex_b\n end\n surface.setVertices(new_vertices)\n num_removed = vertices.size - surface.vertices.size\n runner.registerWarning(\"#{surface.name} has duplicate vertices. Started with #{vertices.size} vertices, removed #{num_removed}.\")\n fixed = true\n else\n array << vertex\n end\n end\n end\n\n # remove collinear points in a surface\n model.getPlanarSurfaces.each do |surface|\n new_vertices = OpenStudio.removeCollinear(surface.vertices)\n starting_count = surface.vertices.size\n final_count = new_vertices.size\n if final_count < starting_count\n runner.registerWarning(\"Removing #{starting_count - final_count} collinear vertices from #{surface.name}.\")\n surface.setVertices(new_vertices)\n end\n end\n\n # remove duplicate surfaces in a space (should be done after remove duplicate and collinear points)\n model.getSpaces.each do |space|\n # secondary array to compare against\n surfaces_b = space.surfaces.sort\n\n space.surfaces.sort.each do |surface_a|\n # delete from secondary array\n surfaces_b.delete(surface_a)\n\n surfaces_b.each do |surface_b|\n next if surface_a == surface_b # dont' test against same surface\n\n if surface_a.equalVertices(surface_b)\n runner.registerWarning(\"#{surface_a.name} and #{surface_b.name} in #{space.name} have duplicate geometry, removing #{surface_b.name}.\")\n surface_b.remove\n elsif surface_a.reverseEqualVertices(surface_b)\n # TODO: - add logic to determine which face naormal is reversed and which is correct\n runner.registerWarning(\"#{surface_a.name} and #{surface_b.name} in #{space.name} have reversed geometry, removing #{surface_b.name}.\")\n surface_b.remove\n end\n end\n end\n end\n\n # secondary array of spaces that we can remove items from once they have gone through in primary loop\n spaces_b = model.getSpaces.sort\n\n # looping through vector of each space\n model.getSpaces.sort.each do |space_a|\n runner.registerInfo(\"Intersecting and matching surfaces for #{space_a.name}.\")\n\n # delete from secondary array\n spaces_b.delete(space_a)\n\n spaces_b.each do |space_b|\n # runner.registerInfo(\"Intersecting and matching surfaces between #{space_a.name} and #{space.name}\")\n spaces = OpenStudio::Model::SpaceVector.new\n spaces << space_a\n spaces << space_b\n\n # intersect and match surfaces in pair of spaces\n OpenStudio::Model.intersectSurfaces(spaces)\n OpenStudio::Model.matchSurfaces(spaces)\n end\n end\n\n json = JSON.parse(File.read(path.get.to_s))\n\n # error checking\n if json['space_types'].empty?\n runner.registerInfo('No space types were created.')\n end\n\n # set the space type standards fields based on what user wrote in the editor\n json['space_types'].each do |st|\n model.getSpaceTypes.each do |space_type|\n next unless space_type.name.to_s.include? st['name']\n next if space_type.standardsSpaceType.is_initialized\n\n space_type.setStandardsSpaceType(st['name'])\n end\n end\n\n # remove any unused space types\n model.getSpaceTypes.each do |space_type|\n if space_type.spaces.empty?\n space_type.remove\n end\n end\n\n # for any spaces with no assigned zone, create (unless another space of the same space type has an assigned zone) a thermal zone based on the space type\n # todo - add argument to enable disable zone creation\n model.getSpaceTypes.each do |space_type|\n space_type.spaces.each do |space|\n unless space.thermalZone.is_initialized\n thermal_zone = OpenStudio::Model::ThermalZone.new(model)\n thermal_zone.setName(space.name.to_s)\n space.setThermalZone(thermal_zone)\n end\n end\n end\n\n # report final condition of model\n runner.registerFinalCondition(\"Final model has #{model.getPlanarSurfaceGroups.size} planar surface groups.\")\n\n return true\n end", "def before_processing\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n city_db_url = runner.getStringArgumentValue('city_db_url', user_arguments)\n project_id = runner.getStringArgumentValue('project_id', user_arguments)\n scenario_id = runner.getStringArgumentValue('scenario_id', user_arguments)\n feature_id = runner.getStringArgumentValue('feature_id', user_arguments)\n\n @runner = runner\n @result = true\n\n uri = URI.parse(city_db_url)\n @city_db_url = uri.host\n @port = uri.port\n @city_db_is_https = uri.scheme == 'https'\n\n feature = get_feature(project_id, feature_id)\n if feature[:properties].nil? || feature[:properties][:district_system_type].nil?\n runner.registerError(\"Cannot get feature #{feature_id} missing required property district_system_type\")\n return false\n end\n\n district_system_type = feature[:properties][:district_system_type]\n if district_system_type == 'Community Photovoltaic'\n # add in geometry for PV, maybe this should happen in add geometry measure? add to this workflow?\n vertices = OpenStudio::Point3dVector.new\n vertices << OpenStudio::Point3d.new(0, 1, 0)\n vertices << OpenStudio::Point3d.new(0, 0, 0)\n vertices << OpenStudio::Point3d.new(1, 0, 0)\n vertices << OpenStudio::Point3d.new(1, 1, 0)\n surface = OpenStudio::Model::ShadingSurface.new(vertices, model)\n\n shading_group = OpenStudio::Model::ShadingSurfaceGroup.new(model)\n surface.setShadingSurfaceGroup(shading_group)\n\n runner.registerInfo(\"No need to import loads for district system type '#{district_system_type}'\")\n return true\n end\n\n datapoint_ids = get_datapoint_ids(project_id, scenario_id)\n\n datapoint_files = []\n datapoint_ids.each do |datapoint_id|\n datapoint_file = download_datapoint(project_id, datapoint_id)\n if datapoint_file\n datapoint_files << datapoint_file\n end\n end\n\n # get timesteps\n time_step_per_hour = model.getTimestep.numberOfTimestepsPerHour\n num_rows = 8760 * time_step_per_hour\n start_date = model.getYearDescription.makeDate(1, 1)\n time_step = OpenStudio::Time.new(0, 0, 60 / time_step_per_hour, 0)\n\n timeseries = [{ name: 'District Cooling Chilled Water Rate', units: 'W', normalize: false },\n { name: 'District Cooling Mass Flow Rate', units: 'kg/s', normalize: true },\n { name: 'District Heating Hot Water Rate', units: 'W', normalize: false },\n { name: 'District Heating Mass Flow Rate', units: 'kg/s', normalize: true }]\n\n summed_values = {}\n datapoint_files.each do |file|\n runner.registerInfo(\"Reading #{file}\")\n\n basename = File.basename(file, '.csv').gsub('_timeseries', '')\n\n i = 0\n headers = []\n values = {}\n CSV.foreach(file) do |row|\n if i == 0\n # header row\n headers = row\n headers.each do |header|\n values[header] = OpenStudio::Vector.new(num_rows, 0.0)\n if summed_values[header].nil?\n summed_values[header] = OpenStudio::Vector.new(num_rows, 0.0)\n end\n end\n elsif i <= num_rows\n headers.each_index do |j|\n v = row[j].to_f\n values[headers[j]][i - 1] = v\n summed_values[headers[j]][i - 1] = summed_values[headers[j]][i - 1] + v\n end\n end\n i += 1\n end\n\n # to make one individual schedules\n # timeseries.each do |ts|\n # makeSchedule(start_date, time_step, values[ts[:name]], model, basename, ts)\n # end\n end\n\n # to make one summed schedule\n timeseries.each do |ts|\n makeSchedule(start_date, time_step, summed_values[ts[:name]], model, 'Summmed', ts)\n end\n\n # TODO: create a plant loop\n\n return @result\n end", "def child_relation; end", "def create_service_line\n @service_line = ServicePaymentEob.new(:details=>{:date_of_service_from_ocr_output=>\"\"})\n @insurance_payment_eob.service_payment_eobs << @service_line\n @service_line.save(:validate => false)\n return @service_line\n end", "def build\n raise FedoraMigrate::Errors::MigrationError, \"No qualified targets found in #{source.pid}\" if target.nil?\n\n # create target, and apply depositor metadata\n obj = target.new\n\n obj.apply_depositor_metadata @depositor_utln\n obj.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC\n\n user = User.find_by_user_key(@depositor_utln)\n# CurationConcerns::Workflow::ActivateObject.call(target: obj, comment: 'activate object', user: user)\n\n create_and_add_payload(obj, @payload_primary, @depositor_utln)\n\n #deal with 2 primary datastream objects, storing second object in a new file set\n create_and_add_payload(obj, @payload_secondary, @depositor_utln) unless @payload_secondary.nil?\n\n #handle a case of bad hand created data on old records\n create_and_add_payload(obj, \"ARCHIVAL_SOUND\", @depositor_utln) if @payload_primary == \"ARCHIVAL_WAV\"\n\n # back up old data\n #create_and_add_fcrepo3_set obj\n\n process_desc_metadata obj\n process_admin_metadata obj\n process_technical_metadata obj\n process_relsext_metadata obj\n\n# obj.save\n\n process_collection_metadata obj\n\n active_workflow = Sipity::Workflow.find(2)\n Sipity::Entity.create!(proxy_for_global_id: obj.to_global_id.to_s,\n workflow: active_workflow,\n workflow_state: nil)\n\n obj\n end", "def set_lab_result\n @lab_result = @patient.lab_results.find(params[:id])\n end", "def create_lab_result(params, patient, create_history)\n return if params[:first_positive_lab].blank?\n\n lab = Laboratory.new(lab_type: params[:first_positive_lab][:lab_type],\n specimen_collection: params[:first_positive_lab][:specimen_collection],\n report: params[:first_positive_lab][:report],\n result: params[:first_positive_lab][:result],\n patient_id: patient.id)\n\n # Create history item on successful create\n ActiveRecord::Base.transaction do\n if lab.save && create_history\n History.lab_result(patient: patient.id, created_by: current_user.email, comment: \"User added a new lab result (ID: #{lab.id}).\")\n end\n end\n\n lab.id\n end", "def execute!; end", "def child_process(result)\n end", "def has_one(*attrs)\n associate(Associations::HasOne, attrs)\n end", "def create\n @result = Admin::Result.new(result_params)\n if @result.save && @result.result_check\n redirect_to @result, notice: t('notice.created',{model: \"#{t('activerecord.models.admin/result')}\"})\n else\n @games = Admin::Game.none\n @divisions = Admin::Division.none\n render :new\n return\n end\n end", "def run_and_transform; end", "def set_result\n @result = Result.new\n end", "def execute()\r\n\tend", "def has_one(direction, name = nil, options = { type: nil })\n if name.is_a?(Hash)\n options.merge(name)\n name = direction\n direction = nil\n elsif name.is_a?(Proc)\n name = direction\n direction = nil\n elsif name.nil?\n name = direction\n end\n reflections[name] = { direction: direction, type: options[:type], kind: :has_one }\n # @!method promise_[name]\n # @return [Promise] on success the .then block will receive a [HyperRecord::Collection] as arg\n # on failure the .fail block will receive the HTTP response object as arg\n define_method(\"promise_#{name}\") do\n @fetch_states[name] = 'i'\n self.class._promise_get(\"#{self.class.resource_base_uri}/#{self.id}/relations/#{name}.json?timestamp=#{`Date.now() + Math.random()`}\").then do |response|\n @relations[name] = self.class._convert_json_hash_to_record(response.json[self.class.to_s.underscore][name])\n @fetch_states[name] = 'f'\n _notify_observers\n @relations[name]\n end.fail do |response|\n error_message = \"#{self.class.to_s}[#{self.id}].#{name}, a has_one association, failed to fetch records!\"\n `console.error(error_message)`\n response\n end\n end\n # @!method [name] get records of the relation\n # @return [HyperRecord::Collection] either a empty one, if the data has not been fetched yet, or the\n # collection with the real data, if it has been fetched already\n define_method(name) do\n _register_observer\n if @fetch_states.has_key?(name) && 'fi'.include?(@fetch_states[name])\n @relations[name]\n elsif self.id\n send(\"promise_#{name}\")\n @relations[name]\n else\n @relations[name]\n end\n end\n # @!method update_[name] mark internal structures so that the relation data is updated once it is requested again\n # @return nil\n define_method(\"update_#{name}\") do\n @fetch_states[name] = 'u'\n nil\n end\n # define_method(\"#{name}=\") do |arg|\n # _register_observer\n # @relations[name] = arg\n # @fetch_states[name] = 'f'\n # @relations[name]\n # end\n end", "def after_commit_on_create\n # Instead of using an external manager, for now we're going to fork the process using the Spawn plugin\n # post_to_dj_central\n spawn do\n begin \n Delayed::Worker.new.work_off\n rescue\n Rails.logger.warn \"Problem with working off DJs: #{$!}\"\n end\n end\n end", "def create\n args = process_byte_size.merge({ plan_id: @plan.id })\n args = process_nillable_values(args: args)\n # Create custom repositories and metadata standards if applicable\n args[:repositories_attributes] = create_custom_repositories(\n existing: args.fetch(:repositories_attributes, []), custom: custom_repo_params\n )\n args[:metadata_standards_attributes] = create_custom_standards(\n existing: args.fetch(:metadata_standards_attributes, []), custom: custom_standard_params\n )\n @research_output = ResearchOutput.new(args)\n authorize @research_output\n\n if @research_output.save\n redirect_to plan_research_outputs_path(@plan),\n notice: success_message(@research_output, _('added'))\n else\n flash.now[:alert] = failure_message(@research_output, _('add'))\n render 'research_outputs/new'\n end\n end", "def process_after_create\n # Note: Both contacts and addresses fields are same so when organization create then address info will store in Address table so commented the code for contact :- Vishal\n\n # contact = contacts.build(contact_address_1: organization_address_1, contact_address_2: organization_address_2,\n # contact_city: organization_city, contact_country: organization_country, contact_description: organization_description,\n # contact_email: organization_email, contact_fax: organization_fax, contact_notes: organization_notes,\n # contact_state: organization_state, contact_telephone: organization_telephone, contact_title: organization_name,\n # contact_website: organization_website, contact_zipcode: organization_zipcode, contact_type: 'address')\n # contact.save\n\n address = addresses.build(address_address_1: organization_address_1, address_address_2: organization_address_2,\n address_city: organization_city, address_country: organization_country, address_description: organization_description,\n address_email: organization_email, address_fax: organization_fax, address_notes: organization_notes,\n address_state: organization_state, address_telephone: organization_telephone, address_title: organization_name,\n address_website: organization_website, address_zipcode: organization_zipcode, address_type: 'address')\n address.save\n end", "def after_create_account(result)\n\n end", "def before_create\n super\n @uuid = Concept.find_by_sql(\"SELECT UUID() uuid\").first.uuid\n \n self.uuid = @uuid if !self.uuid?\n end", "def create_reference\n self.reference or Reference.new\n end", "def has_one(goal, options = { })\n goal.belongs_to(self) unless options[:skip_belongs_to]\n self.associate(:has_one, goal, options)\n end", "def dependent=(_arg0); end", "def dependent=(_arg0); end", "def execute\n end", "def execute\n end", "def reciprocal_type\n :many_to_one\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n floorplan_path = runner.getStringArgumentValue(\"floorplan_path\", user_arguments)\n\n # check the floorplan_path for reasonableness\n if floorplan_path.empty?\n runner.registerError(\"Empty floorplan path was entered.\")\n return false\n end\n\n path = runner.workflow.findFile(floorplan_path)\n if path.empty?\n runner.registerError(\"Cannot find floorplan path '#{floorplan_path}'.\")\n return false\n end\n\n runner.registerInfo(\"path = #{path.get.to_s}\")\n\n json = nil\n File.open(path.get.to_s, 'r') do |file|\n json = file.read\n end\n\n floorplan = OpenStudio::FloorplanJS::load(json)\n if floorplan.empty?\n runner.registerError(\"Cannot load floorplan from '#{floorplan_path}'.\")\n return false\n end\n\n scene = floorplan.get.toThreeScene(true)\n\n rt = OpenStudio::Model::ThreeJSReverseTranslator.new\n \n new_model = rt.modelFromThreeJS(scene)\n \n handle_mapping = rt.handleMapping()\n\n if new_model.empty?\n runner.registerError(\"Cannot convert floorplan to model.\")\n return false\n end\n\n runner.registerInitialCondition(\"Initial model has #{model.getPlanarSurfaceGroups.size} planar surface groups\")\n\n mm = OpenStudio::Model::ModelMerger.new\n mm.mergeModels(model, new_model.get, handle_mapping)\n\n runner.registerFinalCondition(\"Final model has #{model.getPlanarSurfaceGroups.size} planar surface groups\")\n\n return true\n\n end", "def create\n @three_result = ThreeResult.new(three_result_params)\n\n respond_to do |format|\n if @three_result.save\n format.html { redirect_to @three_result, notice: 'Three result was successfully created.' }\n format.json { render :show, status: :created, location: @three_result }\n else\n format.html { render :new }\n format.json { render json: @three_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_consequence\n @consequence = Consequence.find(params[:id])\n end", "def process_result\n end", "def perform_create\n resource.save!\n end", "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 execute\n super()\n end", "def reciprocal_type\n :many_to_one\n end", "def initialize # clinic\n # @company = clinic.company\n\n response = create\n end", "def create\n @todo = Todo.new(todo_params)\n\n respond_to do |format|\n if @todo.save\n event = @todo.target_events.build(content: 'created todo', target_field: 'content')\n event.user = current_user\n event.save\n\n if @todo.executor_id\n event = @todo.target_events.build(content: 'assign executor for todo', target_field: 'content', resultable_type: 'User', resultable_id: @todo.executor_id, result_field: 'name')\n event.user = current_user\n event.save\n end\n\n\n format.html { redirect_to @todo, notice: 'Todo was successfully created.' }\n format.json { render :show, status: :created, location: @todo }\n else\n format.html { render :new }\n format.json { render json: @todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def has_one(relation, options = {})\n has :one, relation, options\n end", "def has_one?\n true\n end", "def after_create #:nodoc:\n return if self.slave?\n \n soa = SOA.new( :domain => self )\n SOA_FIELDS.each do |f|\n soa.send( \"#{f}=\", send( f ) )\n end\n soa.serial = serial unless serial.nil? # Optional\n soa.save\n end", "def create\n @project = Project.find(params[:project_id])\n @project_implementation = @project.build_project_implementation(project_implementation_params)\n respond_to do |format|\n if @project_implementation.save!\n format.html { redirect_to new_project_project_evaluation_path(@project), notice: 'Project implementation was successfully created.' }\n format.json { render :show, status: :created, location: @project_implementation }\n else\n format.html { render :new }\n format.json { render json: @project_implementation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @project = Project.where(:key => params[:project_key]).first\n # session[:last_update_active_step]= ProjectStep.where(:project_id => @project.id, :step_id => session[:active_step]).first.updated_at.to_s + \" \" + Job.where(:project_id => @project.id, :step_id => session[:active_step]).sort.map{|j| j.updated_at.to_s}.join(\",\") \n if analyzable?(@project)\n jobs = Job.where(:project_id => @project.id, :step_id => session[:active_step]).all.to_a.sort{|a, b| (a.updated_at.to_s || '0') <=> (b.updated_at.to_s || '0')}\n last_job = jobs.last\n session[:last_update_active_step] = @project.status_id.to_s + \",\"\n session[:last_update_active_step] = [jobs.size, last_job.status_id, last_job.updated_at].join(\",\") if last_job\n \n @gene_enrichment = GeneEnrichment.new(gene_enrichment_params)\n \n @gene_enrichment.project_id = @project.id\n tmp_attrs = params[:attrs]\n to_delete = (tmp_attrs[:geneset_type] == 'global') ? :custom_geneset : :global_geneset\n tmp_attrs.delete(to_delete)\n\n @gene_enrichment.attrs_json = tmp_attrs.to_json\n #de_method = @gene_enrichment.diff_expr\n #list_attrs = JSON.parse(de_method.attrs_json)\n h_attr={'adj' => 'Adjusted p-value', 'p_value' =>'p-value', 'nber_best_hits' => '# of selected hits', 'type_best_hits' => 'Type of best hits', \n 'geneset_type' => 'Geneset type', 'global_geneset' => \"Global geneset\", \"custom_geneset\" => \"Custom geneset\" }\n\n other_params = tmp_attrs.keys.map{|attr| \n tmp_val = tmp_attrs[attr] \n if attr == 'custom_geneset' or attr == 'global_geneset'\n tmp_val = GeneSet.find(tmp_val).label\n end\n \"#{h_attr[attr]}=#{tmp_val}\" if tmp_val != ''}.join(\", \")\n other_params = \"(\" + other_params + \")\" if other_params != ''\n selections = []\n \n @gene_enrichment.label = [\"DE #\" + @gene_enrichment.diff_expr.num.to_s, other_params].join(\" \")\n @existing_gene_enrichment = GeneEnrichment.where(:project_id => @project.id, :label => @gene_enrichment.label).first\n last_gene_enrichment = GeneEnrichment.where(:project_id => @project.id).last\n @gene_enrichment.num = (last_gene_enrichment and last_gene_enrichment.num) ? (last_gene_enrichment.num + 1) : 1\n @gene_enrichment.user_id = (current_user) ? current_user.id : 1\n @project.update_attributes(:status_id => 1, :step_id => 7) if @project.status_id > 2 and !@existing_gene_enrichment\n \n respond_to do |format|\n \n if @existing_gene_enrichment\n @gene_enrichment = @existing_gene_enrichment\n @gene_enrichments= GeneEnrichment.where(:project_id => @project.id).all\n format.html {\n render :partial => 'index'\n }\n elsif @gene_enrichment.save\n job = Basic.create_job(@gene_enrichment, 7, @project, :job_id, 1)\n #@gene_enrichment.update_attributes(:status_id => 1)#, :num => (last_cluster and last_cluster.num) ? (last_cluster.num + 1) : 1) \n session[:last_step_status_id]=2\n # @gene_enrichment.run\n# @gene_enrichment.delay(:queue => 'fast').run\n delayed_job = Delayed::Job.enqueue GeneEnrichment::NewGeneEnrichment.new(@gene_enrichment), :queue => 'fast'\n job.update_attributes(:delayed_job_id => delayed_job.id) #job.id) \n @gene_enrichments=GeneEnrichment.where(:project_id => @project.id).all\n \n format.html {\n render :partial => 'index'\n }\n else\n \n format.html { render :new }\n format.json { render json: @gene_enrichment.errors, status: :unprocessable_entity }\n end\n end\n else\n render :nothing => true\n end\n end", "def test_following_belongs_to_when_nil_gives_nil\n Project.create()\n\n project = Project.find_version(1, 1)\n assert_nil project.main_use_case\n end", "def after_save(record)\n \n end", "def create_common_part(stepcode)\n @trantax = FutureTransaction.new\n fiolength = @employee.fio + \" salary to pay\"\n @chartslim = Chart.where(\"users_id = ? and content = ?\", current_user.id,fiolength)\n @trantax.users_id = current_user.id\n @trantax.code = @chartslim.first.code + stepcode\n @trantax.chart_clones_id = @trantax.code/10000\n @trantax.date = DateTime.now\n @trantax.gsttype = 0\n @trantax.gst_include = 0\n @trantax.co = 2\n @trantax.gstamount = 0\n @trantax.for_moving = 0\n end", "def create\n @challenge = Challenge.new(challenge_params)\n @challenge.owner_id = current_user.id\n @challenge.participant_number = 0\n @challenge.failed_number = 0\n Activity.create(user_id: current_user.id, challenge_id: @challenge.id, relation:\"Created\")\n if @challenge.image.attached?\n @challenge.pic_link = @challenge.image.service_url\n end\n respond_to do |format|\n if @challenge.save\n format.html { redirect_to @challenge, notice: 'Challenge was successfully created.' }\n format.json { render :show, status: :created, location: @challenge }\n else\n format.html { render :new }\n format.json { render json: @challenge.errors, status: :unprocessable_entity }\n end\n end\n end", "def callback\n save({'result' => @datastore['result']})\n end", "def callback\n save({'result' => @datastore['result']})\n end", "def perform!\n super\n\n pipeline = Pipeline.new\n\n pipeline << mysql\n\n pipeline.run\n if pipeline.success?\n log!(:finished)\n else\n raise Error, \"Execution Failed!\\n\" + pipeline.error_messages\n end\n end", "def post_process\n end" ]
[ "0.5544524", "0.53742033", "0.5256601", "0.51525205", "0.50925136", "0.5025746", "0.5025746", "0.50197214", "0.50197214", "0.50178915", "0.5017191", "0.4990979", "0.49557236", "0.49461472", "0.48944542", "0.4881921", "0.48762062", "0.4873938", "0.4871976", "0.48446843", "0.48065755", "0.47919977", "0.47861835", "0.47781625", "0.47762746", "0.47762746", "0.47496498", "0.474784", "0.4738887", "0.47265315", "0.47070345", "0.47070345", "0.47047344", "0.46997887", "0.46995994", "0.4699493", "0.46897197", "0.4669457", "0.46613935", "0.4660775", "0.4656623", "0.4654109", "0.4638045", "0.46376094", "0.46374574", "0.46360314", "0.4631003", "0.46309558", "0.46261498", "0.46258318", "0.46229288", "0.4622112", "0.46057698", "0.4599297", "0.45940402", "0.45851707", "0.45834288", "0.45800817", "0.457773", "0.45770088", "0.45645204", "0.4562693", "0.45600483", "0.4556416", "0.45524666", "0.4546627", "0.4546293", "0.45443293", "0.45438763", "0.45373675", "0.45366073", "0.4534243", "0.45280343", "0.45255327", "0.45255327", "0.4524373", "0.4524373", "0.45215154", "0.4517465", "0.45155486", "0.45142797", "0.4513166", "0.45107037", "0.45090634", "0.45044383", "0.45031092", "0.4494716", "0.44937935", "0.44907588", "0.44905093", "0.44879022", "0.4482224", "0.44805223", "0.4479421", "0.44777173", "0.44774523", "0.4476726", "0.44744235", "0.44744235", "0.44724628", "0.44693992" ]
0.0
-1
get every test to pass before coding runner below
def runner welcome() currentsum = initial_round() currentsum = hit?(currentsum) while currentsum < 22 currentsum = hit?(currentsum) end end_game(currentsum) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_tests\n puts \"Running exactly #{@spec.size} tests.\"\n @spec.each do |test_case|\n sleep test_case.wait_before_request\n response = send_request_for(test_case)\n Checker.available_plugins.each do |plugin|\n result = @expectation.check(plugin, response, test_case)\n if not result.success?\n putc \"F\"\n @results << result\n break\n else\n if plugin == Checker.available_plugins.last\n @results << result\n putc \".\"\n end\n end\n end\n end\n end", "def test_all\n @results['test_start'] = Time.now()\n passed = []\n boot_vm() if @options[:vmm_enabled]\n prep\n freeze_vm() if @options[:vmm_enabled]\n @log.info \"RUNNING NO-SERVICE TEST\"\n passed << one_test(@config['init_scenario'])\n # Stop testing if our initial test fails.\n unless passed.first == true\n @log.error \"Initial setup failed.. sleeping 60 seconds for debugging.\"\n sleep 60\n stop_vm() if @options[:vmm_enabled]\n return passed\n end\n freeze_vm() if @options[:vmm_enabled]\n @log.info \"RUNNING TESTS\"\n scenarios = get_scenarios\n test_counter = 0\n scenarios.each do |scenario|\n test_counter += 1\n @log.info \"Running test for #{scenario} - #{test_counter} of #{scenarios.size}\"\n passed << one_test(scenario)\n end\n stop_vm() if @config[:vmm_enabled]\n all_passed = passed.select{|p| p == false}.size == 0\n @log.info \"Number of tests run : #{passed.size}\"\n @log.info \"Result of ALL tests: Passed? #{all_passed}\"\n @results['test_stop'] = Time.now()\n @results['elapsed_time'] = @results['test_stop'] - @results['test_start']\n return all_passed\n end", "def test_cases; end", "def passed_tests\n self.tests.select do |test|\n test.status == 'passed'\n end\n end", "def final_test\n return unless MiniApivore.all_test_ran?\n\n @errors = MiniApivore.prepare_untested_errors\n assert(@errors.empty?, @errors.join(\"\\n\"))\n\n # preventing duplicate execution\n MiniApivore.runnable_list << \"#{self.class}::#{__method__}_runned\"\n end", "def run_tests\n tests_passed = true\n %w(desktop mobile kc_dm).each do |profile|\n tests_passed &= execute_test(profile)\n end\n tests_passed\n end", "def running_test_case; end", "def all_tests_pass\n cucumber_guard = ::Guard.guards({ :name => 'cucumber', :group => 'puppet_tests'}).first\n cucumber_passed = cucumber_guard.instance_variable_get(\"@failed_paths\").empty?\n rspec_guard = ::Guard.guards({ :name => 'rspec', :group => 'puppet_tests'}).first\n rspec_passed = rspec_guard.instance_variable_get(\"@failed_paths\").empty?\n return rspec_passed && cucumber_passed\nend", "def my_tests\n end", "def tests; end", "def tests; end", "def passed_checks\n all_checks_which_pass\n end", "def passes\n count - failures - errors - skips\n end", "def report\n\t\t\tputs \"Tests: #{@ok} ok, #{@fail} failures.\"\n\t\t\tif (@fail > 0)\n\t\t\t\tputs \"*** THERE WERE FAILURES *** \"\n\t\t\telse \n\t\t\t\tputs \"*** ALL TESTS PASSED ***\"\n\t\t\tend\n\t\tend", "def all_external_test_runs_passed?(test_types = nil)\n external_tests_blocking(test_types).empty?\n end", "def doTests( *tests )\n tests.find_all {|name,data|\n ! doTest(name)\n }\nend", "def go_run_tests\n @status = :running\n Thread.new do\n begin\n test_cases = @test_suite.sources\n\n @mutex.synchronize do\n @test_cases = test_cases\n @test_results = {}\n end\n\n @test_suite.run_tests do |result|\n @mutex.synchronize do\n @test_results[result[:source]] = result[:result]\n end\n end\n\n rescue => e\n puts e\n print e.bracktrace.join(\"\\n\")\n ensure\n @status = :ran\n end\n\n end\n end", "def run\n @testcases.each do |test|\n print \"[ RUN... ] \".green + \" #{name} #{test.name}\\r\"\n\n if test.run\n puts \"[ OK ] \".green + \" #{name} #{test.name}\"\n else\n puts \"[ FAIL ] \".red + \" #{name} #{test.name}\"\n puts\n puts \"Command that failed:\"\n test.explain\n return false\n end\n end\n\n true\n end", "def test_steps; end", "def test_steps; end", "def uninit_ok_tests\n if (!@num_tests_run.nil? && !@num_tests_failed.nil?)\n @num_tests_ok += @num_tests_run - @num_tests_failed\n end\n end", "def before_test(test); end", "def before_test(test); end", "def generate_alltest\n\n end", "def running_test_step; end", "def _test_pages_available\n #execute this code x number of times\n @custom_number_of_users.times do |i|\n puts 'Running tests for user #'+i.to_s\n # assert_section nil\n end\n end", "def testing_begin(files)\n end", "def unitTests\n\t\ttotalTests = 12\n\t\ttotalFailed = 0\n\t\toutput = \"\"\n\t\t@debug = true\n\n\t\t#CLEAR DB BEFORE RUNNING TEST. DEFINITELY CRUDE BUT THE ONLY THING I COULD GET WORKING\n\t\tself.TESTAPI_resetFixture\n\n\t\t#Test1: \"Does not allow a non-registered user login\"\n\t\tresponse = self.login(\"NonUser\",\"pass0\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test1\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test2: \"Allows a user that supplies no password get added\"\n\t\tresponse = self.add(\"user2\",\"\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test2\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test3: \"Allows a user with a username and password get added\"\n\t\tresponse = self.add(\"user3\",\"pass3\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test3\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test4: \"Doesn't allow an already added user get added again\"\n\t\tresponse = self.add(\"user3\",\"pass3\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -2\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test4\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test5: \"Doesn't allow a blank username get added\"\n\t\tresponse = self.add(\"\",\"pass5\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -3\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test5\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test6: \"It allows a username and password of 128 characters to get added\"\n\t\tresponse = self.add(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test6\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test7: \"Does not allow a username greater than 128 characters\"\n\t\tresponse = self.add(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"pass7\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -3\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test7\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test8: \"Does not allow a password greater than 128 characters\"\n\t\tresponse = self.add(\"user8\",\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -4\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test8\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test9: \"Allows a registered user with a password to login and counts number of logins\"\n\t\tresponse = self.login(\"user3\", \"pass3\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 2\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test9\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test10: \"Allows a registered user without a password to login and counts number of logins\"\n\t\tresponse = self.login(\"user2\", \"\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 2\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test10\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test11: \"Doesn't allow a user with wrong password to login\"\n\t\tresponse = self.login(\"user3\", \"pass2\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test11\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test12: \"Sucessfully Deletes the DB with call to TESTAPI_reset_fixture\"\n\t\tresponse = self.TESTAPI_resetFixture\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test12\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t@debug = false\n\t\trender json: {:totalTests => totalTests, :nrFailed => totalFailed, :output => output}\n\t\t\n\tend", "def run\n test_using_random_sample\n test_using_first_of\n end", "def done\n puts 'Done running tests'\n end", "def all_failing\n all(\"#qunit-tests .fail\")\n end", "def passing_tests\n return self.product_tests.includes(:test_executions).select do |test|\n test.execution_state == :passed\n end\n end", "def run_all\n passed = Runner.run(['spec'], cli)\n if passed\n Formatter.notify \"How cool, all works!\", :image => :success\n else\n Formatter.notify \"Failing... not there yet.\", :image => :failed\n end\n end", "def run_tests_under(config, options, root)\n summary = {}\n test_list(File.join($work_dir,root)).each do |path|\n name = path.sub(\"#{$work_dir}/\", '')\n puts \"\", \"\", \"#{name} executing...\"\n result = TestWrapper.new(config,options,path).run_test\n puts \"#{name} returned: #{result.fail_flag}\"\n summary[name] = result.fail_flag\n end\n return summary\nend", "def init_tests\n unless @init_tests\n @test_duration = 0\n @num_tests_run = 0\n @num_tests_failed = 0\n @num_tests_ok = 0\n @num_tests_skipped = 0\n @init_tests = true\n end\n end", "def before_test_case(*args)\n @test_steps =[]\n @scenario_tags = []\n @failed_step = {}\n end", "def test_step; end", "def scenarios\n @runner.done_scenarios\n end", "def define_tests\n @ours.each do |pkg|\n their = @theirs.find { |x| x.name == pkg.name }\n class_eval do\n define_method(\"test_#{pkg.name}_#{pkg.version}\") do\n PackageVersionCheck.new(ours: pkg, theirs: their).run\n end\n end\n end\n end", "def external_test_runs_passed_for?(test_type)\n test_types = ExternalTestType.get(test_type).with_related_types\n current_runs = current_external_test_runs_for(test_types)\n current_runs.any? && current_runs.all?(&:passed_ok?)\n end", "def test_passed(array)\n last_item = array.length - 1\n test_name = array[last_item - 1]\n test_suite_verify(array[@class_name])\n printf \"%-40s PASS\\n\", test_name\n\n return unless @xml_out\n\n @array_list.push ' <testcase classname=\"' + @test_suite + '\" name=\"' + test_name + '\"/>'\n end", "def execute_all &decision\n @result = nil\n @exception = nil\n\n @test_lines.each do |line|\n break if execute_line line, &decision\n end\n unless @exception\n #puts \"=> \" + @result.inspect\n end\n end", "def call(*tests, env:)\n summary = execute_all(tests, env)\n List.new(\n List.new(Symbol.new(\"success\"), List.new(*summary[:success])),\n List.new(Symbol.new(\"failures\"), List.new(*summary[:failures]))\n )\n end", "def run_test(tests, ints_to_test, current_test_name)\n require \"./primality_tests/\" + current_test_name + \".rb\"\n tests[current_test_name.to_sym][:result] = []\n ints_to_test.each {|int|\n tests[current_test_name.to_sym][:result] << send(current_test_name, int)\n }\nend", "def failures; end", "def failures; end", "def failures; end", "def process(files) #called at end of script\n if files.class==Array \n files.each {|f| \n puts \"\\n\\n--------------------\\n#{f}:\\n\\n\"\n result=system(\"#{$PROGRAM_NAME} #{f} #{ARGV}\")\n puts \"\\n\\nERRORS IN TEST #{f}!!!\\n\\n\" unless result\n }\n else\n test_name=File.basename(files).sub(/\\..*?$/,'')\n test_case=Class.new(Test::Unit::TestCase)\n Object.const_set(:\"Test#{test_name.capitalize}\", test_case)\n mk_test_context(files, test_case)\n end\nend", "def run\n\t\t @stats.tests += 1\n\t\t\tputs \"Testi: #{@name}\"\n\t\t\tctx = Context.new\n\t\t\tbegin\n\t\t\t\tctx.instance_eval(&@block)\n\t\t\trescue TestAbort # we don't really care if it aborts.\n\t\t\trescue Exception => ex\n\t\t\t\tctx.fail\n\t\t\t\[email protected] += 1\n\t\t\t\tputs ex.inspect\n\t\t\t\tputs ex.backtrace.join(\"\\n\")\n\t\t\tend\n\t\t\tif ctx.failed?\n\t\t\t\tputs \" # FAIL!!! ############\"\n\t\t\t\[email protected] += 1\n\t\t\telsif ctx.skipped?\n\t\t\t\tputs \" = skipped ============\"\n\t\t\t\[email protected] += 1\n\t\t\telse\n\t\t\t\tputs \" - ok.\"\n\t\t\t\[email protected] += 1\n\t\t\tend\n\t\t\tputs\n\t\tend", "def test_case; end", "def print_results\n if [email protected]?\n @failures.each do |test|\n pout \"\\nFailed: #{test[:desc]}\"\n puts test[:result]\n # print a newline for easier reading\n puts \"\"\n end\n abort\n else\n puts \"All passed!\".green\n end\nend", "def test_contains_13_eachsuit\n assert true == false\n end", "def test_runnable_methods_random\n @assertion_count = 0\n\n random_tests_1 = sample_test_case 42\n random_tests_2 = sample_test_case 42\n random_tests_3 = sample_test_case 1_000\n\n assert_equal random_tests_1, random_tests_2\n refute_equal random_tests_1, random_tests_3\n end", "def compare_tests(test_a, test_b); end", "def compare_tests(test_a, test_b); end", "def test_setup\r\n \r\n end", "def test_truth\n end", "def start_tests(files)\n end", "def run(selected_tests)\n # Test names (ordered) to be performed in game, per tests suite\n # Hash< Symbol, Array<String> >\n in_game_tests = {}\n selected_tests.each do |tests_suite, suite_selected_tests|\n if @tests_suites[tests_suite].respond_to?(:run_test)\n # Simple synchronous tests\n suite_selected_tests.each do |test_name|\n # Store statuses after each test just in case of crash\n set_statuses_for(tests_suite, [[test_name, @tests_suites[tests_suite].run_test(test_name)]])\n end\n end\n # We run the tests from the game itself.\n in_game_tests[tests_suite] = suite_selected_tests if @tests_suites[tests_suite].respond_to?(:in_game_tests_for)\n end\n return if in_game_tests.empty?\n\n # Keep track of the mapping between tests suites and in-game tests, per in-game tests suite.\n # Associated info is:\n # * *tests_suite* (Symbol): The tests suite that has subscribed to the statuses of some in-game tests of the in-game tests suite.\n # * *in_game_tests* (Array<String>): List of in-game tests that the tests suite is interested in.\n # * *selected_tests* (Array<String>): List of selected tests for which in-game tests are useful.\n # Hash< Symbol, Array< Hash< Symbol, Object > > >\n in_game_tests_subscriptions = {}\n # List of all in-game tests to perform, per in-game tests suite\n # Hash< Symbol, Array< String > >\n merged_in_game_tests = {}\n # Get the list of in-game tests we have to run and that we will monitor\n in_game_tests.each do |tests_suite, suite_selected_tests|\n in_game_tests_to_subscribe = @tests_suites[tests_suite].in_game_tests_for(suite_selected_tests)\n in_game_tests_to_subscribe.each do |in_game_tests_suite, selected_in_game_tests|\n selected_in_game_tests_downcase = selected_in_game_tests.map(&:downcase)\n in_game_tests_subscriptions[in_game_tests_suite] = [] unless in_game_tests_subscriptions.key?(in_game_tests_suite)\n in_game_tests_subscriptions[in_game_tests_suite] << {\n tests_suite: tests_suite,\n in_game_tests: selected_in_game_tests_downcase,\n selected_tests: suite_selected_tests\n }\n merged_in_game_tests[in_game_tests_suite] = [] unless merged_in_game_tests.key?(in_game_tests_suite)\n merged_in_game_tests[in_game_tests_suite] = (merged_in_game_tests[in_game_tests_suite] + selected_in_game_tests_downcase).uniq\n end\n end\n in_game_tests_runner = InGameTestsRunner.new(@config, @game)\n in_game_tests_runner.run(merged_in_game_tests) do |in_game_tests_suite, in_game_tests_statuses|\n # This is a callback called for each in-game test status change.\n # Update the tests results based on what has been run in-game.\n # Find all tests suites that are subscribed to those in-game tests.\n # Be careful that updates can be given for in-game tests suites we were not expecting\n if in_game_tests_subscriptions.key?(in_game_tests_suite)\n in_game_tests_subscriptions[in_game_tests_suite].each do |tests_suite_subscription|\n selected_in_game_tests_statuses = in_game_tests_statuses.slice(*tests_suite_subscription[:in_game_tests])\n next if selected_in_game_tests_statuses.empty?\n\n tests_suite = @tests_suites[tests_suite_subscription[:tests_suite]]\n tests_suite.statuses = tests_suite.\n parse_auto_tests_statuses_for(tests_suite_subscription[:selected_tests], { in_game_tests_suite => selected_in_game_tests_statuses }).\n select { |(test_name, _test_status)| tests_suite_subscription[:selected_tests].include?(test_name) }\n end\n end\n end\n end", "def define_tests\n Apt.update if Process.uid.zero? # update if root\n @lister.packages.each do |pkg|\n class_eval do\n define_method(\"test_#{pkg.name}_#{pkg.version}\") do\n PackageVersionCheck.new(pkg).run\n end\n end\n end\n end", "def test_contains_four_eachface\n assert true == false\n end", "def check test, block\n res = []\n begin\n block.call\n rescue ApiPi::AssertionError => e\n res << e.message\n end\n failed = !res.empty?\n failed ? @failure_count += 1 : @success_count += 1\n puts \"\\tERROR: #{res.first}\\n\" if failed\n end", "def runTest(browser)\n puts \"Step 2: At step description here\"\n #Do shit here\n #....\n puts \"Step 3: ....\"\n #Do more shit here\n #....\n\n puts \"Expected Result:\"\n puts \"Result that we expect to happen.\"\n\n if true #Test passed condition here\n self.passed = true\n puts \"TEST PASSED. Add some description/details here\"\n else #Test failed condition here\n self.passed = false\n puts \"TEST FAILED. Show what we have screwed up\"\n end\n end", "def testcase_processed\n\t\n\t\tcontinue = true\n\n\t\tthread = ::Thread.new do\n\t\t\n\t\t\tkill_browser\n\n\t\t\tcase @current_pass\n\t\t\t\twhen 1\n\t\t\t\t\t# Initial verification\n\t\t\t\t\[email protected]\n\t\t\t\twhen 2\n\t\t\t\t\t# Reducing elements\n\t\t\t\t\[email protected]\n\t\t\t\twhen 3\n\t\t\t\t\t# Reducing idx's\n\t\t\t\t\[email protected]\n\t\t\t\twhen 4\n\t\t\t\t\t# Final verification\n\t\t\t\t\t# booo, pass 4 has failed!?!.\n\t\t\t\t\tcontinue = false\n\t\t\t\telse\n\t\t\t\t\tcontinue = false\n\t\t\tend\n\n\t\t\t# while we still have testcases to generate...\n\t\t\tif( continue )\n\t\t\t\t# we go again an try the next testcase in a new browser instance\n\t\t\t\tspawn_browser\n\t\t\telse\n\t\t\t\t@reduction_server.stop\n\t\t\t\t::Thread.current.kill\n\t\t\tend\n\t\tend\n\t\t\n\t\tthread.join\n\t\t\n\t\treturn continue\n\tend", "def passes; end", "def passes; end", "def rspec_test(nodes)\n node_manager.assert_known(nodes)\n for node in nodes\n node_manager.find(node).rspec_test\n end\n end", "def test_checklist_status_values_not_started\n test = @product.product_tests.checklist_tests.first\n passing, failing, not_started, total = checklist_status_values(test)\n\n assert_equal 0, passing\n assert_equal 0, failing\n assert_equal 1, not_started\n assert_equal 1, total\n end", "def test\n\n puts \"Performing test tasks:\"\n\n puts \"Test 1 \" + (generate_intcode([1, 0, 0, 0, 99]) === [2, 0, 0, 0, 99] ? \"succeeded\": \"failed\") + \"!\"\n puts \"Test 2 \" + (generate_intcode([2, 3, 0, 3, 99]) === [2, 3, 0, 6, 99] ? \"succeeded\": \"failed\") + \"!\"\n puts \"Test 3 \" + (generate_intcode([2, 4, 4, 5, 99, 0]) === [2, 4, 4, 5, 99, 9801] ? \"succeeded\": \"failed\") + \"!\"\n puts \"Test 4 \" + (generate_intcode([1, 1, 1, 4, 99, 5, 6, 0, 99]) === [30, 1, 1, 4, 2, 5, 6, 0, 99] ? \"succeeded\": \"failed\") + \"!\"\n\nend", "def run_all\n run_suite(@suite)\n end", "def completed_tests()\n test_array = []\n self.problems.each do |problem|\n problem.tests.each do |test|\n test_array.push(test)\n end\n end\n test_array\n end", "def run\n test_files.each do |file|\n eval File.read(file)\n end\n\n results = []\n @tests.each_pair do |name, test|\n results << test.call(@config)\n end\n results.reject!(&:nil?)\n results.reject!(&:empty?)\n results.flatten!\n results\n end", "def check_all_here\n end", "def final_test_methods\n return []\n end", "def run_all\n @last_run_states = @persistence ? @persistence.read('final_states', {}) : {}\n @skipped = {}\n run_suite(@suite)\n @persistence.store('final_states', @last_run_states) if @persistence\n end", "def run(selected_tests)\n unknown_tests_suites = selected_tests.keys - @available_tests_suites\n log \"[ In-game testing #{@game.name} ] - !!! The following in-game tests suites are not supported: #{unknown_tests_suites.join(', ')}\" unless unknown_tests_suites.empty?\n tests_to_run = selected_tests.reject { |tests_suite, _tests| unknown_tests_suites.include?(tests_suite) }\n return if tests_to_run.empty?\n\n FileUtils.mkdir_p \"#{@game.path}/Data/SKSE/Plugins/StorageUtilData\"\n tests_to_run.each do |tests_suite, tests|\n # Write the JSON file that contains the list of tests to run\n File.write(\n \"#{@game.path}/Data/SKSE/Plugins/StorageUtilData/AutoTest_#{tests_suite}_Run.json\",\n JSON.pretty_generate(\n 'stringList' => {\n 'tests_to_run' => tests\n }\n )\n )\n # Clear the AutoTest test statuses that we are going to run\n statuses_file = \"#{@game.path}/Data/SKSE/Plugins/StorageUtilData/AutoTest_#{tests_suite}_Statuses.json\"\n next unless File.exist?(statuses_file)\n\n File.write(\n statuses_file,\n JSON.pretty_generate('string' => JSON.parse(File.read(statuses_file))['string'].delete_if { |test_name, _test_status| tests.include?(test_name) })\n )\n end\n auto_test_config_file = \"#{@game.path}/Data/SKSE/Plugins/StorageUtilData/AutoTest_Config.json\"\n # Write the JSON file that contains the configuration of the AutoTest tests runner\n File.write(\n auto_test_config_file,\n JSON.pretty_generate(\n 'string' => {\n 'on_start' => 'run',\n 'on_stop' => 'exit'\n }\n )\n )\n out ''\n out '=========================================='\n out '= In-game tests are about to be launched ='\n out '=========================================='\n out ''\n out 'Here is what you need to do once the game will be launched (don\\'t launch it by yourself, the test framework will launch it for you):'\n out '* Load the game save you want to test (or start a new game).'\n out ''\n out 'This will execute all in-game tests automatically.'\n out ''\n out 'It is possible that the game crashes during tests:'\n out '* That\\'s a normal situation, as tests don\\'t mimick a realistic gaming experience, and the Bethesda engine is not meant to be stressed like that.'\n out '* In case of game crash (CTD), the Modsvaskr test framework will relaunch it automatically and resume testing from when it crashed.'\n out '* In case of repeated CTD on the same test, the Modsvaskr test framework will detect it and skip the crashing test automatically.'\n out '* In case of a game freeze without CTD, the Modsvaskr test framework will detect it after a few minutes and automatically kill the game before re-launching it to resume testing.'\n out ''\n out 'If you want to interrupt in-game testing: invoke the console with ~ key and type stop_tests followed by Enter.'\n out ''\n out 'Press enter to start in-game testing (this will lauch your game automatically)...'\n wait_for_user_enter\n last_time_tests_changed = nil\n with_auto_test_monitoring(\n on_auto_test_statuses_diffs: proc do |in_game_tests_suite, in_game_tests_statuses|\n yield in_game_tests_suite, in_game_tests_statuses\n last_time_tests_changed = Time.now\n end\n ) do\n # Loop on (re-)launching the game when we still have tests to perform\n idx_launch = 0\n loop do\n # Check which test is supposed to run first, as it will help in knowing if it fails or not.\n first_tests_suite_to_run = nil\n first_test_to_run = nil\n current_tests_statuses = check_auto_test_statuses\n @available_tests_suites.each do |tests_suite|\n next unless tests_to_run.key?(tests_suite)\n\n found_test_ok =\n if current_tests_statuses.key?(tests_suite)\n # Find the first test that would be run (meaning the first one having no status, or status 'started')\n tests_to_run[tests_suite].find do |test_name|\n found_test_name, found_test_status = current_tests_statuses[tests_suite].find { |(current_test_name, _current_test_status)| current_test_name == test_name }\n found_test_name.nil? || found_test_status == 'started'\n end\n else\n # For sure the first test of this suite will be the first one to run\n tests_to_run[tests_suite].first\n end\n next unless found_test_ok\n\n first_tests_suite_to_run = tests_suite\n first_test_to_run = found_test_ok\n break\n end\n if first_tests_suite_to_run.nil?\n log \"[ In-game testing #{@game.name} ] - No more test to be run.\"\n break\n else\n log \"[ In-game testing #{@game.name} ] - First test to run should be #{first_tests_suite_to_run} / #{first_test_to_run}.\"\n # Launch the game to execute AutoTest\n @game.launch(autoload: idx_launch.zero? ? false : 'auto_test')\n idx_launch += 1\n log \"[ In-game testing #{@game.name} ] - Start monitoring in-game testing...\"\n last_time_tests_changed = Time.now\n while @game.running?\n check_auto_test_statuses\n # If the tests haven't changed for too long, consider the game has frozen, but not crashed. So kill it.\n if Time.now - last_time_tests_changed > @game.timeout_frozen_tests_secs\n log \"[ In-game testing #{@game.name} ] - Last time in-game tests statuses have changed is #{last_time_tests_changed.strftime('%F %T')}. Consider the game is frozen, so kill it.\"\n @game.kill\n else\n sleep @game.tests_poll_secs\n end\n end\n last_test_statuses = check_auto_test_statuses\n # Log latest statuses\n log \"[ In-game testing #{@game.name} ] - End monitoring in-game testing. In-game test statuses after game run:\"\n last_test_statuses.each do |tests_suite, statuses_for_type|\n log \"[ In-game testing #{@game.name} ] - [ #{tests_suite} ] - #{statuses_for_type.select { |(_name, status)| status == 'ok' }.size} / #{statuses_for_type.size}\"\n end\n # Check for which reason the game has stopped, and eventually end the testing session.\n # Careful as this JSON file can be written by Papyrus that treat strings as case insensitive.\n # cf. https://github.com/xanderdunn/skaar/wiki/Common-Tasks\n auto_test_config = JSON.parse(File.read(auto_test_config_file))['string'].map { |key, value| [key.downcase, value.downcase] }.to_h\n if auto_test_config['stopped_by'] == 'user'\n log \"[ In-game testing #{@game.name} ] - Tests have been stopped by user.\"\n break\n end\n if auto_test_config['tests_execution'] == 'end'\n log \"[ In-game testing #{@game.name} ] - Tests have finished running.\"\n break\n end\n # From here we know that the game has either crashed or has been killed.\n # This is an abnormal termination of the game.\n # We have to know if this is due to a specific test that fails deterministically, or if it is the engine being unstable.\n # Check the status of the first test that should have been run to know about it.\n first_test_status = nil\n _found_test_name, first_test_status = last_test_statuses[first_tests_suite_to_run].find { |(current_test_name, _current_test_status)| current_test_name == first_test_to_run } if last_test_statuses.key?(first_tests_suite_to_run)\n if first_test_status == 'ok'\n # It's not necessarily deterministic.\n # We just have to go on executing next tests.\n log \"[ In-game testing #{@game.name} ] - Tests session has finished in error, certainly due to the game's normal instability. Will resume testing.\"\n else\n # The first test doesn't pass.\n # We need to mark it as failed, then remove it from the runs.\n log \"[ In-game testing #{@game.name} ] - First test #{first_tests_suite_to_run} / #{first_test_to_run} is in error status: #{first_test_status}. Consider it failed and skip it for next run.\"\n # If the test was started but failed before setting its status to something else then change the test status in the JSON file directly so that AutoTest does not try to re-run it.\n if first_test_status == 'started' || first_test_status == '' || first_test_status.nil?\n File.write(\n \"#{@game.path}/Data/SKSE/Plugins/StorageUtilData/AutoTest_#{first_tests_suite_to_run}_Statuses.json\",\n JSON.pretty_generate(\n 'string' => ((last_test_statuses[first_tests_suite_to_run] || []) + [[first_test_to_run, '']]).map do |(test_name, test_status)|\n [\n test_name,\n test_name == first_test_to_run ? 'failed_ctd' : test_status\n ]\n end.to_h\n )\n )\n # Notify the callbacks updating test statuses\n check_auto_test_statuses\n end\n end\n # We will start again. Leave some time to interrupt if we want.\n if @config.no_prompt\n out 'Start again automatically as no_prompt has been set.'\n else\n # First, flush stdin of any pending character\n $stdin.getc until select([$stdin], nil, nil, 2).nil?\n out \"We are going to start again in #{@game.timeout_interrupt_tests_secs} seconds. Press Enter now to interrupt it.\"\n key_pressed =\n begin\n Timeout.timeout(@game.timeout_interrupt_tests_secs) { $stdin.gets }\n rescue Timeout::Error\n nil\n end\n if key_pressed\n log \"[ In-game testing #{@game.name} ] - Run interrupted by user.\"\n # TODO: Remove AutoTest start on load: it has been interrupted by the user, so we should not keep it in case the user launches the game by itself.\n break\n end\n end\n end\n end\n end\n end", "def querytests(binaries)\n # There are no test cases -- inconclusive.\n return 0 if binaries.empty?\n\n # If there are test cases, and _at least_ one of them managed to\n # _pass_, we assume the function is implemented.\n binaries.each { |b|\n f = File.new(\"#{b[0]}/log.passed\", 'r')\n while (line = f.gets)\n return 1 if line.include? b[1]\n end\n f.close\n }\n\n # Require at least 2 failing test cases.\n # XXX: Increase this to eliminate false positive results.\n return 0 if binaries.size < 2\n\n # The function is not implemented.\n return -1\nend", "def testloop\n \n end", "def test test_cases, f\n test_cases.each do |s, l, e|\n a = send(f, s, l)\n print \"#{f} #{s}, #{l} = #{a} ... \"\n if a == e\n puts 'PASS'\n else\n puts 'FAIL'\n end\n end\nend", "def integration_test()\n return [\"all\"]\n end", "def save_tests\n filtered_builds.each do |build|\n tests = test_failures(build['build_num'])\n tests.each do |test|\n save_test(test, build['build_num'])\n end\n end\n end", "def failed_checks\n all_checks_which_pass(false)\n end", "def run_test\n # Add your code here...\n end", "def run_test\n # Add your code here...\n end", "def spec_tests(&block)\n require 'onceover/testconfig'\n\n # Load up all of the tests and deduplicate them\n testconfig = Onceover::TestConfig.new(@onceover_yaml, @opts)\n testconfig.spec_tests.each { |tst| testconfig.verify_spec_test(self, tst) }\n tests = testconfig.run_filters(Onceover::Test.deduplicate(testconfig.spec_tests))\n\n # Loop over each test, executing the user's block on each\n tests.each do |tst|\n block.call(tst.classes[0].name, tst.nodes[0].name, tst.nodes[0].fact_set, tst.nodes[0].trusted_set, tst.nodes[0].trusted_external_set, testconfig.pre_condition)\n end\n end", "def after_test(_test); end", "def after_test(_test); end", "def after_test(_test); end", "def testing\n # ...\n end", "def passed?\n return @test_passed\n end", "def run\n checks.each(&:run)\n end", "def count_tests\n Dir.entries(@path.to_s + \"sandbox\").each do |currFile|\n isFile = currFile.to_s =~ /\\.java$|\\.py$|\\.c$|\\.cpp$|\\.js$|\\.php$|\\.rb$|\\.hs$|\\.clj$|\\.go$|\\.scala$|\\.coffee$|\\.cs$|\\.groovy$\\.erl$/i\n\n unless isFile.nil?\n file = @path.to_s + \"sandbox/\" + currFile.to_s\n begin\n case @language.to_s\n when \"Java-1.8_JUnit\"\n if File.open(file).read.scan(/junit/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Java-1.8_Mockito\"\n if File.open(file).read.scan(/org\\.mockito/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Java-1.8_Powermockito\"\n if File.open(file).read.scan(/org\\.powermock/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Java-1.8_Approval\"\n if File.open(file).read.scan(/org\\.approvaltests/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Python-unittest\"\n if File.open(file).read.scan(/unittest/).count > 0\n @totaltests += File.open(file).read.scan(/def /).count\n end\n when \"Python-pytest\"\n if file.include?\"test\"\n @totaltests += File.open(file).read.scan(/def /).count\n end\n when \"Ruby-TestUnit\"\n if File.open(file).read.scan(/test\\/unit/).count > 0\n @totaltests += File.open(file).read.scan(/def /).count\n end\n when \"Ruby-Rspec\"\n if File.open(file).read.scan(/describe/).count > 0\n @totaltests += File.open(file).read.scan(/it /).count\n end\n when \"C++-assert\"\n if File.open(file).read.scan(/cassert/).count > 0\n @totaltests += File.open(file).read.scan(/static void /).count\n end\n when \"C++-GoogleTest\"\n if File.open(file).read.scan(/gtest\\.h/).count > 0\n @totaltests += File.open(file).read.scan(/TEST\\(/).count\n end\n when \"C++-CppUTest\"\n if File.open(file).read.scan(/CppUTest/).count > 0\n @totaltests += File.open(file).read.scan(/TEST\\(/).count\n end\n when \"C++-Catch\"\n if File.open(file).read.scan(/catch\\.hpp/).count > 0\n @totaltests += File.open(file).read.scan(/TEST_CASE\\(/).count\n end\n when \"C-assert\"\n if File.open(file).read.scan(/assert\\.h/).count > 0\n @totaltests += File.open(file).read.scan(/static void /).count\n end\n when \"Go-testing\"\n if File.open(file).read.scan(/testing/).count > 0\n @totaltests += File.open(file).read.scan(/func /).count\n end\n when \"Javascript-assert\"\n if File.open(file).read.scan(/assert/).count > 0\n @totaltests += File.open(file).read.scan(/assert/).count - 2 #2 extra because of library include line\n end\n when \"C#-NUnit\"\n if File.open(file).read.scan(/NUnit\\.Framework/).count > 0\n @totaltests += File.open(file).read.scan(/\\[Test\\]/).count\n end\n when \"PHP-PHPUnit\"\n if File.open(file).read.scan(/PHPUnit_Framework_TestCase/).count > 0\n @totaltests += File.open(file).read.scan(/function /).count\n end\n when \"Perl-TestSimple\"\n if File.open(file).read.scan(/use Test/).count > 0\n @totaltests += File.open(file).read.scan(/is/).count\n end\n when \"CoffeeScript-jasmine\"\n if File.open(file).read.scan(/jasmine-node/).count > 0\n @totaltests += File.open(file).read.scan(/it/).count\n end\n when \"Erlang-eunit\"\n if File.open(file).read.scan(/eunit\\.hrl/).count > 0\n @totaltests += File.open(file).read.scan(/test\\(\\)/).count\n end\n when \"Haskell-hunit\"\n if File.open(file).read.scan(/Test\\.HUnit/).count > 0\n @totaltests += File.open(file).read.scan(/TestCase/).count\n end\n when \"Scala-scalatest\"\n if File.open(file).read.scan(/org\\.scalatest/).count > 0\n @totaltests += File.open(file).read.scan(/test\\(/).count\n end\n when \"Clojure-.test\"\n if File.open(file).read.scan(/clojure\\.test/).count > 0\n @totaltests += File.open(file).read.scan(/deftest/).count\n end\n when \"Groovy-JUnit\"\n if File.open(file).read.scan(/org\\.junit/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Groovy-Spock\"\n if File.open(file).read.scan(/spock\\.lang/).count > 0\n @totaltests += File.open(file).read.scan(/def /).count - 1 #1 extra because of object def\n end\n else\n @totaltests = \"NA\"\n end\n rescue\n puts \"Error: Reading in count_tests\"\n end\n end\n end\nend", "def run test_identifier=nil\n @dispatcher.run!\n # start\n message(\"start\")\n suite_setup,suite_teardown,setup,teardown,tests=*parse(test_identifier)\n if tests.empty? \n @dispatcher.exit\n raise RutemaError,\"No tests to run!\"\n else\n # running - at this point all checks are done and the tests are active\n message(\"running\")\n run_scenarios(tests,suite_setup,suite_teardown,setup,teardown)\n end\n message(\"end\")\n @dispatcher.exit\n @dispatcher.report(tests)\n end", "def report_from(tests)\n tests.map do |test|\n report = [test.name, test.executed?]\n report << test.platform.name unless test.platform.nil?\n report << test.node unless test.node.nil?\n # Only report the first line of the error messages, as some contain callstacks\n report << test.errors.map { |error| error.split(\"\\n\").first } unless test.errors.empty?\n report\n end\n end", "def run_all\n UI.info \"Running all tests...\"\n _really_run(Util.xcodebuild_command(options))\n end", "def process_test_cases\n raise NotImplementedError, 'You must implement this'\n end", "def test_run_completed(test_run)\n report_results test_run\n end", "def run_fe_tests\n end", "def run_all\n passed = @runner.run_all!\n\n throw :task_has_failed unless passed\n end", "def run_tests\n\n ::RSpec::Core::Runner.run([])\n\n print ::IRB.CurrentContext.io.prompt\n\n end", "def test_list\n list = []\n instance_methods.each do |m|\n next unless m.to_s =~ /^(ok|no)[_ ]/\n list << m\n end\n list\n end" ]
[ "0.7274132", "0.7200911", "0.71905994", "0.7134598", "0.7127439", "0.70358455", "0.6860759", "0.68229115", "0.68049264", "0.6790065", "0.6790065", "0.6768047", "0.65728307", "0.65551996", "0.65487796", "0.65460235", "0.65293026", "0.64595217", "0.6447049", "0.6447049", "0.6441135", "0.64316434", "0.64316434", "0.642825", "0.63923085", "0.636345", "0.6343057", "0.63372016", "0.63203555", "0.6299623", "0.6284468", "0.62774086", "0.62632114", "0.6259585", "0.62464374", "0.6235319", "0.62153786", "0.62005377", "0.6199617", "0.6199139", "0.61982924", "0.6195854", "0.61939454", "0.6193542", "0.6192025", "0.6192025", "0.6192025", "0.61888516", "0.6185608", "0.6170051", "0.61620754", "0.6158359", "0.61409265", "0.61348844", "0.61348844", "0.61343503", "0.61328936", "0.61303157", "0.6121021", "0.6111094", "0.6106691", "0.60886276", "0.6087629", "0.6087446", "0.60841537", "0.60841537", "0.60830265", "0.60774684", "0.60764015", "0.6075713", "0.6073246", "0.6063769", "0.6051214", "0.6050966", "0.6042158", "0.60243255", "0.60241014", "0.6019627", "0.6019041", "0.60136944", "0.60131127", "0.6006864", "0.6000295", "0.6000295", "0.6000057", "0.5990331", "0.5990331", "0.5990331", "0.5983938", "0.5971915", "0.5969684", "0.59696263", "0.5965452", "0.5955056", "0.59545577", "0.59439194", "0.594306", "0.5942392", "0.5942066", "0.5933383", "0.59289336" ]
0.0
-1
Command to pass to shell_out.
def command if new_resource.command.is_a?(Array) [new_resource.python] + new_resource.command else "#{new_resource.python} #{new_resource.command}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shell_out_command(cmd, msg)\n cmd_local = \"#{cmd}\" + \" -c #{knife_config}\" + \"#{grep_cmd}\"\n shell_out = Mixlib::ShellOut.new(\"#{cmd_local}\", :timeout => timeout)\n puts \"#{msg}\"\n puts \"#{cmd_local}\"\n @op = shell_out.tap(&:run_command).stdout\n puts \"#{cmd_stdout}\"\n return shell_out\n end", "def command\n @command ||= Mixlib::ShellOut.new from_instructions\n end", "def shell_out(command)\n process_status, out, err = jruby? ? jruby_out(command) : mri_out(command)\n Response.new(process_status, out, err)\n end", "def shell_out!(*command_args)\n cmd = shell_out(*command_args)\n cmd.error!\n cmd\n end", "def out(command)\n assert(system(command))\n end", "def commandGetOut _args\n \"commandGetOut _args;\" \n end", "def `(cmd)\n $shell_result\n end", "def shell_wrap(cmd)\n return cmd unless @shell\n\n shell = @shell_command || \"$SHELL\"\n options = \" #{@shell_options}\" if @shell_options\n\n \"#{safe_string(cmd)} | #{shell}#{options}\"\n end", "def backtick\n @out = `#{@command}`\n self\n end", "def command\n ([executable] + options_composition + @redirections).join(\" \")\n end", "def shell(cmd)\n `#{cmd}`\n end", "def shell(cmd)\n `#{cmd}`\n end", "def shell_commands(cmd, args); end", "def system_command(*command_args)\n cmd = Mixlib::ShellOut.new(*command_args)\n cmd.run_command\n cmd\n end", "def output(command)\n @buffer << command.gsub(/'/, '\"')\n end", "def run_cmd(cmd)\n Chef::Log.info \"executing: #{cmd}\"\n result = Mixlib::ShellOut.new(cmd).run_command.stdout.strip\n return result\nend", "def system_command(*command_args)\n cmd = Mixlib::ShellOut.new(*command_args)\n cmd.run_command\n cmd\n end", "def shell(*) end", "def powershell_out!(*command_args)\n cmd = powershell_out(*command_args)\n cmd.error!\n cmd\n end", "def capture_stdout(*command, dir: repo_cache_dir)\n success, output = Samson::CommandExecutor.execute(\n *command,\n whitelist_env: ['HOME', 'PATH'],\n timeout: 30.minutes,\n err: '/dev/null',\n dir: dir\n )\n output.strip if success\n end", "def sh_out(cmd, fail = true, stdin = '')\n r_in, w_in = IO.pipe\n r_out, w_out = IO.pipe\n r_err, w_err = IO.pipe\n w_in.write(stdin)\n w_in.close\n pid = Process.spawn(cmd, in: r_in, out: w_out, err: w_err)\n Process.wait(pid)\n\n r_in.close\n w_out.close\n w_err.close\n stdout = r_out.read\n r_out.close\n stderr = r_err.read\n r_err.close\n\n if fail && $CHILD_STATUS.exitstatus != 0\n raise CommandError, \"`#{cmd}` exited #{$CHILD_STATUS.exitstatus}\\n\" \\\n \"stdout:\\n\" \\\n \"#{stdout}\\n\" \\\n \"stderr:\\n\" \\\n \"#{stderr}\\n\"\n end\n stdout\n end", "def template_command_with_output_cleaned(command)\n base = template_command(command)\n\n stream = if hide_both?\n '&'\n elsif hide_stderr?\n '2'\n elsif hide_stdout?\n '1'\n end\n\n base = \"#{base} #{stream}> /dev/null\" if stream\n base\n end", "def shell_commands(cmd, *args); end", "def shell(command, output: false)\n command += ' > /dev/null 2>&1' if !output\n system(command)\nrescue => e\n lex(e, \"Failed to execute shell command: #{command}\")\nend", "def run_for_output(cmd)\n LOG.debug \"RUNNING (for output): #{cmd}\"\n out, _status = Open3.capture2e(cmd)\n out.strip\n end", "def backtick_output(command)\n success, output = run_external(command, {}, SETTINGS[:project])\n return output, success\n end", "def command_output(command)\n command command\n last_command_output\n end", "def from_cmd(cmd)\n so = shell_out(cmd)\n so.stdout.split($/)[0]\n end", "def shell_output\n $shell_history ||= []\n cmd = get_string(\"Enter shell command:\", :maxlen => 50) do |f|\n require 'canis/core/include/rhistory'\n f.extend(FieldHistory)\n f.history($shell_history)\n end\n if cmd && !cmd.empty?\n run_command cmd\n $shell_history.push(cmd) unless $shell_history.include? cmd\n end\n end", "def command_output(stream=nil)\n case stream\n when 'stdout'\n command_stdout\n when 'stderr'\n command_stderr\n else\n \"#{command_stdout}\\n#{command_stderr}\"\n end\n end", "def output\n (value = parent.get(@name)).nil? ? @raw_command : value.to_s\n end", "def stdout\n @cmd_result.stdout\n end", "def format_redirect_stdout(cmd, target = NULL_OUTPUT_NAME)\n return cmd + \" 1>#{target}\"\n end", "def commandResult\n\t\t\t%x(#{@cmd} 2> /dev/null)\n\t\tend", "def raw(command)\n puts command\n end", "def read_command_output( cmd, *args )\n\t\t\t# output = IO.read( '|-' ) or exec cmd, *args # No popen on some platforms. :(\n\t\t\targstr = Shellwords.join( args )\n\t\t\toutput = `#{cmd} #{argstr}`.chomp\n\t\t\treturn output\n\t\tend", "def backtix cmd\n out, err = backtix2 cmd\n err.strip!\n if 0 != err.length\n raise Hipe::AppFail.new(\"failed to run system command -- #{err}\")\n end\n out\n end", "def command_output\n [command.stdout, command.stderr].join(\"\\n\\n\")\n end", "def to_s\n \"#{@dir}> #{@cmd}\"\n end", "def stdout(command, data)\n # called when the process writes to STDOUT\n end", "def shell_command(command)\n command.map {|word| shell_single_word(word) }.join(' ')\n end", "def sh(command)\n provider.sh command\n end", "def command\n return \"#{@command} #{options}\"\n end", "def stdout_of command\n win_os? && command.gsub!(/'/, '\"')\n stdout = `#{command}`\n $?.success? || fail(\"`#{command}` failed\")\n stdout\nend", "def getCommandOutput(command)\n #N If we don't output the command it won't be echoed before it's output appears\n puts \"#{command.inspect} ...\"\n #N If we don't call this, the command won't run(?) and it's output won't be available\n return IO.popen(command)\n end", "def plain_command cmd, options={}\n system(cmd)\n exitstatus = $?.exitstatus == 0 || $?.exitstatus == 1\n show_output(exitstatus, options)\n exitstatus\n end", "def ex(cmd)\n puts cmd\n puts `#{cmd}`\nend", "def |(cmd)\n IO.popen(cmd.to_s, 'r+') do |pipe|\n pipe.write(self)\n pipe.close_write\n pipe.read.strip\n end\n end", "def run(cmd)\n shell_out! \"#{jboss_cli} '#{cmd}'\", cli_options\n end", "def sh( cmd )\n logger.info( cmd )\n\n io = IO.popen( \"#{cmd} 2>&1\" )\n io.each_line do |l|\n logger.debug( l.strip )\n end\n end", "def systemu(*args)\n cmd = Mixlib::ShellOut.new(*args)\n cmd.run_command\n cmd\n end", "def `(cmd)\n old_execute(cmd + \" 2>&1\")\nend", "def execute(command)\n #2>&1 Redirect standard error to standard output\n system(\"#{command} > #{OUTPUT} 2>&1\")\n puts File.read(OUTPUT) if SHOW_OUTPUT\nend", "def cmd(str)\n\t\[email protected] str\n\tend", "def command(cmd); \"#{cmd}#{options.tail ? ' -f' : ''}\" end", "def sh cmd\n puts cmd\n put `#{cmd}`\nend", "def command\n return @raw_command\n end", "def shell_out command=nil\n $shell_history ||= []\n command ||= get_string(\"Enter system command:\", :maxlen => 50) do |f|\n require 'canis/core/include/rhistory'\n f.extend(FieldHistory)\n f.history($shell_history)\n end\n ##w = @window || @form.window\n #w.hide\n Ncurses.endwin\n ret = system command\n Ncurses.refresh\n #Ncurses.curs_set 0 # why ?\n #w.show\n return ret\n end", "def doGetOut _args\n \"doGetOut _args;\" \n end", "def command_stdout(command)\n return '' if command.empty?\n\n stdout, = Open3.capture3(command)\n stdout.strip\n end", "def handle_shell(cmd)\n cmd = cmd[1, cmd.size - 2]\n result = \"\"\n export_vim\n IO.popen(\"sh -s\", 'w+') do |p|\n p.write cmd\n p.write \"\\nexit 0\\n\" # make shure to end it\n result = p.read\n end\n result.strip\n end", "def command_shell_string__from call, *args\n \"#{call} #{args.join \" \"}\"\n end", "def wrapped_command(command)\n \"#{command}; __rvm_show_command_epilog\"\n end", "def capture(cmd)\n output = `#{cmd}`\n\n check_status!\n\n output\n end", "def doCmd(cmd)\n puts cmd;\n puts `#{cmd}`;\nend", "def execoutput (cmd)\n output = ''\n begin\n execpipe(cmd) do |out|\n output = out.readlines.join('').chomp!\n end\n rescue Puppet::ExecutionFailure\n raise Puppet::ExecutionFailure, output.split(\"\\n\")[0]\n end\n output\n end", "def command\n return nil unless commands\n\n # Map commands to template & chain\n commands.map(&method(:template_command_with_output_cleaned)).join(' && ')\n end", "def cmd(command)\n\t\tbegin\n\t\t\t`#{command}`\n\t\trescue Exception => e\n\t\t\te.to_s\n\t\tend\n\tend", "def pipe_command(command)\n case command\n when :exit\n \"\\x00\"\n when :execute\n \"\\x01\"\n end\n end", "def write_shell(buf, shell = nil)\n\t\traise NotImplementedError\n\tend", "def my_backticks(cmd)\n rd, wr = IO.pipe\n\n pid = fork {\n rd.close\n\n $stdout.reopen(wr)\n exec(cmd)\n }\n\n wr.close\n Process.wait(pid)\n rd.read\nend", "def puts_cmd(dir, cmd)\n puts \"(#{dir}) [#{cmd}]\"\nend", "def output_command(command_string)\n $stdout.puts\n $stdout.puts StringMasker.new(command_string, :username => username, :password => password).to_s\n end", "def cmd\n (@cmd ? @cmd : @ctx.cmd).join ' '\n end", "def command\n if args.skip?\n ''\n else\n commands.join('; ')\n end\n end", "def raw\n orig_command = \"fsctl #{@command}\"\n end", "def sh command_string\n with_80_columns do\n `2>&1 #{command_string}`\n end\nend", "def cmd(cmd)\n puts cmd\n system cmd\n end", "def cmd(*args)\n command = Shellwords.join(args)\n out = `#{command}`.strip\n fail!(puts \"command failed: #{command}\", $?.exitstatus) unless $?.success?\n out\nend", "def run_and_output(cmd)\n run(cmd).output\n end", "def command\n if self.valid\n command = [\"command=\\\"#{Rails.root}/#{Settings.application.aq_shell} #{self.login}\\\"\",\n \"no-port-forwarding\", \"no-X11-forwarding\", \"no-agent-forwarding\"]\n command.join(\",\")\n end\n end", "def shell_cmd(cmd)\n stdout_str, stderr_str, status = Open3.capture3(cmd)\n unless status&.success?\n raise(ShfConditionError::BackupCommandNotSuccessfulError, \"Backup Command Failed: #{cmd}. return status: #{status} Error: #{stderr_str} Output: #{stdout_str}\")\n end\n end", "def run_wrapped_cmd(cmd)\n separator = '-' * (TW - 4)\n\n puts \"Command output follows, on STDERR:\\n#{separator}\"\n ret = nil\n\n Open3.popen2e(cmd) do |_in, out, thr|\n # rubocop:disable Lint/AssignmentInCondition\n while l = out.gets do warn l end\n # rubocop:enable Lint/AssignmentInCondition\n ret = thr.value.exitstatus\n end\n\n puts separator\n ret\n end", "def do_shell(line)\n shell = ENV['SHELL']\n line ? write(%x(#{line}).strip) : system(shell)\n end", "def execute_shell(command, input = nil)\n Open3.popen3(command) do |stdin, stdout, stderr, thrd|\n stdin.puts input unless input.nil?\n stdin.close\n SystemCallError.new(\"Error invoking #{command}, #{stderr.read}\", thrd.value.exitstatus)\n out = stdout.read\n end\n rescue Errno::EPIPE\n \"\"\n end", "def stdout_pipe\n @stdout\n end", "def capture_command_output(*command, **kwargs, &block)\n # Default block returns what's passed in\n block ||= -> line { line }\n IO.popen(command.flatten, **kwargs) { |io| io.each_line { |line| print block.call(line) } }\n end", "def stdout; end", "def stdout; end", "def stdout; end", "def stdout; end", "def stdout; end", "def stdout; end", "def get_from_shell_cmd(cmd, proc_id)\n stdout, stderr, status = Open3.capture3(cmd)\n if not status.success?\n cancel_job(\"error executing command '#{cmd}' - #{stderr}\", proc_id)\n end\n return stdout.strip!\nend", "def cmd; end", "def echo _args\n \"echo _args;\" \n end", "def p4sh cmd\n sh \"#{cmd};\"\n end", "def `(cmd) #` for highlighter\n case cmd\n #when /^roll\\ use/\n # can't run b/c of child shell\n when /^roll/\n cmd = cmd.sub('roll', 'ruby -Ilib bin/roll -')\n end\n stdout, stderr = shell.execute(cmd)\n#puts stdout\n#puts stderr\n @stdout = stdout\n @stderr = stderr\n raise \"#{stderr}\" if shell.status != 0\n return @stdout\nend", "def run_program(cmd, input = \"\")\n stdout, = Open3.capture2e(shell_out_env, *cmd, stdin_data: input)\n\n stdout\n end", "def shell_command(cmd, timeout = 1800)\n # insert random marker\n strm = Rex::Text.rand_text_alpha(15)\n endm = Rex::Text.rand_text_alpha(15)\n\n # Send the shell channel's stdin.\n shell_write(\";'#{strm}'\\n\" + cmd + \"\\n'#{endm}';\\n\")\n\n etime = ::Time.now.to_f + timeout\n\n buff = \"\"\n # Keep reading data until the marker has been received or the 30 minture timeout has occured\n while (::Time.now.to_f < etime)\n res = shell_read(-1, timeout)\n break unless res\n timeout = etime - ::Time.now.to_f\n\n buff << res\n if buff.include?(endm)\n # if you see the end marker, read the buffer from the start marker to the end and then display back to screen\n buff = buff.split(/#{strm}\\r\\n/)[-1]\n buff = buff.split(endm)[0]\n buff.gsub!(/(?<=\\r\\n)PS [^>]*>/, '')\n return buff\n end\n end\n buff\n end", "def run(command)\n puts command\n `#{command}`.tap &method(:puts)\nend" ]
[ "0.7550706", "0.69870144", "0.69238216", "0.6903258", "0.68766254", "0.6657787", "0.6609094", "0.64676195", "0.64654976", "0.6357223", "0.6346813", "0.6346813", "0.6336614", "0.63284785", "0.631996", "0.6314063", "0.6297181", "0.6275871", "0.6267741", "0.6235331", "0.6219414", "0.6198893", "0.61884874", "0.61667746", "0.61645865", "0.6143317", "0.61340976", "0.61191714", "0.61110514", "0.61041516", "0.61004496", "0.6076864", "0.6073401", "0.60568017", "0.60249406", "0.6009129", "0.59944475", "0.59775436", "0.59757566", "0.5974341", "0.5957479", "0.5942797", "0.5940076", "0.5920333", "0.591071", "0.5907076", "0.59002036", "0.58998793", "0.5882856", "0.5882728", "0.58757967", "0.58726907", "0.58703476", "0.5858445", "0.58572847", "0.58567494", "0.58519256", "0.5845663", "0.5841381", "0.58399206", "0.5837633", "0.583621", "0.5822942", "0.58090305", "0.57940984", "0.5793312", "0.57927865", "0.5792634", "0.5785414", "0.5772667", "0.5765064", "0.57588446", "0.57520944", "0.57404625", "0.5734267", "0.5715974", "0.568968", "0.5688352", "0.56872606", "0.567865", "0.56786364", "0.56724995", "0.5670705", "0.5664394", "0.56557316", "0.5654678", "0.5649833", "0.56435406", "0.56435406", "0.56435406", "0.56435406", "0.56435406", "0.56435406", "0.5636573", "0.56147754", "0.56144565", "0.5612326", "0.5608633", "0.56046563", "0.5604579", "0.55999905" ]
0.0
-1
Environment variables to pass to shell_out.
def environment if new_resource.parent_python environment = new_resource.parent_python.python_environment if new_resource.environment environment = environment.merge(new_resource.environment) end environment else new_resource.environment end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def msys_apps_envvars_for_cmd\n vars = with_msys_install_hint{ msys_apps_envvars }\n vars.map do |key, val|\n \"#{key}=#{val}\"\n end.join(\"\\n\")\n end", "def cmd_getenv(*args)\n vars = client.sys.config.getenvs(*args)\n\n if vars.length == 0\n print_error(\"None of the specified environment variables were found/set.\")\n else\n table = Rex::Text::Table.new(\n 'Header' => 'Environment Variables',\n 'Indent' => 0,\n 'SortIndex' => 1,\n 'Columns' => [\n 'Variable', 'Value'\n ]\n )\n\n vars.each do |var, val|\n table << [ var, val ]\n end\n\n print_line\n print_line(table.to_s)\n end\n end", "def shell_env\n @shell.env\n end", "def set_env vars\n command = <<~HEREDOC\n echo \"Setting Environment Variables\"\n source ~/.bashrc\n HEREDOC\n\n vars.each do |key, value|\n command += <<~HEREDOC\n if [ -z \"$#{key}\" ]; then\n echo \"export #{key}=#{value}\" >> ~/.profile\n fi\n HEREDOC\n end\n\n return command\nend", "def export_dynatrace_app_environment_variables\n profiled_dir = File.join(@app_dir, '.profile.d')\n FileUtils.mkdir_p(profiled_dir)\n\n variables = {}\n variables[RUXIT_APPLICATION_ID] = application_id\n variables[RUXIT_HOST_ID] = host_id\n\n env_file_name = File.join(profiled_dir, '0dynatrace-app-env.sh')\n env_file = File.new(env_file_name, 'w')\n variables.each do |key, value|\n env_file.puts(\"export #{key}=\\\"${#{key}:-#{value}}\\\"\") # \"${VAR1:-default value}\"\n end\n env_file.close\n end", "def ps_environment(obj)\n commands = obj.map do |k, v|\n \"$env:#{k} = '#{v}'\"\n end\n\n commands.join(\"\\n\")\n end", "def environment_variables\n global_variables = @config.environment_variables\n process_vars = @config.process_options[@name] ? @config.process_options[@name]['env'] || {} : {}\n process_local_vars = @config.local_process_options[@name] ? @config.local_process_options[@name]['env'] || {} : {}\n global_variables.merge(process_vars.merge(process_local_vars)).each_with_object({}) do |(key, value), hash|\n hash[key.to_s] = value.to_s\n end\n end", "def environ_env(var, what, returns = false)\n # => get env from ENV.foo\n puts \"environ_env: #{var}, #{what}, #{returns}\"\n asgn = \"\"\n what.each { |x| asgn << handle(x) }\n\n return if returns\n puts \"environ_env: export #{var} = #{asgn}\" if var\n # XXX: FIXME check for []_ ('_' in environment); it reveals if this is a\n # assginment or calling\n @@install << \"export #{var}=\\\"#{asgn}\\\"\"\n end", "def get_environment\n if @environment.empty?\n \":\"\n else\n env = @environment.map { |key, value| %(#{key}=\"#{value}\") }\n \"export #{env.join(' ')}\"\n end\n end", "def set_vars(vars_dictionary)\n command = <<~HEREDOC\n echo \"setting Environment Variables\"\n sources ~/.bashec\n HEREDOC\n\n vars_dictionary.each do |key, value|\n command = <<~HEREDOC\n if [ -z \"#{key}\"]; then\n echo \"export#{key}=#{value}\" >> ~/.bashrc\n fi\n HEREDOC\n end\n\n return command\nend", "def test_Enviroment_005_PrintEnv\r\n\r\n puts2(\"\")\r\n puts2(\"#######################\")\r\n puts2(\"Testcase: test_Enviroment_005_PrintEnv\")\r\n puts2(\"#######################\")\r\n\r\n puts2(\"\")\r\n puts2(\" Display current settings of some OS variables using printenv()...\")\r\n printenv(\"BOGUS_ENVVAR\")\r\n printenv(\"COMPUTERNAME\") # Is this one platform independent?\r\n printenv(\"USERDNSDOMAIN\") # Is this one platform independent?\r\n printenv(\"NUMBER_OF_PROCESSORS\") # Is this one platform independent?\r\n printenv(\"OS\") # Is this one platform independent?\r\n printenv(\"PROCESSOR_IDENTIFIER\") # Is this one platform independent?\r\n printenv(\"SHELL\") # Is this one platform independent? Yes on: Ubuntu,\r\n printenv(\"USERNAME\") # Is this one platform independent? Yes on: Win, Ubuntu\r\n\r\n puts2(\"\")\r\n puts2(\"\")\r\n puts2(\" Display current settings of ALL OS variables using printenv()...\")\r\n printenv()\r\n\r\n end", "def env_vars\n @env ||= calculate_env_vars\n end", "def shell_environment\n { 'HOME' => ENV.fetch('HOME', '/var/lib/rabbitmq') }\nend", "def test_Enviroment_006_GetEnv\r\n\r\n puts2(\"\")\r\n puts2(\"#######################\")\r\n puts2(\"Testcase: test_Enviroment_006_GetEnv\")\r\n puts2(\"#######################\")\r\n\r\n sEnvVarName = \"COMPUTERNAME\" # Is this one platform independent?\r\n\r\n puts2(\"\")\r\n puts2(\"Retrieve all OS variables using getenv()\")\r\n hMyEnvVars = getenv() # Get them all\r\n\r\n # Loop through the hash and display each variable name and its setting\r\n hMyEnvVars.each do | key, value |\r\n puts2(\" OS variable: \\\"#{key.to_s}\\\" is set to \\\"#{value}\\\" \")\r\n end\r\n\r\n puts2(\"\")\r\n puts2(\"Retrieve a specific OS variable using getenv\")\r\n hMyEnvVars = getenv(sEnvVarName)\r\n\r\n # Loop through the hash and display each variable name and its setting\r\n hMyEnvVars.each do | key, value |\r\n puts2(\" OS variable: \\\"#{key.to_s}\\\" is set to \\\"#{value}\\\" \")\r\n end\r\n\r\n end", "def setenv( vm, host )\n return unless host.key?('env')\n cmd=\"tee -a \\\"/etc/profile.d/setenv.sh\\\" > \\\"/dev/null\\\" <<ENDHERE\"\n host['env'].each do |key, val|\n cmd=\"#{cmd}\\nexport #{key}=\\\"#{val}\\\"\"\n end\n cmd=\"#{cmd}\\nENDHERE\"\n vm.provision \"shell\", inline: cmd, run: \"always\"\nend", "def exports\n File.exist?(ENV_LOG) or return {}\n env = {}\n File.read(ENV_LOG).each_line do |row|\n (var, val) = row.strip.split(\"=\")\n env[var] = val\n end\n env\n end", "def envvar\n CircleCi.request(@conf, \"/project/#{username}/#{project}/envvar\").get\n end", "def env(key)\n capture(\"echo $#{key}\")\n end", "def export_env(env = {})\n @env = env\n end", "def env_vars\n {\n \"VMWARE_USER\" => auth.userid || \"\",\n \"VMWARE_PASSWORD\" => auth.password || \"\",\n \"VMWARE_HOST\" => auth.host || \"\"\n }\n end", "def load_envvars\n Pkg::Params::ENV_VARS.each do |v|\n if var = ENV[v[:envvar].to_s]\n case v[:type]\n when :bool\n self.instance_variable_set(\"@#{v[:var]}\", Pkg::Util.boolean_value(var))\n when :array\n self.instance_variable_set(\"@#{v[:var]}\", string_to_array(var))\n else\n self.instance_variable_set(\"@#{v[:var]}\", var)\n end\n end\n end\n end", "def extract_environment_variables! #:nodoc:\n args.delete_if do |arg|\n next unless arg.match(/^(\\w+)=(.*)$/)\n ENV[$1] = $2\n end\n end", "def prepend_env(cmd)\n return cmd unless @rye_current_environment_variables.is_a?(Hash)\n env = ''\n @rye_current_environment_variables.each_pair do |n,v|\n env << \"export #{n}=#{Escape.shell_single_word(v)}; \"\n end\n [env, cmd].join(' ')\n end", "def env_vars\n {\n \"AWS_ACCESS_KEY_ID\" => auth.userid || \"\",\n \"AWS_SECRET_ACCESS_KEY\" => auth.password || \"\",\n \"AWS_SECURITY_TOKEN\" => auth.auth_key\n }.delete_nils\n end", "def env_vars\n env = {\n \"ANSIBLE_NET_USERNAME\" => auth.userid || \"\",\n \"ANSIBLE_NET_PASSWORD\" => auth.password || \"\",\n \"ANSIBLE_NET_AUTHORIZE\" => auth.authorize ? \"1\" : \"0\"\n }\n\n env[\"ANSIBLE_NET_AUTH_PASS\"] = auth.become_password || \"\" if auth.authorize\n env[\"ANSIBLE_NET_SSH_KEYFILE\"] = network_ssh_key_file if auth.auth_key\n env\n end", "def env_vars\n { \"OS_CLIENT_CONFIG_FILE\" => os_credentials_file }\n end", "def local_env(body)\n env = ''\n vtmp = @var.dup\n vtmp[:pub_rsa] = '[PUBLIC RSA KEY]'\n vtmp[:prv_rsa] = '[PRIVATE RSA KEY]'\n vtmp[:user_keys] = @var[:user_keys].collect { |k,_| k }\n vtmp.each { |k,v| env << \"#{(k.to_s + ' '*20)[0,20]} => #{v.inspect}\\n\" }\n _notice \" -- Current Environment Variables --\\n#{env}\"\nend", "def envvar\n CircleCi.request(conf, \"#{base_path}/envvar\").get\n end", "def write_environment_variable(cartridge, path, *hash)\n FileUtils.mkpath(path) unless File.exist? path\n\n hash.first.each_pair do |k, v|\n name = \"OPENSHIFT_#{cartridge.short_name.upcase}_#{k.to_s.upcase}\"\n File.open(PathUtils.join(path, name), 'w', 0660) do |f|\n f.write(%Q(export #{name}='#{v}'))\n end\n end\n end", "def export_env(script)\n environment = script.job_environment\n (environment ? environment : {}).tap{\n |hsh|\n hsh['SINGULARITY_BINDPATH'] = singularity_bindpath(script.native)\n }.map{\n |key, value| \"export #{key}=#{Shellwords.escape(value)}\"\n }.sort.join(\"\\n\")\n end", "def env(variable_name, variable_value, &block); end", "def set_variable(config, variable_name)\n value = ENV[variable_name]\n\n if value.to_s != ''\n config.vm.provision 'shell' do |s|\n s.inline = \"echo export #{variable_name}=\\\"\\'\\\"\\'#{value.to_s}\\'\\\"\\'\\\" | tee -a /home/vagrant/.bashrc\"\n end\n end\nend", "def with_custom_env_variables(&block)\n saved_env = {}\n begin\n Git::Lib::ENV_VARIABLE_NAMES.each { |k| saved_env[k] = ENV[k] }\n return block.call\n ensure\n Git::Lib::ENV_VARIABLE_NAMES.each { |k| ENV[k] = saved_env[k] }\n end\n end", "def env=(environment); end", "def env=(environment); end", "def get_env_var key\n key = key.to_s\n exec(Beaker::Command.new(\"env | grep ^#{key}=\"), :accept_all_exit_codes => true).stdout.chomp\n end", "def forward_local_env(env_variable_patterns); end", "def registered_env_vars\n @registered_env_vars = @registered_env_vars || {}\n end", "def registered_env_vars\n @registered_env_vars = @registered_env_vars || {}\n end", "def getenv(varname)\n out = runcmd 'getenv', varname\n out.strip!\n end", "def export_dynatrace_connection_environment_variables\n profiled_dir = File.join(@app_dir, '.profile.d')\n FileUtils.mkdir_p(profiled_dir)\n\n if supports_apitoken? && File.file?(File.join(@app_dir, DYNATRACE_HOME_DIR, 'dynatrace-env.sh'))\n # copy dynatrace-env.sh from agent zip to .profile.d for setting DT_CONNECTION_POINT etc\n dynatrace_env_sh = File.join(@app_dir, DYNATRACE_HOME_DIR, 'dynatrace-env.sh')\n FileUtils.cp(dynatrace_env_sh, profiled_dir)\n else\n credentials = @services.find_service(DYNATRACE_SERVICE_NAME)[CREDENTIALS_KEY]\n variables = {}\n variables[DT_TENANT] = tenant(credentials)\n variables[DT_TENANTTOKEN] = tenanttoken(credentials)\n variables[DT_CONNECTION_POINT] = server(credentials)\n\n env_file_name = File.join(profiled_dir, 'dynatrace-env.sh')\n env_file = File.new(env_file_name, 'w')\n variables.each do |key, value|\n env_file.puts(\"export #{key}=\\\"${#{key}:-#{value}}\\\"\") # \"${VAR1:-default value}\"\n end\n env_file.close\n end\n end", "def environ\n\t\tif @os.to_i == 0\n\t\t\tputs \"[\".light_red + \"X\".white + \"] Your target appears to be Winblows\".light_red + \"!\".white\n\t\t\tputs \"[\".light_red + \"X\".white + \"] This option is only available for *nix machines\".light_red + \"!\".white\n\t\telse\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Testing for \".light_green + \"/proc/self/environ\".white + \" RCE Vuln\".light_green + \".....\".white\n\n\t\t\tfilez = [ \"proc/self/./environ\", \"proc/self/environ\" ]\n\n\t\t\t@ua=0\n\t\t\t@found=0\n\t\t\t@accept=0\n\t\t\twhile @found.to_i < 1\n\t\t\t\tfilez.each do |file|\n\t\t\t\t\tif $module_required['Min'].to_i == 0\n\t\t\t\t\t\t@thegoods=\"/#{file}\"\n\t\t\t\t\telse\n\t\t\t\t\t\t@thegoods=\"#{@stepstone}#{file}\"\n\t\t\t\t\tend\n\t\t\t\t\tbody = basicregex(@thegoods, 69)\n\t\t\t\t\t#Regex for /proc/self/environ file\n\t\t\t\t\tif body =~ /HTTP_USER_AGENT=/ or body =~ /HTTP_ACCEPT=/ or body =~ /DOCUMENT_ROOT=/ or body =~ /VHOST_ROOT=/ or body =~ /HTTP_HOST/\n\t\t\t\t\t\t@environ = 'true'\n\t\t\t\t\t\tif body =~ /HTTP_USER_AGENT=/\n\t\t\t\t\t\t\t@ua = 1\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif body =~ /HTTP_ACCEPT=/\n\t\t\t\t\t\t\t@accept = 1\n\t\t\t\t\t\tend\n\t\t\t\t\t\t#Successful injection will match our regex, failure won't (concat on exec proves its working)\n\t\t\t\t\t\tif body =~ /:#{@rnd}:(.+):#{@rnd}:/ \n\t\t\t\t\t\t\t@envirores = $1 #make results available\n\t\t\t\t\t\tend\n\t\t\t\t\t\t@found = 1\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\t@environ = 'false'\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tif @found.to_i == 0\n\t\t\t\t\t@found = 2 #break cause we are out of file options to test, will use value to offset from true success...\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif @environ == 'true'\n\t\t\t\tputs \"[\".light_green + \"*\".white + \"] File Found: \".light_green + \"/proc/self/environ\".white\n\t\t\t\tputs \"[\".light_green + \"*\".white + \"] User-Agent is present in response\".light_green + \"!\".white if @ua.to_i == 1\n\t\t\t\tputs \"[\".light_green + \"*\".white + \"] Accept Header is present in response\".light_green + \"!\".white if @accept.to_i == 1\n\t\t\t\tenvirosupport\n\t\t\telse\n\t\t\t\tputs \"[\".light_red + \"X\".white + \"] Sorry, \".light_red + \"/proc/self/environ\".white + \" doesn't appear to be available\".light_red + \".....\".white\n\t\t\t\tputs \"[\".light_red + \"X\".white + \"] Returning to Previous Menu\".light_red + \"...\".white\n\t\t\tend\n\t\tend\n\tend", "def escaped_env(env, options={})\n return \"\" if env.empty?\n\n if options[:rerun] && gemfile = env[\"BUNDLE_GEMFILE\"]\n env[\"BUNDLE_GEMFILE\"] = gemfile.sub(\"#{Dir.pwd}/\", \"\")\n end\n\n env = env.map { |k,v| \"#{k}=#{Shellwords.escape(v)}\" }\n if options[:rerun]\n env.join(\" \") + \" \"\n else\n env.map { |e| \"export #{e}\" }.join(\" && \") + \" && \"\n end\n end", "def env_key; end", "def create_env_wrapper(command, environment)\r\n if environment\r\n env_string = environment.map { |k, v| \"$env:#{k}='#{v}'\" }.join('; ')\r\n \"& { #{env_string}; #{command} }\"\r\n else\r\n command\r\n end\r\nend", "def save_env\n f = File.new(TddDeploy::Environ::ENV_FNAME, \"w\")\n self.env_types.keys.sort.each do |k|\n v = self.env_hash[k] || ''\n case self.env_types[k]\n when :int then f.write \"#{k}=#{v}\\n\"\n when :string then f.write \"#{k}=#{v}\\n\"\n when :list then\n f.write \"#{k}=#{self.list_to_str(k)}\\n\" unless k == 'hosts'\n when :pseudo then next\n when :capfile then next\n else\n raise ::RuntimeError.new(\"unknown key: #{k}\")\n end\n end\n f.close\n end", "def environment\n @env_vars ||= VARS.reduce({}) do |hash, (key, value)|\n hash.merge(\"#{prefix}_#{value}\" => send(key))\n end.merge(env)\n end", "def assert_env_var_values(puppet_output, expected_values)\n expected_values.each do |env_var, value|\n assert_match(/#{env_var}=#{value}/, puppet_output, \"Expected '#{env_var}=#{value}' to be printed as part of the output!\")\n end\n end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def list_user_env_variables(vars=[])\n result_io = get_app_dns_gear.list_user_env_vars(vars)\n JSON.parse(result_io.resultIO.string)\n end", "def env_config; end", "def env_config; end", "def env_config; end", "def env_config; end", "def env\n %w[INSTALLATION=1] + extra_env\n end", "def setup_docker_env_vars_str\n \"eval \\\"$(docker-machine env #{project_config['docker-machine']['name']})\\\" && \"\nend", "def env(key, value)\n @environment_variables[key] = value \n end", "def visit_EnvNode(node)\n node.env.each_pair do |key,val|\n ENV[key] = val\n end\n Yap::Shell::Execution::Result.new(status_code:0, directory:Dir.pwd, n:1, of:1)\n end", "def get_environment_strings\n env_ptr = GetEnvironmentStringsW()\n\n # pass :invalid => :replace to the Ruby String#encode to use replacement characters\n pairs = env_ptr.read_arbitrary_wide_string_up_to(65534, :double_null, { :invalid => :replace })\n .split(?\\x00)\n .reject { |env_str| env_str.nil? || env_str.empty? || env_str[0] == '=' }\n .reject do |env_str|\n # reject any string containing the Unicode replacement character\n if env_str.include?(\"\\uFFFD\")\n Puppet.warning(_(\"Discarding environment variable %{string} which contains invalid bytes\") % { string: env_str })\n true\n end\n end\n .map { |env_pair| env_pair.split('=', 2) }\n Hash[ pairs ]\n ensure\n if env_ptr && ! env_ptr.null?\n if FreeEnvironmentStringsW(env_ptr) == FFI::WIN32_FALSE\n Puppet.debug \"FreeEnvironmentStringsW memory leak\"\n end\n end\n end", "def get_parameters\n\t\t# get available envs\n\t\tSTDOUT.puts \"Enter environment to run tests on: (mwho, etc.): \"\n\t\tENV['environment']=STDIN.gets.strip.downcase\n\t\t# validate input\n\n\t\t# get available user permission levels for the env\n\t\tSTDOUT.puts \"Enter the permission level of the USER for this test: \"\n\t\tENV['permission']=STDIN.gets.strip.downcase\n\t\t# validate input\n\t\t\n\t\t# get available url permission levels for the env\n\t\tSTDOUT.puts \"Enter the permission level of the URLS for this test (all_defaults will be used if nothing is entered): \"\n\t\tENV['urls']=STDIN.gets.strip.downcase\n\t\t# validate input\n\t\tif ENV['urls'] == \"\" || ENV['urls'] == nil\n\t\t\tENV['urls'] = \"all_defaults\"\n\t\tend\n\tend", "def set_remote_env(env); end", "def args_env_vars\r\n puts \"SMS Order Notifier for Blomming, release: 1 February 2014, by: [email protected]\"\r\n puts \"CTRL+C to stop\"\r\n\r\n # get necessary environment variables\r\n @username = ENV['SMSNOTIFIER_SKEBBY_USERNAME']\r\n @password = ENV['SMSNOTIFIER_SKEBBY_PASSWORD'] \r\n @seller_cell_number = ENV['SMSNOTIFIER_SELLER_PHONENUM']\r\n\r\n if @username.nil? || @password.nil? || @seller_cell_number.nil?\r\n puts \"please set environment variables:\"\r\n puts \"export SMSNOTIFIER_SKEBBY_USERNAME=your_skebby_username\"\r\n puts \"export SMSNOTIFIER_SKEBBY_PASSWORD=your_skebby_password\"\r\n puts \"export SMSNOTIFIER_SELLER_PHONENUM=seller_cell_number as: <country_prefix><number> by example: 391234567890\"\r\n exit 1\r\n end\r\n\r\n # get Blomming YAML configuration filename\r\n if ARGV[0].nil?\r\n puts \" usage: #{$0} <blomming_config_file.yml>\" \r\n puts \"example: ruby #{$0} $CONFIG\"\r\n exit 2\r\n end\r\n\r\n blomming_config_file = ARGV[0]\r\nend", "def with_env(vars) #, &block)\n return if !block_given?\n #vars.each {|v| ENV[v] = eval(v, block.binding)}\n temp = {}\n vars.each do |k, v|\n temp[k.to_s] = ENV[k.to_s]\n ENV[k.to_s] = v\n end\n output = yield\n vars.each do |k,v|\n if temp[k.to_s] \n ENV[k.to_s] = temp[k.to_s]\n else\n ENV.delete(k.to_s)\n end\n end\n return output\n end", "def require_env(*args)\n args.each do |arg|\n env_var = \"#{arg}\".upcase\n if ENV[env_var]\n instance_variable_set(\"@#{env_var.downcase}\", ENV[env_var])\n else\n puts \"You need to provide the ENV variable '#{env_var}'\"\n exit 1\n end\n end\n end", "def environment_variables\n return [] unless options[\"environment_variables\"]\n options[\"environment_variables\"].map do |options|\n EnvironmentVariable.new options\n end\n end", "def env_values\n @parse[@env] || @parse[@env.to_s] || {}\n end", "def spawn_args\n result = Array.new\n unless environment.empty?\n result << environment\n end\n result.concat(command_line)\n opts = Hash.new\n opts[:chdir] = directory.to_s unless directory.nil?\n opts[:pgroup] = pgroup unless pgroup.nil?\n opts[:umask] = umask unless umask.nil?\n opts[:unsetenv_others] = unsetenv_others unless unsetenv_others.nil?\n opts[:close_others] = close_others unless close_others.nil?\n rlimit.each do |key, value|\n opts[\"rlimit_#{key}\".to_sym] = value\n end\n redirection.each do |key, value|\n opts[key] = value\n end\n result << opts\n result\n end", "def busser_env\n root = config[:root_path]\n gem_home = gem_path = remote_path_join(root, \"gems\")\n gem_cache = remote_path_join(gem_home, \"cache\")\n\n [\n shell_env_var(\"BUSSER_ROOT\", root),\n shell_env_var(\"GEM_HOME\", gem_home),\n shell_env_var(\"GEM_PATH\", gem_path),\n shell_env_var(\"GEM_CACHE\", gem_cache),\n ].join(\"\\n\")\n .tap { |str| str.insert(0, reload_ps1_path) if windows_os? }\n end", "def inline_variables( command )\n\t\tpairs = command.scan( ENV_VARIABLE_REGEX )\n\t\treturn Hash[ *pairs.flatten ]\n\tend", "def private_env_vars\n {\n 'DISCONTINUE_API' => \"http://#{ENV['MACHINE_IP']}:8080\",\n 'AWS_REGION' => build.build_config.aws_region,\n 'S3_BUCKET' => build.build_config.aws_cache_bucket,\n 'AWS_ACCESS_KEY_ID' => build.build_config.aws_access_key,\n 'AWS_SECRET_ACCESS_KEY' => build.build_config.aws_access_secret,\n }\n end", "def getenv(key=nil)\n if @rye_getenv && @rye_getenv.empty? && self.can?(:env)\n vars = self.quietly { env } rescue []\n vars.each do |nvpair| \n # Parse \"GLORIA_HOME=/gloria/lives/here\" into a name/value\n # pair. The regexp ensures we split only at the 1st = sign\n n, v = nvpair.scan(/\\A([\\w_-]+?)=(.+)\\z/).flatten\n @rye_getenv[n] = v\n end\n end\n key.nil? ? @rye_getenv : @rye_getenv[key.to_s]\n end", "def env(arguments, options)\n puts \"Versions:\",\n \"* executable: #{Version}\",\n \"* library: #{BareTest::VERSION}\",\n \"* ruby #{RUBY_VERSION}\",\n \"\"\n end", "def sh_test_options\n {\n :cmd_pattern => '% ',\n :cmd => '2>&1 ',\n :indents => true,\n :env => {\n 'TAPFILE' => nil,\n 'TAP_GEMS' => nil, \n 'TAP_PATH' => nil,\n 'TAPENV' => nil,\n 'TAPRC' => nil,\n 'TAP_DEBUG' => nil\n },\n :replace_env => false\n }\n end", "def make_env_bash_script\n env_str = shell_env.map{|e| e.join(\"=\")}.join(\" \")\n \"#!/bin/bash\\nenv #{env_str} \\\"$@\\\"\"\n end", "def execute_dotenv_params(dotenv_path = '.env')\n # The .dot env file\n dotenv_file = deploy_path.join(dotenv_path)\n dotenv_keys = \"$(cut --delimiter== --fields=1 #{dotenv_file})\"\n ['echo', '.env', '&&', '.', dotenv_file, '&&', 'export', dotenv_keys, '&&']\nend", "def shell_var(name, value)\n Util.shell_var(name, value, powershell)\n end", "def apply_variables_to_environment!(options = {})\n variables_to_apply = variables.except(\"RACK_ENV\", \"RAILS_ENV\")\n \n variables_to_apply.each do |key, value|\n if !ENV.has_key?(key.to_s) || options[:overwrite] == true\n ENV[key.to_s] = value.to_s\n end\n end\n \n variables_to_apply\n end", "def set_env_variables(env_vars = [])\n env_vars.each do |_v|\n key, value = _v.split(\"=\")\n\n ENV[key] = value\n end\n end", "def list_user_env_vars(gear, env_var_names)\n args = build_base_gear_args(gear)\n args['--with-keys'] = env_var_names.join(' ') if env_var_names.present?\n result = execute_direct(@@C_CONTROLLER, 'user-var-list', args)\n parse_result(result)\n end", "def hk_env(box)\n %x(hk env -a #{box})\nend" ]
[ "0.6823074", "0.680961", "0.6693461", "0.66444445", "0.6540566", "0.6395838", "0.63755846", "0.63488823", "0.6346558", "0.63415444", "0.6338589", "0.62040025", "0.6192248", "0.6190188", "0.6178436", "0.61660635", "0.6165813", "0.61602134", "0.61581105", "0.61447906", "0.6131259", "0.61166006", "0.61056775", "0.60855067", "0.60824114", "0.60823405", "0.6067675", "0.60668576", "0.60518837", "0.60112333", "0.59750384", "0.5953409", "0.5915192", "0.58948547", "0.58948547", "0.58877796", "0.58843607", "0.5880533", "0.5880533", "0.5870364", "0.5862344", "0.58534384", "0.5834289", "0.583189", "0.582915", "0.582903", "0.5823997", "0.58074045", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.57954395", "0.5793156", "0.57854545", "0.57854545", "0.57854545", "0.57854545", "0.57756054", "0.57702684", "0.57685274", "0.57440215", "0.574036", "0.57273173", "0.5714539", "0.5709366", "0.56927216", "0.56825614", "0.56760633", "0.56592405", "0.56452054", "0.56424516", "0.5630833", "0.5628131", "0.5626359", "0.56132716", "0.5612447", "0.5593359", "0.55893624", "0.55869263", "0.55792904", "0.5569756", "0.5562282", "0.55469894" ]
0.0
-1
before_action :load_flats, only: [:conversations_by_user]
def index # p 'in users, BookingsController' @conversations = Conversation.where(user_id: @user.id) # p @conversations if @conversations conversations_serializer = parse_json @conversations json_response "Indexed user's conversations successfully", true, {conversations: conversations_serializer}, :ok else json_response "Cannot find conversations for user", false, {}, :not_found end # @flat = Flat.order(created_at: :desc) # @flat = policy_scope(Flat).order(created_at: :desc) # authorize @cars end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @user_conversations = UserConversation.all\n end", "def index\n # @conversations = Conversation.all\n @conversations = current_user.conversations\n end", "def index\n #find the current user object\n @user = User.find(session[:user_id])\n #get the id of current user\n user_id = User.find(session[:user_id]).id\n #get all conversations of current user\n @started_conversations = @user.started_conversations\n @joined_conversations = @user.joined_conversations\n end", "def set_conversations\n @conversations = @conversations.send(@order) unless @conversations.blank?\n @conversations = @conversations.page(params[:page]).per(15)\n\n render :index\n end", "def index\n @conversations = current_user.conversations\n end", "def index\n @users = User.all \n @conversations = Conversation.all\n end", "def index\n @conversations = current_profile.conversations\n\n end", "def call\n all_private_conversations = Private::Conversation.all_by_user(@user.id)\n .includes(:messages)\n all_group_conversations = @user.group_conversations.includes(:messages)\n all_conversations = all_private_conversations + all_group_conversations\n\n ##filtered_conversations = []\n\n ##all_conversations.each do |conv|\n ## empty_conversations << conv if conv.messages.last\n ##end\n\n ##filtered_conversations = filtered_conversations.sort{ |a, b|\n ## b.messages.last.created_at <=> a.messages.last.created_at\n ##}\n\n return all_conversations\n end", "def show\n @cl = Classified.find(params[:id])\n @user = User.find(@cl.user_id)\n #@conversations = Conversation.involving(current_user).order(\"created_at DESC\")\n end", "def index\n @title = 'Conversation'\n @users = User.all\n @conversations = Conversation.all\n end", "def show\n @conversation = Conversation.find(params[:id])\n @reciever = interlocutor(@conversation)\n @messages = @conversation.messages.sort_by(&:created_at)\n @message = Message.new\n @admin = current_user.admin\n if @admin\n @conversations = Conversation.where(\"recipient_id = ?\", current_user.id)\n else\n @conversation.update_column(\"open\",true)\n end\n end", "def index\n @conversations = Conversation.where(contype: \"OneToMany\", sender_id: current_member.id).order(name: :asc)\n end", "def index\n #@messages = Message.all\n #@messages = current_owner.messages\n @users = current_owner.conversation_users\n end", "def index\n if current_user.seller?\n @conversations = current_user.seller.company.conversations\n else\n @conversations = current_user.conversations\n end\n end", "def index\n @users = User.all #to list all the registered users\n @conversations = Conversation.all\n \t\n end", "def index\n @conversations = Conversation.involving(current_user)\n conversations_new_message = Array.new\n unread = 0\n\n @conversations.each do |conversation|\n conversation.last_message = ActionView::Base.full_sanitizer.sanitize(conversation.messages.order('created_at').last.body[0..75])\n conversation.last_message_date = conversation.messages.order('created_at').last.created_at\n conversation.count_unread = conversation.messages.unread(conversation.id, current_user).size\n\n size = conversation.messages.unread(conversation.id, current_user).size\n if size > 0\n conversations_new_message.push(conversation)\n unread = unread + size\n end\n\n @subs=current_user.subscribtions\n end\n\n conversations_new_message.each do |conversation|\n set_messages_receive(conversation, false)\n end\n\n if unread > 0\n if unread == 1\n flash[:info] = t('welcome.you_have') + unread.to_s + t('welcome.unread_message')\n else\n flash[:info] = t('welcome.you_have') + unread.to_s + t('welcome.unread_messages')\n end\n end\n\n @invites = Invite.by_recipient_id(current_user.id).order('id');\n\n\n end", "def get_conversations\n n = Notification.where(user_id:current_user)\n conversation_ids = Array.new\n n.each do |v|\n conversation_ids << v.conversation_id\n end\n conversations = Conversation.where(id:conversation_ids)\n\n end", "def set_conversations\n if current_user == @listing.seller\n @conversations = @listing.conversations\n else\n @conversations = @listing.conversations.between(@listing.seller, current_user)\n if @conversations.empty? \n @conversations = create_conversation\n end\n end\n end", "def index\n\t\t@conversations = current_user.mailbox.conversations\n\tend", "def set_conversations\n conversations = Conversation.where(\n \"user1_id = :current_user_id OR user2_id =:current_user_id\",\n current_user_id: current_user.id\n )\n\n @conversations = conversations.sort_by do |conversation|\n last_message = conversation.last_message\n\n if last_message\n last_message.created_at\n else\n Time.zone.now\n end\n end\n\n @conversations.reverse!\n end", "def load_private_messages(conversation)\n if conversation.messages.count > 0\n 'private/conversations/conversation/messages_list/link_to_previous_messages'\n else\n 'shared/empty_partial'\n end\n end", "def fetch\n conversation_users = paginate ConversationUser.where(conversation_id: params[:conversation_id])\n\n render json: conversation_users.to_json(:include => :user)\n end", "def load_conversation\n @conversation = ConversationService.new(params[:id]).call if params[:id]\n end", "def show\n @conversations = @ticket.conversations\n end", "def load_private_messages(conversation)\n if conversation.messages.count.positive?\n 'private/conversations/conversation/messages_list/link_to_previous_messages'\n else\n 'shared/empty_partial'\n end\n end", "def index\n\t\tputs(getAllFriendsConversation)\n\t\t@conversations = current_user.mailbox.conversations\n\t\t@current_user = current_user\n\tend", "def fetch\n messages = paginate ConversationMessage.where(conversation_id: params[:conversation_id])\n .order('created_at DESC')\n render json: messages.to_json(:include => :user)\n end", "def index\n @conversations = @group.conversations\n end", "def index\n if @box.eql? \"inbox\"\n @conversations = @mailbox.inbox\n elsif @box.eql? \"sent\"\n @conversations = @mailbox.sentbox\n else\n @conversations = @mailbox.trash\n end\n \n @conversations = @conversations.paginate(page: params[:page], per_page: 10)\n end", "def sent\n @messages = current_user.messages.order('created_at DESC').unarchived.paginate(:page => params[:page], :per_page => 10)\n end", "def show\n @item = Item.find(params[:id])\n @conversations = Conversation.includes(:recipient, :messages)\n end", "def show\n @user = User.find(params[:id])\n gon.user_id = @user.id\n gon.conversations = @user.conversations.select(\"name\").map(&:name)\n end", "def getConversations\n @conversations = Conversation.all.select(\"name\").map(&:name)\n\n respond_to do |format|\n format.json {render :json => {:conversations => @conversations}}\n end\n end", "def index\n\n @users_with_conversation = []\n @messages = Message.where(receiver_id: params[:user_id]).reverse_order\n @new_messages = @messages.where(unread: true)\n @messages.each do |message|\n unless @users_with_conversation.include?(message.sender)\n @users_with_conversation.push(message.sender)\n end\n end\n @messages = Message.all\n end", "def show\n @conversation = current_user.conversations.find_by_id params.require(:id)\n @messages = @conversation.messages.order('created_at')\n\n uc = @conversation.user_conversations.find_by_user_id(current_user)\n uc.read = true\n uc.save\n\n friend = @conversation.users.collect { |u| u if u != current_user }.compact.first\n @message = Message.new user: friend\n @to = friend.number\n @name = friend.name\n\n respond_to do |format|\n format.html\n format.json { render :json => @messages.to_json(include: :user, :methods => [:file_url]) }\n end\n end", "def index\n @messages = @conversation.messages.includes(:user).order('created_at ASC').page(1)\n\n conversation_user = ConversationUser.find_by(conversation: @conversation, user: current_user)\n @message = conversation_user.messages.build\n\n authorize @message\n @other = @conversation.users.find_by('users.id != ?', current_user.id)\n end", "def dashboard\n @user = User.find(params[:id])\n @wizard = get_next_wizard\n @profile_completion = @user.profile_completion\n @participation_requests = (@user.participation_requests.upcoming.accepted + @user.participation_requests.upcoming.pending).sort_by(&:date)\n @conversations = (@user.mailbox.conversations - @participation_requests.map(&:conversation))[0..4]\n end", "def index\n @conversations = Conversation.where(language_id: params[:language_id])\n end", "def index\n @conversations = @current_user.conversations\n @not_viewed = 0\n @conversations.each do |c|\n @not_viewed += c.how_many_not_viewed(@current_user) unless c.how_many_not_viewed(@current_user) == nil\n end\n @current_user\n end", "def index\n # check if this current_user are involved in conversation\n if current_user == @conversation.sender || current_user == @conversation.recipient\n @other = current_user == @conversation.sender ? @conversation.recipient : @conversation.sender\n\n # 送信先のユーザー名を取得\n if current_user == @conversation.sender\n @recipient_user_name = @conversation.recipient.name\n else\n @recipient_user_name = @conversation.sender.name\n end\n\n @messages = @conversation.messages.order(\"created_at DESC\")\n else\n redirect_to conversations_path, alert: \"他人のメッセージにアクセスできません\"\n end\n\n end", "def index\n respond_to do |format|\n # GET parameters\n @count = params.has_key?(:count) ? ApplicationHelper.checkEmptyValue(params[:count]) : 20\n @count = @count.to_i > 200 ? 200 : @count\n @since_id = params.has_key?(:since_id) ? ApplicationHelper.checkEmptyValue(params[:since_id]) : 0\n @max_id = params.has_key?(:max_id) ? ApplicationHelper.checkEmptyValue(params[:max_id]) : -1\n @order = \"DESC\"\n @recipient_id = params.has_key?(:user_id) ? params[:user_id] : nil\n\n puts \"USER_ID = #{@recipient_id}\"\n\n\n if (params.has_key?(:since_id))\n @query = \"id > #{@since_id}\"\n @order = \"ASC\"\n elsif (params.has_key?(:max_id))\n @query = \"id < #{@max_id}\"\n else\n @query = nil\n end\n\n @user_id = get_auth_token_user_id()\n\n if (!@recipient_id.nil?)\n @conversations = Conversation.where(\"creator_id = ? and recipient_id = ? or creator_id = ? and recipient_id = ?\", @recipient_id, @user_id, @user_id, @recipient_id)\n .where(@query).order(\"id \" + @order).limit(@count)\n else\n @conversations = Conversation.where(\"creator_id = ? or recipient_id = ?\", @user_id, @user_id)\n .where(@query).order(\"id \" + @order).limit(@count)\n end\n\n @conversations = @order == \"ASC\" ? @conversations.reverse : @conversations\n @data = ApplicationHelper.jsonResponseFormat(0, \"success\", {:conversations => @conversations})\n format.json { render json: @data.as_json(:opt => \"index\",\n :params => request.protocol + request.host_with_port,\n :user_id => @user_id) }\n end\n end", "def system_conversations\n system.conversations\n end", "def get_specific_conversations usr, c_type \n conv_ids = Array.new\n convos = Conversation.get_conversations(usr)\n convos.find_each do |convo|\n convo.posts.find_each do |post|\n if (c_type == \"received\" && post.recipient_id == usr.id && post.recipient_status == 'active') ||\n (c_type == \"sent\" && post.user_id == usr.id && post.status == 'active')\n conv_ids << convo.id if usr_msg?(convo, usr); break\n end\n end\n end\n return convos.where([\"id in (?)\", conv_ids]).sort_by {|x| x.posts.last.created_at }.reverse \n end", "def index\n @user_chats = Chatroom.where(friendship_id: friendship_chats)\n @messages = Message.where(chatroom_id: @user_chats)\n end", "def show\n puts \"############ messages show ###############\"\n @message = current_user.messages.find_by_id(params[:id])\n if [email protected]?\n @conversations = @message.conversations.includes(:sender => [:profile, :profile_photo])\n\n @message_status = @message.message_statuses.find_by_user_id(current_user)\n latest_conversation = @message_status.start_at\n if @message_status.start_at == nil\n @conversations = @message.conversations.includes(:sender => [:profile, :profile_photo])\n else\n @conversations = @message.conversations.where(\"id > ?\", latest_conversation).includes(:sender => [:profile, :profile_photo])\n end\n if !@message_status.nil?\n if @message_status.status == MessageStatus::UNREAD\n @message_status.status = MessageStatus::READ\n @message_status.save!\n end\n else\n flash[:error] = \"Message is not found\"\n return redirect_to messages_path\n end\n @reply_conversation = Conversation.new\n @reply_conversation.content = nil\n else\n flash[:error] = \"Message is not found\"\n return redirect_to messages_path\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @message }\n end\n end", "def index\n @users = User.all.where(\"id != ?\", current_user.id)\n @conversations = Conversation.all\n @users = User.page(params[:page]).per(3)\n q_param = params[:q]\n @q = User.ransack q_param\n @users = @q.result.page\n end", "def set_conversation\n @conversation = Conversation.where(featured: true).find(params[:id])\n end", "def conversation\n @user = User.find(params[:id])\n @messages = Message.find(:all, :conditions => [\"((messages.user_id = #{current_user.id} and messages.receiver_id = #{params[:id]}) and messages.user_status != 'deleted') or ((messages.receiver_id = #{current_user.id} and messages.user_id = #{params[:id]}) and messages.receiver_status != 'deleted')\"], :order => \"created_at Desc\")\n for message in @messages\n if message.receiver_id == current_user.id\n message.update_attribute(:receiver_status, \"read\") if message.receiver_status == \"unread\"\n end\n end\n respond_to do |format|\n format.xml { render :xml => @messages }\n format.json { render :json => @messages }\n end\n end", "def conversation\n current_user_id = current_user.id\n other_user_id = params[:id]\n @messages = Message.get_conversation(current_user_id, other_user_id)\n render json: @messages\n end", "def index\n @conversations = Conversation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @conversations }\n end\n end", "def index\n @h = {}\n @user = []\n convo1 = Conversation.where(:sender_id => current_user.id)\n convo2 = Conversation.where(:recipient_id => current_user.id)\n convo1.each do |u|\n h1 = {}\n h1[\"id\"] = u.recipient_id\n messages = Message.where(:conversation_id => u.id).order(:created_at).last\n h1[\"time\"] = messages.created_at\n h1[\"message\"] = messages.body\n @user.push(u.recipient.username)\n @h[u.recipient.username] = h1\n end\n convo2.each do |u|\n if @h.key?(u.sender.username)\n messages = Message.where(:conversation_id => u.id).order(:created_at).last\n if messages.created_at > @h[u.sender.username][\"time\"]\n @h[u.sender.username][\"message\"] = messages.body\n end\n else\n h1={}\n h1[\"id\"] = u.sender_id\n messages = Message.where(:conversation_id => u.id).order(:created_at).last\n h1[\"time\"] = messages.created_at\n h1[\"message\"] = messages.body\n @user.push(u.sender.username)\n @h[u.sender.username] = h1\n end\n end\n @conversations = Conversation.all\n end", "def conversations\n Conversation.where(\"sender_id = ? or recipient_id = ?\",self.id,self.id)\n end", "def show\n unless params[:conversation_id]\n render json: { success: 'no', msg: 'not enough info' }\n return\n end\n if !Direct.exists?(conversation_id: params[:conversation_id]) & !Group.exists?(conversation_id: params[:conversation_id])\n render json: { success: 'no', msg: 'convo does not exist' }\n return\n end\n unless Message.exists?(conversation_id: params[:conversation_id])\n render json: { success: 'no', msg: 'no messages' }\n return\n end\n\n allMsgs = Array.new\n Message.where(conversation_id: params[:conversation_id]).find_each do |message|\n senderNickname = UserProfile.find_by(user_id: message.sender_id).nick_name\n senderEmail = User.find_by(user_id: message.sender_id).email\n output = { :conversation_id => message.conversation_id, :sender_nickname => senderNickname , :sender_email => senderEmail, :message_body => message.message_body, :updated_at => message.updated_at }\n\n allMsgs.push(output)\n end\n\n render json: { success: 'ok', messageList: allMsgs }\n end", "def list\n convos_for_json = []\n conversations = (Conversation.where(buyer_id: @current_user.id).all + Conversation.where(seller_id: @current_user.id).all).sort_by(&:updated_at).reverse!\n conversations.each do |conversation|\n other_user = conversation.seller\n is_seller = false\n if other_user.id == @current_user.id\n other_user = conversation.buyer\n is_seller = true\n end\n prev_message = conversation.messages.last\n convo_for_json = {\n id: conversation.id,\n user_id_of_other: other_user.id,\n username_of_other: other_user.username,\n first_name_of_other: other_user.first_name,\n last_name_of_other: other_user.last_name,\n is_seller: is_seller,\n\t\t num_unread: conversation.messages.count - ((is_seller)? conversation.seller_marker : conversation.buyer_marker),\n other_user: {\n id: other_user.id,\n username: other_user.username,\n first_name: other_user.first_name,\n last_name: other_user.last_name\n },\n offer: {\n id: conversation.offer.id,\n price: conversation.offer.price\n },\n product: {\n id: conversation.offer.product.id,\n product_name: conversation.offer.product.product_name,\n price: conversation.offer.product.price\n },\n prev_message: prev_message ? {\n user_id: prev_message.user_id,\n message: prev_message.message,\n created_at: prev_message.created_at\n } : nil\n }\n convos_for_json << convo_for_json\n end\n render status: 200, json: {conversations: convos_for_json}\n end", "def conversations\n object.conversations.map {|a| ConversationSerializer.new(a).as_json }\n end", "def set_user_conversation\n @user_conversation = UserConversation.find(params[:id])\n end", "def sent_messages\n @user = User.find(params[:id])\n @messages = Message.find(:all, :conditions => [\"(messages.user_id = #{current_user.id} and messages.receiver_id = #{@user.id}) and messages.user_status != 'deleted'\"], :order => \"created_at Desc\")\n respond_to do |format|\n format.xml { render :xml => @messages }\n format.json { render :json => @messages }\n end\n end", "def index\n @lier_private_message_users = LierPrivateMessageUser.all\n end", "def index\n @conversations = Conversation.all\n\n render json: @conversations\n end", "def show\n if user_signed_in?\n @message_has_been_sent = conversation_exist?\nend\n end", "def index\n @conversations = Conversation.by_tenant(current_agent.tenant).unresolved\n respond_with(@conversations, :methods => [:customer_display_name, :last_message_author_role,\n :last_message_author_display_name, :last_message_created_at,\n :last_message_text, :engaged_agent_name, :message_count])\n end", "def index\n @items = Item.all\n\n if params[:search]\n @items = Item.search(params[:search]).order(\"created_at DESC\")\n else\n @items = Item.all.order(\"created_at DESC\")\n end\n\n session[:conversations] ||= []\n\n @users = User.all.where.not(id: current_user)\n @conversations = Conversation.includes(:recipient, :messages)\n .find(session[:conversations])\n end", "def index\n @messages = Message.none_system_message.paginate(:all, :order => \"messages.sent_at DESC\", :page => params[:page], :per_page => 20)\n @sub_partial = \"/admin/messages/inbox\" \n render_list\n end", "def index\n @messages = Message.where(:to_user => current_user.id).order('id desc').paginate(:page => params[:page])\n @sent_messages = Message.where(:user_id => current_user.id).order('id desc').paginate(:page => params[:sent_page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @messages }\n end\n end", "def index_user\n\t\t@user_convos = Conversation.involving_user(params[:user_id])\n\t\trender_list_of_convos(@user_convos)\n\tend", "def show\n @conversations = @group.post_conversations.paginate(page: params[:page], per_page: 10)\n @conversation = Conversation.new\n end", "def conversation\n @messages = Message.get_conversation(current_user, params[:user_id])\n render json: @messages, each_serializer: MessageConversationSerializer\n end", "def particular_conversation\n @this_conversation = Conversation.find(params[:id])\n end", "def conversation\n @conversation ||= mailbox.conversations.find(params[:id])\n end", "def conversation\n @conversation ||= mailbox.conversations.find(params[:id])\n end", "def index\n @support_conversations = SupportConversation.participating(current_client).order('updated_at DESC')\n end", "def find_open_conversations()\n Conversation.find_open_conversations( @sms.to, @sms.from ).order( 'challenge_sent_at' )\n end", "def index\n if !user_signed_in?\n flash.alert = \"You must be logged in to use Messaging\"\n redirect_to root_path\n return\n elsif current_user.rolable.class.name != \"Charity\" && current_user.rolable.class.name != \"Business\"\n flash.alert = \"Messaging is available to Charities and Businesses only\"\n redirect_to root_path\n return\n end\n\n all_messages = (Message.where(\"user_received_id = \" + current_user.id.to_s + \" OR user_sent_id = \" + current_user.id.to_s)).order(:id)\n \n @friends = []\n \n # get people online\n @friends << User.where.not(rolable_type: \"Donor\").where(\"last_ping_time >= ? AND id != ?\", Time.current - 1.minutes, current_user.id) \n\n # get existing conversations\n all_messages.each do |x|\n if(x.user_received_id == current_user.id)\n @friends << User.find(x.user_sent_id) unless @friends.include?(User.find(x.user_sent_id))\n else\n @friends << User.find(x.user_received_id) unless @friends.include?(User.find(x.user_sent_id))\n end\n end\n\n # get people up to 10 total people\n if(@friends.count < 9) \n @friends << User.where.not(rolable_type: [\"Donor\", current_user.rolable_type]).where(\"last_ping_time <= ? or last_ping_time is null\", Time.current - 1.minutes).limit(10 - @friends.count)\n end\n\n @friends.flatten!\n @friends.uniq!\n @search_users = searchUsers()\n @last_message = all_messages.last()\n end", "def index\n @conversations = Conversation.participates(current_user).order(updated_at: \"DESC\")\n respond_to do |format|\n format.html\n format.js\n end\n end", "def show\n @users = User.all.where(\"followed_id != ?\", current_user.id)\n @users = User.all.where(\"id != ?\", current_user.id)\n @favorite = current_user.favorites.find_by(user_id: @user.id)\n @favorites_users = current_user.favorite_users\n @admission = @user.admissions\n @publications = Publication.all\n @conversations = Conversation.all.where(\"id != ?\", current_user.id)\n @messages = Message.all.where(\"id != ?\", current_user.id)\n if @messages.length > 5\n @over_five = true\n @messages = @messages[-5..-1]\n end\n\n if params[:m]\n @over_ten = false\n @messages = Message.all\n end\n\n if @messages.last\n if @messages.last.user_id != current_user.id\n @messages.last.read = true\n end\n end\n \n end", "def show\n @conversation = current_user.conversations.find(params[:conversation_id])\n render json: @conversation.as_json()\n end", "def show\n @conversation = Conversation.find(params[:id])\n\n if @conversation.postedByUser.present?\n @user = User.find(@conversation.postedByUser)\n end\n\n @assign_to_users = User.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conversation }\n end\n end", "def load_available_recipients\n @posts = ChapterPost.find(:all)\n @committees = Committee.find(:all)\n end", "def set_conversation\n @conversation = Conversation.find(params[:id])\n end", "def set_conversation\n @conversation = Conversation.find(params[:id])\n end", "def set_conversation\n @conversation = Conversation.find(params[:id])\n end", "def set_conversation\n @conversation = Conversation.find(params[:id])\n end", "def set_conversation\n @conversation = Conversation.find(params[:id])\n end", "def index\n @conversations = @pad.conversations\n @message = Message.new\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @conversations }\n end\n end", "def get_conversation(user)\n cnv = self.conversations.where(id: user.conversations.where(multiple_users_flag: false).select(:id), multiple_users_flag: false).first\n if cnv.nil?\n cnv = Conversation.create(cnv_users: [self.id, user.id], name: user.name, multiple_users_flag: false)\n end\n return cnv\n end", "def add_to_conversations\n session[:conversations] ||= []\n session[:conversations] << @conversation.id\n end", "def load_tailors\n\t\t@shop_name=params[:shop_name]\n\t\t@title=params[:title]\n\t\tuser = User.where(:user_type => \"tailor\", :shop_name => @shop_name, :title => @title).select(\"id\",\"username\",\"email\")\n\t\tif user.nil?\n\t\t\trender json: {message: \"No any tailor in this group\"}\n\t\telse\t\t\t\n\t\t \tdetails = []\n\t\t\tuser.each do |chat|\n\t\t\t\tdetails << { :id => chat.id, :type => chat.username, :email => chat.email}\n\t\t\tend\n\t\t\trender :json => details.to_json\t\n\t\tend\n\tend", "def index\n # @user = User.find(params[:user_id])\n # @communities = @user.communities\n @communities = Community.all\n end", "def conversations\n Conversation.where(\"sender_id = ? OR recipient_id = ?\", id,id)\n end", "def index\n @message_categories = current_user.message_categories\n end", "def index\n # @chat_messages = ChatMessage.all\n\n if params[:chat_room_id].present?\n @chat_room = ChatRoom.find(params[:chat_room_id])\n else\n if current_user.present?\n @user_chat_rooms = current_user.chat_rooms_as_sender + current_user.chat_rooms_as_reciever\n elsif current_super_admin.present?\n @user_chat_rooms = current_super_admin.chat_rooms_as_sender + current_super_admin.chat_rooms_as_reciever\n end \n @common_chat_rooms = @user_chat_rooms.select{ |cr| cr.senderable == @user || cr.recieverable == @user }\n if @common_chat_rooms.first.present?\n @chat_room = @common_chat_rooms.first\n else\n @chat_room = ChatRoom.create(senderable: current_user || current_super_admin, recieverable: @user )\n end\n end\n @chat_messages = @chat_room.chat_messages\n end", "def index\n list = current_user.chats.pluck :id\n\n options = filter_params\n options[:id] = filter_params[:id] == 'all' ? list : [filter_params[:id]]\n @messages = ChatMessage.filter options\n @messages = @messages.group_by(&:chat_id)\n end", "def sent_messages\n @user = current_user\n\t # retrieve all sent messages by the current user\n @sent_messages = @user.sent_messages.sort_by{|m| m.created_at}.reverse\n @unread_messages = Message.find(:all, :conditions => {:receiver_id => current_user.id, :unread => true})\n end", "def index\n @users = User.all\n @chats = Chat.all\n end", "def index\n @recipient_menus = RecipientMenu.all\n end", "def build_thread\n @private_messages = PrivateMessage.find_conversation(current_user,params[:id])\n end", "def find_conversation!\n if params[:receiver_id]\n @receiver = User.find_by(id: params[:receiver_id])\n @conversation = Conversation.between(current_user.id, @receiver.id)[0]\n if @conversation\n redirect_to conversation_personal_messages_path(@conversation)\n else\n @conversation = Conversation.create(params.permit(:author_id, :receiver_id))\n redirect_to conversation_personal_messages_path(@conversation)\n end\n else\n @conversation = Conversation.find_by(id: params[:conversation_id])\n # redirect_to(root_path) unless @conversation && @conversation.participates?(current_user)\n end\nend", "def saveConversations\n user = User.find(params[:id])\n conversation = Conversation.find_by_name(params[:conversation])\n\n userConversation = user.conversations.where(:name => conversation.name).first\n\n if userConversation.blank?\n user.conversations << conversation\n success = true\n else \n success = false\n end\n\n respond_to do |format|\n format.json {render :json => {:success => success}}\n end\n end", "def index\n @conversations = \n if params[:read].present? && params[:read] == \"true\"\n current_user.mailbox.inbox(:read => true)\n elsif params[:read].present? && params[:read] == \"false\"\n current_user.mailbox.inbox(:unread => true)\n else \n current_user.mailbox.inbox\n end.page(params[:page])\n \n respond_with(@conversations)\n end", "def games\n @users = User.all\n @conversation = Conversation.new\n end" ]
[ "0.6640121", "0.65178794", "0.63903695", "0.63703316", "0.63354474", "0.6295956", "0.6285403", "0.6263965", "0.62322944", "0.6191548", "0.61489576", "0.6141955", "0.61242044", "0.6079881", "0.60319126", "0.5969224", "0.5966668", "0.58922404", "0.586439", "0.5860623", "0.5853916", "0.5830465", "0.5786021", "0.57747287", "0.5752612", "0.57303095", "0.57291853", "0.5692158", "0.56589246", "0.56410563", "0.56339794", "0.560771", "0.56035066", "0.55851436", "0.55834866", "0.5581937", "0.5552471", "0.5537819", "0.553283", "0.55313015", "0.55294937", "0.54955673", "0.5468779", "0.5452502", "0.54331386", "0.5428297", "0.54249275", "0.54141736", "0.541349", "0.540697", "0.5404609", "0.53938425", "0.53931797", "0.53879446", "0.53657174", "0.5363632", "0.536252", "0.5360763", "0.53520423", "0.5350068", "0.5344376", "0.5342813", "0.53290606", "0.53259516", "0.5325598", "0.53245026", "0.53210837", "0.5313381", "0.53105646", "0.53105646", "0.53000337", "0.52962726", "0.52947646", "0.52851695", "0.52845234", "0.52804387", "0.5276798", "0.52668333", "0.52640307", "0.52640307", "0.52640307", "0.52640307", "0.52640307", "0.52631015", "0.52549756", "0.52317727", "0.52213955", "0.5220995", "0.52030426", "0.52025056", "0.52021074", "0.5197778", "0.5196806", "0.51901907", "0.518126", "0.5174408", "0.5174064", "0.51728326", "0.51719683", "0.51711285" ]
0.62607527
8
reference for passing array in params
def conversation_params params.require(:conversation).permit(:flat_id, flat_id_array: []) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getArray _args\n \"getArray _args;\" \n end", "def rewrite_param_values(array_params); end", "def params_array_from(raw_params); end", "def params=(_arg0); end", "def params=(_arg0); end", "def initialize(*args)\n params_init # paramable\n array_init(*args)\n end", "def splat_mth(*mult_arg)\n p mult_arg #it's array :) !\n p mult_arg.class\n p mult_arg.object_id\n mult_arg.map {|arg| }\n end", "def mutliplied(array)\nend", "def paramstype\n \"Array\"\n end", "def added(array)\nend", "def params=(_); end", "def parameters=(_arg0); end", "def array_converter(*args)\n \nend", "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 tricky_method_two(a_string_param, an_array_param)\n a_string_param << 'rutabaga'\n an_array_param = ['pumpkins', 'rutabaga']\n p a_string_param.object_id # 260\n p an_array_param.object_id # 300\nend", "def g *args # accept multiple arguments as an array\n\targs # returns an array\nend", "def double_array(array)\n # your code here\nend", "def params(*); {}; end", "def &(arr)\n raise 'Not Implemented'\n end", "def tricky_method_two(a_string_param, an_array_param)\n a_string_param << 'rutabaga'\n # Appends the given object to str/original object\n an_array_param = ['pumpkins', 'rutabaga']\n # Assigns a new object to local variable an_array_param (but not my_array)\nend", "def Array(p0) end", "def doubler(array)\n \nend", "def doubler(array)\n \nend", "def & arg\n IterableArray.new(@array & arg.to_a)\n end", "def build_array(param1, param2, param3)\n\t[param1, param2, param3]\nend", "def test_correct_encoding_for_array_params\n get :some_action, :an_array => [1, 2]\n assert_equal \"http://test.host/test/some_action?an_array[]=1&an_array[]=2\", @response.body\n assert_equal ActionController::Routing::PathSegment::Result, @request.query_parameters[:an_array].class\n end", "def bound_variable_arg(arg, conn)\n case arg\n when ArrayRow\n \"(#{arg.map{|v| bound_variable_array(v) if v}.join(',')})\"\n when HashRow\n arg.check_columns!\n \"(#{arg.values_at(*arg.columns).map{|v| bound_variable_array(v) if v}.join(',')})\"\n else\n super\n end\n end", "def argument_references(argument); end", "def method(*\r\n\ta)\r\nend", "def initialize(input_arr=[])\n @internal_arr = []\n \n # take the input_arr and pass each value to add \n input_arr.each{|new_ele| add(new_ele)}\n\n end", "def add_parameter array, params = MESSAGE\n a = []\n params.each do |param|\n a = a + array.collect {|element| element.clone + param}\n end\n a\n end", "def isArray _args\n \"isArray _args;\" \n end", "def name_array(name1, name2)\n real_name_array = [name1, name2]\n real_name_array\nend", "def params=(value); end", "def accept(evaluator)\n evaluator.array_ref_field(self)\n end", "def tricky_method_two(a_string_param, an_array_param)\n a_string_param << 'rutabaga' # modifies existing variable\n an_array_param = ['pumpkins', 'rutabaga'] # new variable -> no effect on my_array\nend", "def tricky_method_two(a_string_param, an_array_param)\n a_string_param << 'rutabaga'\n an_array_param = ['pumpkins', 'rutabaga']\nend", "def tricky_method_two(a_string_param, an_array_param)\n a_string_param << 'rutabaga'\n an_array_param = ['pumpkins', 'rutabaga']\nend", "def tricky_method_two(a_string_param, an_array_param)\n a_string_param << 'rutabaga'\n an_array_param = ['pumpkins', 'rutabaga']\nend", "def tricky_method_two(a_string_param, an_array_param)\n a_string_param << 'rutabaga'\n an_array_param = ['pumpkins', 'rutabaga']\nend", "def tricky_method_two(a_string_param, an_array_param)\n a_string_param << 'rutabaga'\n an_array_param = ['pumpkins', 'rutabaga']\nend", "def arguments=(_arg0); end", "def args(*) end", "def initialize(input_arr=[])\n @internal_arr = []\n input_arr.each {|ele| add ele}\n\n # Fill in the rest of the initialize method here.\n \n # What should you do with each element of the incoming array?\n end", "def tricky_method!(a_string_param, an_array_param)\n a_string_param << \", rutabega\"\n an_array_param << \"rutabega\"\nend", "def tricky_method_two(a_string_param, an_array_param)\n a_string_param << 'rutabaga' # Mutating the string\n an_array_param = ['pumpkins', 'rutabaga'] # Re-assigning a new array\nend", "def tricky_method!(a_string_param, an_array_param)\n a_string_param << \"rutabaga\"\n an_array_param << \"rutabaga\"\nend", "def call(v)\n _pg_array(v.array)\n end", "def hello\n @array = [1, 2, 3, 4]\n @id = params['id']\n @page = params[:page]\n end", "def args()\n #This is a stub, used for indexing\n end", "def param_array(keys)\n puts \"Entering param_array '#{@sy}'\" if DEBUG\n type = nil\n \n if @sy.type == TokenType::ARRAY_TOKEN\n next_token\n if @sy.type == TokenType::OF_TOKEN\n next_token\n type = param_type(keys | Array.follow)\n else\n error(\"Line #{@sy.line_number} expected 'of', but saw '#{@sy.text}'\", keys | Array.follow)\n end\n else\n error(\"Line #{@sy.line_number} expected 'array', but saw '#{@sy.text}'\", keys | Array.follow)\n end\n puts \"Leaving param_array '#{@sy}'\" if DEBUG\n \n TypeNode.new \"array of #{type.type}\"\n end", "def tricky_method_two(a_string_param, an_array_param)\n a_string_param << 'rutabaga' # string is mutated\n an_array_param = ['pumpkins', 'rutabaga'] # array is reassigned, hence not mutated\nend", "def array(name, options={})\n param(:array, name, options)\n end", "def accept(evaluator)\n evaluator.array_ref(self)\n end", "def pass_block(arr)\n yield arr\nend", "def initialize(input_arr=[])\n @internal_arr = []\n input_arr.each { |x| add x }\n # Fill in the rest of the initialize method here.\n # What should you do with each element of the incoming array?\n end", "def [](*args)\n self.to_a[*args]\n end", "def [](*args)\n self.to_a[*args]\n end", "def []=(*args); end", "def method(*a)\r\n\ta\r\nend", "def my_function(argument_a, argument_b, *args)\n puts argument_a\n puts argument_b\n p args.class.name # this is now an array\n puts args\nend", "def c(*list)\n list\nend", "def tricky_method_two(a_string_param, an_array_param)\n a_string_param << 'rutabaga' # \"pumpkinsrutabaga\"\n an_array_param = ['pumpkins', 'rutabaga'] # [\"pumpkins\", \"rutabaga\"]\nend", "def tricky_method(a_string_param, an_array_param)\n a_string_param += \"rutabaga\"\n an_array_param << \"rutabaga\"\n p a_string_param.object_id # 60\n p an_array_param.object_id # 80\nend", "def calls_array\n a = return_array\n a[1]\n end", "def not_so_tricky_method(string_param, array_param)\n string_param += \"rutabaga\"\n array_param += [\"rutabaga\"]\n\n return a_string_param, an_array_param\nend", "def args\n @args \n end", "def query_params=(_arg0); end", "def initialize(array)\n @array = array\n end", "def arbitrary_params( *args)\n args.each do |arg|\n puts arg\n end\n # other method of iterating through array\n # args.each { |arg| puts arg }\nend", "def args() return @args end", "def array_method(input)\n\treturn \"thanks for the sweet array!\"\nend", "def parameters=(_); end", "def method(*p1)\n\nend", "def **(p0) end", "def args=(_arg0); end", "def args=(_arg0); end", "def args=(_arg0); end", "def args=(_arg0); end", "def args=(_arg0); end", "def method(**a)\r\nend", "def fetch\n\t\t\t\t[self.[], @args]\n\t\t\tend", "def [](*rest) end", "def [](*rest) end", "def lcts(array)\nend" ]
[ "0.656562", "0.6534699", "0.6503011", "0.65019804", "0.65019804", "0.64515084", "0.6325931", "0.631942", "0.62071174", "0.61715233", "0.6159177", "0.61419606", "0.61369824", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123749", "0.6123162", "0.61220264", "0.61092335", "0.6104447", "0.606797", "0.5997819", "0.59914094", "0.5973398", "0.5973398", "0.5973228", "0.59048903", "0.59044236", "0.58837587", "0.5874486", "0.5861898", "0.58447933", "0.58382833", "0.5821901", "0.57967234", "0.5796155", "0.57832044", "0.57771593", "0.5772791", "0.5772791", "0.5772791", "0.5772791", "0.5772791", "0.57656467", "0.57622224", "0.57371366", "0.57343155", "0.57254726", "0.5724374", "0.572294", "0.5721247", "0.5714526", "0.57085955", "0.5700087", "0.5696278", "0.5692015", "0.56805557", "0.56734395", "0.5673356", "0.5673356", "0.5672675", "0.566897", "0.5668579", "0.56645805", "0.5651148", "0.5639083", "0.56325424", "0.56291723", "0.5616844", "0.56154287", "0.5613849", "0.56134033", "0.5610377", "0.5599834", "0.55981225", "0.5594678", "0.55916184", "0.55888784", "0.55888784", "0.55888784", "0.55888784", "0.55888784", "0.55872536", "0.55841124", "0.557428", "0.557428", "0.5568038" ]
0.0
-1
To prevent users from using something insecure like "Password" we make sure that the secret they've provided is at least 30 characters in length.
def ensure_secret_secure(secret) if secret.blank? raise ArgumentError, "A secret is required to generate an " + "integrity hash for cookie session data. Use " + "config.secret_token = \"some secret phrase of at " + "least #{SECRET_MIN_LENGTH} characters\"" + "in config/initializers/secret_token.rb" end if secret.length < SECRET_MIN_LENGTH raise ArgumentError, "Secret should be something secure, " + "like \"#{SecureRandom.hex(16)}\". The value you " + "provided, \"#{secret}\", is shorter than the minimum length " + "of #{SECRET_MIN_LENGTH} characters" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def secret_length\n @secret_length ||= 32\n end", "def friendly_secret\n self.class.friendly_secret(length)\n end", "def validate_secret(opt) # parse the title for the secret\n unless @secret.nil?\n (key, @secret) = @secret.split(/:\\s?/)\n @secret.strip!\n end\n if (@secret.nil? || @secret != opt)\n puts \"#{@subject}: Secret incorrect, skipping\"\n raise StandardError, \"Secret incorrect or missing\"\n end\n end", "def friendly_token(length=40)\n Pillowfort::Helpers::DeprecationHelper.warn(self.name, :friendly_token, :friendly_secret)\n friendly_secret(length)\n end", "def pick_secret_word\n\t\t@secret_word.length\n\tend", "def ensure_secret_secure(secret)\n # There's no way we can do this check if they've provided a proc for the\n # secret.\n return true if secret.is_a?(Proc)\n\n if secret.blank?\n raise ArgumentError, \"A secret is required to generate an \" +\n \"integrity hash for cookie session data. Use \" +\n \"config.action_controller.session = { :key => \" +\n \"\\\"_myapp_session\\\", :secret => \\\"some secret phrase of at \" +\n \"least #{SECRET_MIN_LENGTH} characters\\\" } \" +\n \"in config/environment.rb\"\n end\n\n if secret.length < SECRET_MIN_LENGTH\n raise ArgumentError, \"Secret should be something secure, \" +\n \"like \\\"#{ActiveSupport::SecureRandom.hex(16)}\\\". The value you \" +\n \"provided, \\\"#{secret}\\\", is shorter than the minimum length \" +\n \"of #{SECRET_MIN_LENGTH} characters\"\n end\n end", "def generate_secret\n rand(36**secret_length).to_s(36)\n end", "def check_secret\n fail 'Secret must be initialized' if @secret.nil?\n end", "def encrypt_secret\n return if @secret.to_s.empty?\n self.crypted_secret = Password.create(@secret)\n end", "def client_secret_privacy\n return nil if client_secret.nil?\n return \"*****\" if client_secret.length < 10\n \"*****#{client_secret.last(3)}\"\n end", "def update_secret\n o = [('a'..'z'), ('A'..'Z'), ('0'..'9')].map { |i| i.to_a }.flatten\n secret = (0...64).map{ o[rand(o.length)] }.join\n self.client_secret = Password.create(secret)\n self.save\n\n secret\n end", "def test_secret\n assert pass = Argon2::Password.create('mypassword', secret: \"A secret\")\n skip(\"The secret isn't kept on the Argon2::Password instance\")\n assert_equal pass.secret, \"A secret\"\n end", "def password_complexity\n if password.present? and not password.match(/\\A(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).*/)\n errors.add :password, I18n.t('weak_password')\n end\n end", "def secret\n \"whatamidoing\"\n end", "def secret\n @secret || ''\n end", "def generate_secret\n @secret = (1..4).map{ rand(10).to_s }.join \"\"\n @is_showing_secret = true\n return @secret\n end", "def secret\n decrypt_secret\n end", "def secret\n decrypt_secret\n end", "def test_length\n pw1 = \"Test1\"\n pw2 = \"Test2test\"\n\n assert_equal(false, StringChecker.is_safe_pw?(pw1)) # to short, min 8 character inputs\n assert_equal(true, StringChecker.is_safe_pw?(pw2))\n end", "def passphrase_length\n if @passphrase and @passphrase.length < 5\n errors.add(:passphrase, 'is too short (minimum is 5 characters)')\n end\n end", "def secret_generate\n Secret.generate\n end", "def secret_params\n params.require(:secret).permit(:body, :password, :expiration, :unlock_password)\n end", "def user_long_enough(user)\n if user.length <= 6 && user.length <= 6\n 'Sorry, username and password must be at least 6 characters.'\n else\n 'Yay, username and password are at least 6 characters.'\n end\nend", "def random_secret\n SecureRandom.base64(config.fetch(:vault, :pseudo_parameter_length, 15))\n end", "def generate_secret\r\n ActiveSupport::SecureRandom.hex(64)\r\n end", "def password_strength\n minimum_length = 8\n # Regex matches at least one lower case letter, one uppercase and one digit\n complexity_regex = /\\A(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])/\n # When a user is updated but not its password, the password param is nil\n if password.present? &&\n (password.length < minimum_length || !password.match(complexity_regex))\n errors.add :password, :weak_password\n end\n end", "def strong_password\n /^(?=.*\\d)(?=.*[a-z])(?=.*[\\W_]).{6,}$/i\n end", "def validate_password_length\n if @password.present? && @password.length < MIN_PASSWORD_LENGTH\n errors.add(:password, \"must be at least #{MIN_PASSWORD_LENGTH} characters\")\n end\n end", "def test_assert_that_password_with_5_chars_is_invalid\n\t\tpassword = \"hTi\"\n\t\tassert_equal(\"invalid\", set_up_password(password))\n\tend", "def validate_create_user(params)\n params[\"username\"].length < 25 and params[\"password\"].length < 25\n end", "def generate_secret\n self.password = self.class.generate_secret\n end", "def set_Secret(value)\n set_input(\"Secret\", value)\n end", "def set_Secret(value)\n set_input(\"Secret\", value)\n end", "def secret\n @secret or raise MissingSecret\n end", "def base32_secret(name, length=20)\n @manager.secrets.set(name, Base32.encode(Util::Secret.generate(length)), @node[:environment])\n end", "def password(length=20)\n SecureRandom.base64(length+2).tr('=', '')\n end", "def password_complexity\n if password.present? and not password.match('^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@$!%*?&#]).{8,}')\n errors.add :password, \"must include at least one lowercase letter, one uppercase letter,one Special Character and one digit\"\n end\n end", "def generate_two_factor_secret_if_missing!\n return unless otp_secret.nil?\n # update!(otp_secret: User.generate_otp_secret)\n end", "def password_complexity\n return if password.blank? || password =~ /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,20}$/\n\n errors.add :password, 'Password complexity requirement not met.'\n end", "def token_secret; end", "def token_secret; end", "def token_secret; end", "def secret_word=(word)\n @secret_word = word.upcase\n @secret_word_length = word.length\n end", "def password_valid\n @password.length >= 7 && (@password.include?(\"!\") || @password.include?(\"$\"))\n end", "def validate_password(input_string)\n password, rule = parse_input(input_string)\n\n # vjkjjcjjrjjmtnbjjjnj\n password_size =\n password.chars.filter { |char| char == rule.letter }.size\n\n rule.min <= password_size && password_size <= rule.max\nend", "def is_valid_passchars?(passphrase)\n words = passphrase.split(' ').map { |word| word.chars.sort.join('') }\n words.uniq.length == words.length\nend", "def test_rejects_password_of_7_characters\n result = valid_password?(\"1Abils&\")\n refute(result, \"'1ABils&' should be invalid because it only has 7 characters\")\n end", "def validate_password(password)\n return false unless password != nil\n if password.length < 4 || password.length > 19\n return false\n end\n return true\n end", "def valid_password?; end", "def validate_password(new_password)\n new_password.is_a?(String) && new_password.length >= 6 && new_password =~ /\\d/\n end", "def validate_password(new_password)\n new_password.is_a?(String) && new_password.length >= 6 && new_password =~ /\\d/\n end", "def is_valid_passphrase?(passphrase)\n words = passphrase.split(' ')\n words.uniq.length == words.length\nend", "def secret(name, length=32)\n @manager.secrets.set(name, Util::Secret.generate(length), @node[:environment])\n end", "def generate_two_factor_secret_if_missing!\n return unless otp_secret.nil?\n update!(otp_secret: User.generate_otp_secret)\n end", "def generate_two_factor_secret_if_missing!\n return unless otp_secret.nil?\n update!(otp_secret: User.generate_otp_secret)\n end", "def generate_two_factor_secret_if_missing!\n return unless otp_secret.nil?\n update!(otp_secret: User.generate_otp_secret)\n end", "def valid_password?(password); end", "def valid_api_key?(input_key)\n return false if encrypted_api_secret_key.blank?\n bcrypt = ::BCrypt::Password.new(encrypted_api_secret_key)\n key = ::BCrypt::Engine.hash_secret(\"#{input_key}#{User.pepper}\", bcrypt.salt)\n Devise.secure_compare(key, encrypted_api_secret_key)\n end", "def secret\n secret_value or raise 'secret is only available for new access keys'\n end", "def set_secret(opts)\n opts = check_params(opts,[:secrets])\n super(opts)\n end", "def secret_key\n \"\"\n end", "def standard_password\n \"!@Cd5678\"\n end", "def token_secret\n config_method_not_implemented\n end", "def validate_password(password)\n raise 'Password cannot be empty!' if password.empty?\n end", "def password_complexity\n # Regexp extracted from https://stackoverflow.com/questions/19605150/regex-for-password-must-contain-at-least-eight-characters-at-least-one-number-a\n return if password.blank? || password =~ /^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$/\n errors.add :password, ' must have the following requirements: password must be at least 8 character, with a capital letter, a number, and a special character'\n end", "def generate_password(length=6)\n chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ23456789'\n password = ''\n length.times { |i| password << chars[rand(chars.length)] }\n password\n end", "def check_password_contents\n if /[a-zA-Z]+/.match(@password) && /\\d+/.match(@password) && /[[:punct:]]/.match(@password)\n else\n generate\n end\n end", "def secret_key; end", "def password_required?; end", "def tell_secret_word_length\n @secret_word = @dictionary.sample\n @secret_word.length\n end", "def test_rejects_passwords_containing_forbidden_words\n result = valid_password?(\"1Abjpasswordils&a\")\n refute(result, \"'1Abjpasswordils&a' should be invalid because it contains 'password'\")\n end", "def getsecretword\r\n\t\t return @secretword\r\n\t\t end", "def password_complexity\n if password.present? and not password.match(/(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])/)\n errors.add :password, \"must include at least one lowercase letter, one uppercase letter, and one digit\"\n end\n end", "def random_password(size=10)\n random_string(size, :chars, 'ABCDEFGHJKLMNPQRSTUVWXYabcdefghkmnpqrstuvwxyz23456789#%^&$*i-_+=')\n end", "def value\n if show_secret\n secret\n else\n Digest::SHA1.hexdigest secret\n end\n end", "def creating_vault_validation_length(params)\n if params[\"Username\"].length > 0 and params[\"Password\"].length > 0\n return true\n else \n return false\n end \n end", "def validate_secret_strategies\n token_secret_strategy.validate_for(:token)\n application_secret_strategy.validate_for(:application)\n end", "def valid_password? password\r\n self.password === Digest::MD5.hexdigest(password)[0..19]\r\n end", "def encode_string_as_password_protected(encryptable_portion, pass = nil)\n pish = @password\n pish = pass unless pass.nil?\n raise \"error, password given was too long, must be 56 or less chars\" if pish.length > 56\n \n encrypted = Blowfish.encrypt(pish, encryptable_portion)\n \n encrypted\n end", "def secret\n\t\tputs \"This IS a secret\"\n\tend", "def consumer_secret\n config_method_not_implemented\n end", "def restricted_password\n return nil if game_state == 'active'\n\n password.word\n end", "def password_complexity\n\t\tif password.present? and not password.match(/(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).+/)\n\t\t\terrors.add(:password, \"must include at least one lowercase letter, one\" +\n\t\t\t\t\" uppercase letter, and one digit\")\n\t\tend\n\tend", "def load_secret_word\n @secret_word = File.readlines('5desk.txt').sample.downcase.strip\n until @secret_word.length > 5 && @secret_word.length < 12\n puts \"Choosing secret word...\"\n @secret_word = File.readlines('5desk.txt').sample.downcase.strip\n end\n @secret_display = %{#{\"_\" * @secret_word.length}} # change this to update based on previous guesses\n end", "def string_length(password)\n if password.size >= 10 && password.size < 17\n return 0\n else\n return password.size > 16 ? (16 - password.size) : 10 - password.size\n end\n end", "def server_secret\n base = (modpow(@user.verifier, u.hex) * aa.hex) % BIG_PRIME_N\n modpow(base, @b)\n end", "def exceeds_max_length?\n input.match(Patterns::ALPHABETICAL_PATTERN) && input.length > 15\n end", "def secret_params\n params.require(:secret).permit(:message, :key, :algorithm)\n end", "def test_5_rejects_password_of_7_characters\n result = at_least_eight_characters?(\"1Abils&\")\n refute(result, \"'1ABils&' has 7 characters, should be valid\")\n end", "def create_password(length)\n chars = ('a' .. 'z').to_a + ('1' .. '9').to_a + '%$?@!'.split(//)\n Array.new(length, '').collect { chars[rand(chars.size)] }.join\nend", "def password=(secret)\n if secret.present?\n @password = secret\n self.password_digest = BCrypt::Password.create(secret)\n end\n end", "def api_secret_field(value = nil)\n rw_config(:api_secret_field, value, first_column_to_exist(nil, :api_secret, :application_secret))\n end", "def mutate_bcrypt_password(_)\n '400$8$2d$f6ed5a490c441958$67f59aa61bc617849a3280b5e80f78607e53b5aa5807a44ddbc53e804e2e2a99'\n end", "def create_secret_token\n time = Time.now\n salt = rand(2048)\n random_string = \"#{url}#{time}#{salt}\"\n random_token = Digest::SHA256.hexdigest(random_string)\n secret_token = Base64.urlsafe_encode64(random_token.to_s)\n\n self.secret_token = secret_token\n end", "def password length=1\n '•' * length\n end", "def token_secret=(_arg0); end", "def token_secret=(_arg0); end", "def token_secret=(_arg0); end", "def random_password\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n password = ''\n #40.times { |i| password << chars[rand(chars.size-1)] }\n 15.times { |i| password << chars[rand(chars.size-1)] }\n self.password = password\n self.password_confirmation = password\n self.pwd = password\n self\n end", "def client_secret\n base = bb.hex\n # base += BIG_PRIME_N * @multiplier\n base -= modpow(GENERATOR, @user.private_key) * multiplier\n base = base % BIG_PRIME_N\n modpow(base, @user.private_key * u.hex + @a)\n end" ]
[ "0.7520606", "0.7257533", "0.70026004", "0.6868733", "0.6802432", "0.678343", "0.67611235", "0.6724692", "0.66394", "0.6613152", "0.6591436", "0.6514654", "0.6506961", "0.6505508", "0.6470401", "0.6457895", "0.6428709", "0.6428709", "0.6411107", "0.6401201", "0.6398188", "0.639398", "0.63932085", "0.6390362", "0.63548684", "0.63355047", "0.63313603", "0.6313123", "0.63025707", "0.6292915", "0.62786126", "0.6254143", "0.6254143", "0.6246871", "0.6245074", "0.62384176", "0.62281656", "0.62266743", "0.62251973", "0.6215498", "0.6215498", "0.6215498", "0.61676276", "0.61538047", "0.61385506", "0.6137318", "0.6113222", "0.6100617", "0.609614", "0.6093686", "0.6093686", "0.60932773", "0.60886776", "0.608498", "0.608498", "0.608498", "0.60821176", "0.6067153", "0.6065605", "0.60597026", "0.60449415", "0.60442156", "0.6030425", "0.6015539", "0.6011406", "0.6003958", "0.60038656", "0.5999344", "0.59961575", "0.5994954", "0.5981395", "0.5980957", "0.5977362", "0.5973578", "0.5955511", "0.5951555", "0.5926811", "0.5902763", "0.5891052", "0.588648", "0.5885374", "0.58828664", "0.5880461", "0.5877991", "0.587796", "0.5877129", "0.5870888", "0.5870628", "0.58486325", "0.5847556", "0.5844067", "0.584274", "0.58416736", "0.58403623", "0.58328354", "0.58215535", "0.58215535", "0.58215535", "0.5817297", "0.5814771" ]
0.72543395
2
Build an unbalanced tree from unsorted data
def build_tree_from_unsorted(arr) return nil if arr.empty? @root = Node.new(arr.shift) until arr.empty? child_node = Node.new(arr.shift) assign_children(@root, child_node) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_tree(data, node=self)\n data = data.sort\n build_bin_tree(data, 0, data.length - 1, node)\n end", "def build_tree(data)\n @root = Node.new(data[0])\n data.shift\n data.each { |value| @root.insert(value) }\n end", "def build_tree(data_array)\n root = nil\n \n data_array.each do |elem|\n cur_node = root\n \n node = Node.new(elem)\n\tnode.children = Array.new(2, nil)\n\t\n\twhile !cur_node.nil?\n\t if elem < cur_node.value\n\t if cur_node.children[0].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[0] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[0]\n\t else\n\t if cur_node.children[1].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[1] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[1]\n\t end\n\tend\n\t\n\troot ||= node\n\t \n end\n \n root\nend", "def build_tree_from_sorted(arr)\n return nil if arr.empty?\n left, right, middle = get_left_right_middle(arr)\n @root = Node.new(middle)\n make_children(@root, left)\n make_children(@root, right)\n end", "def build_tree_unsorted(arr)\n root = nil\n arr.each do |item|\n root = insert_tree(item, root)\n end\n\n root\nend", "def build_tree(ary)\n # If the array is sorted, the tree will not be balanced\n ary.shuffle!\n ary.each { |item| insert(item) }\n end", "def build_tree(arr)\n #arr.shuffle!\n arr.each do |x|\n if @root == nil\n @root = Node.new(x)\n else\n current_node = @root\n until current_node == nil\n if x < current_node.value\n parent = current_node\n direction = \"left\"\n current_node = current_node.left_child\n elsif x > current_node.value\n parent = current_node\n direction = \"right\"\n current_node = current_node.right_child\n end\n end\n if direction == \"left\"\n parent.left_child = Node.new(x)\n elsif direction == \"right\"\n parent.right_child = Node.new(x)\n end\n end\n end\n end", "def produce_tree(ary); end", "def build_tree(data_array)\n @root = nil # overwrites tree, even if array is empty\n data_array.each_with_index do |data, index|\n if index == 0\n @root = Node.new(data)\n else\n set_next_node(data)\n end\n end\n end", "def build_tree_2(data_array)\n root = nil\n \n data_array.each do |elem|\n node = insert_node(root, nil, elem) \n\troot ||= node\n end\n \n root\nend", "def build_tree(arr)\n @root = Node.new(arr.shift)\n arr.each { |data| insert_data(data, @root) }\n end", "def build_tree(data, par_node)\n return nil if data.empty?\n \n if @node.value <= par_node.value\n if par_node.left == nil\n par_node.left = @node\n else\n build_tree(data, par_node.left)\n end\n else\n if par_node.right == nil\n par_node.right = @node\n else\n build_tree(data, par_node.right)\n end\n end\n\n @node = Node.new(data.shift)\n build_tree(data, @root)\n end", "def build_tree(data, parent = nil)\n return if data.size.zero?\n center = half(data)\n value = data[center]\n @depth_first << value\n\n # Recusion to split halves until zero then execute logic\n build_tree(l_half = data[0...center], value)\n build_tree(r_half = data[center + 1..-1], value)\n\n # Node creation and set node properties\n l_child = l_half[half(l_half)]\n r_child = r_half[half(r_half)]\n Node.new(value, parent, l_child, r_child)\n end", "def build_tree(array)\n array.sort!.uniq!\n left = 0\n right = array.length\n\n return build_driver(array, left, right)\n end", "def build_tree( n , d )\n \n if d.key?('v')\n n < d['v'] ? build_tree(n , d['l']) : build_tree(n, d['r'])\n else\n d['l'] = {}\n d['v'] = n\n d['r'] = {}\n end\n \nend", "def build_tree(arr)\n #take array, turn into bt with node objs\n return nil if arr.empty?\n\n mid = (arr.size - 1)/2\n current_node = Node.new(arr[mid])\n\n current_node.left = build_tree(arr[0...mid])\n current_node.right = build_tree(arr[(mid+1)..-1])\n \n current_node\n end", "def build_tree(input_array)\n sorted_set = input_array.sort.uniq\n build_tree_aux(sorted_set, 0, sorted_set.length - 1)\n end", "def make_tree(pre, inord)\n return if pre.size == 0\n root_node = Node.new(pre[0])\n idx = inord.index(pre[0])\n root_node.left = make_tree(pre[1..idx], inord[0...idx])\n root_node.right = make_tree(pre[idx+1...pre.size], inord[idx+1...inord.size])\n return root_node\nend", "def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend", "def build_tree(arr)\n @root = insert_node(nil, arr.shift)\n arr.each { |value| insert_node(@root, value) }\n end", "def construct_tree(arr)\n root = TreeNode.new(arr.shift)\n xtd = [root]\n while !xtd.empty? && !arr.empty?\n cur_node = xtd.shift\n a, b = arr.shift(2) # doesn't matter if arr.size < 2. in this case, a, b might be nil\n cur_node.left = a.nil? ? nil : TreeNode.new(a)\n cur_node.right = b.nil? ? nil : TreeNode.new(b)\n xtd << cur_node.left unless cur_node.left.nil?\n xtd << cur_node.right unless cur_node.right.nil?\n end\n root\nend", "def build_tree(tree_size, input)\n nodes = Array.new(tree_size) { Node.new(nil, nil, nil) }\n\n tree_size.times do |i|\n line = input.next\n val, left, right = line.chomp.split.map(&:to_i)\n nodes[i].val = val\n nodes[i].left = nodes[left] unless left == -1\n nodes[i].right = nodes[right] unless right == -1\n end\n \n nodes.first\nend", "def build_tree(array)\n first_node = Node.new(nil, nil, array[0])\n this_node = first_node\n i = 1\n\n finished = false\n while !finished\n if array[i] == nil\n finished = true\n elsif array[i] < this_node.data\n if this_node.left_child == nil\n this_node.left_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.left_child\n end\n elsif array[i] > this_node.data\n if this_node.right_child == nil\n this_node.right_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.right_child\n end \n elsif array[i] == this_node.data\n i += 1\n end\n end\n return first_node\nend", "def buildTree(node,arr)\n node.value = arr.shift\n size = (arr.size/2.0).round\n if size > 0\n left, right = arr.each_slice( size ).to_a\n if left and left.count > 0\n node.left = TreeNode.new\n buildTree(node.left, left)\n end\n if right and right.count > 0\n node.right = TreeNode.new\n buildTree(node.right, right)\n end\n end\nend", "def build_tree(arr)\n\tend", "def mk_tree(ch_arr)\n\t# set up top node based on smallest 2 values\n\ttop = Node.new # initial top node; no values yet\n\tmins = min_vals(ch_arr, 2)\n\tputs mins[0], mins[1]\n\tputs ch_arr[mins[0]]\n\tputs ch_arr[mins[1]]\n\ttop.set_left(Node.new(ch_arr[mins[0]], mins[0]))\n\ttop.set_right(Node.new(ch_arr[mins[1]], mins[1]))\n\ttop.set_count(ch_arr[mins[0]] + ch_arr[mins[1]])\n\tch_arr.delete(mins[0])\n\tch_arr.delete(mins[1])\n\t# build tree based upon current top node and next smallest value; repeat until no values left in hash\n\twhile(ch_arr.length >= 1)\n\t\ttemp = Node.new # temporary new node; this will become the top node\n\t\tmin = min_vals(ch_arr, 1)\n\t\tputs min\n\t\tputs ch_arr[min]\n\t\t# if top node's value is less than lowest number, put it on left; otherwise, put it on right\n\t\t#puts top.get_count, ch_arr[min]\n\t\tif(top.get_count <= ch_arr[min])\n\t\t\ttemp.set_left(top)\n\t\t\ttemp.set_right(Node.new(ch_arr[min], min))\n\t\telse\n\t\t\ttemp.set_left(Node.new(ch_arr[min], min))\n\t\t\ttemp.set_right(top)\n\t\tend\n\t\ttemp.set_count(ch_arr[min] + top.get_count)\n\t\ttop = temp\n\t\tch_arr.delete(min)\n\tend\n\t# return reference to top node\n\treturn top\nend", "def build_tree(array)\n tree = TreeNode.new(array[0], 0)\n (1..array.length-1).each {|i|\n insert_into_tree(tree, array[i], i)\n }\n tree\nend", "def build_tree(array)\n\t\t@root = Node.new(array[0])\n\t\ttemp_root = @root\n\n\t\tarray[1..-1].each do |node_value|\n\t\t\tinsert_node(node_value, temp_root)\n\t\tend\n\tend", "def build_tree_unsorted(array)\n array.each_index{ |index|\n\n }\nend", "def build_tree(list)\n root = Node.new(list[0], nil)\n list[1...list.length].each do |item|\n current_node = root\n while !item.nil?\n if item > current_node.value\n if current_node.right_child.nil?\n current_node.right_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.right_child\n end\n elsif item < current_node.value\n if current_node.left_child.nil?\n current_node.left_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.left_child\n end\n else\n item = nil\n end\n end\n end\n root\nend", "def build_tree_arbitrary(arr)\n node = Node.new(arr[0])\n queue = [node]\n @root = node\n i = 0\n\n until queue.empty?\n node = queue.shift\n children = node_children(node, i, arr)\n queue.concat(children)\n i += 2\n end\n end", "def build_tree(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 build_tree_helper(arr)\n\treturn Node.new(arr[0]) if arr.size == 1\n\tnode = Node.new(arr.slice!(arr.size / 2))\n\ttree = build_tree(arr)\n\tuntil (node.value > tree.value && tree.right_child.nil?) || (node.value <= tree.value && tree.left_child.nil?)\n\t\ttree = node.value > tree.value ? tree.right_child : tree.left_child\n\tend\n\tif node.value > tree.value\n\t\ttree.right_child = node\n\t\tnode.parent = tree\n\telse\n\t\ttree.left_child = node\n\t\tnode.parent = tree\n\tend\nend", "def build_tree array\n\t\t@root = Node.new(array.shift)\n\t\tparent = @root\n\t\tarray.each do |el|\n\t\t\twhile true\n\t\t\t\tif el <= parent.value\n\t\t\t\t\tif parent.left_child.nil?\n\t\t\t\t\t\tparent.left_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.left_child\n\t\t\t\t\tend\n\t\t\t\telsif el > parent.value\n\t\t\t\t\tif parent.right_child.nil?\n\t\t\t\t\t\tparent.right_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.right_child\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def build_struct_tree data\n data.to_hashugar\n end", "def build_tree(array)\n return nil if array.empty?\n\n mid = (array.length - 1) / 2\n node = Node.new(array[mid])\n node.left = build_tree(array[0...mid])\n node.right = build_tree(array[mid+1..-1])\n node\n end", "def build_tree(item_list = @sorted_list,root_node = nil)\n #sorted root sorts and removes duplicates from the item list\n if (item_list[0] == nil)\n return nil\n else\n start = 0\n end_of_item_list = item_list.length - 1\n mid = (start + item_list.length) / 2\n #set the root node then start creating a tree node for the left and right side of the array\n #Then after that branch is created attach it to the correct position\n root_node = Node.new(item_list[item_list.length/2])\n root_node.right = build_tree(item_list[0,mid],root_node) \n root_node.left = build_tree(item_list[mid+1,end_of_item_list],root_node)\n return root_node\n end\n \n end", "def build_tree(preorder, inorder)\n return nil if preorder.empty? || inorder.empty?\n \n root = TreeNode.new(preorder.first)\n idx = inorder.find_index(preorder.first)\n preorder.shift\n\n root.left = build_tree(preorder, inorder.slice(0..(idx-1))) unless idx==0\n root.right = build_tree(preorder, inorder.slice((idx+1)..-1)) if idx!=inorder.size-1\n \n return root\nend", "def build_tree(array)\n\t\t@root = Node.new(array.shift)\n\t\tarray.each { |value| add_node(value, @root)}\n\tend", "def build_tree(sorted_array)\n return if sorted_array.length.zero?\n\n return Node.new(sorted_array[0]) if sorted_array.length == 1\n\n midpoint = (sorted_array.length - 1) / 2\n subtree_root = Node.new(sorted_array[midpoint])\n # Don't include the root in the left subtree.\n subtree_root.left = build_tree(sorted_array[0...midpoint])\n subtree_root.right = build_tree(sorted_array[midpoint + 1..-1])\n\n subtree_root\n end", "def build_tree(preorder, inorder)\n return nil if preorder.empty? && inorder.empty?\n\n array = []\n\n node = Node.new(preorder.first)\n\n array << preorder.first\n\n idx = inorder.index(preorder.first)\n\n left_inorder = inorder[0...idx]\n right_inorder = inorder[(idx+1)..-1]\n\n left_preorder = preorder & left_inorder\n right_preorder = preorder & right_inorder\n\n node.left = build_tree(left_preorder, left_inorder)\n node.right = build_tree(right_preorder, right_inorder)\n\n node\nend", "def build_tree(arr)\n if arr.empty?\n return nil\n end\n\n mid = arr.length/2\n root = Node.new(arr[mid])\n\n root.left = build_tree(arr[0...mid])\n root.right = build_tree(arr[(mid+1)..-1])\n\n root\nend", "def build_tree_rec(preorder, inorder)\n if inorder.length != 0\n original = preorder.shift\n ind = inorder.index(original)\n root = TreeNode.new(inorder[ind])\n root.left = build_tree(preorder, inorder[0...ind])\n root.right = build_tree(preorder, inorder[ind + 1..-1])\n root\n end\nend", "def build_tree(array, left=0, right=array.length-1)\n \n# base case\n return if left > right\n\n# from smallest to largest\n array = merge_sort(array)\n\n# middle index, make this the first node\n index_mid = left + (right-left) / 2 \n node = Node.new(array[index_mid]) \n \n# i think it's making the left node (smaller), & right (larger)\n# looks like it is recursion\n node.left_child = build_tree(array, left, index_mid-1) \n node.right_child = build_tree(array, index_mid+1, right) \n\n @tree = node\n @tree\n end", "def make_binary_tree(sorted_array)\n if sorted_array.length == 0\n return nil\n elsif sorted_array.length == 1\n return TreeNode.new(sorted_array[0])\n end\n divide_index = sorted_array.length / 2\n tree_node = TreeNode.new(sorted_array[divide_index])\n tree_node.left = make_binary_tree(sorted_array[0..divide_index-1])\n tree_node.right = make_binary_tree(sorted_array[divide_index+1..sorted_array.length-1])\n return tree_node\nend", "def build_from_data(data)\n data.each do |list_data|\n adjacent_list = AdjacentList.new\n list_data.reduce do |ele1, ele2|\n node2 = Node.new(ele2)\n\n if ele1.is_a?(Node)\n ele1.next_node = node2\n else\n node1 = Node.new(ele1, node2)\n adjacent_list.head_node = node1\n self.dict[node1.value] = self.adj_list_array.length\n end\n # return node2 to next reduce iteration\n node2\n end\n self.adj_list_array.push(adjacent_list)\n end\n end", "def build_tree(array)\n return nil if array.empty?\n \n middle = (array.size - 1) / 2\n root_node = Node.new(array[middle])\n \n root_node.left = build_tree(array[0...middle])\n root_node.right = build_tree(array[(middle + 1)..-1])\n \n root_node\n end", "def build_tree array\n\t\t@root = Node.new array[0]\n\t\t@nodes += 1\n\t\tarray[1..-1].each do |var|\n\t\t\tinsert(@root,var)\n\t\tend\n\tend", "def build_tree(inorder, postorder)\n return nil if inorder.empty?\n last_node_val = postorder.last\n last_node_index = inorder.index(last_node_val)\n node = TreeNode.new(last_node_val)\n \n if last_node_index > 0\n node.left = build_tree(inorder[0..last_node_index-1], postorder[0..last_node_index-1])\n end\n \n if last_node_index < inorder.length-1\n node.right = build_tree(inorder[last_node_index+1..-1], postorder[last_node_index..-2])\n end\n node\nend", "def build_tree(array)\n\t\t@root_node = Node.new(array[array.length / 2])\n\t\tarray[array.length / 2] = nil\n\t\tcounter = 0\n\t\tuntil counter == array.length\n\t\t\tset_value(array[counter], @root_node) if array[counter] != nil\n\t\t\tcounter += 1\n\t\tend\n\n\tend", "def build_tree(unit, node, level = 0)\r\n return nil if level > @max_depth\r\n \t\r\n unit.next_move(node.current_case).each do |next_case|\r\n next if next_case[0] < 0 || next_case[0] > 7 ||\r\n next_case[1] < 0 || next_case[1] > 7 \r\n \r\n next_node = Node.new(next_case, node)\r\n node.children << next_node\r\n\r\n build_tree(unit, next_node, level + 1)\r\n end \r\n end", "def create_bst(sorted_arr)\n\n return nil if sorted_arr.length == 0\n return BinaryNode.new(sorted_arr[0]) if sorted_arr.length == 1\n if sorted_arr.length == 2\n child = BinaryNode.new(sorted_arr[0])\n parent = BinaryNode.new(sorted_arr[1])\n parent.left = child\n return parent\n end\n\n middle = sorted_arr.length / 2\n left_start = 0\n left_end = (sorted_arr.length / 2) - 1\n right_start = left_end + 2\n right_end = sorted_arr.length\n\n cur_root = BinaryNode.new(sorted_arr[middle])\n cur_root.left = create_bst(sorted_arr[left_start..left_end])\n cur_root.right = create_bst(sorted_arr[right_start..right_end])\n\n return cur_root\n\nend", "def build_tree(values)\n return nil if values.length == 0\n\n middle = values.length / 2\n middle_value = values[middle]\n left = values.take(middle)\n right = values.drop(middle + 1)\n\n Node.new(middle_value, build_tree(left), build_tree(right))\n end", "def calc_tree\n tree = []\n n = 1\n while n <= @n\n result = []\n result = [[0, 1]] if n == 1\n tree.each do |row|\n line1 = []\n line2 = []\n row.each_with_index do |elem, i|\n line1 << \"#{elem}0\" if i.positive?\n line2 << \"#{elem}0\" if i.zero?\n line2 << \"#{elem}1\"\n end\n result << line1 unless row.count == 1\n result << line2\n end\n tree = result\n n += 1\n end\n tree\n end", "def build_tree_rec(inorder, postorder)\n if inorder.length != 0\n original = postorder.pop\n ind = inorder.index(original)\n root = TreeNode.new(inorder[ind])\n root.right = build_tree(inorder[ind + 1..-1], postorder)\n root.left = build_tree(inorder[0...ind], postorder)\n root\n end\nend", "def make_tree(in_list, pid = self.pid)\n [].tap do |top_level|\n left_over = []\n # Categorize into top level, or not top level\n in_list.each do |node|\n if node['parent_page_id'].blank? || node['parent_page_id'] == pid\n top_level.unshift node\n else\n left_over.unshift node\n end\n end\n\n # For each of the top_level nodes make a subtree with the leftovers.\n top_level.each do |node|\n node['children'] = make_tree(left_over, node['id'])\n end\n end\n end", "def build_tree(arr, root, i, n)\n\tif i < n\n\t\troot = TreeNode.new(arr[i])\n\t\troot.left = build_tree(arr, root.left, i*2+1, n)\n\t\troot.right = build_tree(arr, root.right, i*2+2, n)\n\tend\n\treturn root\nend", "def build_tree(arr, start_index = 0, end_index = arr.length - 1)\n return nil if start_index > end_index\n\n mid = (start_index + end_index) / 2\n curr_root = arr[mid].is_a?(Node) ? arr[mid] : Node.new(arr[mid])\n curr_root.left = build_tree(arr, start_index, mid - 1)\n curr_root.right = build_tree(arr, mid + 1, end_index)\n curr_root\n end", "def get_all_trees_from_preorder(array, start=0, end_index=array.size-1)\n #Pre-order visits root first. So 1st element is always root of the tree. next element could be left or right\n #Form all trees with next element being its left, then trees with next element as its right etc.\n # [1,2,3,4] => Use DP approach, bottom up approach. Go all the way down to last 2 nodes\n # 3 3\n # 4 and 4\n # Now 2 can be added as the root and left could be 3 and right could be 3\n # 4 4\n # And follow this till root\n if (start == array.size-1)\n return [Node.new(array[start])]\n end\n results = []\n trees = get_all_trees_from_preorder(array, start+1, end_index-1)\n trees.each do |tree|\n node1 = Node.new(array[start])\n node1.left = tree\n results << node1\n node2 = Node.new(array[start])\n node2.right = tree\n results << node2\n end\n results\nend", "def generate_tree\n root =\tTreeNode.new(3)\n root.left =\tTreeNode.new(9)\n right = \t\tTreeNode.new(20)\n right.left = \tTreeNode.new(15)\n right.right = TreeNode.new(7)\n root.right = \tright\n root\nend", "def build_tree(elements)\n return if elements.empty?\n char = elements.shift\n node = BinaryTree.new(char)\n if char == \"I\"\n node.left = build_tree(elements)\n node.right = build_tree(elements)\n end\n return node\nend", "def data_shapes tree\n acc = Array.new(MAX_DIM + 1) { [] }\n min_level = MAX_DIM + 1\n max_level = 0\n minmax = [min_level, max_level]\n\n search max_level, tree, acc, minmax\n\n min_level = minmax[0]\n max_level = minmax[1]\n\n if acc[max_level] && acc[max_level].all? { |a| a.nil? }\n # min_level is not set in this special case. Hence the check.\n elsif min_level != max_level\n raise ValueError, \"unbalanced tree: min depth #{min_level} and max depth #{max_level}\"\n end\n\n data = acc[max_level]\n shapes = acc[0...max_level].reverse\n\n [data, shapes]\n end", "def n_ary_trees(range=2..2, minimize=true)\n raise \"Range parameter expected\" unless range.is_a? Range\n min = range.first.to_i\n raise \"minimum branches must be at least 2\" unless min > 1\n max = range.last.to_i\n max -= 1 if range.exclude_end?\n raise \"maximum branches less than minimum branches\" if max < min\n return [] if empty?\n\n # a lambda so we can do recursion without sticking private methods in Array\n\n # all n-way branches of a\n nwb = -> (a, n) do\n n = a.length if n > a.length\n if n == 1\n [a]\n else\n rv = []\n (1..( a.length - n + 1 )).each do |i|\n a1 = a[0...i]\n r = n - 1\n nwb.call( a[i..-1], r ).each do |branches|\n branches = [branches] if r == 1\n rv << [a1.dup] + branches\n end\n end\n rv\n end\n end\n\n # faux method for recursively making n-ary trees\n nt = -> (a) do\n if a.length <= min\n [a]\n else\n rv = []\n (min..( a.length < max ? a.length : max )).each do |branchiness|\n nwb.call( a, branchiness ).each do |part|\n head, *tail = part.map{ |a2| nt.call a2 }\n if tail.any?\n head = head.map{ |t| [t] }\n tail.each do |nxt|\n h = []\n head.each do |a1|\n nxt.each do |a2|\n h << a1 + [a2]\n end\n end\n head = h\n end\n end\n rv += head\n end\n end\n rv\n end\n end\n\n trees = nt.(self)\n\n if minimize\n m = -> (t) do\n if t.is_a? Array\n if t.length == 1\n m.call( t[0] )\n else\n t.map{ |t2| m.call t2 }\n end\n else\n t\n end\n end\n\n m.call trees\n else\n trees\n end\n end", "def build_tree\n c1 = ComponentNode.new(110)\n c2 = ComponentNode.new(20)\n c3 = ComponentNode.new(20)\n c4 = ComponentNode.new(150)\n c5 = ComponentNode.new(80)\n c6 = ComponentNode.new(120, [c1, c2, c3])\n c7 = ComponentNode.new(180, [c4, c5])\n return(ComponentNode.new(200, [c6, c7]))\n end", "def build_tree( arr, first_index = 0, last_index = arr.length - 1 )\n return nil if first_index > last_index\n \n middle_of_array = (first_index + last_index)/2\n \n root = Node.new(arr[middle_of_array])\n \n root.left_child = build_tree(arr, first_index, middle_of_array - 1)\n root.right_child = build_tree(arr, middle_of_array + 1, last_index)\n \n return root \n end", "def rebalance\n order = self.level_order\n return build_tree(order)\n end", "def reconstruct_bst_from_traversal(pre_order)\n reconstruct_bst_rec(0, pre_order.length - 1, pre_order)\nend", "def initialize(arr)\n @value = arr.sort.uniq\n @root = build_tree(value)\n end", "def array_to_bst(array, l, r, parent=nil, d=1)\n return if l > r\n mid = (l + r)/2\n node = Node.new(array[mid], nil, nil, nil, d)\n node.l = array_to_bst(array, l, mid - 1, node, d + 1)\n node.r = array_to_bst(array, mid + 1, r, node, d + 1)\n node.parent = parent\n node\n end", "def build_tree\n index = 0\n @ignore_list.each do |attribute|\n #puts \"Attribute: #{attribute}\"\n #puts \"Result: #{@max_result_array[index]}\"\n #puts \"Count: #{@max_class_count_array[index]}\"\n\n @max_class_count_array[index].each do |label, count|\n isLeaf = false\n result = nil\n #puts \"Label: #{label}, Count: #{count}\"\n c1_count = count['<=50K.']\n c2_count = count['>50K.']\n ratio_a = c1_count.to_f / c2_count.to_f\n ratio_b = c2_count.to_f / c1_count.to_f\n #puts \"ratio_a: #{ratio_a} || ratio_b: #{ratio_b} || c1: #{c1_count} || c2: #{c2_count}\"\n if ratio_a >= 30 or ratio_b >= 30 then\n # Have a high ratio, thus we can declare a class\n if c1_count > c2_count\n # declare class 1\n #puts \"Ratio is HIGH, #{ratio_a}, declare any #{attribute} with a #{label} to be class <=50K.\"\n isLeaf = true\n result = '<=50k'\n else\n #puts \"Ratio B is HIGH, #{ratio_b}, declare any #{attribute} with a #{label} to be class >50K.\"\n isLeaf = true\n result = '>50k'\n end\n else\n #puts \"Ratio is too LOW for #{attribute} with label #{label}.\"\n end\n\n if index == 0 then parent = nil else parent = @ignore_list[index-1] end\n\n if isLeaf then\n @tree[label] = Hash['attribute' => attribute, 'label' => label, 'isLeaf' => isLeaf, 'result' => result, 'child' => nil, 'parent' => parent]\n else\n @tree[label] = Hash['attribute' => attribute, 'label' => label, 'isLeaf' => isLeaf, 'result' => result, 'child' => @ignore_list[index+1], 'parent' => parent]\n end\n\n end\n index += 1\n end\n\n @tree.each { |node| puts node }\n end", "def insert(data)\n node = Node.new(data)\n\n if @size == 0\n @root = node\n else\n parent = @root\n\n loop do\n if data <= parent.value\n if !parent.left # found a leaf node\n parent.left = node # insert here\n break\n else\n parent = parent.left\n end\n else # data > node.value\n if !parent.right # found a leaf node\n parent.right = node # insert here\n break\n else\n parent = parent.right\n end\n end\n end\n end\n\n @size += 1\n end", "def 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 buildTree( prefixArray )\n return nil if prefixArray.empty?\n value = prefixArray.pop\n if( root.nil? )\n @root = TreeNode.new(value, nil, nil)\n # the right child comes before left since prefixArray \n # is really a _stack_\n @root.rightChild = buildTree( prefixArray )\n @root.leftChild = buildTree( prefixArray )\n elsif( isOp?(value) )\n newNode = TreeNode.new(value, nil, nil)\n newNode.rightChild = buildTree( prefixArray )\n newNode.leftChild = buildTree( prefixArray )\n return newNode\n else\n return TreeNode.new(value, nil, nil)\n end\n end", "def create_tree(start_tile)\n queue = [start_tile]\n visited.add(start_tile.pos)\n\n while !queue.empty?\n cur_tile = queue.shift\n tiles = adjacent_tiles(cur_tile.pos)\n\n tiles.each do |tile_pos|\n tile = self[tile_pos]\n tile.parent = cur_tile\n queue.push(tile)\n visited.add(tile.pos)\n end\n end\n start_tile\n end", "def rebalance!\n # Short-circut if already balanced.\n return @root if balanced?\n\n @root = build_tree(inorder)\n end", "def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend", "def build_hierarchy\n root = LetterNode.new(nil)\n\n # TODO: Limit word table to 50,000 highest ranking words\n\n words.each do |word|\n wl = root\n word.spelling.each_char do |letter|\n wl = wl.add(letter, word.count)\n end\n wl.word!(word.count)\n end\n\n root\n end", "def build_tree_node(l, u) \n return TreeNode.new(l, u, nil, nil) if l == u\n \n half_it = ((u - l) + 1) / 2\n if half_it <= 1\n TreeNode.new(l,\n u,\n build_tree_node(l, l),\n build_tree_node(u, u)\n )\n else\n TreeNode.new(\n l,\n u,\n build_tree_node(l, l + half_it-1),\n build_tree_node(u-half_it+1, u)\n )\n end\nend", "def rebalance\n @root = build_tree(self.level_order_traversal) if !self.balanced?\n end", "def generate_unique_bst_supp(unique_bst_arr, input_arr, start_index, end_index)\n if start_index > end_index\n unique_bst_arr << nil\n return\n end\n i = start_index\n while i <= end_index\n left_nodes_arr, right_nodes_arr = [], []\n generate_unique_bst_supp(left_nodes_arr, input_arr, start_index, i-1)\n generate_unique_bst_supp(right_nodes_arr, input_arr, i+1, end_index)\n (0..(left_nodes_arr.length-1)).each do |left_index|\n (0..right_nodes_arr.length-1).each do |right_index|\n node = ::BinaryTree::Node.new\n node.value = input_arr[i]\n node.left = left_nodes_arr[left_index]\n node.left.parent = node unless node.left.nil?\n node.right = right_nodes_arr[right_index]\n node.right.parent = node unless node.right.nil?\n unique_bst_arr << node\n end\n end\n i += 1\n end\n end", "def gen_tree\n new_tree = {}\n node_list = {}\n @json_tree.each do |k, v|\n if v['child_of'].nil?\n # top\n new_tree[k] = v\n node_list[k] = new_tree[k]\n else\n parent = v['child_of']\n if v['condition'] == 'and'\n node_list[parent]['and'] ||= {}\n node_list[parent]['and'][k] = v\n node_list[k] = node_list[parent]['and'][k]\n elsif v['condition'] == 'or'\n node_list[parent]['or'] ||= {}\n node_list[parent]['or'][k] = v\n node_list[k] = node_list[parent]['or'][k]\n else\n # TODO: sink?\n node_list[parent]['or'] ||= {}\n node_list[parent]['or'][k] = v\n node_list[k] = node_list[parent]['or'][k]\n end\n end\n end\n\n @json_tree_type = 'tree'\n @json_tree = new_tree\n end", "def initialize(arr=[])\n @tree = []\n @tree.push(:dummy_head)\n 0.upto(arr.size-1) do |i|\n push(arr[i])\n end\n end", "def build_tree(start, finish, node = Node.new(start), queue = [node])\n @root = node\n\n until queue.index { |n| n.value == finish }\n node = queue.shift\n node.children = generate_move_nodes(node.value, finish)\n node.children.each { |c| queue << c }\n end\n end", "def tree\n @tree ||= build_tree\n end", "def create_binary_search_tree(size)\n\t\tarray_of_nums = (0..size).to_a.shuffle\n\t\tnew_tree = BinarySearchTree.new\n\t\tarray_of_nums.each do |num|\n\t\t\tnew_tree.insert(num)\n\t\tend\n\t\treturn new_tree\n\tend", "def tree=(data)\n @tree = HashWithIndifferentAccess.new(\n case data\n when Array\n hash_from_git(data)\n when Hash, HashWithIndifferentAccess\n data\n end\n )\n end", "def tree\n root = Node.new(1)\n root.left = Node.new(2)\n root.right = Node.new(3)\n root.left.left = Node.new(4)\n root.left.right = Node.new(5)\n root.right.left = Node.new(6)\n root.right.right = Node.new(7)\n root.right.right.right = Node.new(8)\n root\nend", "def build_tree_aux(input_array, start_index, stop_index)\n return nil if start_index > stop_index\n\n middle_index = (start_index + stop_index) / 2\n left_half = build_tree_aux(input_array, start_index, middle_index - 1)\n middle_value = input_array[middle_index]\n right_half = build_tree_aux(input_array, middle_index + 1, stop_index)\n Node.new(middle_value, left_half, right_half)\n end", "def build_tree\n t = RDTree.new\n t.add_node(0, DummyRoot)\n root = root_node_of\n t.add_edge(0, root.attributes[\"ID\"])\n do_build_tree(root, 1, t) \n t\n end", "def create_tree(node, elem, level, parent)\n node.level = level\n elemtype = check_type(elem[1])\n case elemtype\n when \"array\"\n node.kind = \"array\"\n node.arrsize = elem[1][\".array_size\"].to_i\n if elem[1].has_key?(\".subtype\") && elem[1][\".subtype\"].has_key?(\".members\")\n elem[1][\".subtype\"][\".members\"].each do |m|\n x = Tree.new(m[0], item_type(elem[1]), node)\n node.create_child(x)\n create_tree(x, m, level+1, node)\n end\n if elem[1][\".subtype\"].has_key?(\".type_or_id_name\")\n elem[1][\".subtype\"][\".type_or_id_name\"] =~ /\\((.+)\\): (\\w+)/\n node.s_u_name = $2.clone\n else\n node.s_u_name = \"__ANON__\"\n end\n node.basetype = node.data = elem[1][\".subtype\"][\".type\"].clone\n else\n subkind = check_type(elem[1][\".subtype\"])\n case subkind\n when \"enum\"\n node.basetype = \"enum\"\n node.data = {\".type\" => elem[1][\".subtype\"][\".type\"]}\n node.data[\".type_or_id_name\"] = elem[1][\".subtype\"][\".type_or_id_name\"]\n arr = []\n elem[1][\".subtype\"][\".values\"].each { |k,v| arr << [k,v] }\n node.data[\".values\"] = arr.clone\n node.data[\".values\"].sort! { |a,b| a[1] <=> b[1] }\n when \"numeric_ose\", \"boolean\"\n elem[1][\".subtype\"][\".type_or_id_name\"] =~ /\\((.+)\\): (\\w+)/\n node.basetype = $2.clone\n when \"native\", \"numeric_other\"\n node.basetype = \"OTHER\"\n node.data = {\".type\" => elem[1][\".subtype\"][\".type\"]}\n if elem[1][\".subtype\"].has_key?(\".signed\")\n node.data[\".signed\"] = elem[1][\".subtype\"][\".signed\"] \n end\n if elem[1][\".subtype\"].has_key?(\".type_or_id_name\")\n node.data[\".type_or_id_name\"] = elem[1][\".subtype\"][\".type_or_id_name\"]\n end\n end\n node.leaf = true\n end\n when \"struct\", \"union\"\n node.kind = elemtype\n if is_anon?(elem[1])\n node.s_u_name = \"__ANON__\"\n else\n node.s_u_name = item_name(elem[1])\n end\n elem[1][\".members\"].each do |m|\n x = Tree.new(m[0], item_type(elem[1]), node)\n node.create_child(x)\n create_tree(x, m, level+1, node)\n end\n when \"enum\"\n node.kind = \"enum\"\n node.basetype = \"enum\"\n node.s_u_name = item_name(elem[1])\n node.parent = parent\n node.leaf = true\n arr = []\n elem[1][\".values\"].each { |k,v| arr << [k,v] }\n node.data = arr.clone\n node.data.sort! { |a,b| a[1] <=> b[1] }\n when \"numeric_ose\"\n node.kind = \"numeric\"\n node.basetype = item_name(elem[1])\n node.parent = parent\n node.leaf = true\n when \"boolean\"\n node.kind = \"boolean\"\n node.basetype = item_name(elem[1])\n node.parent = parent\n node.leaf = true\n when \"native\", \"numeric_other\"\n node.kind = \"numeric\"\n node.basetype = \"OTHER\"\n node.data = {'.type' => elem[1][\".type\"]}\n node.data[\".signed\"] = elem[1][\".signed\"] if elem[1].has_key?(\".signed\")\n if elem[1].has_key?(\".type_or_id_name\")\n node.data[\".type_or_id_name\"] = elem[1][\".type_or_id_name\"]\n end\n node.parent = parent\n node.leaf = true\n else\n raise \"Node #{node.name} contains erroneous data\" \n end\n end", "def elegant_tree_by_levels(node)\n stack=[]\n stack.push node if node\n stack.each do |n|\n stack.push n.left if n.left\n stack.push n.right if n.right\n end\n stack.map! &:value\nend", "def balanced_binary_with_sorted_array(arr, min, max)\n return nil if min > max\n mid = (min + max) / 2\n # Always passes the next middle as next root, so the tree stays balanced.\n root = TreeNode.new(arr[mid])\n root.left = balanced_binary_with_sorted_array(arr, min, mid - 1)\n root.right = balanced_binary_with_sorted_array(arr, mid + 1, max)\n root\n end", "def create_tree_positions\n # Get the number of qualified participants from the tournament\n if tournament.rankings.empty?\n participants_number = tournament.max_participants\n else\n # Or from the number of qualified from last ranking\n participants_number = tournament.rankings[tournament.rankings.size - 1].qualified\n end\n\n special = false\n next_depth = participants_number\n special_falling = false\n (participants_number * 2 - 1).downto(1) do |pos|\n tree_positions.create(:position => pos, :special => special)\n if tree_type == DOUBLE\n if pos.even?\n tree_positions.create(:position => -pos, :special => false)\n tree_positions.create(:position => -pos, :special => true) if special_falling\n elsif special_falling and pos != 1\n tree_positions.create(:position => -pos, :special => true)\n end\n end\n if pos == next_depth\n special_falling = true\n special = !special\n next_depth /= 2\n end\n end\n end", "def build_tree(model)\n # inflate the node id to test id wrap around edge cases\n ENV[\"NODES\"].to_i.times { model.create!.destroy } if ENV[\"NODES\"]\n\n n1 = model.create!\n n2 = model.create!(:parent => n1)\n n3 = model.create!(:parent => n2)\n n4 = model.create!(:parent => n2)\n n5 = model.create!(:parent => n1)\n n6 = model.create!(:parent => n5)\n\n puts \"create: #{n1.id}..#{n6.id}\" if ENV[\"NODES\"]\n [n1, n2, n3, n4, n5, n6]\n end", "def huffTree(text)\r\n\t\tqueue = Array.new\r\n\t\tcount = countChars(text)\r\n\r\n\t\tcount.each do |char, freq|\r\n\t\t\tnode = Node.new(char, freq)\r\n\t\t\tqueue.push(node)\r\n\t\tend\r\n\t\tqueue.sort_by!{|ch| ch.freq}\r\n\r\n\t\twhile queue.size != 1\r\n\t\t\tnode = Node.new\r\n\t\t\tnode.left = queue.shift\r\n\t\t\tnode.right = queue.shift\r\n\t\t\tnode.freq = node.left.freq + node.right.freq\r\n\t\t\tqueue.push(node)\r\n\t\t\tqueue.sort_by!{|ch| ch.freq}\r\n\t\tend\r\n return queue[0]\r\n\tend", "def insert(data)\n current_node = @root\n if @root\n while current_node != nil\n if data < current_node.data && current_node.left == nil\n current_node.left = TreeNode.new(data)\n elsif data > current_node.data && current_node.right == nil\n current_node.right = TreeNode.new(data)\n elsif data < current_node.data\n current_node = current_node.left\n elsif data >= current_node.data\n current_node = current_node.right\n else\n return\n end\n end\n else\n @root = TreeNode.new(data)\n end\n end", "def build_parents(data)\n data.inject({}) do |h, d|\n (1...d.length).each { |i| h[d[i]] = d[0] }; h\n end\nend", "def build_score_tree\n tree_nodes = []\n root_node = nil\n\n @nodes.each do |n|\n if n['key'] == 1\n root_node = build_node_from_model(n)\n root_node['parent_id'] = 0\n else\n tree_nodes.push(build_node_from_model(n))\n end\n end\n\n node_list = { 1 => root_node }\n tree_nodes.each do |n|\n node_list[n['id']] = n\n node_list[n['parent_id']]['children'].push(node_list[n['id']])\n end\n root_node\n end", "def tree(n)\n SegmentTree.new list(n)\nend", "def solve\n if list_size.to_i == 1\n return BinaryTreeNode.new(@node.value), @node\n end\n\n left_tree, left_last_node = LinkedListToBSTConverter.new(@node, left_length).solve\n\n middle_node = left_last_node.next\n tree = BinaryTreeNode.new middle_node.value\n tree.left = left_tree\n\n if has_right_half?\n right_tree, right_last_node = LinkedListToBSTConverter.new(middle_node.next, right_length).solve\n tree.right = right_tree\n [tree, right_last_node]\n else\n [ tree, middle_node ]\n end\n end" ]
[ "0.78237903", "0.7754102", "0.761129", "0.7323377", "0.7283544", "0.7247971", "0.72393286", "0.7217896", "0.71982557", "0.7164551", "0.71630865", "0.7153899", "0.71277064", "0.70789814", "0.70767045", "0.70371664", "0.6996168", "0.6983732", "0.69540966", "0.69359505", "0.69289714", "0.690175", "0.689778", "0.6888616", "0.6874119", "0.68617487", "0.6835257", "0.6740933", "0.67378956", "0.67336035", "0.6729885", "0.6726261", "0.67155325", "0.6711048", "0.6704416", "0.6683451", "0.6656454", "0.6647823", "0.66440433", "0.6600135", "0.6587988", "0.65859616", "0.65560424", "0.6553513", "0.6553295", "0.6539212", "0.6497304", "0.6456133", "0.64455813", "0.64201987", "0.64004284", "0.6395302", "0.6393687", "0.6380842", "0.6370636", "0.63230973", "0.6300541", "0.6292095", "0.62841296", "0.62568945", "0.62455535", "0.6244621", "0.6218772", "0.6168178", "0.6139885", "0.6121697", "0.6118087", "0.6117349", "0.60995865", "0.60757494", "0.60606474", "0.6046201", "0.6035674", "0.5982378", "0.59634185", "0.59449947", "0.5941593", "0.59389985", "0.5938834", "0.5936609", "0.59313637", "0.5910864", "0.59039795", "0.58989835", "0.58872163", "0.58849305", "0.5872338", "0.5865844", "0.5862267", "0.58592254", "0.5840601", "0.58339787", "0.5808552", "0.5782725", "0.5766754", "0.57641834", "0.5747296", "0.57318944", "0.57140136", "0.57129717" ]
0.7492917
3
Build a tree from sorted data, setting the median as the root
def build_tree_from_sorted(arr) return nil if arr.empty? left, right, middle = get_left_right_middle(arr) @root = Node.new(middle) make_children(@root, left) make_children(@root, right) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_tree(data)\n @root = Node.new(data[0])\n data.shift\n data.each { |value| @root.insert(value) }\n end", "def build_tree(data, node=self)\n data = data.sort\n build_bin_tree(data, 0, data.length - 1, node)\n end", "def build_tree(data_array)\n root = nil\n \n data_array.each do |elem|\n cur_node = root\n \n node = Node.new(elem)\n\tnode.children = Array.new(2, nil)\n\t\n\twhile !cur_node.nil?\n\t if elem < cur_node.value\n\t if cur_node.children[0].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[0] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[0]\n\t else\n\t if cur_node.children[1].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[1] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[1]\n\t end\n\tend\n\t\n\troot ||= node\n\t \n end\n \n root\nend", "def mk_tree(ch_arr)\n\t# set up top node based on smallest 2 values\n\ttop = Node.new # initial top node; no values yet\n\tmins = min_vals(ch_arr, 2)\n\tputs mins[0], mins[1]\n\tputs ch_arr[mins[0]]\n\tputs ch_arr[mins[1]]\n\ttop.set_left(Node.new(ch_arr[mins[0]], mins[0]))\n\ttop.set_right(Node.new(ch_arr[mins[1]], mins[1]))\n\ttop.set_count(ch_arr[mins[0]] + ch_arr[mins[1]])\n\tch_arr.delete(mins[0])\n\tch_arr.delete(mins[1])\n\t# build tree based upon current top node and next smallest value; repeat until no values left in hash\n\twhile(ch_arr.length >= 1)\n\t\ttemp = Node.new # temporary new node; this will become the top node\n\t\tmin = min_vals(ch_arr, 1)\n\t\tputs min\n\t\tputs ch_arr[min]\n\t\t# if top node's value is less than lowest number, put it on left; otherwise, put it on right\n\t\t#puts top.get_count, ch_arr[min]\n\t\tif(top.get_count <= ch_arr[min])\n\t\t\ttemp.set_left(top)\n\t\t\ttemp.set_right(Node.new(ch_arr[min], min))\n\t\telse\n\t\t\ttemp.set_left(Node.new(ch_arr[min], min))\n\t\t\ttemp.set_right(top)\n\t\tend\n\t\ttemp.set_count(ch_arr[min] + top.get_count)\n\t\ttop = temp\n\t\tch_arr.delete(min)\n\tend\n\t# return reference to top node\n\treturn top\nend", "def build_tree(data, parent = nil)\n return if data.size.zero?\n center = half(data)\n value = data[center]\n @depth_first << value\n\n # Recusion to split halves until zero then execute logic\n build_tree(l_half = data[0...center], value)\n build_tree(r_half = data[center + 1..-1], value)\n\n # Node creation and set node properties\n l_child = l_half[half(l_half)]\n r_child = r_half[half(r_half)]\n Node.new(value, parent, l_child, r_child)\n end", "def build_tree(values)\n return nil if values.length == 0\n\n middle = values.length / 2\n middle_value = values[middle]\n left = values.take(middle)\n right = values.drop(middle + 1)\n\n Node.new(middle_value, build_tree(left), build_tree(right))\n end", "def build_tree_unsorted(arr)\n root = nil\n arr.each do |item|\n root = insert_tree(item, root)\n end\n\n root\nend", "def build_tree_from_unsorted(arr)\n return nil if arr.empty?\n @root = Node.new(arr.shift)\n\n until arr.empty?\n child_node = Node.new(arr.shift)\n assign_children(@root, child_node)\n end\n end", "def build_tree(ary)\n # If the array is sorted, the tree will not be balanced\n ary.shuffle!\n ary.each { |item| insert(item) }\n end", "def build_tree(data, par_node)\n return nil if data.empty?\n \n if @node.value <= par_node.value\n if par_node.left == nil\n par_node.left = @node\n else\n build_tree(data, par_node.left)\n end\n else\n if par_node.right == nil\n par_node.right = @node\n else\n build_tree(data, par_node.right)\n end\n end\n\n @node = Node.new(data.shift)\n build_tree(data, @root)\n end", "def build_tree(arr)\n #arr.shuffle!\n arr.each do |x|\n if @root == nil\n @root = Node.new(x)\n else\n current_node = @root\n until current_node == nil\n if x < current_node.value\n parent = current_node\n direction = \"left\"\n current_node = current_node.left_child\n elsif x > current_node.value\n parent = current_node\n direction = \"right\"\n current_node = current_node.right_child\n end\n end\n if direction == \"left\"\n parent.left_child = Node.new(x)\n elsif direction == \"right\"\n parent.right_child = Node.new(x)\n end\n end\n end\n end", "def build_tree(data_array)\n @root = nil # overwrites tree, even if array is empty\n data_array.each_with_index do |data, index|\n if index == 0\n @root = Node.new(data)\n else\n set_next_node(data)\n end\n end\n end", "def build_tree_2(data_array)\n root = nil\n \n data_array.each do |elem|\n node = insert_node(root, nil, elem) \n\troot ||= node\n end\n \n root\nend", "def build_tree(arr)\n @root = Node.new(arr.shift)\n arr.each { |data| insert_data(data, @root) }\n end", "def build_tree(list)\n root = Node.new(list[0], nil)\n list[1...list.length].each do |item|\n current_node = root\n while !item.nil?\n if item > current_node.value\n if current_node.right_child.nil?\n current_node.right_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.right_child\n end\n elsif item < current_node.value\n if current_node.left_child.nil?\n current_node.left_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.left_child\n end\n else\n item = nil\n end\n end\n end\n root\nend", "def build_tree(array, left=0, right=array.length-1)\n \n# base case\n return if left > right\n\n# from smallest to largest\n array = merge_sort(array)\n\n# middle index, make this the first node\n index_mid = left + (right-left) / 2 \n node = Node.new(array[index_mid]) \n \n# i think it's making the left node (smaller), & right (larger)\n# looks like it is recursion\n node.left_child = build_tree(array, left, index_mid-1) \n node.right_child = build_tree(array, index_mid+1, right) \n\n @tree = node\n @tree\n end", "def median_floor\n\t\tif self.size == 0\n \t\t \tnil\n \t\telse\n\t\t\tsorted = self.sort\n\t\t\tif sorted.size % 2 == 0\n\t\t\t\tsorted[(sorted.size / 2) - 1]\n\t\t\telse\n\t\t\t\tsorted[sorted.size / 2]\n\t\t\tend\n\t\tend\n\tend", "def build_tree_helper(arr)\n\treturn Node.new(arr[0]) if arr.size == 1\n\tnode = Node.new(arr.slice!(arr.size / 2))\n\ttree = build_tree(arr)\n\tuntil (node.value > tree.value && tree.right_child.nil?) || (node.value <= tree.value && tree.left_child.nil?)\n\t\ttree = node.value > tree.value ? tree.right_child : tree.left_child\n\tend\n\tif node.value > tree.value\n\t\ttree.right_child = node\n\t\tnode.parent = tree\n\telse\n\t\ttree.left_child = node\n\t\tnode.parent = tree\n\tend\nend", "def build_medoids_tree(metric)\n $stderr.puts \"Building medoids tree (metric = #{metric})\"\n db = query_db(metric)\n return unless File.size? db\n\n out_base = File.expand_path(dataset.name, home)\n ds_matrix = \"#{out_base}.txt\"\n ds_matrix_fh = File.open(ds_matrix, 'w')\n ds_matrix_fh.puts %w[a b value].join(\"\\t\")\n # Find all values in the database\n seq2 = []\n foreach_in_db(db, metric) do |r|\n seq2 << r[0]\n ds_matrix_fh.puts r[0, 3].join(\"\\t\")\n end\n # Find all values among visited datasets in ref_project\n ref_r = ref_project.result(\"#{metric}_distances\") or return\n Zlib::GzipReader.open(ref_r.file_path(:matrix)) do |fh|\n fh.each_line do |ln|\n r = ln.chomp.split(\"\\t\")\n next unless seq2.include?(r[1]) or seq2.include?(r[2])\n\n ds_matrix_fh.puts r[1, 3].join(\"\\t\")\n end\n end\n ds_matrix_fh.close\n ref_tree = File.expand_path('utils/ref-tree.R', MiGA::MiGA.root_path)\n `\"#{ref_tree}\" \"#{ds_matrix}\" \"#{out_base}\" \"#{dataset.name}\"`\n File.unlink ds_matrix\n end", "def build_tree(item_list = @sorted_list,root_node = nil)\n #sorted root sorts and removes duplicates from the item list\n if (item_list[0] == nil)\n return nil\n else\n start = 0\n end_of_item_list = item_list.length - 1\n mid = (start + item_list.length) / 2\n #set the root node then start creating a tree node for the left and right side of the array\n #Then after that branch is created attach it to the correct position\n root_node = Node.new(item_list[item_list.length/2])\n root_node.right = build_tree(item_list[0,mid],root_node) \n root_node.left = build_tree(item_list[mid+1,end_of_item_list],root_node)\n return root_node\n end\n \n end", "def median(data)\n data.sort!\n\n if(data.length % 2 != 0)\n p data[(data.length/2).to_i]\n else\n p ((data[data.length/2] + data[(data.length/2) - 1]).to_f / 2)\n end\nend", "def make_tree(pre, inord)\n return if pre.size == 0\n root_node = Node.new(pre[0])\n idx = inord.index(pre[0])\n root_node.left = make_tree(pre[1..idx], inord[0...idx])\n root_node.right = make_tree(pre[idx+1...pre.size], inord[idx+1...inord.size])\n return root_node\nend", "def build_tree(array)\n array.sort!.uniq!\n left = 0\n right = array.length\n\n return build_driver(array, left, right)\n end", "def build_tree(arr)\n @root = insert_node(nil, arr.shift)\n arr.each { |value| insert_node(@root, value) }\n end", "def build_tree(sorted_array)\n return if sorted_array.length.zero?\n\n return Node.new(sorted_array[0]) if sorted_array.length == 1\n\n midpoint = (sorted_array.length - 1) / 2\n subtree_root = Node.new(sorted_array[midpoint])\n # Don't include the root in the left subtree.\n subtree_root.left = build_tree(sorted_array[0...midpoint])\n subtree_root.right = build_tree(sorted_array[midpoint + 1..-1])\n\n subtree_root\n end", "def create_tree_helper(tree, list, first = 0, last = list.length - 1)\n # base case\n if first == last\n tree.add(first)\n return\n elsif first > last\n return\n end\n\n middle_node = (last + first) / 2\n tree.add(list[middle_node])\n create_tree_helper(tree, list, first, middle_node - 1)\n create_tree_helper(tree, list, first, middle_node + 1)\n end", "def find_median()\n if @lo.size > @hi.size\n @lo.peek\n else\n (@lo.peek + @hi.peek)/2.0\n end\n end", "def sort\n\n arr_len = @data.length\n start_build_idx = arr_len / 2 - 1 # The last half of the array is just leaves\n\n for i in (start_build_idx).downto(0)\n\n max_heapify(@data, arr_len, i) # Build the heap from the array\n end\n\n for i in (arr_len-1).downto(0)\n\n swap(@data, i, 0) # Move the current root to the end of the array\n max_heapify(@data, i, 0) # Heapify the remaining part of the array excluding the root which was just sorted to the end\n end\n\n puts(@data)\n end", "def median(data)\n data = data.sort\n len = data.length\n\n if len % 2 == 1\n return data[len/2]\n else\n return ((data[(len / 2) - 1] + data[len / 2]).to_f) / 2\n end\n end", "def median_maintain(array)\n max_heap = []\n min_heap = []\n if array[0] > array[1]\n max_heap = [array[1]]\n min_heap = [array[0]]\n else\n max_heap = [array[0]]\n min_heap = [array[1]]\n end\n m = [array[0], max_heap[0]]\n (2..array.count - 1).each do |i|\n if array[i] > max_heap[0]\n min_heap << array[i]\n balance_min(min_heap, min_heap.count - 1)\n if min_heap.count > max_heap.count + 1\n max_heap << min_heap[0]\n extract_min(min_heap)\n balance_max(max_heap, max_heap.count - 1)\n end\n else\n max_heap << array[i]\n balance_max(max_heap, max_heap.count - 1)\n if max_heap.count > min_heap.count + 1\n min_heap << max_heap[0]\n extract_max(max_heap)\n balance_min(min_heap, min_heap.count - 1)\n end\n end\n m << if max_heap.count == min_heap.count\n max_heap[0]\n elsif max_heap.count > min_heap.count\n max_heap[0]\n else\n min_heap[0]\n end\n end\n sum = 0\n (0..m.count - 1).each do |i|\n sum += m[i]\n end\n sum % 10_000\nend", "def build_tree(arr, start_index = 0, end_index = arr.length - 1)\n return nil if start_index > end_index\n\n mid = (start_index + end_index) / 2\n curr_root = arr[mid].is_a?(Node) ? arr[mid] : Node.new(arr[mid])\n curr_root.left = build_tree(arr, start_index, mid - 1)\n curr_root.right = build_tree(arr, mid + 1, end_index)\n curr_root\n end", "def build_tree array\n\t\t@root = Node.new(array.shift)\n\t\tparent = @root\n\t\tarray.each do |el|\n\t\t\twhile true\n\t\t\t\tif el <= parent.value\n\t\t\t\t\tif parent.left_child.nil?\n\t\t\t\t\t\tparent.left_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.left_child\n\t\t\t\t\tend\n\t\t\t\telsif el > parent.value\n\t\t\t\t\tif parent.right_child.nil?\n\t\t\t\t\t\tparent.right_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.right_child\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def build_tree(arr)\n #take array, turn into bt with node objs\n return nil if arr.empty?\n\n mid = (arr.size - 1)/2\n current_node = Node.new(arr[mid])\n\n current_node.left = build_tree(arr[0...mid])\n current_node.right = build_tree(arr[(mid+1)..-1])\n \n current_node\n end", "def build_tree(array)\n first_node = Node.new(nil, nil, array[0])\n this_node = first_node\n i = 1\n\n finished = false\n while !finished\n if array[i] == nil\n finished = true\n elsif array[i] < this_node.data\n if this_node.left_child == nil\n this_node.left_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.left_child\n end\n elsif array[i] > this_node.data\n if this_node.right_child == nil\n this_node.right_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.right_child\n end \n elsif array[i] == this_node.data\n i += 1\n end\n end\n return first_node\nend", "def build_tree(arr)\n if arr.empty?\n return nil\n end\n\n mid = arr.length/2\n root = Node.new(arr[mid])\n\n root.left = build_tree(arr[0...mid])\n root.right = build_tree(arr[(mid+1)..-1])\n\n root\nend", "def generate_tree\n root =\tTreeNode.new(3)\n root.left =\tTreeNode.new(9)\n right = \t\tTreeNode.new(20)\n right.left = \tTreeNode.new(15)\n right.right = TreeNode.new(7)\n root.right = \tright\n root\nend", "def median(already_sorted=false)\n return nil if empty?\n a = already_sorted ? self : sort\n m_pos = size / 2\n size % 2 == 1 ? a[m_pos] : (a[m_pos-1] + a[m_pos]).to_f / 2\n end", "def produce_tree(ary); end", "def build_tree(array)\n return nil if array.empty?\n \n middle = (array.size - 1) / 2\n root_node = Node.new(array[middle])\n \n root_node.left = build_tree(array[0...middle])\n root_node.right = build_tree(array[(middle + 1)..-1])\n \n root_node\n end", "def build_tree(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 median\n size==0 ? nil : ((0==self.size%2) ? sort[size/2-1,2].mean : sort[self.size/2].to_f)\n end", "def build_tree( arr, first_index = 0, last_index = arr.length - 1 )\n return nil if first_index > last_index\n \n middle_of_array = (first_index + last_index)/2\n \n root = Node.new(arr[middle_of_array])\n \n root.left_child = build_tree(arr, first_index, middle_of_array - 1)\n root.right_child = build_tree(arr, middle_of_array + 1, last_index)\n \n return root \n end", "def initialize(arr)\n @value = arr.sort.uniq\n @root = build_tree(value)\n end", "def median\n\t\tif self.size == 0\n \t\t \tnil\n \t\telse\n\t\t\tsorted = self.sort\n\t\t\tif sorted.size % 2 == 0\n\t\t\t\t(sorted[sorted.size / 2] + sorted[(sorted.size / 2) - 1]) / 2.0\n\t\t\telse\n\t\t\t\tsorted[sorted.size / 2]\n\t\t\tend\n\t\tend\n\tend", "def build_tree(array)\n return nil if array.empty?\n\n mid = (array.length - 1) / 2\n node = Node.new(array[mid])\n node.left = build_tree(array[0...mid])\n node.right = build_tree(array[mid+1..-1])\n node\n end", "def build_tree(array)\n\t\t@root_node = Node.new(array[array.length / 2])\n\t\tarray[array.length / 2] = nil\n\t\tcounter = 0\n\t\tuntil counter == array.length\n\t\t\tset_value(array[counter], @root_node) if array[counter] != nil\n\t\t\tcounter += 1\n\t\tend\n\n\tend", "def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend", "def make_binary_tree(sorted_array)\n if sorted_array.length == 0\n return nil\n elsif sorted_array.length == 1\n return TreeNode.new(sorted_array[0])\n end\n divide_index = sorted_array.length / 2\n tree_node = TreeNode.new(sorted_array[divide_index])\n tree_node.left = make_binary_tree(sorted_array[0..divide_index-1])\n tree_node.right = make_binary_tree(sorted_array[divide_index+1..sorted_array.length-1])\n return tree_node\nend", "def median\n sorted = @array.sort\n middle = ((@array.size + 1.0) / 2) - 1 # subscript of middle element of array, with .5 if there are two middle values\n if middle.floor == middle # middle is an integer\n sorted[middle]\n else\n (sorted[middle.floor] + sorted[middle.ceil]) / 2.0\n end\n end", "def find_median(arr)\n mid = arr.length / 2\n\n arr.sort_by { |obj| obj[:rating] }[mid][:name]\nend", "def build_tree(array)\n\t\t@root = Node.new(array.shift)\n\t\tarray.each { |value| add_node(value, @root)}\n\tend", "def build_tree(array)\n\t\t@root = Node.new(array[0])\n\t\ttemp_root = @root\n\n\t\tarray[1..-1].each do |node_value|\n\t\t\tinsert_node(node_value, temp_root)\n\t\tend\n\tend", "def build_tree( n , d )\n \n if d.key?('v')\n n < d['v'] ? build_tree(n , d['l']) : build_tree(n, d['r'])\n else\n d['l'] = {}\n d['v'] = n\n d['r'] = {}\n end\n \nend", "def build_tree_arbitrary(arr)\n node = Node.new(arr[0])\n queue = [node]\n @root = node\n i = 0\n\n until queue.empty?\n node = queue.shift\n children = node_children(node, i, arr)\n queue.concat(children)\n i += 2\n end\n end", "def median_ceil\n\t\tif self.size == 0\n \t\t \tnil\n \t\telse\n\t\t\tsorted = self.sort\n\t\t\tif sorted.size % 2 == 0\n\t\t\t\tsorted[sorted.size / 2]\n\t\t\telse\n\t\t\t\tsorted[sorted.size / 2]\n\t\t\tend\n\t\tend\n\tend", "def build_struct_tree data\n data.to_hashugar\n end", "def median(values)\n i = (values.size / 2) - 1\n values.sort[i]\n end", "def median(array)\nplace = array.sort\n #ordena el array de min a max\n\n size = place.length\n # te dice el numero de valores que ahi en el array\n #3\n #6\nmedia_parte1 = place[(size - 1)/2] \n #place[1]\n #5\n #place[2]\n #3\n media_parte2 = place[size / 2]\n # place[1]\n #5\n # place[3] \n #4\n media_parte3 = (media_parte1 + media_parte2) / 2.0\n # sumas el valor ( 5 + 5 ) / 2.0\n #5\n # suma el valor ( 3 + 4) / 2.0\n #3.5\nend", "def median(already_sorted = false)\n return nil if empty?\n\n ret = already_sorted ? self : sort\n m_pos = size / 2 # no to_f!\n size.odd? ? ret[m_pos] : ret[m_pos - 1..m_pos].mean\n end", "def median(already_sorted = false)\n return nil if empty?\n\n sort! unless already_sorted\n m_pos = size / 2 # no to_f!\n size.odd? ? self[m_pos] : self[m_pos - 1..m_pos].mean\n end", "def build_tree(start, finish, node = Node.new(start), queue = [node])\n @root = node\n\n until queue.index { |n| n.value == finish }\n node = queue.shift\n node.children = generate_move_nodes(node.value, finish)\n node.children.each { |c| queue << c }\n end\n end", "def buildTree(node,arr)\n node.value = arr.shift\n size = (arr.size/2.0).round\n if size > 0\n left, right = arr.each_slice( size ).to_a\n if left and left.count > 0\n node.left = TreeNode.new\n buildTree(node.left, left)\n end\n if right and right.count > 0\n node.right = TreeNode.new\n buildTree(node.right, right)\n end\n end\nend", "def build_tree_aux(input_array, start_index, stop_index)\n return nil if start_index > stop_index\n\n middle_index = (start_index + stop_index) / 2\n left_half = build_tree_aux(input_array, start_index, middle_index - 1)\n middle_value = input_array[middle_index]\n right_half = build_tree_aux(input_array, middle_index + 1, stop_index)\n Node.new(middle_value, left_half, right_half)\n end", "def build_tree(arr)\n\tend", "def insert(data)\n node = Node.new(data)\n\n if @size == 0\n @root = node\n else\n parent = @root\n\n loop do\n if data <= parent.value\n if !parent.left # found a leaf node\n parent.left = node # insert here\n break\n else\n parent = parent.left\n end\n else # data > node.value\n if !parent.right # found a leaf node\n parent.right = node # insert here\n break\n else\n parent = parent.right\n end\n end\n end\n end\n\n @size += 1\n end", "def insertUtil( parent, child, index, key)\n if (child.leaf == true)\n # Finds the location where new key will be inserted\n # by moving all keys greater than key to one place forward.\n i = child.n - 1\n while (i >= 0 && child.keys[i] > key)\n child.keys[i + 1] = child.keys[i]\n i -= 1\n end\n # Insert the new key at found location\n child.keys[i + 1] = key\n child.n += 1\n else\n i = 0\n # insert the node to the proper child.\n while (i < child.n && child.keys[i] < key) \n\t\t\t\ti += 1\n end\n self.insertUtil(child, child.arr[i], i, key)\n end\n if (child.n == self.max)\n # More nodes than allowed.\n # divide the child into two and then add the median to the parent.\n self.split(parent, child, index)\n end\n end", "def build_tree\n index = 0\n @ignore_list.each do |attribute|\n #puts \"Attribute: #{attribute}\"\n #puts \"Result: #{@max_result_array[index]}\"\n #puts \"Count: #{@max_class_count_array[index]}\"\n\n @max_class_count_array[index].each do |label, count|\n isLeaf = false\n result = nil\n #puts \"Label: #{label}, Count: #{count}\"\n c1_count = count['<=50K.']\n c2_count = count['>50K.']\n ratio_a = c1_count.to_f / c2_count.to_f\n ratio_b = c2_count.to_f / c1_count.to_f\n #puts \"ratio_a: #{ratio_a} || ratio_b: #{ratio_b} || c1: #{c1_count} || c2: #{c2_count}\"\n if ratio_a >= 30 or ratio_b >= 30 then\n # Have a high ratio, thus we can declare a class\n if c1_count > c2_count\n # declare class 1\n #puts \"Ratio is HIGH, #{ratio_a}, declare any #{attribute} with a #{label} to be class <=50K.\"\n isLeaf = true\n result = '<=50k'\n else\n #puts \"Ratio B is HIGH, #{ratio_b}, declare any #{attribute} with a #{label} to be class >50K.\"\n isLeaf = true\n result = '>50k'\n end\n else\n #puts \"Ratio is too LOW for #{attribute} with label #{label}.\"\n end\n\n if index == 0 then parent = nil else parent = @ignore_list[index-1] end\n\n if isLeaf then\n @tree[label] = Hash['attribute' => attribute, 'label' => label, 'isLeaf' => isLeaf, 'result' => result, 'child' => nil, 'parent' => parent]\n else\n @tree[label] = Hash['attribute' => attribute, 'label' => label, 'isLeaf' => isLeaf, 'result' => result, 'child' => @ignore_list[index+1], 'parent' => parent]\n end\n\n end\n index += 1\n end\n\n @tree.each { |node| puts node }\n end", "def median\n\t\tif self.length > 0\n\t\t\tsorted_values = self.digitize.sort\n\t\t\tlength = sorted_values.length\n\t\t\tif length.odd?\n\t\t\t\tsorted_values[length/2]\n\t\t\telse\n\t\t\t\t( sorted_values[length/2] + sorted_values[-1+length/2] ).to_f / 2\n\t\t\tend\n\t\telse\n\t\t\tnil\n\t\tend\n\tend", "def build_tree(input_array)\n sorted_set = input_array.sort.uniq\n build_tree_aux(sorted_set, 0, sorted_set.length - 1)\n end", "def collect_medians\n data = Hash.new\n @data.keys.each { |key|\n nums = @data[key].sort\n data[key] = [nums[nums.length/2]]\n }\n end", "def build_tree_unsorted(array)\n array.each_index{ |index|\n\n }\nend", "def custom_tree\n\t\t#if they haven't made a shrink range/trunk yet, make one for them\n\t\tif $shrink_range.empty?\n\t\t\t$shrink_Range = (4..6).to_a\n\t\tend\n\t\tif $trunk.empty?\n\t\t\t$trunk = (175..250).to_a\n\t\tend\n\t\t\n\t\t@shrink = \"0.#{$shrink_range[0]}\".to_f\n\t\t#Height is 600, so y is in (0,600)\n\t\t$angle_of_separation = (@window.mouse_y / 10).to_i #this gives max of 60 degree angle, min of 0 (line)\n\t\t\n\t\t@branches = []\n\t\t@branches << [ [[@x, Height - @bot_margin], [@x, Height - $trunk[0]]] ]\n\t\t#Width is 800, so x is in (0,800)\n\t\t$num_splits = (((@window.mouse_x) / 100).to_i)+2 #this gives max of 8+2=10 splits, min of 2\n\t\t\n\t\tputs \"This output is from Custom Tree\"\n\t\tputs \"Number of splits: #{$num_splits}\"\t\n\t\tputs \"Angle of separation: #{$angle_of_separation}\"\n\t\tputs \"Shrink range: #{$shrink_range[0]} to #{$shrink_range[$shrink_range.length-1]}\"\n\t\tputs \"Split range: #{$split_range}\"\t\t\n\t\tputs \"Initial branch length: #{$trunk[0]} to #{$trunk[$trunk.length-1]}\"\n\t end", "def median (array)\n array.sort!\n mediana = array.length.to_f/2\n mediana = mediana % 1 == 0 ? (array[mediana]+array[mediana-1])/2.0 : array[mediana - 0.5]\n\nend", "def test_should_calculate_median\n assert_equal 6, TestSet.new(8, 10, 2, 6, 4).median\n assert_equal 4.5, TestSet.new(10, 0, 1, 9, 8, 1).median\n end", "def median(sorted)\n return sorted[0] if sorted.size == 1\n (sorted[(sorted.size - 1) / 2] + sorted[sorted.size / 2]) / 2.0\n end", "def minimal_tree(array)\n raise \"Please enter an array of at least one element\" if array.empty?\n\n midpoint = array.length/2\n root = BinaryTreeNode.new(array[midpoint])\n\n add_node = lambda do |left, right|\n return if left > right\n\n mid = left + (right-left) / 2\n\n node = BinaryTreeNode.new(array[mid])\n\n node.left = add_node.call(left, mid - 1)\n node.right = add_node.call(mid + 1, right)\n\n node\n end\n\n root.left = add_node.call(0, midpoint - 1)\n root.right = add_node.call(midpoint + 1, array.length - 1)\n\n root\nend", "def data_shapes tree\n acc = Array.new(MAX_DIM + 1) { [] }\n min_level = MAX_DIM + 1\n max_level = 0\n minmax = [min_level, max_level]\n\n search max_level, tree, acc, minmax\n\n min_level = minmax[0]\n max_level = minmax[1]\n\n if acc[max_level] && acc[max_level].all? { |a| a.nil? }\n # min_level is not set in this special case. Hence the check.\n elsif min_level != max_level\n raise ValueError, \"unbalanced tree: min depth #{min_level} and max depth #{max_level}\"\n end\n\n data = acc[max_level]\n shapes = acc[0...max_level].reverse\n\n [data, shapes]\n end", "def median\n { value: \"%0.2f\" % @median, color: Openreply::Color.color(@median) }\n end", "def build_tree\n t = RDTree.new\n t.add_node(0, DummyRoot)\n root = root_node_of\n t.add_edge(0, root.attributes[\"ID\"])\n do_build_tree(root, 1, t) \n t\n end", "def median(ary)\n mid = ary.length / 2\n sorted = ary.sort\n ary.length.odd? ? sorted[mid] : 0.5 * (sorted[mid] + sorted[mid - 1])\n end", "def random_tree\n\t\t#range of possible angle separations between branches\n\t\t#big range seems to be ok, 30 to 60 works nice\n\t\t$angle_of_separation = (30..60).to_a\n\t\t#range of possible shrinkage values, will have a decimal in front of it\n\t\t#shrink determines how short each branch is\n\t\t$shrink_range = (4..6).to_a\n\t\t#split determines how many levels of branches there are\n\t\t#below 5 makes a pretty weak tree\n\t\t#above 7 makes a big blob of black\n\t\t$split_range = (5..7).to_a\n\t\t\n\t\t#Determines how many branches the current one splits off into\n\t\t$num_splits = rand(4)+2\n\t\t\n\t\t#how long the \"trunk\" is, height is 600\n\t\t#this gets ugly above 250\n\t\t$trunk = (150..250).to_a\n\t\t\n\t\t#pick a random number from the split range to be used as the number of splits\n\t\t$split_range = $split_range[rand($split_range.length)]\n\t\t#as a decimal, find the factor we will multiply future branches by\n\t\t@shrink = \"0.#{$shrink_range[rand($shrink_range.length)]}\".to_f\n\t\t#pick a random value for the angle of separation from the range\n\t\t$angle_of_separation = $angle_of_separation[rand($angle_of_separation.length)]\n\t\t\n\t\t#make a multidimensional array for branches\n\t\t@branches = []\n\t\t#start at the bottom, but not all the way down\n\t\t#move @x to the top of the trunk, ready for next branches\n\t\t@branches << [ [[@x, Height - @bot_margin], [@x, Height - $trunk[rand($trunk.length)]]] ] \n\t\t\n\t\tputs \"This output is from Random Tree\"\n\t\tputs \"Number of splits: #{$num_splits}\"\n\t\tputs \"Angle of separation: #{$angle_of_separation}\"\n\t\tputs \"Shrink range: #{$shrink_range[0]} to #{$shrink_range[$shrink_range.length-1]}\"\n\t\tputs \"Split range: #{$split_range}\"\n\t\tputs \"Initial branch length: #{$trunk[0]} to #{$trunk[$trunk.length-1]}\"\n\t\t\n\t end", "def median(arr)\n\nend", "def huffTree(text)\r\n\t\tqueue = Array.new\r\n\t\tcount = countChars(text)\r\n\r\n\t\tcount.each do |char, freq|\r\n\t\t\tnode = Node.new(char, freq)\r\n\t\t\tqueue.push(node)\r\n\t\tend\r\n\t\tqueue.sort_by!{|ch| ch.freq}\r\n\r\n\t\twhile queue.size != 1\r\n\t\t\tnode = Node.new\r\n\t\t\tnode.left = queue.shift\r\n\t\t\tnode.right = queue.shift\r\n\t\t\tnode.freq = node.left.freq + node.right.freq\r\n\t\t\tqueue.push(node)\r\n\t\t\tqueue.sort_by!{|ch| ch.freq}\r\n\t\tend\r\n return queue[0]\r\n\tend", "def initialize(array = [], sorted = false)\n raise TypeError, 'Tree requires an array to initialize.' unless array.is_a? Array\n\n # Extract unique elements for sorting\n build_array = array.uniq\n\n # Requires a sorted array to properly build the tree.\n build_array.sort! unless sorted\n\n @root = build_tree(build_array)\n end", "def median\n sorted = self.dup.sort\n\n result = 0\n\n middle = length / 2\n if sorted.length.odd?\n return self.take(middle + 1).last\n else\n return (self.drop(middle).first + self.take(middle).last)/2.0\n end\n end", "def balanced_binary_with_sorted_array(arr, min, max)\n return nil if min > max\n mid = (min + max) / 2\n # Always passes the next middle as next root, so the tree stays balanced.\n root = TreeNode.new(arr[mid])\n root.left = balanced_binary_with_sorted_array(arr, min, mid - 1)\n root.right = balanced_binary_with_sorted_array(arr, mid + 1, max)\n root\n end", "def calculate_median(values)\n count = values.count\n list_sort = values.sort\n\n # calculate the median position rounding up \n avg_position = (count / 2.0).ceil\n\n # returns the median value or a calculation between the middle 2\n if count.even?\n nice_calculation_median(list_sort[avg_position] + list_sort[avg_position - 1])\n else\n list_sort[avg_position - 1] \n end\n end", "def insert(data)\n current_node = @root\n if @root\n while current_node != nil\n if data < current_node.data && current_node.left == nil\n current_node.left = TreeNode.new(data)\n elsif data > current_node.data && current_node.right == nil\n current_node.right = TreeNode.new(data)\n elsif data < current_node.data\n current_node = current_node.left\n elsif data >= current_node.data\n current_node = current_node.right\n else\n return\n end\n end\n else\n @root = TreeNode.new(data)\n end\n end", "def median(array)\n sorted = array.sort\n length = array.length\n if length % 2 ==0\n place1 = length/2\n place2 = (length-2)/2\n sum =(sorted[place1] + sorted[place2])\n median = sum/2.0\n else\n place = (length-1)/2\n median = sorted[place]\n end\n return median\n\nend", "def construct_tree(arr)\n root = TreeNode.new(arr.shift)\n xtd = [root]\n while !xtd.empty? && !arr.empty?\n cur_node = xtd.shift\n a, b = arr.shift(2) # doesn't matter if arr.size < 2. in this case, a, b might be nil\n cur_node.left = a.nil? ? nil : TreeNode.new(a)\n cur_node.right = b.nil? ? nil : TreeNode.new(b)\n xtd << cur_node.left unless cur_node.left.nil?\n xtd << cur_node.right unless cur_node.right.nil?\n end\n root\nend", "def pivot_on_median_of_three(sort_range, ary)\n fidx, midx, lidx = sort_range.first, sort_range.first + sort_range.count/2, sort_range.last\n midx -= 1 if sort_range.count.even?\n f, m, l = ary[fidx], ary[midx], ary[lidx]\n median = fidx if f < [m,l].max and f > [m,l].min\n median = midx if m < [f,l].max and m > [f,l].min\n median = lidx if l < [m,f].max and l > [m,f].min\n median = midx if median.nil? # fidx, midx, lidx are all the same element\n ary[fidx], ary[median] = ary[median], ary[fidx]\n fidx\nend", "def median(values)\n values.sort![values.size/2-1]\n end", "def build_tree array\n\t\t@root = Node.new array[0]\n\t\t@nodes += 1\n\t\tarray[1..-1].each do |var|\n\t\t\tinsert(@root,var)\n\t\tend\n\tend", "def create_tree(vupper, vlower, &block)\n @root = Node.new(vupper, vlower, @depth)\n @root.create_children &block\n end", "def median(array)\n\tif array.include?(Integer)\n\treturn array.inject{|memo, i| memo + i} / array.size\nelse \n return array.sort_by{|x| x}.mid\nend\nend", "def heapify(index)\n left = @tree[left(index)]\n right = @tree[right(index)]\n current = @tree[index]\n if !left && !right # if no children exist nothing to compare with\n nil\n elsif left && !right\n if left.rating < current.rating\n temp = @tree[index]\n @tree[index] = @tree[left]\n @tree[left] = temp\n #no need to heapify at a leaf\n end\n elsif left.rating < current.rating || right.rating < current.rating\n if @tree[left].rating <= @tree[right].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[left]\n @tree[left] = temp\n heapify(left(index))\n elsif @tree[right].rating < @tree[left].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[right]\n @tree[right] = temp\n heapify(right(index))\n end\n end\n end", "def calculate_median(arr)\n arr.sort[arr.length / 2]\nend", "def build_ranked_tree(model)\n # inflate the node id to test id wrap around edge cases\n # NODES=4..9 seem like edge cases\n ENV[\"NODES\"].to_i.times { model.create!.destroy } if ENV[\"NODES\"]\n\n n1 = model.create!(:rank => 0)\n n2 = model.create!(:rank => 1)\n n3 = model.create!(:rank => 3, :parent => n1)\n n4 = model.create!(:rank => 0, :parent => n2)\n n5 = model.create!(:rank => 0, :parent => n1)\n n6 = model.create!(:rank => 1, :parent => n2)\n\n puts \"create: #{n1.id}..#{n6.id}\" if ENV[\"NODES\"]\n [n1, n2, n3, n4, n5, n6]\n end", "def create_bst(sorted_arr)\n\n return nil if sorted_arr.length == 0\n return BinaryNode.new(sorted_arr[0]) if sorted_arr.length == 1\n if sorted_arr.length == 2\n child = BinaryNode.new(sorted_arr[0])\n parent = BinaryNode.new(sorted_arr[1])\n parent.left = child\n return parent\n end\n\n middle = sorted_arr.length / 2\n left_start = 0\n left_end = (sorted_arr.length / 2) - 1\n right_start = left_end + 2\n right_end = sorted_arr.length\n\n cur_root = BinaryNode.new(sorted_arr[middle])\n cur_root.left = create_bst(sorted_arr[left_start..left_end])\n cur_root.right = create_bst(sorted_arr[right_start..right_end])\n\n return cur_root\n\nend", "def tree(root = '')\n build_hash(files(root), root)\n end" ]
[ "0.6558561", "0.64382875", "0.63553596", "0.6242733", "0.6241094", "0.6067161", "0.6034394", "0.5961088", "0.5960198", "0.59091127", "0.5840622", "0.5820964", "0.5820257", "0.5804957", "0.5770254", "0.5727567", "0.5711552", "0.5703989", "0.569803", "0.56913126", "0.56734544", "0.5656934", "0.5642216", "0.5628441", "0.55749196", "0.55608505", "0.5556084", "0.555272", "0.5538097", "0.5536581", "0.55235285", "0.55127656", "0.55079114", "0.54907894", "0.54805315", "0.54758734", "0.54556197", "0.54420525", "0.544168", "0.54309547", "0.54112", "0.5403514", "0.5361652", "0.53574806", "0.53565097", "0.53547734", "0.5333547", "0.5327204", "0.5323451", "0.53212446", "0.53196025", "0.53109235", "0.5310713", "0.5300618", "0.5300029", "0.52994263", "0.52868825", "0.5277186", "0.5271456", "0.5268805", "0.5250718", "0.5249755", "0.52456254", "0.52373296", "0.5237115", "0.5219817", "0.52057225", "0.5189034", "0.5188945", "0.51844907", "0.5180143", "0.51728654", "0.51717895", "0.51702297", "0.51696926", "0.5168172", "0.51628596", "0.51535827", "0.51449054", "0.5140338", "0.5138608", "0.5136825", "0.5119019", "0.5113022", "0.5104748", "0.5102696", "0.5099939", "0.50998884", "0.50889677", "0.5082991", "0.5081856", "0.5064824", "0.5057432", "0.5051971", "0.5048452", "0.5046642", "0.5046213", "0.5038681", "0.503442", "0.50166523" ]
0.65351343
1
Build a meaningless tree and waste your time
def build_tree_arbitrary(arr) node = Node.new(arr[0]) queue = [node] @root = node i = 0 until queue.empty? node = queue.shift children = node_children(node, i, arr) queue.concat(children) i += 2 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def produce_tree(ary); end", "def build_tree(arr)\n\tend", "def tree\n @tree ||= build_tree\n end", "def generate_tree\n root =\tTreeNode.new(3)\n root.left =\tTreeNode.new(9)\n right = \t\tTreeNode.new(20)\n right.left = \tTreeNode.new(15)\n right.right = TreeNode.new(7)\n root.right = \tright\n root\nend", "def build_tree(data)\n @root = Node.new(data[0])\n data.shift\n data.each { |value| @root.insert(value) }\n end", "def build_tree( n , d )\n \n if d.key?('v')\n n < d['v'] ? build_tree(n , d['l']) : build_tree(n, d['r'])\n else\n d['l'] = {}\n d['v'] = n\n d['r'] = {}\n end\n \nend", "def build_tree(arr)\n #arr.shuffle!\n arr.each do |x|\n if @root == nil\n @root = Node.new(x)\n else\n current_node = @root\n until current_node == nil\n if x < current_node.value\n parent = current_node\n direction = \"left\"\n current_node = current_node.left_child\n elsif x > current_node.value\n parent = current_node\n direction = \"right\"\n current_node = current_node.right_child\n end\n end\n if direction == \"left\"\n parent.left_child = Node.new(x)\n elsif direction == \"right\"\n parent.right_child = Node.new(x)\n end\n end\n end\n end", "def build_tree\n t = RDTree.new\n t.add_node(0, DummyRoot)\n root = root_node_of\n t.add_edge(0, root.attributes[\"ID\"])\n do_build_tree(root, 1, t) \n t\n end", "def build_tree\n c1 = ComponentNode.new(110)\n c2 = ComponentNode.new(20)\n c3 = ComponentNode.new(20)\n c4 = ComponentNode.new(150)\n c5 = ComponentNode.new(80)\n c6 = ComponentNode.new(120, [c1, c2, c3])\n c7 = ComponentNode.new(180, [c4, c5])\n return(ComponentNode.new(200, [c6, c7]))\n end", "def build_tree(array)\n array.sort!.uniq!\n left = 0\n right = array.length\n\n return build_driver(array, left, right)\n end", "def build_tree_unsorted(arr)\n root = nil\n arr.each do |item|\n root = insert_tree(item, root)\n end\n\n root\nend", "def build_tree(array)\n\t\t@root = Node.new(array.shift)\n\t\tarray.each { |value| add_node(value, @root)}\n\tend", "def gen_tree\n new_tree = {}\n node_list = {}\n @json_tree.each do |k, v|\n if v['child_of'].nil?\n # top\n new_tree[k] = v\n node_list[k] = new_tree[k]\n else\n parent = v['child_of']\n if v['condition'] == 'and'\n node_list[parent]['and'] ||= {}\n node_list[parent]['and'][k] = v\n node_list[k] = node_list[parent]['and'][k]\n elsif v['condition'] == 'or'\n node_list[parent]['or'] ||= {}\n node_list[parent]['or'][k] = v\n node_list[k] = node_list[parent]['or'][k]\n else\n # TODO: sink?\n node_list[parent]['or'] ||= {}\n node_list[parent]['or'][k] = v\n node_list[k] = node_list[parent]['or'][k]\n end\n end\n end\n\n @json_tree_type = 'tree'\n @json_tree = new_tree\n end", "def build_tree(arr)\n @root = insert_node(nil, arr.shift)\n arr.each { |value| insert_node(@root, value) }\n end", "def build_tree(array)\n\t\t@root = Node.new(array[0])\n\t\ttemp_root = @root\n\n\t\tarray[1..-1].each do |node_value|\n\t\t\tinsert_node(node_value, temp_root)\n\t\tend\n\tend", "def tree\n root = Node.new(1)\n root.left = Node.new(2)\n root.right = Node.new(3)\n root.left.left = Node.new(4)\n root.left.right = Node.new(5)\n root.right.left = Node.new(6)\n root.right.right = Node.new(7)\n root.right.right.right = Node.new(8)\n root\nend", "def build_tree(unit, node, level = 0)\r\n return nil if level > @max_depth\r\n \t\r\n unit.next_move(node.current_case).each do |next_case|\r\n next if next_case[0] < 0 || next_case[0] > 7 ||\r\n next_case[1] < 0 || next_case[1] > 7 \r\n \r\n next_node = Node.new(next_case, node)\r\n node.children << next_node\r\n\r\n build_tree(unit, next_node, level + 1)\r\n end \r\n end", "def make_tree(pre, inord)\n return if pre.size == 0\n root_node = Node.new(pre[0])\n idx = inord.index(pre[0])\n root_node.left = make_tree(pre[1..idx], inord[0...idx])\n root_node.right = make_tree(pre[idx+1...pre.size], inord[idx+1...inord.size])\n return root_node\nend", "def build_tree(elements)\n return if elements.empty?\n char = elements.shift\n node = BinaryTree.new(char)\n if char == \"I\"\n node.left = build_tree(elements)\n node.right = build_tree(elements)\n end\n return node\nend", "def build_tree(arr)\n #take array, turn into bt with node objs\n return nil if arr.empty?\n\n mid = (arr.size - 1)/2\n current_node = Node.new(arr[mid])\n\n current_node.left = build_tree(arr[0...mid])\n current_node.right = build_tree(arr[(mid+1)..-1])\n \n current_node\n end", "def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend", "def build_tree(arr)\n @root = Node.new(arr.shift)\n arr.each { |data| insert_data(data, @root) }\n end", "def create_tree(node, elem, level, parent)\n node.level = level\n elemtype = check_type(elem[1])\n case elemtype\n when \"array\"\n node.kind = \"array\"\n node.arrsize = elem[1][\".array_size\"].to_i\n if elem[1].has_key?(\".subtype\") && elem[1][\".subtype\"].has_key?(\".members\")\n elem[1][\".subtype\"][\".members\"].each do |m|\n x = Tree.new(m[0], item_type(elem[1]), node)\n node.create_child(x)\n create_tree(x, m, level+1, node)\n end\n if elem[1][\".subtype\"].has_key?(\".type_or_id_name\")\n elem[1][\".subtype\"][\".type_or_id_name\"] =~ /\\((.+)\\): (\\w+)/\n node.s_u_name = $2.clone\n else\n node.s_u_name = \"__ANON__\"\n end\n node.basetype = node.data = elem[1][\".subtype\"][\".type\"].clone\n else\n subkind = check_type(elem[1][\".subtype\"])\n case subkind\n when \"enum\"\n node.basetype = \"enum\"\n node.data = {\".type\" => elem[1][\".subtype\"][\".type\"]}\n node.data[\".type_or_id_name\"] = elem[1][\".subtype\"][\".type_or_id_name\"]\n arr = []\n elem[1][\".subtype\"][\".values\"].each { |k,v| arr << [k,v] }\n node.data[\".values\"] = arr.clone\n node.data[\".values\"].sort! { |a,b| a[1] <=> b[1] }\n when \"numeric_ose\", \"boolean\"\n elem[1][\".subtype\"][\".type_or_id_name\"] =~ /\\((.+)\\): (\\w+)/\n node.basetype = $2.clone\n when \"native\", \"numeric_other\"\n node.basetype = \"OTHER\"\n node.data = {\".type\" => elem[1][\".subtype\"][\".type\"]}\n if elem[1][\".subtype\"].has_key?(\".signed\")\n node.data[\".signed\"] = elem[1][\".subtype\"][\".signed\"] \n end\n if elem[1][\".subtype\"].has_key?(\".type_or_id_name\")\n node.data[\".type_or_id_name\"] = elem[1][\".subtype\"][\".type_or_id_name\"]\n end\n end\n node.leaf = true\n end\n when \"struct\", \"union\"\n node.kind = elemtype\n if is_anon?(elem[1])\n node.s_u_name = \"__ANON__\"\n else\n node.s_u_name = item_name(elem[1])\n end\n elem[1][\".members\"].each do |m|\n x = Tree.new(m[0], item_type(elem[1]), node)\n node.create_child(x)\n create_tree(x, m, level+1, node)\n end\n when \"enum\"\n node.kind = \"enum\"\n node.basetype = \"enum\"\n node.s_u_name = item_name(elem[1])\n node.parent = parent\n node.leaf = true\n arr = []\n elem[1][\".values\"].each { |k,v| arr << [k,v] }\n node.data = arr.clone\n node.data.sort! { |a,b| a[1] <=> b[1] }\n when \"numeric_ose\"\n node.kind = \"numeric\"\n node.basetype = item_name(elem[1])\n node.parent = parent\n node.leaf = true\n when \"boolean\"\n node.kind = \"boolean\"\n node.basetype = item_name(elem[1])\n node.parent = parent\n node.leaf = true\n when \"native\", \"numeric_other\"\n node.kind = \"numeric\"\n node.basetype = \"OTHER\"\n node.data = {'.type' => elem[1][\".type\"]}\n node.data[\".signed\"] = elem[1][\".signed\"] if elem[1].has_key?(\".signed\")\n if elem[1].has_key?(\".type_or_id_name\")\n node.data[\".type_or_id_name\"] = elem[1][\".type_or_id_name\"]\n end\n node.parent = parent\n node.leaf = true\n else\n raise \"Node #{node.name} contains erroneous data\" \n end\n end", "def build_tree(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 build_tree_2(data_array)\n root = nil\n \n data_array.each do |elem|\n node = insert_node(root, nil, elem) \n\troot ||= node\n end\n \n root\nend", "def build_tree(data_array)\n root = nil\n \n data_array.each do |elem|\n cur_node = root\n \n node = Node.new(elem)\n\tnode.children = Array.new(2, nil)\n\t\n\twhile !cur_node.nil?\n\t if elem < cur_node.value\n\t if cur_node.children[0].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[0] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[0]\n\t else\n\t if cur_node.children[1].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[1] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[1]\n\t end\n\tend\n\t\n\troot ||= node\n\t \n end\n \n root\nend", "def build_tree(ary)\n # If the array is sorted, the tree will not be balanced\n ary.shuffle!\n ary.each { |item| insert(item) }\n end", "def buildTree( prefixArray )\n return nil if prefixArray.empty?\n value = prefixArray.pop\n if( root.nil? )\n @root = TreeNode.new(value, nil, nil)\n # the right child comes before left since prefixArray \n # is really a _stack_\n @root.rightChild = buildTree( prefixArray )\n @root.leftChild = buildTree( prefixArray )\n elsif( isOp?(value) )\n newNode = TreeNode.new(value, nil, nil)\n newNode.rightChild = buildTree( prefixArray )\n newNode.leftChild = buildTree( prefixArray )\n return newNode\n else\n return TreeNode.new(value, nil, nil)\n end\n end", "def build_tree(data, parent = nil)\n return if data.size.zero?\n center = half(data)\n value = data[center]\n @depth_first << value\n\n # Recusion to split halves until zero then execute logic\n build_tree(l_half = data[0...center], value)\n build_tree(r_half = data[center + 1..-1], value)\n\n # Node creation and set node properties\n l_child = l_half[half(l_half)]\n r_child = r_half[half(r_half)]\n Node.new(value, parent, l_child, r_child)\n end", "def build_tree(array)\n first_node = Node.new(nil, nil, array[0])\n this_node = first_node\n i = 1\n\n finished = false\n while !finished\n if array[i] == nil\n finished = true\n elsif array[i] < this_node.data\n if this_node.left_child == nil\n this_node.left_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.left_child\n end\n elsif array[i] > this_node.data\n if this_node.right_child == nil\n this_node.right_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.right_child\n end \n elsif array[i] == this_node.data\n i += 1\n end\n end\n return first_node\nend", "def build_tree array\n\t\t@root = Node.new array[0]\n\t\t@nodes += 1\n\t\tarray[1..-1].each do |var|\n\t\t\tinsert(@root,var)\n\t\tend\n\tend", "def build_tree_from_unsorted(arr)\n return nil if arr.empty?\n @root = Node.new(arr.shift)\n\n until arr.empty?\n child_node = Node.new(arr.shift)\n assign_children(@root, child_node)\n end\n end", "def build_tree(model)\n # inflate the node id to test id wrap around edge cases\n ENV[\"NODES\"].to_i.times { model.create!.destroy } if ENV[\"NODES\"]\n\n n1 = model.create!\n n2 = model.create!(:parent => n1)\n n3 = model.create!(:parent => n2)\n n4 = model.create!(:parent => n2)\n n5 = model.create!(:parent => n1)\n n6 = model.create!(:parent => n5)\n\n puts \"create: #{n1.id}..#{n6.id}\" if ENV[\"NODES\"]\n [n1, n2, n3, n4, n5, n6]\n end", "def make_tree(in_list, pid = self.pid)\n [].tap do |top_level|\n left_over = []\n # Categorize into top level, or not top level\n in_list.each do |node|\n if node['parent_page_id'].blank? || node['parent_page_id'] == pid\n top_level.unshift node\n else\n left_over.unshift node\n end\n end\n\n # For each of the top_level nodes make a subtree with the leftovers.\n top_level.each do |node|\n node['children'] = make_tree(left_over, node['id'])\n end\n end\n end", "def make_tree_for(position)\n root = TreeNode.new(nil, position)\n\n\nend", "def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend", "def build\n nodes = []\n chars = []\n\n expression.each_char do |character|\n\n if '(' == character\n\n chars << character\n\n elsif /\\d+/.match(character)\n\n nodes.push Tree.new(character.to_i)\n\n elsif operands.include?(character)\n\n while(chars.any? && chars.last != '(')\n t = Tree.new(chars.pop)\n t.right = nodes.pop\n t.left = nodes.pop\n nodes << t\n end\n\n chars << Operation::OPERATIONS[character].new\n\n elsif ')' == character\n\n while(chars.any? && chars.last != '(')\n t = Tree.new(chars.pop)\n t.right = nodes.pop\n t.left = nodes.pop\n nodes << t\n end\n\n chars.pop\n\n end\n\n end\n\n unless nodes.empty? && chars.empty?\n self.root = Tree.new(chars.pop)\n root.right = nodes.pop\n root.left = nodes.pop\n end\n\n raise \"Ka-Blam! You still have nodes and/or chars\" if nodes.any? || chars.any?\n\n root\n end", "def build_server_tree(tree, options= {})\n result = ''\n tree = Array.wrap tree\n opts = {\n # node and base node params\n :id => :id, # node id field\n :title => :title, # name of title fileld\n :node => nil, # node\n\n # base options\n :type => :tree, # tree type\n :root => false, # is it root node?\n :level => 0, # recursion level\n :namespace => [], # :admin\n\n # BOOST! hash\n :boost => {}\n }.merge!(options)\n\n # Basic vars\n root = opts[:root]\n node = opts[:node]\n\n # namespace prepare [Rails require]\n opts[:namespace] = Array.wrap opts[:namespace]\n\n # Module with **Render** class\n opts[:render_module] = TREE_RENDERERS[opts[:type]] unless opts[:render_module]\n\n # Define tree class\n opts[:klass] = define_class_of_elements_of(tree) unless opts[:klass]\n\n # BOOST PATCH (BUILD ONCE)\n # solution of main perfomance problem\n # magick index-hash, which made me happy!\n\n # Performance comparison\n # Boost OFF: 8000 nodes, 3 levels => (Views: 176281.9ms | ActiveRecord: 189.8ms)\n # Boost ON: 8000 nodes, 3 levels => (Views: 8987.8ms | ActiveRecord: 141.6ms)\n\n if opts[:boost].empty?\n tree.each do |item|\n num = item.parent_id || -1\n opts[:boost][num.to_s] = [] unless opts[:boost][num.to_s]\n opts[:boost][num.to_s].push item\n end\n end\n\n unless node\n # RENDER ROOTS\n roots = opts[:boost]['-1']\n\n # Boost OFF\n # roots = tree.select{ |node| node.parent_id.blank? }\n\n # define roots, if it's need\n if roots.nil? && !tree.empty?\n # Looks like the new algo really does what we need (28 sept. 2016)\n # Thanks to: https://github.com/patrick-nits\n #\n ids = tree.map(&:id)\n opt_ids = opts[:boost].keys.map(&:to_i)\n candidate_ids = (ids + opt_ids).uniq - (ids & opt_ids) # xor\n roots = candidate_ids.map {|c| opts[:boost][c.to_s]}.compact.flatten\n end\n\n # children rendering\n if roots\n roots.each do |root|\n _opts = opts.merge({ :node => root, :root => true, :level => opts[:level].next, :boost => opts[:boost] })\n result << build_server_tree(tree, _opts)\n end\n end\n else\n # RENDER NODE'S CHILDREN\n children_res = ''\n children = opts[:boost][node.id.to_s]\n\n # Boost OFF\n # children = tree.select{ |_node| _node.parent_id == node.id }\n\n opts.merge!({ :has_children => children.blank? })\n\n unless children.nil?\n children.each do |elem|\n _opts = opts.merge({ :node => elem, :root => false, :level => opts[:level].next, :boost => opts[:boost] })\n children_res << build_server_tree(tree, _opts)\n end\n end\n\n result << build_tree_html(self, opts[:render_module], opts.merge({ :root => root, :node => node, :children => children_res }))\n end\n\n raw result\n end", "def construct_tree(arr)\n root = TreeNode.new(arr.shift)\n xtd = [root]\n while !xtd.empty? && !arr.empty?\n cur_node = xtd.shift\n a, b = arr.shift(2) # doesn't matter if arr.size < 2. in this case, a, b might be nil\n cur_node.left = a.nil? ? nil : TreeNode.new(a)\n cur_node.right = b.nil? ? nil : TreeNode.new(b)\n xtd << cur_node.left unless cur_node.left.nil?\n xtd << cur_node.right unless cur_node.right.nil?\n end\n root\nend", "def build_tree(arr, root, i, n)\n\tif i < n\n\t\troot = TreeNode.new(arr[i])\n\t\troot.left = build_tree(arr, root.left, i*2+1, n)\n\t\troot.right = build_tree(arr, root.right, i*2+2, n)\n\tend\n\treturn root\nend", "def tree\n return nil if messages.size == 0\n build_tree unless @tree\n @tree\n end", "def build_hierarchy\n root = LetterNode.new(nil)\n\n # TODO: Limit word table to 50,000 highest ranking words\n\n words.each do |word|\n wl = root\n word.spelling.each_char do |letter|\n wl = wl.add(letter, word.count)\n end\n wl.word!(word.count)\n end\n\n root\n end", "def build_tree_helper(arr)\n\treturn Node.new(arr[0]) if arr.size == 1\n\tnode = Node.new(arr.slice!(arr.size / 2))\n\ttree = build_tree(arr)\n\tuntil (node.value > tree.value && tree.right_child.nil?) || (node.value <= tree.value && tree.left_child.nil?)\n\t\ttree = node.value > tree.value ? tree.right_child : tree.left_child\n\tend\n\tif node.value > tree.value\n\t\ttree.right_child = node\n\t\tnode.parent = tree\n\telse\n\t\ttree.left_child = node\n\t\tnode.parent = tree\n\tend\nend", "def build_tree(data, node=self)\n data = data.sort\n build_bin_tree(data, 0, data.length - 1, node)\n end", "def build_tree_node(l, u) \n return TreeNode.new(l, u, nil, nil) if l == u\n \n half_it = ((u - l) + 1) / 2\n if half_it <= 1\n TreeNode.new(l,\n u,\n build_tree_node(l, l),\n build_tree_node(u, u)\n )\n else\n TreeNode.new(\n l,\n u,\n build_tree_node(l, l + half_it-1),\n build_tree_node(u-half_it+1, u)\n )\n end\nend", "def build_tree(data_array)\n @root = nil # overwrites tree, even if array is empty\n data_array.each_with_index do |data, index|\n if index == 0\n @root = Node.new(data)\n else\n set_next_node(data)\n end\n end\n end", "def build_move_tree\n move_q = [@root]\n while move_q.length > 0\n children = new_move_positions(move_q[0].value)\n children.each do |kid|\n move_q[0].add_child(PolyTreeNode.new(kid))\n end\n move_q += move_q[0].children\n move_q.shift\n end\n nil\n end", "def build_tree(input_array)\n sorted_set = input_array.sort.uniq\n build_tree_aux(sorted_set, 0, sorted_set.length - 1)\n end", "def build_struct_tree data\n data.to_hashugar\n end", "def build_tree array\n\t\t@root = Node.new(array.shift)\n\t\tparent = @root\n\t\tarray.each do |el|\n\t\t\twhile true\n\t\t\t\tif el <= parent.value\n\t\t\t\t\tif parent.left_child.nil?\n\t\t\t\t\t\tparent.left_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.left_child\n\t\t\t\t\tend\n\t\t\t\telsif el > parent.value\n\t\t\t\t\tif parent.right_child.nil?\n\t\t\t\t\t\tparent.right_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.right_child\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def buildTree(node,arr)\n node.value = arr.shift\n size = (arr.size/2.0).round\n if size > 0\n left, right = arr.each_slice( size ).to_a\n if left and left.count > 0\n node.left = TreeNode.new\n buildTree(node.left, left)\n end\n if right and right.count > 0\n node.right = TreeNode.new\n buildTree(node.right, right)\n end\n end\nend", "def build_tree(array)\n\t\t@root_node = Node.new(array[array.length / 2])\n\t\tarray[array.length / 2] = nil\n\t\tcounter = 0\n\t\tuntil counter == array.length\n\t\t\tset_value(array[counter], @root_node) if array[counter] != nil\n\t\t\tcounter += 1\n\t\tend\n\n\tend", "def build_tree(arr)\n if arr.empty?\n return nil\n end\n\n mid = arr.length/2\n root = Node.new(arr[mid])\n\n root.left = build_tree(arr[0...mid])\n root.right = build_tree(arr[(mid+1)..-1])\n\n root\nend", "def to_string_tree\n if ((@children).nil? || (@children.size).equal?(0))\n return self.to_s\n end\n buf = StringBuffer.new\n if (!is_nil)\n buf.append(\"(\")\n buf.append(self.to_s)\n buf.append(Character.new(?\\s.ord))\n end\n i = 0\n while !(@children).nil? && i < @children.size\n t = @children.get(i)\n if (i > 0)\n buf.append(Character.new(?\\s.ord))\n end\n buf.append(t.to_string_tree)\n i += 1\n end\n if (!is_nil)\n buf.append(\")\")\n end\n return buf.to_s\n end", "def build_tree(data, par_node)\n return nil if data.empty?\n \n if @node.value <= par_node.value\n if par_node.left == nil\n par_node.left = @node\n else\n build_tree(data, par_node.left)\n end\n else\n if par_node.right == nil\n par_node.right = @node\n else\n build_tree(data, par_node.right)\n end\n end\n\n @node = Node.new(data.shift)\n build_tree(data, @root)\n end", "def parsed_tree; end", "def tree\n while token = @tokens.next\n case token.type\n when :operator\n token.build(@nodes.pop, tree).tap do |node|\n @nodes.push(node)\n end\n when :value\n token.build.tap do |leaf|\n @nodes.push(leaf)\n end\n end\n end\n rescue StopIteration\n @nodes.last || Lexeme::Null.new\n end", "def build_tree(array)\n return nil if array.empty?\n\n mid = (array.length - 1) / 2\n node = Node.new(array[mid])\n node.left = build_tree(array[0...mid])\n node.right = build_tree(array[mid+1..-1])\n node\n end", "def build_tree(array, left=0, right=array.length-1)\n \n# base case\n return if left > right\n\n# from smallest to largest\n array = merge_sort(array)\n\n# middle index, make this the first node\n index_mid = left + (right-left) / 2 \n node = Node.new(array[index_mid]) \n \n# i think it's making the left node (smaller), & right (larger)\n# looks like it is recursion\n node.left_child = build_tree(array, left, index_mid-1) \n node.right_child = build_tree(array, index_mid+1, right) \n\n @tree = node\n @tree\n end", "def build_tree(nodes_fragement)\n nodes_element = LonelyPlanet::Node.new nodes_fragement\n node = LonelyPlanet::TreeNode.new(nodes_element.name, nodes_element.id)\n if nodes_element.has_child?\n nodes_element.children.all? { |child_frag|\n node << build_tree(child_frag)\n }\n end\n node\n end", "def build_tree\n roots = Set.new\n hash = {}\n nodes = selected_nodes\n\n nodes.each do |node|\n loop do\n id = node.id\n parent_id = node.parent_id\n\n hash[id] ||= {}\n if hash.key?(parent_id)\n # Another loop has already added our parent. Add ourself to its hash\n # and break early.\n hash[parent_id][id] = hash[id]\n break\n else\n if selected_node_ids.include?(parent_id)\n # Our parent is a selected node. Add a hash for it and add ourself\n # to that. Keep looping to add our parent's parent.\n hash[parent_id] = {}\n hash[parent_id][id] = hash[id]\n node = nodes_by_id[parent_id]\n else\n # Our parent isn't selected, so we must be a root.\n roots.add(id)\n break\n end\n end\n end\n end\n\n hash.keep_if { |k, _| roots.include?(k) }\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 create_tree(father,tree)\n tree.each do |name|\n n = Meta::create_class(father, name[0], name[1])\n create_tree(n, name[2])\n end\nend", "def build_tree(list)\n root = Node.new(list[0], nil)\n list[1...list.length].each do |item|\n current_node = root\n while !item.nil?\n if item > current_node.value\n if current_node.right_child.nil?\n current_node.right_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.right_child\n end\n elsif item < current_node.value\n if current_node.left_child.nil?\n current_node.left_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.left_child\n end\n else\n item = nil\n end\n end\n end\n root\nend", "def create_tree(start_tile)\n queue = [start_tile]\n visited.add(start_tile.pos)\n\n while !queue.empty?\n cur_tile = queue.shift\n tiles = adjacent_tiles(cur_tile.pos)\n\n tiles.each do |tile_pos|\n tile = self[tile_pos]\n tile.parent = cur_tile\n queue.push(tile)\n visited.add(tile.pos)\n end\n end\n start_tile\n end", "def build_tree(preorder, inorder)\n return nil if preorder.empty? || inorder.empty?\n \n root = TreeNode.new(preorder.first)\n idx = inorder.find_index(preorder.first)\n preorder.shift\n\n root.left = build_tree(preorder, inorder.slice(0..(idx-1))) unless idx==0\n root.right = build_tree(preorder, inorder.slice((idx+1)..-1)) if idx!=inorder.size-1\n \n return root\nend", "def build_tree(array)\n tree = TreeNode.new(array[0], 0)\n (1..array.length-1).each {|i|\n insert_into_tree(tree, array[i], i)\n }\n tree\nend", "def recursive => nil", "def elegant_tree_by_levels(node)\n stack=[]\n stack.push node if node\n stack.each do |n|\n stack.push n.left if n.left\n stack.push n.right if n.right\n end\n stack.map! &:value\nend", "def build_tree(array)\n return nil if array.empty?\n \n middle = (array.size - 1) / 2\n root_node = Node.new(array[middle])\n \n root_node.left = build_tree(array[0...middle])\n root_node.right = build_tree(array[(middle + 1)..-1])\n \n root_node\n end", "def build_tree_rec(preorder, inorder)\n if inorder.length != 0\n original = preorder.shift\n ind = inorder.index(original)\n root = TreeNode.new(inorder[ind])\n root.left = build_tree(preorder, inorder[0...ind])\n root.right = build_tree(preorder, inorder[ind + 1..-1])\n root\n end\nend", "def build_move_tree\n queue = [@root_node]\n until queue.empty?\n current_node = queue.shift\n possible_positions = new_move_positions(current_node.value) #[]\n possible_positions.each do |position| #[1,2]\n child_node = PolyTreeNode.new(position) #node object(value = 1,2)\n child_node.parent = current_node\n current_node.add_child(child_node)\n queue << child_node\n end\n end\n end", "def build_tree(values)\n return nil if values.length == 0\n\n middle = values.length / 2\n middle_value = values[middle]\n left = values.take(middle)\n right = values.drop(middle + 1)\n\n Node.new(middle_value, build_tree(left), build_tree(right))\n end", "def ascii_tree; end", "def build_tree_from_sorted(arr)\n return nil if arr.empty?\n left, right, middle = get_left_right_middle(arr)\n @root = Node.new(middle)\n make_children(@root, left)\n make_children(@root, right)\n end", "def build_tree(start, finish, node = Node.new(start), queue = [node])\n @root = node\n\n until queue.index { |n| n.value == finish }\n node = queue.shift\n node.children = generate_move_nodes(node.value, finish)\n node.children.each { |c| queue << c }\n end\n end", "def tree(capa = 1)\n R3::Tree.new(capa)\nend", "def build(node)\n return @nodes[node] if @nodes[node]\n @nodes[node] = Node.new(node.val)\n @nodes[node].next = build(node.next) if node.next\n @nodes[node].random = build(node.random) if node.random\n @nodes[node]\nend", "def simple_tree\n tree = BinaryTree.new(1)\n tree.insert_left(2)\n tree.insert_right(3)\n tree.left_subtree.insert_left(4)\n tree.left_subtree.insert_right(5)\n tree.right_subtree.insert_left(6)\n tree.right_subtree.insert_right(7)\n return tree\n end", "def build_node\n \"\"\n end", "def build_tree_rec(inorder, postorder)\n if inorder.length != 0\n original = postorder.pop\n ind = inorder.index(original)\n root = TreeNode.new(inorder[ind])\n root.right = build_tree(inorder[ind + 1..-1], postorder)\n root.left = build_tree(inorder[0...ind], postorder)\n root\n end\nend", "def mk_tree(ch_arr)\n\t# set up top node based on smallest 2 values\n\ttop = Node.new # initial top node; no values yet\n\tmins = min_vals(ch_arr, 2)\n\tputs mins[0], mins[1]\n\tputs ch_arr[mins[0]]\n\tputs ch_arr[mins[1]]\n\ttop.set_left(Node.new(ch_arr[mins[0]], mins[0]))\n\ttop.set_right(Node.new(ch_arr[mins[1]], mins[1]))\n\ttop.set_count(ch_arr[mins[0]] + ch_arr[mins[1]])\n\tch_arr.delete(mins[0])\n\tch_arr.delete(mins[1])\n\t# build tree based upon current top node and next smallest value; repeat until no values left in hash\n\twhile(ch_arr.length >= 1)\n\t\ttemp = Node.new # temporary new node; this will become the top node\n\t\tmin = min_vals(ch_arr, 1)\n\t\tputs min\n\t\tputs ch_arr[min]\n\t\t# if top node's value is less than lowest number, put it on left; otherwise, put it on right\n\t\t#puts top.get_count, ch_arr[min]\n\t\tif(top.get_count <= ch_arr[min])\n\t\t\ttemp.set_left(top)\n\t\t\ttemp.set_right(Node.new(ch_arr[min], min))\n\t\telse\n\t\t\ttemp.set_left(Node.new(ch_arr[min], min))\n\t\t\ttemp.set_right(top)\n\t\tend\n\t\ttemp.set_count(ch_arr[min] + top.get_count)\n\t\ttop = temp\n\t\tch_arr.delete(min)\n\tend\n\t# return reference to top node\n\treturn top\nend", "def compose_tree(elements)\n tree = []\n leaf = []\n\n elements.each do |element|\n case element.type\n when :day\n tree << leaf unless leaf.empty?\n leaf = [element]\n\n when :hour\n # leaf << [:date, 'today'] if leaf.empty?\n leaf << element\n\n else\n raise \"Unexpected element #{element}\"\n end\n end\n\n tree << leaf unless leaf.empty?\n tree\n end", "def build\n\t\t\tfifo_q = Array.new\n\t\n\t\t\t# Set the failures for the nodes coming out of the root node.\n\t\t\[email protected]_pair do |item, node|\n\t\t\t\tnode.failure = @root\n\t\t\t\tfifo_q.push node\n\t\t\tend\n\n\t\t\t# Set the failures in breadth-first search order\n\t\t\t# using a FIFO queue. A failure identifies the deepest node\n\t\t\t# that is a proper suffix of the current node. \n\t\t\twhile !fifo_q.empty?\n\t\t\t\tp_node = fifo_q.shift\n\t\t\t\tif p_node.get\n\t\t\t\t\tp_node.get.each_pair do |item, node|\n\t\t\t\t\t\t# Push the current node onto the queue, so any child\n\t\t\t\t\t\t# nodes can be processed later.\n\t\t\t\t\t\tfifo_q.push node \n\t\t\t\t\t\n\t\t\t\t\t\tf_node = p_node.failure\n\t\t\t\t\t\t\n\t\t\t\t\t\t# Follow the failures until we find a goto transition\n\t\t\t\t\t\t# or arrive back at the root node\n\t\t\t\t\t\twhile f_node.goto(item) == nil and !f_node.eql? @root\n\t\t\t\t\t\t\tf_node = f_node.failure\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tif f_node.eql? @root and f_node.goto(item) == nil\n\t\t\t\t\t\t\tnode.failure = @root\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tnode.failure = f_node.goto(item)\n\t\t\t\t\t\t\tif block_given?\n\t\t\t\t\t\t\t\tnode.output = yield node.output, (node.failure).output\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tif node.output && (node.failure).output\n\t\t\t\t\t\t\t\t\tnode.output = node.output + (node.failure).output\n\t\t\t\t\t\t\t\telsif (node.failure).output\n\t\t\t\t\t\t\t\t\tnode.output = (node.failure).output\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\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tbuild_dfa if @type == :DFA\n\n\t\tend", "def build_tree(arr, start_index = 0, end_index = arr.length - 1)\n return nil if start_index > end_index\n\n mid = (start_index + end_index) / 2\n curr_root = arr[mid].is_a?(Node) ? arr[mid] : Node.new(arr[mid])\n curr_root.left = build_tree(arr, start_index, mid - 1)\n curr_root.right = build_tree(arr, mid + 1, end_index)\n curr_root\n end", "def build_tree(preorder, inorder)\n return nil if preorder.empty? && inorder.empty?\n\n array = []\n\n node = Node.new(preorder.first)\n\n array << preorder.first\n\n idx = inorder.index(preorder.first)\n\n left_inorder = inorder[0...idx]\n right_inorder = inorder[(idx+1)..-1]\n\n left_preorder = preorder & left_inorder\n right_preorder = preorder & right_inorder\n\n node.left = build_tree(left_preorder, left_inorder)\n node.right = build_tree(right_preorder, right_inorder)\n\n node\nend", "def build_tree(item_list = @sorted_list,root_node = nil)\n #sorted root sorts and removes duplicates from the item list\n if (item_list[0] == nil)\n return nil\n else\n start = 0\n end_of_item_list = item_list.length - 1\n mid = (start + item_list.length) / 2\n #set the root node then start creating a tree node for the left and right side of the array\n #Then after that branch is created attach it to the correct position\n root_node = Node.new(item_list[item_list.length/2])\n root_node.right = build_tree(item_list[0,mid],root_node) \n root_node.left = build_tree(item_list[mid+1,end_of_item_list],root_node)\n return root_node\n end\n \n end", "def to_tree\n if term?\n [type, *args]\n else\n [type, *args.map(&:to_tree)]\n end\n end", "def build_tree\n index = 0\n @ignore_list.each do |attribute|\n #puts \"Attribute: #{attribute}\"\n #puts \"Result: #{@max_result_array[index]}\"\n #puts \"Count: #{@max_class_count_array[index]}\"\n\n @max_class_count_array[index].each do |label, count|\n isLeaf = false\n result = nil\n #puts \"Label: #{label}, Count: #{count}\"\n c1_count = count['<=50K.']\n c2_count = count['>50K.']\n ratio_a = c1_count.to_f / c2_count.to_f\n ratio_b = c2_count.to_f / c1_count.to_f\n #puts \"ratio_a: #{ratio_a} || ratio_b: #{ratio_b} || c1: #{c1_count} || c2: #{c2_count}\"\n if ratio_a >= 30 or ratio_b >= 30 then\n # Have a high ratio, thus we can declare a class\n if c1_count > c2_count\n # declare class 1\n #puts \"Ratio is HIGH, #{ratio_a}, declare any #{attribute} with a #{label} to be class <=50K.\"\n isLeaf = true\n result = '<=50k'\n else\n #puts \"Ratio B is HIGH, #{ratio_b}, declare any #{attribute} with a #{label} to be class >50K.\"\n isLeaf = true\n result = '>50k'\n end\n else\n #puts \"Ratio is too LOW for #{attribute} with label #{label}.\"\n end\n\n if index == 0 then parent = nil else parent = @ignore_list[index-1] end\n\n if isLeaf then\n @tree[label] = Hash['attribute' => attribute, 'label' => label, 'isLeaf' => isLeaf, 'result' => result, 'child' => nil, 'parent' => parent]\n else\n @tree[label] = Hash['attribute' => attribute, 'label' => label, 'isLeaf' => isLeaf, 'result' => result, 'child' => @ignore_list[index+1], 'parent' => parent]\n end\n\n end\n index += 1\n end\n\n @tree.each { |node| puts node }\n end", "def build_tree(inorder, postorder)\n return nil if inorder.empty?\n last_node_val = postorder.last\n last_node_index = inorder.index(last_node_val)\n node = TreeNode.new(last_node_val)\n \n if last_node_index > 0\n node.left = build_tree(inorder[0..last_node_index-1], postorder[0..last_node_index-1])\n end\n \n if last_node_index < inorder.length-1\n node.right = build_tree(inorder[last_node_index+1..-1], postorder[last_node_index..-2])\n end\n node\nend", "def generate_class_tree_level(parent='')\n $all.map { |klass|\n if parent == klass['parentname']\n [\n klass['name'],\n \"classes/#{klass['fullname']}.html\", # klass.path, \n '',\n generate_class_tree_level(klass['fullname'])\n ]\n else\n nil\n end\n }.compact\nend", "def tree\r\n @rootNode\r\n end", "def tree(name, finder, partial = T.unsafe(nil), seen = T.unsafe(nil)); end", "def generate_tree(operands, operators, parent_node)\n return operands[0] if operands.length==1\n\n i = index_of_lowest_precedence(operators)\n operator = operators[i]\n new_operand = node_class.new(parent_node)\n new_operand.add_match generate_tree(operands[0..i], operators[0..i-1],new_operand), :left\n new_operand.add_match operators[i], :operator_node\n new_operand.add_match generate_tree(operands[i+1..-1], operators[i+1..-1],new_operand), :right\n new_operand\n end", "def generate_tree_nodes(ttt)\n while !@avail_moves.empty?\n player_moves = create_new_players_moves_array\n player_makes_move(player_moves)\n create_new_child_node(ttt, player_moves)\n end\n end", "def build_score_tree\n tree_nodes = []\n root_node = nil\n\n @nodes.each do |n|\n if n['key'] == 1\n root_node = build_node_from_model(n)\n root_node['parent_id'] = 0\n else\n tree_nodes.push(build_node_from_model(n))\n end\n end\n\n node_list = { 1 => root_node }\n tree_nodes.each do |n|\n node_list[n['id']] = n\n node_list[n['parent_id']]['children'].push(node_list[n['id']])\n end\n root_node\n end", "def print_tree\n ''\n end", "def leaf?; false end", "def test_tree_representation\n e =\n'ROOT (0.94)\n outlook => rainy (0.694)\n windy => TRUE (0.0)\n play => no (0.0)\n windy => FALSE (0.0)\n play => yes (0.0)\n outlook => overcast (0.694)\n play => yes (0.0)\n outlook => sunny (0.694)\n humidity => normal (0.0)\n play => yes (0.0)\n humidity => high (0.0)\n play => no (0.0)\n'\n assert_equal e, @tree.to_s\n end", "def build_tree_unsorted(array)\n array.each_index{ |index|\n\n }\nend" ]
[ "0.7332564", "0.7331433", "0.71261656", "0.7088093", "0.7037673", "0.69999087", "0.69929796", "0.69334954", "0.6877431", "0.6811008", "0.6750986", "0.6740798", "0.6737556", "0.6732581", "0.6728313", "0.6715232", "0.67077535", "0.6706999", "0.66814226", "0.66759896", "0.66495144", "0.66451806", "0.66246265", "0.6607098", "0.6601769", "0.6595946", "0.6574459", "0.6571607", "0.6565462", "0.65345776", "0.6531626", "0.652342", "0.6515479", "0.6513828", "0.64929426", "0.64924324", "0.6488997", "0.64651287", "0.644541", "0.64439183", "0.64424044", "0.6440845", "0.6438195", "0.6433452", "0.64084095", "0.63861966", "0.6379081", "0.63754475", "0.6374041", "0.6372355", "0.63713443", "0.63665897", "0.63656026", "0.630901", "0.6301353", "0.62834907", "0.6279068", "0.6262085", "0.6245523", "0.6244633", "0.6240056", "0.6238417", "0.6236798", "0.6222366", "0.62197477", "0.62190783", "0.6217882", "0.62087643", "0.6191944", "0.61888236", "0.61784375", "0.61535823", "0.6138684", "0.61169213", "0.611526", "0.6111916", "0.61115104", "0.6103158", "0.6095976", "0.60954434", "0.6093837", "0.60746855", "0.60605866", "0.60592484", "0.60533303", "0.6042323", "0.6027157", "0.60106456", "0.6009335", "0.6003642", "0.60031444", "0.6001925", "0.5994214", "0.59927696", "0.5983558", "0.5966218", "0.59641534", "0.5959631", "0.59478045", "0.59451556" ]
0.67709553
10
Some students should be enrolled in multiple courses to make the test effective.
def populate_students CoursesUsers.create(courses_users) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_multiple_courses\n \n end", "def enrolled_service_learning_courses(quarter = Quarter.current_quarter, unit = Unit.find_by_abbreviation(\"carlson\"), options = {:enrolled_courses_options => {}})\n quarter = [quarter] unless quarter.is_a?(Array)\n @enrolled_service_learning_courses = []\n for q in quarter\n service_learning_courses = unit.nil? ? q.service_learning_courses : q.service_learning_courses.for_unit(unit)\n enrolled_courses = enrolled_courses(q, {:include_extra_enrollees => true}.merge(options[:enrolled_courses_options]))\n eslc ||= extra_service_learning_courses\n for slc in service_learning_courses\n @enrolled_service_learning_courses << slc if !(slc.courses.collect(&:course) & enrolled_courses).empty? || eslc.include?(slc)\n end\n end\n @enrolled_service_learning_courses.uniq\n # service_learning_courses = quarter.is_a?(Array) ? quarter.collect(&:service_learning_courses).flatten : quarter.service_learning_courses\n # service_learning_courses.reject {|service_learning_course| !service_learning_course.enrolls?(self, :include_extra_enrollees => true)}\n end", "def courses\n Course.all.select { |course_inst| course_inst.student == self }\n end", "def test_courses_are_associated_with_course_students\n course = Course.create(name: \"Ruby on Rails\", course_code: \"ROR600\", color: \"Violet\")\n student = CourseStudent.create(student_id: 1)\n student_two = CourseStudent.create(student_id: 2)\n\n assert course.course_students << student\n assert course.course_students << student_two\n\n assert_equal 2, course.course_students.count\n end", "def section_courses\n all_sections = sections.to_a.concat(sections_as_student).uniq\n\n # In the future we may want to make it so that if assigned a script, but that\n # script has a default course, it shows up as a course here\n all_sections.map(&:course).compact.uniq\n end", "def check_courses\n\t\t# Check permissions\n\t\tif (not @current_user.is_administrator?) && (not @current_user.courses.include?(@course))\n\t\t\tredirect_to root_path, notice: \"Access Denied\"\n\t\t\treturn\n\t\tend\n\tend", "def check_courses\n\t\t# Check permissions\n\t\tif (not @current_user.is_administrator?) && (not @current_user.courses.include?(@course))\n\t\t\tredirect_to root_path, notice: \"Access Denied\"\n\t\t\treturn\n\t\tend\n\tend", "def requisite_course_taken?(courses, department, level)\n courses.any? do |course|\n course.department == department && course.level.to_s == level\n end\n end", "def enrolled_in?(course)\n\t self.courses.include?(course)\n end", "def enrolled_in_which?(courses)\n courses.reject {|course| !self.enrolled_in?(course)}\n end", "def show_enrolled_courses\n EnrolledCourse.where(student: self).order(:course_id).map(&:course)\n end", "def test_course_associated_with_students_through_course_students\n c = Course.create(course_code: \"tiy 234\", name: \"Goat Cheese Making\", term_id: 2)\n cs = CourseStudent.create()\n u = User.create(first_name: \"Ilan\", last_name: \"Man\", email: \"[email protected]\", photo_url: \"http://www.photo.com\")\n c.course_students << cs\n u.course_students << cs\n assert_equal [u], Course.find(c.id).students\n end", "def courses\n # Course.all.select do |course|\n # course.student == self\n # end \n Course.all.select { |course| course.student == self }\n end", "def add_students\n @course = Course.find(params[:id])\n to_add = params[:to_be_added]\n if to_add\n\t\t\tnot_added = []\n to_add.each do |stu_id, do_it|\n if do_it == \"yes\"\n student = Student.find(stu_id)\n\t\t\t\t\tif not @course.add_student(student)\n\t\t\t\t\t\t not_added << student.name\n\t\t\t\t\tend\n end\n end\n end\n\t\tif not not_added.empty?\n\t\t\tflash[:notice] = \"Students has already joined this course:\" + not_added.join(\",\")\n\t\tend\n\t\tredirect_to students_admin_course_path(@course)\n end", "def can_add_course?\n self.available_courses > 0 || self.clearance?\n end", "def is_taking?(course)\n courses.include?(course)\n end", "def get_test_courses\n return [get_courses_in_page('https://www.sis.hawaii.edu/uhdad/avail.classes?i=MAN&t=201430&s=ICS'),\n get_courses_in_page('https://www.sis.hawaii.edu/uhdad/avail.classes?i=MAN&t=201430&s=MATH'),\n get_courses_in_page('https://www.sis.hawaii.edu/uhdad/avail.classes?i=MAN&t=201430&s=PSY')]\n end", "def set_students\n @courses = Course.find(params[:course_id])\n end", "def pass_student(student, test_name)\n BoatingTest.all.select{|bt| bt.instructor == self }.select{|bt| bt.student == student && bt.test_name == test_name}.each{|bt| bt.test_status = 'passed'}\n end", "def process_courses(user)\n if !user.global_role.can_edit_system_configuration? &&\n !user.global_role.can_manage_all_courses?\n\n # Everyone can manage their own course enrollments\n can :manage, CourseEnrollment, user_id: user.id\n\n can :enroll, CourseOffering, self_enrollment_allowed: true\n\n can :unenroll, CourseOffering\n\n # A user can manage a CourseOffering if they are enrolled in that\n # offering and have a CourseRole where can_manage_course? is true.\n can [:edit, :update], CourseOffering,\n CourseOffering.managed_by_user(user) do |co|\n co.is_manager? user\n end\n\n # A user can grade a CourseOffering if they are enrolled in that\n # offering and have a CourseRole where can_grade_submissions? is true.\n can :generate_gradebook, CourseOffering do |co|\n co.is_staff? user\n end\n\n # Likewise, a user can only manage enrollments in a CourseOffering\n # that they have can_manage_courses? permission in.\n can :manage, CourseEnrollment do |enrollment|\n enrollment.course_offering.is_manager? user\n end\n end\n end", "def test_school_courses_thru_terms_06\n s = School.create(name: \"The Iron Yard\")\n c = Course.create(name: \"Things 101\")\n t = Term.create(name: \"Fall 2015\")\n t.courses << c\n s.terms << t\n assert s.courses.include?(c)\n end", "def courses_taked\n\t\tself.normal_scores.includes(:course_detail, :semester, :course_teachership, :course, :course_field)\n\tend", "def update_courses(courses)\n courses = courses.to_s.split(\"\\r\\n\").map { |c| c.upcase.gsub(/\\s+/, \"\") }.map{ |name| {:name => name, :semester => self.current_semester}} #split, remove spaces/capitialize, and turn into an array of hashes\n #should now look like ex: [{:name => CS61A, :semester => \"Spring2019\"}, {:name => CS170, :semester => \"Spring2019\"}]\n # can verify correctness of hashes by uncommenting lines below\n # courses2.each do |c|\n # puts(c[:name])\n # end\n\n # update all current_semester_courses to be inactive\n self.where(semester: self.current_semester).update_all(:active => false)\n\n\n # find existing courses and update to active or create new courses\n courses.each do |course|\n @c = self.where(course).first_or_create\n @c.update(:active => true)\n end\n\n # verify that the number of active courses is now the same.\n return self.current_active_courses.count == courses.uniq.count\n end", "def update_courses\n unless course_ids.nil?\n self.enrollments.each do |e|\n e.destroy unless course_ids.include?(e.course_id.to_s)\n course_ids.delete(e.course_id.to_s)\n end \n course_ids.each do |c|\n self.enrollments.create(:course_id => c) unless c.blank?\n @cse = Course.find(c)\n @cse.assignments.each do |assignment|\n Gradation.create(:assignment_id => assignment.id, :student_id => self.id, :course_id => c)\n end\n reload\n self.course_ids = nil\n end\n end\nend", "def test_school_can_have_many_courses_through_terms\n school = School.create(name: \"The Iron Yard\")\n term = Term.create(name: \"Spring 2016 Cohort\", starts_on: \"2016-02-01\", ends_on: \"2016-05-22\")\n course = Course.create(name: \"Ruby on Rails\", course_code: \"ROR600\", color: \"Violet\")\n course_one = Course.create(name: \"Front End\", course_code: \"JST600\", color: \"Mustard\")\n\n school.terms << term\n term.courses << course\n term.courses << course_one\n\n assert_equal 2, school.courses.count\n end", "def save_courses\n if self.course_selections.empty?\n self.errors.add(:you, 'must apply for at least one course')\n return false\n end\n self.current_stage = :submit_stage\n self.save validate: false # don't want to worry about rest of application here.\n end", "def test_assignments_are_associated_with_courses\n course = Course.create(name: \"Ruby on Rails\", course_code: \"ROR600\", color: \"Violet\")\n assignment = Assignment.create(name: \"Battleship\", percent_of_grade: 10)\n assignment_two = Assignment.create(name: \"Currency Converter\", percent_of_grade: 10)\n assignment_three = Assignment.create(name: \"Time Entries\", percent_of_grade: 10)\n\n assert course.assignments << assignment\n assert course.assignments << assignment_two\n assert course.assignments << assignment_three\n\n assert_equal 3, course.assignments.count\n end", "def index\n @courses = Course.all\n @student = User.find(session[:user_id])\n @courses_enrolled = @student.courses\n end", "def show_your_courses_label?\n return true if submitted_and_current_courses?\n return false if only_past_submitted_courses?\n return true if submitted_but_no_current_or_past_courses?\n return true if current_courses_but_incomplete_instructor_training?\n end", "def course_user_and_group_in_same_course\n return if group.course == course_user.course\n errors.add(:course_user, :not_enrolled)\n end", "def update_exam_collisions\n @colliding_courses = false\n\n @list_selected_courses.each do |model, path, iter|\n course = iter[2]\n next if course.first_test_date.nil?\n other_courses = @selected_courses - [ course ]\n\n my_test_dates = [course.first_test_date, course.second_test_date]\n\n my_test_dates.reject! { |x| x.nil? }\n\n exam_dates_a = other_courses.collect { |c| c.first_test_date }\n exam_dates_b = other_courses.collect { |c| c.second_test_date }\n\n exam_dates_a.reject! { |x| x.nil? }\n exam_dates_b.reject! { |x| x.nil? }\n\n exam_dates = Set.new(exam_dates_a + exam_dates_b)\n\n if exam_dates.intersection(my_test_dates).empty?\n iter[0] = course.name\n iter[3] = nil\n else\n @colliding_courses = true\n iter[0] = \"*%s*\" % course.name\n iter[3] = \"red\"\n end\n end\n\n on_selected_course_selection\n end", "def expected_grades\n assignment.course.students.count\n end", "def course_students\n return student_terms.find_all_by_term_type(\"Course\")\n end", "def index\n @course=current_user.teaching_courses if teacher_logged_in?\n @course=current_user.courses if student_logged_in?\n \n @course_all=Course.all\n @course_all=@course_all-@course\n @course_true = Array.new\n @course_all.each do |single|\n if single.open then\n @course_true.push single\n end\n end\n end", "def process_courses(user)\n # A user can manage a CourseOffering if they are enrolled in that\n # offering and have a CourseRole where can_manage_course? is true.\n\n can :read, CourseOffering do |offering|\n user.course_offerings.include?(offering)\n end\n\n can :manage, CourseOffering do |offering|\n user.managing_course_offerings.include?(offering)\n end\n\n # Likewise, a user can only manage enrollments in a CourseOffering\n # that they have can_manage_courses? permission in.\n can :manage, CourseEnrollment do |enrollment|\n user_enrollment = CourseEnrollment.where(\n user_id: user.id,\n course_offering_id: enrollment.course_offering.id).first\n\n user_enrollment && user_enrollment.course_role.can_manage_course?\n end\n end", "def create_some_user_courses\n\n #UserCourse.destroy_all\n\n # input data\n data = [\n { code: 'MS-A0501', time: '2011-I', grade: 4 }, # stl\n { code: 'MS-A0101', time: '2009-I', grade: 3 }, # diff1\n { code: 'CSE-A1121', time: '2010-III', grade: 5 }, # ohjp2\n { code: 'CSE-A1141', time: '2010-III', grade: 5 }, # trak\n { code: 'MS-C2104', time: '2011-III', grade: 2 } # tap\n ]\n\n @user = User.where( :id => 2 ).first\n\n data.each do |dat|\n puts 'creating user course |%s|...' % [ dat ]\n\n abstract_course = AbstractCourse.where( code: dat[:code] ).first\n if abstract_course.nil?\n raise 'nil abstract course!'\n end\n\n # check whether the user has already passed the course\n if @user.passed?( abstract_course )\n puts ' - course %s already passed' % ( abstract_course.code )\n end\n\n period = get_period( dat[:time] )\n course_instance = CourseInstance.where( 'abstract_course_id = ? AND period_id = ?', abstract_course.id, period.id ).first\n #course_instance = CourseInstance.where( :abstract_course => abstract_course, :period => period ).first\n if course_instance.nil?\n raise 'nil course_instance!'\n end\n\n # creating the user course\n ucourse = UserCourse.create(\n :user_id => @user.id,\n :abstract_course_id => abstract_course.id,\n :course_instance_id => course_instance.id,\n :grade => dat[:grade]\n )\n end\n end", "def same_graduate_course_required\n ids = @current_user.graduate_course_ids\n graduate_course = GraduateCourse.find(:all, :include => {:curriculums => :teachings},\n :conditions => [\"graduate_courses.id IN (?) AND teachings.id = ?\", ids, params[:id]])\n unless graduate_course.size != 0\n flash[:error] = \"Questo insegnamento non appartiene a nessun tuo corso di laurea\"\n redirect_to timetables_url\n end\n end", "def list_courses(courses_collection)\n courses_collection.each do |course|\n\n end\n end", "def initialize(user, user_course)\n super(user)\n user ||= User.new\n user_course ||= UserCourse.new\n course = user_course.course\n\n can :read, course\n can :new, EnrollRequest\n can :read, UserCourse\n unless user.persisted?\n # not logged in user\n cannot :read, [Assessment::Mission, Assessment::Training, Assessment::PolicyMission, Assessment::RealtimeTraining]\n end\n\n if user.is_lecturer?\n can :ask_for_share, Course\n can :create, Course\n user.user_courses.lecturer.includes(:course).each do |uc|\n can :manage, uc.course\n end\n end\n\n if user_course.is_shared?\n can :share, Course\n can :participate, Course\n can :duplicate, Course\n can :read, [Assessment::Mission, Assessment::Training]\n can :view_detail, [Assessment::Mission, Assessment::Training]\n can :read, Tag\n can :students, Course\n end\n\n if user.is_admin? || user_course.is_staff?\n # this is enough since all resources are loaded related to\n # the current course\n can :manage, :all\n # can :manage, [Assessment, Assessment::Training, Assessment::Mission, Assessment::Submission, Assessment::Grading]\n # can :manage, [Assessment::Question, Assessment::McqQuestion, Assessment::CodingQuestion]\n # can :manage, [Assessment::Answer, Assessment::McqAnswer, Assessment::CodingAnswer, Assessment::GeneralAnswer]\n # can :manage, [Level, Achievement, Tab, Announcement]\n # can :manage, [LessonPlanEntry, LessonPlanMilestone, MaterialFolder, Material]\n # can :manage, [Survey, ForumForum, ForumTopic]\n # can :manage, [Course, UserCourse, ExpTransaction]\n # can :manage, [Annotation, Comment]\n # can :manage, [TagGroup, Tag]\n # can :see, :pending_gradings\n # can :see, :pending_comments\n # can :view, :staff_leaderboard\n # can :manage, :forum_participation\n # can :manage, [EnrollRequest, MassEnrollmentEmail]\n\n cannot :modify, Assessment::Submission\n #TOFIX, this is just for english\n cannot :manage, TagGroup, name: \"Uncategorized\"\n end\n\n if user_course.is_lecturer? && !user.is_admin?\n cannot :manage, :user\n end\n\n if user_course.is_ta? && !user.is_admin?\n cannot :manage, :user\n cannot :manage, :course_preference\n cannot :manage, :staff\n cannot :destroy, Course\n cannot :manage, :course_admin\n end\n\n if user.is_admin? || user_course.is_staff?\n return\n end\n\n if user_course.is_student?\n can :participate, Course\n can :read, UserCourse\n can :read, Announcement, Announcement.published\n \n # Materials: The file is accessible to students if the student uploaded\n # the file, or course staff uploaded the file.\n can :read, MaterialFolder, ['open_at <= ? OR open_at IS NULL', DateTime.now] do |folder|\n folder.open_at == nil || folder.open_at <= DateTime.now\n end\n can :upload, MaterialFolder, [\n 'can_student_upload = ? AND \\\n (open_at <= ? OR open_at IS NULL) AND \\\n (close_at >= ? OR close_at IS NULL)', true, DateTime.now, DateTime.now] do |folder|\n folder.can_student_upload? && folder.is_open?\n end\n can :manage, Material, :file => { :creator_id => user.id }\n can :read, Material, :file => {\n :creator_id => UserCourse.staff.where(:course_id => user_course.course).pluck(:user_id) }\n\n # Forums: The posts are accessible if they are not marked hidden, regardless of whether they\n # made the thread or not. Hiding is an admin function.\n #\n # Students can delete their own posts and threads.\n can :read, ForumForum\n can :subscribe, ForumForum\n can :unsubscribe, ForumForum\n can :create, ForumTopic\n can :create_topic, ForumForum, locked: false\n can :reply_topic, ForumTopic do |topic|\n !topic.locked? && !topic.forum.locked?\n end\n can :subscribe, ForumTopic\n can :unsubscribe, ForumTopic\n can :read, ForumTopic, hidden: false\n can :read, ForumTopic, author_id: user_course.id\n can :reply, ForumTopic, locked: false\n can [:edit, :update, :destroy], ForumTopic do |topic|\n !topic.locked? && topic.author == user_course && !topic.forum.locked?\n end\n can :set_answer, ForumPost do |post|\n post.topic.author == user_course && !post.topic.locked?\n end\n can :read, ForumPost\n can :create, ForumPost\n can :set_vote, ForumPost\n\n # Students can edit their own posts\n can [:edit, :update, :destroy], ForumPost do |post|\n post.author == user_course && !post.topic.locked? && !post.topic.forum.locked?\n end\n\n\n # Students cannot make topics sticky nor announcements, they also cannot lock and make posts hidden\n cannot :set_sticky, ForumTopic\n cannot :set_announcement, ForumTopic\n cannot :set_lock, ForumTopic\n cannot :set_hidden, ForumTopic\n\n cannot :destroy, [Assessment::Submission]\n\n can :read, [LessonPlanEntry]\n can :read, [LessonPlanMilestone], is_publish: true\n can :submission, LessonPlanEntry\n can :mission_update, LessonPlanEntry\n\n can :read, Assessment, published: true\n can :access_denied, Assessment\n can :read, [Assessment::Mission, Assessment::Training, Assessment::PolicyMission, Assessment::RealtimeTraining], assessment: {published: true}\n can :answer_sheet, Assessment::PolicyMission\n can :read, Survey, publish: true\n\n # can :read, [Mcq, Question, CodingQuestion]\n\n can :read, Tag\n can :read, Achievement\n \n can :read, Topicconcept\n can :get_topicconcept_rated_data, Topicconcept\n can :get_topicconcept_data, Topicconcept\n can :diagnostic_exploration, Topicconcept\n can :diagnostic_exploration_next_question, Topicconcept\n can :review_diagnostic_exploration, Topicconcept\n can :review_diagnostic_exploration_on_stage, Topicconcept\n can :submit_answer, Topicconcept\n can :get_topicconcept_single_statistics, Topicconcept\n can :get_topicconcept_data_noedit, Topicconcept\n can :get_topicconcept_single_current_statistics, Topicconcept\n can :get_topicconcept_best_concepts, Topicconcept\n can :get_topicconcept_notbest_concepts, Topicconcept\n can :get_progress_bar_info, Topicconcept\n\n can :get_topicconcept_data_with_criteria , Assessment::GuidanceQuiz\n can :get_topicconcept_data_history , Assessment::GuidanceQuiz\n can :get_guidance_concept_data, Assessment::GuidanceQuiz \n can :get_guidance_concept_data_no_stats, Assessment::GuidanceQuiz \n can :get_guidance_concept_edge_data, Assessment::GuidanceQuiz\n can :get_guidance_concept_edges_data, Assessment::GuidanceQuiz\n can :get_scoreboard_data, Assessment::GuidanceQuiz\n\n can :students, Course\n\n can :manage, Assessment::Submission, std_course_id: user_course.id\n can :read, Assessment::Submission do |sub|\n sub.std_course_id.nil? and sub.group_stds.include?(user_course)\n end\n can :manage, [Annotation, Comment], user_course_id: user_course.id\n can :manage, SurveySubmission, user_course_id: user_course.id\n can :manage, SurveyMrqAnswer, user_course_id: user_course.id\n can :manage, Assessment::Answer, std_course_id: user_course.id\n #can :read, Assessment::Grading, std_course_id: user_course.id\n can :read, Assessment::Grading do |grad|\n grad.std_course_id == user_course.id || (grad.std_course_id.nil? and grad.submission.group_stds.include?(user_course))\n end\n can :read, ExpTransaction, user_course_id: user_course.id\n\n can :ignore, PendingAction, user_course: user_course\n\n can :read, Comic\n can :info, Comic\n\n cannot :modify, Assessment::Submission\n cannot :see_all, Assessment::Submission\n\n can :read, Assessment::McqQuestion\n end\n end", "def add_student\n #teacher added student\n if params[:join_code] == nil\n @teacher = current_user\n if @teacher.user_type == 2 or @teacher.user_type = 3\n @course = Course.find_by(id: params[:course_id])\n if @course and @course.teacher_id = @teacher.id\n @student = User.find_by(id: params[:student_id])\n if @student and (@student.enrollments.where(course_id: @course.id) == nil or @student.enrollments.where(course_id: @course.id) == []) and @student.id != @teacher.id\n @enrollment = Enrollment.new\n @enrollment.course_id = @course.id\n @enrollment.user_id = @student.id\n @enrollment.save\n redirect_to \"/courses/view/#{@course.id}\"\n else\n redirect_to \"/users/view/#{@teacher.id}\"\n end\n else\n redirect_to \"/users/view/#{@teacher.id}\"\n end\n else\n redirect_to \"/users/view/#{@teacher.id}\"\n end\n #student joined with join code\n else\n @course = Course.find_by(join_code: params[:join_code])\n puts @course\n @student = current_user\n if @course\n if @student.enrollments.where(course_id: @course.id) == nil or @student.enrollments.where(course_id: @course.id) == []\n @enrollment = Enrollment.new\n @enrollment.course_id = @course.id\n @enrollment.user_id = @student.id\n @enrollment.save\n end\n redirect_to \"/courses/view/#{@course.id}\"\n else\n redirect_to \"/users/view/#{@student.id}\"\n end\n end\n end", "def set_students\n @course = Course.find(params[:course_id])\n end", "def set_students\n @course = Course.find(params[:course_id])\n end", "def test_course_students_associated_with_users\n cs = CourseStudent.create()\n u = User.new(first_name: \"Ruti\", last_name: \"Wajnberg\", email: \"[email protected]\", photo_url: \"https://www.photo.com\")\n u.save\n u.course_students << cs\n assert_equal [cs], User.find(u.id).course_students\n end", "def pass_student (student_name, test_name)\n test_to_change = BoatingTest.all.select {|test|\n test.name == test_name &&\n test.student.first_name == student_name &&\n test.instructor == self\n }\n\n if test_to_change[0] == nil\n test_to_change << BoatingTest.new(Student.find_student(student_name),test_name, \"passed\", self)\n else\n test_to_change[0].status = \"passed\"\n end\n test_to_change\n end", "def research_courses\n Course.find :all, :conditions => { :ts_year => year, :ts_quarter => quarter_code, :ts_research => true }\n end", "def test_courses_are_associated_with_course_students\n course = Course.create(name: \"Ruby on Rails\", course_code: \"ROR600\", color: \"Violet\")\n student = CourseStudent.create(student_id: 1)\n student_two = CourseStudent.create(student_id: 2)\n\n assert course.course_students << student\n assert course.course_students << student_two\n\n refute course.destroy\n end", "def create\n course = Course.find(params[:course_id])\n student = Student.find_by(dni: params[:student_id])\n @enroll = Enroll.new( student: student, course: course)\n TestCourse.of(course).each do |tc|\n Score.create( student: student, test_id: tc.test_id, value: -2)\n end\n \n respond_to do |format|\n if @enroll.save\n format.html { redirect_to course_enrolls_path(course), notice: 'Enroll was successfully created.' }\n format.json { render :show, status: :created, location: course_enrolls_path(course) }\n else\n format.html { render :new }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end", "def handle_courses(course_names)\n return if !self.undergrad? || course_names.nil?\n self.courses = [] # eliminates any previous enrollments so as to avoid duplicates\n course_array = []\n course_array = course_names.split(',').uniq if course_names\n course_array.each do |item|\n self.courses << Course.find_or_create_by(name: item.upcase.strip)\n end\n end", "def passed?(transcript, courses_taken)\n return false unless courses_taken.include?(course_id)\n\n passed_minimum_grade?(transcript)\n end", "def test_courses_must_have_course_code_and_name\n course = Course.new(name: \"Ruby on Rails\", course_code: \"ROR600\", color: \"Violet\")\n course_one = Course.new(course_code: \"JST600\", color: \"Mustard\")\n course_two = Course.new(name: \"Front End\", color: \"Mustard\")\n\n assert course.save\n refute course_one.save\n refute course_two.save\n end", "def index\n @course=current_user.teaching_courses if teacher_logged_in?\n @course=current_user.courses if student_logged_in?\n end", "def enrolled_in?(course)\n course.all_enrollees.include?(self)\n end", "def manage_c6s\n sam_student_id = params[:sam_student_id]\n # retrieves courses which are supervised by the course coordinator\n @courses = current_staff.courses\n @hash = {}\n # if no student ID is submitted,\n # it lists all the students who missed practicals for the courses belonging to the course coordinator\n if sam_student_id.nil?\n @courses.each do |course|\n @hash[course.course_title] = AbsenceCertificate.where(\"certificate_type = ? AND course_id = ?\", \"C6\", course.id)\n end\n else\n # if a student ID is submitted, the absence certificates for that student are displayed\n student = Student.find_by(sam_student_id: sam_student_id)\n # if the student exists in the database, a hash is filled with their absence certificates (to be rendered/presented later in the corresponding view)\n if !student.nil?\n @courses.each do |course|\n @hash[course.course_title] = AbsenceCertificate.where(\"certificate_type = ? AND course_id = ? AND student_id = ?\", \"C6\", course.id, student.id)\n end\n # if no student is found with that ID, it sets an alert message and redirects user to the manage_c6s page\n else\n flash[:alert] = \"There is no student with student ID: #{sam_student_id}\"\n redirect_to manage_c6s_path\n end\n end\n end", "def enrolls?(student, options = {})\n options = {:include_extra_enrollees => true}.merge(options)\n courses.each do |c|\n return true if c.course.enrolls?(student, options)\n end\n return true if options[:include_extra_enrollees] == true && extra_enrollees.include?(student)\n false\n end", "def test_course_has_many_instructors_through_course_instructors\n course = Course.create(name: \"Ruby on Rails\", course_code: \"ROR600\", color: \"Violet\")\n mason = User.create(first_name: \"Mason\", last_name: \"Matthews\", email: \"[email protected]\", photo_url: \"https://avatars1.githubusercontent.com/u/5350842?v=3&s=400\")\n da_me = User.create(first_name: \"Da-Me\", last_name: \"Kim\", email: \"[email protected]\")\n\n course.instructors << mason\n course.instructors << da_me\n\n assert_equal 2, course.course_instructors.count\n assert_equal 2, course.instructors.count\n end", "def courses\n @learn_courses\n end", "def course_sections\n ['1', '2']\n end", "def course\n if validateurl({\"name\": params[:name], \"semester\": params[:semester], \"coursename\": params[:course]})\n @semester = params[:semester]\n @coursename = params[:course]\n courseid = Course.select(\"id\").where(\"name = '\" + @coursename + \"' AND semester = '\" + @semester + \"'\" ).ids[0].to_s\n @students = ActiveRecord::Base.connection.execute(\"SELECT grades.grade, students.name FROM grades, students WHERE '\" + courseid.to_s + \"' = grades.course_id AND '\" + @semester.to_s + \"' = grades.semester AND students.id = grades.student_id\")\n end\n end", "def add_course(valid_course)\n courses << valid_course\n end", "def test_course_instructors_with_courses\n create_course = Course.create(name: \"Ruby 101\", course_code: \"RUB101\")\n instructor = CourseInstructor.create()\n # student = CourseStudent.create()\n create_course.course_instructors << instructor\n assert create_course.reload.course_instructors.include?(instructor)\nend", "def test_terms_are_associated_with_courses\n school = School.create(name: \"The Iron Yard\")\n term = Term.new(name: \"Spring 2016 Cohort\", starts_on: \"2016-02-01\", ends_on: \"2016-05-22\")\n course = Course.new(name: \"Ruby on Rails\", course_code: \"ROR600\", color: \"Violet\")\n course_one = Course.new(name: \"Front End\", course_code: \"JST600\", color: \"Mustard\")\n school.terms << term\n assert term.courses << course\n assert term.courses << course_one\n\n assert_equal 2, term.courses.count\n end", "def get_courses\n\t\tif current_student.id.to_i == params[:id].to_i\n\t\t\t@student = Student.find(params[:id])\n\t\t\t@evaluations = @student.evaluations\n\t\tend\n\t\trender 'get_courses'\n\tend", "def generate_course_memberships(section_rows, instructor_row)\n enrollments = []\n section_rows.each do |section_row|\n enrollments << {\n 'course_id' => section_row['course_id'],\n 'user_id' => instructor_row['user_id'],\n 'role' => 'teacher',\n 'section_id' => section_row['section_id'],\n 'status' => 'active'\n }\n end\n enrollments\n end", "def test_course_students_associated_with_assignment_grades\n cs = CourseStudent.create()\n ag = AssignmentGrade.create()\n cs.assignment_grades << ag\n assert_equal [ag], CourseStudent.find(cs.id).assignment_grades\n end", "def show\n id = params[:c_id]\n\t\tlogger = Logger.new('log/course.log')\n\t\tlogger.info params.inspect\n @course = Course.find(id) \n requires({'role' => ['admin','faculty','student'],'course_id' => id})\n\t\t#if the course is found & and the user is enrolled in the course, retrieve mappings of students and tas to a course.\n unless (@course.nil? || current_user.nil?)\n @students = StudentInCourse.where(:course_id => id)\n @tas = TaForCourse.where(:course_id => id)\n @teacher = User.where(:id => @course.user_id).first\n @admin = User.where(:role => 'admin')\n\t\t\t#Detect whether user is student or faculty for this given course (can't use roles due to TAs)\n @user_is_student = [email protected]_all_by_user_id(current_user.id).empty?\n @user_is_ta_or_faculty_or_admin = [email protected]_all_by_user_id(current_user.id).empty? || (current_user.id == @teacher.id unless @teacher.nil?) || (@admin.include?(current_user) unless @admin.nil?)\n if(@user_is_student)\n @assignments = Assignment.where(:course_id => id, :hidden => false)\n else\n @assignments = Assignment.where(:course_id => id)\n end\n \n @group1 = CourseGroup.find_all_by_course_id_and_group(id, 0).collect(&:user_id)\n @group2 = CourseGroup.find_all_by_course_id_and_group(id, 1).collect(&:user_id)\n \n\t\t\t@review_assignments = ReviewAssignment.find_all_by_course_id(id)\n end\n end", "def teach(cohort) #check what happens with an arrage\n cohort.each {|student| student.learn } #this will put learn into each\n end", "def add_random_courses(user, courses, course_range, per_bin_range)\n #:: Randomly add courses to a users bins\n user_courses = courses.shuffle.take(rand(course_range))\n while user_courses.any?\n bin_courses = user_courses.shift(rand(per_bin_range))\n\n bin = user.add_course(bin_courses.shift)\n bin_courses.each { |course| bin = user.add_course(course, bin) }\n end\n end", "def update_courses(course_list)\n end", "def can_create_course?\n ptainstructors = Ptainstructor.find_by_semester_id(self.id)\n teachers = Teacher.find_by_semester_id(self.id)\n if ((ptainstructors == nil) or (teachers == nil))\n return false\n end\n return true\n end", "def show\n school_id = @student.school_id\n @course_selection = []\n @assigned_school = School.find(school_id)\n course_ids = @student.course_ids\n course_ids.each do |id|\n selection_unit = Course.find(id)\n @course_selection << selection_unit\n end\n end", "def test_associate_courses_students_03\n timmy = CourseStudent.create(id: 1)\n horsies = Course.create(name: \"Are horsies pretty?\", course_code: \"ABC 123\")\n horsies.course_students << timmy\n assert_equal 1, Course.count\n horsies.destroy\n assert_equal 1, Course.count\n end", "def requirement_satisfied?(time_blocks, course)\n lecture_satisfied = false\n lab_satisfied = !course.lab_required # if lab isn't required, it's satisfied immediately\n tutorial_satisfied = !course.tutorial_required\n time_blocks.each do |tb|\n if (tb.section.course == course)\n if (tb.section_type == 'LectureSection')\n lecture_satisfied = true\n elsif (tb.section_type == 'LabSection')\n lab_satisfied = true\n elsif (tb.section_type == 'TutorialSection')\n tutorial_satisfied = true\n end\n end\n end\n return lecture_satisfied && lab_satisfied && tutorial_satisfied\n end", "def schedule_courses(courses, schedules)\n if (courses.empty?)\n return filter_schedules(schedules)\n end\n\n course_required = courses.pop\n\n # add in all possible lecture sections\n new_schedules = schedule_lecture_sections(LectureSection.where(course: course_required), schedules)\n\n # filtering takes place when the base case is proc-ed\n return schedule_courses(courses, new_schedules)\n end", "def test_course_instructors_associated_with_courses\n c = Course.create(name: \"Tech News\", course_code: \"xyz546\")\n i = CourseInstructor.create()\n c.course_instructors << i\n assert_equal [i], Course.find(c.id).course_instructors\n end", "def available_courses\n MAX_COURSES - self.course_selections_count\n end", "def do_course\n\n # set a couple of variables with the params object\n @course = Course.find_by_id(params[:course_id])\n @lectures = Lecture.find_by_course_id(params[:course_id])\n @course_id = params[:course_id]\n @lesson_id = params[:lesson_id]\n\n # -------check if course is over\n first_id_in_course = Lecture.select(:id).where(course_id: @course_id).first\n last_id_in_course = Lecture.select(:id).where(course_id: @course_id).last\n\n # -------check if lesson is over\n # get first and last lecture of this lesson for traversing the quiz\n first_id_in_lesson = Lecture.select(:id).where(course_id: @course_id, lesson_id: @lesson_id).first\n last_id_in_lesson = Lecture.select(:id).where(course_id: @course_id, lesson_id: @lesson_id).last\n\n\n # this is the id of the current lecture\n #@lecture_id = first_id_in_lesson.id.to_i + params[:lecture_id].to_i - 1\n @lecture_id = params[:lecture_id].to_i\n\n # is the course over? => set the flag accordingly\n if @lecture_id == last_id_in_course.id.to_i\n @course_over = true\n else\n @course_over = false\n end\n\n # is the lesson over? => set the flag accordingly\n if @lecture_id == last_id_in_lesson.id.to_i\n @lesson_over = true\n else\n @lesson_over = false\n end\n\n # retrieve the lesson and the quiz content\n @lesson = Lesson.where(course_id: params[:course_id]).first\n @lecture = Lecture.find(@lecture_id)\n @answer = @lecture.quizAnswers\n @options = @lecture.quizOptions.split(\"-\")\n\n # percentage of the lesson the user has already taken\n @progress = 100.*(@lecture_id.to_f - first_id_in_lesson.id.to_f)/(last_id_in_lesson.id.to_f - first_id_in_lesson.id.to_f)\n\n # these are the course, lesson and lecture ids for the next question\n if @course_over\n @params = {user_id: current_user,\n course_id: @course_id, lesson_id: @lesson_id, lecture_id: @lecture_id, save: 'true'}\n elsif @lesson_over\n course_id_next = params[:course_id]\n lesson_id_next = params[:lesson_id].to_i + 1\n lecture_id_next = params[:lecture_id].to_i + 1\n @params = {course_id: course_id_next, lesson_id: lesson_id_next, lecture_id: lecture_id_next}\n else\n course_id_next = params[:course_id]\n lesson_id_next = params[:lesson_id]\n lecture_id_next = params[:lecture_id].to_i + 1\n @params = {course_id: course_id_next, lesson_id: lesson_id_next, lecture_id: lecture_id_next}\n end\n\n end", "def has_course?(course)\n self.courses.include?(course)\n end", "def has_course?(course)\n self.courses.include?(course)\n end", "def enrolled_courses(quarter = Quarter.current_quarter, options = {})\n @registrations ||= {}; @enrolled_courses ||= {}\n @registrations[quarter] ||= sdb.registrations.for(quarter)\n if @registrations[quarter].nil? && !options[:include_extra_enrollees]\n return [] \n elsif !@registrations[quarter].nil?\n # @enrolled_courses ||= r.courses.enrolled.collect(&:course)\n @enrolled_courses[quarter] ||= @registrations[quarter].courses.find(:all, \n :conditions => \"request_status IN ('A','C','R')\", \n :include => :course).collect(&:course)\n end\n if options[:include_extra_enrollees]\n \n if @enrolled_courses[quarter] && options[:remove_old_extra_enrollees]\n for cee in course_extra_enrollees.for(quarter)\n if @enrolled_courses[quarter].include?(cee.course)\n cee.destroy\n end\n end\n end\n \n course = course_extra_enrollees.for(quarter).collect(&:course)\n if @enrolled_courses[quarter]\n @enrolled_courses[quarter] << course\n else\n @enrolled_courses[quarter] = course\n end\n @enrolled_courses[quarter] = @enrolled_courses[quarter].flatten.uniq\n end\n @enrolled_courses[quarter]\n end", "def add_student_to_course(student_id, name, email)\n if Student.find_by_email(email)\n student = Student.find_by_email(email)\n else\n student = Student.new\n student.email = email\n student.student_id = student_id\n student.name = name\n student.university = Faculty.find(faculty_id).university\n end\n\n if self.surveys.count > 0\n add_student_to_course_surveys(student)\n end\n\n self.students << student\nend", "def grade_for_course(course)\n course_students.find_by(course_id: course).grade\n end", "def enroll\n\n response = {}\n status_code = 200\n\n begin\n\n # Must be POST request to create course\n return unless request.post?\n\n # Retrieves current user\n user = get_logged_user()\n return unless user\n\n if !user\n status_code = 401\n raise 'Not logged in!'\n end\n\n if !user.is? \"supervisor\"\n status_code = 403\n raise 'Student cannot edit course!'\n end\n\n # If a supervisor\n if user.is? \"supervisor\"\n # Get parameters\n student_id = params[:student_id]\n course_id = params[:course_id]\n\n # Only allowed to enroll students in courses he supervises\n return unless user.courses.find(course_id)\n else\n # If unknown class, do nothing\n return\n end\n\n # Create plan\n plan = Plan.new\n\n group = Group.create!(\n :name => \"Pessoal\",\n :min_credits => nil,\n :min_subjects => nil\n )\n\n # Supervisor only enrolls if student exists\n if Student.find(student_id) != nil\n plan.course = Course.find(course_id)\n plan.student = Student.find(student_id)\n plan.group = group\n\n plan.save\n else\n status_code = 404\n raise 'Student does not exist!'\n end\n\n redirect_back fallback_location: \"/\"\n rescue Exception => e\n response[:status] = 'error'\n response[:error] = \"#{e}\"\n else\n status_code 201\n response[:status] = 'success'\n response[:message] = 'Student was enrolled with success!'\n end\n end", "def save_students\n\t\tif @students.blank? \n\t\t\t\t\n\t\telse\n\t\t\[email protected] do |student_id|\n\t\t\t\tHasStudent.create(student_id: student_id, course_id: self.id)\n\t\t\tend\n\t\tend\n\tend", "def potential_service_learners\n service_learning_courses.collect(&:enrollees)\n end", "def course_full\r\n\t\tmax_enrol = Course.find_by(courseID: courseID).size\r\n\t\tcurrent_enrol = Enrollment.where(courseID: courseID).count\r\n\t\tif current_enrol < max_enrol\r\n\t\t\treturn false\r\n\t\telse\r\n\t\t\treturn true\r\n\t\tend\r\n\r\n\tend", "def show\n student = params[:id].nil? ? current_student : Student.find(params[:id])\n @registered_courses = student.courses\n @remaining_courses = Course.all - @registered_courses\n end", "def pass_student(student_name, test_name)\n boating_tests.map do |test|\n test.boating_test_status = \"Passed\"\n end\n end", "def set_enrollments\n @enrollments = Enrollment.where(section_id: params[:id])\n .includes(:student).order('students.family_name')\n @active = @enrollments.where(dropped_course: nil)\n @dropped = @enrollments.where.not(dropped_course: nil)\n end", "def index\n @course=current_user.teaching_courses if teacher_logged_in?\n @course=current_user.courses if student_logged_in?\n @credit_isdegree, @credit_nodegree=cal_degree\n end", "def conclude_course\n end", "def courses\n [self]\n end", "def CA_only?\n course_assistant? && !instructor?\n end", "def test_lessons_and_courses_dependent\n create_lesson = Lesson.create(name: \"Regular Expressions\")\n create_course = Course.create(name: \"Ruby 101\", course_code: \"RUB101\")\n create_course.lessons << create_lesson\n assert create_course.reload.lessons.include?(create_lesson)\n end", "def critical?\n course.critical? || course.returned_sheets > 0\n end", "def add_demonstrator\n @courses = current_staff.courses\n # find future practicals\n current_time = DateTime.now\n @practicals_of_course = {}\n @courses.each do |course|\n @practicals_of_course[course.course_title] = course.practicals.where('start_time >= ?', current_time)\n end\n end", "def complete_course(course, grade, term = nil)\n user_completed_course = completed_courses.where(:course => course).first\n if user_completed_course.nil?\n course_scenarios.each do |scenario|\n taking_course = scenario.taking_courses.where(:course_id => course.id).first\n unless taking_course.nil?\n term ||= taking_course.term\n taking_course.destroy\n end\n end\n user_completed_course = UserCompletedCourse.new\n user_completed_course.course = course\n user_completed_course.user = self\n end\n user_completed_course.term = term\n user_completed_course.grade= grade\n if user_completed_course.save\n true\n else\n self.errors.add :completed_courses, user_completed_course.errors.full_messages\n false\n end\n end", "def index\n if current_user.has_role? :admin\n @courses = Course.all\n render and return\n elsif current_user.has_role? :instructor\n @user = current_user\n @courses = current_user.courses.select { |course| current_user.has_local_role? :instructor, course }\n render \"courses/taught\" and return\n else\n @courses = current_user.courses\n render \"courses/enrolled\" and return\n end\n end", "def set_course_times(courses)\n\n course_lectures = 1..4\n lecture_seats = 15..25\n ts_fiber = time_slot_fiber\n\n # For each course add 1 to 4 lectures\n # Each lecture should have two meeting times\n courses.each do |course|\n course.lectures.destroy_all\n\n # Course has 1..4 lectures\n rand(course_lectures).times do\n m1, m2 = ts_fiber.resume\n lecture = Lecture.new(seats: rand(lecture_seats), meeting1: m1, meeting2: m2)\n course.lectures << lecture\n end\n end\n end", "def is_found_exactly_in?(array_of_courses)\n # Define the list of attributes to match. This list must be updated regularly.\n key_attributes = [\n \"crn\",\n \"gwid\",\n \"section\",\n \"course_name\",\n \"hours\",\n \"days\",\n \"day1_start\",\n \"day1_end\",\n \"day2_start\",\n \"day2_end\",\n \"day3_start\",\n \"day3_end\",\n \"day4_start\",\n \"day4_end\",\n \"day5_start\",\n \"day5_end\",\n \"day6_start\",\n \"day6_end\",\n \"day7_start\",\n \"day7_end\",\n \"llm_only\",\n \"jd_only\",\n \"course_name_2\",\n \"alt_schedule\",\n \"additional_info\",\n \"professor\",\n \"prof_id\",\n \"final_time\",\n \"final_date\",\n \"school\"\n ]\n return Scraper.deep_match_course_attributes(key_attributes, self, array_of_courses)\n end", "def enrolled? (student)\n @students.include?(student) # returns true or false on array existence\n end", "def fail_student(student, test_name)\n BoatingTest.all.select{|bt| bt.instructor == self }.select{|bt| bt.student == student && bt.test_name == test_name}.each{|bt| bt.test_status = 'failed'}\n end" ]
[ "0.79511976", "0.6674152", "0.6667313", "0.6646607", "0.66097176", "0.6595312", "0.6595312", "0.6581144", "0.65519035", "0.65425944", "0.6537532", "0.6486666", "0.64061815", "0.63582504", "0.6350201", "0.63409674", "0.6333139", "0.6328302", "0.63206834", "0.6315694", "0.63060975", "0.62956953", "0.6280453", "0.6268419", "0.6263172", "0.6246951", "0.62391424", "0.62335795", "0.6229947", "0.62279266", "0.6220581", "0.6212943", "0.6210363", "0.62058324", "0.6205443", "0.6190363", "0.6185606", "0.61838514", "0.6180559", "0.61787623", "0.6168324", "0.6168324", "0.6167766", "0.61653644", "0.6164725", "0.6160429", "0.6158131", "0.61358535", "0.6129088", "0.6127135", "0.6124758", "0.6107922", "0.60969967", "0.6092808", "0.6087016", "0.6081106", "0.60730493", "0.60655725", "0.6063785", "0.60535705", "0.6049247", "0.60308695", "0.60270846", "0.6024905", "0.60078907", "0.59969556", "0.5991965", "0.59684193", "0.59639376", "0.59623724", "0.5952241", "0.59442604", "0.59392655", "0.59116936", "0.5905781", "0.59044695", "0.5895716", "0.5895716", "0.5883602", "0.587429", "0.58727825", "0.5869765", "0.5860564", "0.5854889", "0.58524317", "0.585004", "0.5847348", "0.5844959", "0.58438635", "0.58401144", "0.58349586", "0.5804956", "0.58031446", "0.57989293", "0.57981133", "0.57975316", "0.5791133", "0.578695", "0.5778816", "0.5776931", "0.5773676" ]
0.0
-1
Return the 'true' (i.e. most specialized) classname of this object When return_id is true, the 'specialized' database id is also returned
def type(return_id = false) query, levels = self.class.cti_outer_join_sql(id) result = self.class.connection.execute(query).first # replace returned ids with the levels corresponding to their classes result_levels = result.inject({}) do |hash, (k,v)| hash[k] = levels[k] unless v.nil? hash end # find class with maximum level value foreign_key = result_levels.max_by { |k,v| v }.first class_name = DBViewCTI::Names.table_to_class_name(foreign_key[0..-4]) if return_id id_ = result[foreign_key].to_i [class_name, id_] else class_name end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def type(return_id = false)\n query, levels = self.class.cti_outer_join_sql(id)\n result = self.class.connection.execute(query).first\n # replace returned ids with the levels corresponding to their classes\n result_levels = result.inject({}) do |hash, (k,v)|\n hash[k] = levels[k] unless v.nil?\n hash\n end\n # find class with maximum level value\n foreign_key = result_levels.max_by { |k,v| v }.first\n class_name = DBViewCTI::Names.table_to_class_name(foreign_key[0..-4])\n if return_id\n id_ = result[foreign_key].to_i\n [class_name, id_]\n else\n class_name\n end\n end", "def id_class\n @id_class ? @id_class : nil\n end", "def class_name\n @class_name ||= active_record.name\n end", "def typed_id\n self.class.name + ':' + self.id.to_s\n end", "def by_type(id)\n DB_TYPE[id]\n end", "def id\n @id ||= self.class.model_name.name.downcase\n end", "def identifier\n @identifier ||= \"#{self.type_prefix}.#{Model::to_id(name)}\"\n end", "def objname\n id\n end", "def sql_type(name)\n name = (name.kind_of?(String) ? name.split('.').first : name.to_s)\n\n return :belongs_to if belongs_to(name)\n\n # Skip using columns() cause we dont need to check for belongs_to\n column = columns.find { |col| col.name == name }\n\n if column.present?\n column.type\n elsif has_many(name)\n :has_many\n elsif has_one(name)\n :has_one\n elsif belongs_to_polymorphic(name)\n :belongs_to_polymorphic\n elsif has_and_belongs_to_many(name)\n :has_and_belongs_to_many\n elsif active_storage(name)\n :active_storage\n elsif name == 'id' && defined?(EffectiveObfuscation) && klass.respond_to?(:deobfuscate)\n :effective_obfuscation\n elsif name == 'roles' && defined?(EffectiveRoles) && klass.respond_to?(:with_role)\n :effective_roles\n elsif (name.ends_with?('_address') || name.ends_with?('_addresses')) && defined?(EffectiveAddresses) && (klass.new rescue nil).respond_to?(name)\n :effective_addresses\n elsif name.ends_with?('_id')\n :integer\n else\n :string\n end\n end", "def id?\n query_attribute(self.class.primary_key)\n end", "def identifier\n @identifier ||= \"#{self.type_prefix}.#{Model::to_id @schema.title}.#{Model::to_id name}\"\n end", "def record_class_name\n doc['record_class_name']\n end", "def returned_type\n model.returned_type\n end", "def return_id\n\t\treturn @idStr\n\tend", "def return_classname(obj)\r\n obj.class.name.underscore\r\n end", "def make_id\n \"#{self.class.name.downcase}#{id}\"\n end", "def result_id_suffix\n resource_class.name.demodulize\n end", "def class_name()\n return self.id.downcase.gsub(/\\Ah?l_/i, \"\")\n end", "def obj\n return if obj_type.blank?\n return obj_type.constantize.find(obj_id) if obj_id.present?\n obj_type[/[A-Z]/] ? obj_type.constantize : obj_type.to_sym\n end", "def identifier\n id || name || default_identifier\n end", "def identifier\n self.class.identifier_for(send(self.class.identifying_attribute))\n end", "def className\n\t\tself.class.to_s\n\tend", "def className\n\t\tself.class.to_s\n\tend", "def className\r\n\t\tself.class.to_s\r\n\tend", "def name\n self.class.name || self.class.to_s\n end", "def for_database_key\n self.without_type\n end", "def name\n self._id.to_s\n end", "def className\r\n self.class.to_s\r\n end", "def type\n record.class.name or super\n end", "def true_class\n return ModelProxy\n end", "def parent_class_name\n if custom_parent?\n parent\n elsif database\n abstract_class_name\n else\n parent\n end\n end", "def id\n @id || self.class.name.underscore.split('/').last #gsub('/', '_')\n end", "def polymorphic_class_for(name)\n if store_full_class_name\n name.constantize\n else\n compute_type(name)\n end\n end", "def identifier\n id_value || super\n end", "def class_name\n @class_name ||= derive_class_name\n end", "def name; self.class.to_s; end", "def return_id(obj)\r\n if (obj.new_record?)\r\n 'new_rec'\r\n else\r\n obj.id\r\n end\r\n end", "def self_key # :nodoc:\n klass = self.class\n if klass.superclass != ActiveRecord::Base\n if klass.superclass.eav_class == klass.eav_class\n klass = klass.superclass\n end\n end\n\n \"#{klass.name.underscore}_id\".to_sym\n end", "def get_true_class(obj)\n return obj.true_class\n end", "def reuseIdentifier\n self.class.name\n end", "def model_identifier\n raise 'Invalid' unless id\n \"#{self.class.name}##{id}\"\n end", "def object_id() end", "def id()\n #This is a stub, used for indexing\n end", "def class_name\n @class_name ||= (options[:class_name] || derive_class_name).to_s\n end", "def class_name\n @class_name ||= (options[:class_name] || derive_class_name).to_s\n end", "def identifier\n best_identifier\n end", "def returning_id\n @sql_returning = ::MultiInsert::QueryBuilder.returning([:id])\n @returning_flat = true\n self\n end", "def class_name\n @class_name ||= association.target_class.name\n end", "def qualified_primary_key\n cached_fetch(:qualified_primary_key){self[:qualify] == false ? primary_key : qualify_assoc(primary_key)}\n end", "def name\n @name ? @name.to_s : unique_id\n end", "def name\n @name || object_id.to_s\n end", "def primary_key\n send( self.class.primary_key )\n end", "def solr_document_id\n \"#{self.class.class_name.underscore.downcase}-#{self.id}\"\n end", "def db_type\n @db_type || self.class.db_type\n end", "def db_type\n @db_type || self.class.db_type\n end", "def primary_key\n return @primary_key if @primary_key\n @primary_key = dimension_table.to_s.camelize.constantize.primary_key.to_sym\n rescue NameError => e\n ETL::Engine.logger.debug \"couldn't get primary_key from dimension model class, using default :id\"\n @primary_key = :id\n end", "def instance_class\n @dbi.db_instance_class\n end", "def instance_class\n @dbi.db_instance_class\n end", "def record_name\n @record_name ||= record_name_for(record_class)\n end", "def to_s\n \"#{self.class} #{self[:id]}\"\n end", "def class_name\n table.model.name\n end", "def name; self.class.name; end", "def get_object\n class_name.create_from_database(id)\n end", "def use_single?(results)\n if(results.class.superclass.to_s == 'ActiveRecord::Base')\n return true\n end\n false\n end", "def primary_key\n cached_fetch(:primary_key){associated_class.primary_key || raise(Error, \"no primary key specified for #{associated_class.inspect}\")}\n end", "def class_name\n self.class.to_s\n end", "def class_name\n self.class.to_s\n end", "def class_info?; \"#{self.class.name}\" end", "def get_id\n default_id = self.class.to_s.split('::').last\n default_id[0] = default_id[0].downcase\n return default_id\n end", "def as_id(object)\n object.kind_of?(PublicEarth::Db::Base) && object.id || object\n end", "def discriminate_class_for_record(record)\n self\n end", "def qualified_primary_key\n cached_fetch(:qualified_primary_key){qualify_cur(primary_key)}\n end", "def class_name\n return @options[:class_name] if not @options[:class_name].nil?\n class_main_found = false\n @catalog['resources'].each_with_index do |r,i|\n if r['type'] == 'Class' and r['title'] == 'main'\n class_main_found = true\n next\n end\n if class_main_found and r['type'] == 'Class'\n return r['title'].downcase\n end\n end\n end", "def default_key\n :\"#{self[:model].name.to_s.demodulize.underscore}_id\"\n end", "def model_name\n self.class\n end", "def column_name_for(class_type)\n if class_type == \"User\"\n return \"task_owners.user_id\"\n elsif class_type == \"Project\"\n return \"tasks.project_id\"\n elsif class_type == \"Task\"\n return \"tasks.id\"\n elsif class_type == \"Customer\"\n return \"projects.customer_id\"\n elsif class_type == \"Company\"\n return \"tasks.company_id\"\n elsif class_type == \"Milestone\"\n return \"tasks.milestone_id\"\n elsif class_type == \"Tag\"\n return \"task_tags.tag_id\"\n else\n return \"#{ class_type.downcase }_id\"\n end\n end", "def resource_class\n case @options[:class]\n when false\n name.to_sym\n when nil\n namespaced_name.to_s.camelize.constantize\n when String\n @options[:class].constantize\n else\n @options[:class]\n end\n end", "def solr_id\n \"#{self.class.name}:#{record_id(self)}\"\n end", "def id\n name\n end", "def real(options={})\n @real ||= self.type.constantize.find(self.id, options)\n end", "def discriminate_class_for_record(record)\n if using_single_table_inheritance?(record)\n find_sti_class(record[inheritance_column])\n else\n super\n end\n end", "def discriminate_class_for_record(record)\n if using_single_table_inheritance?(record)\n find_sti_class(record[inheritance_column])\n else\n super\n end\n end", "def name\n id\n end", "def id\n name\n end", "def id\n name\n end", "def primary_key\n self.class.primary_key == :id ? id : @saved_attributes[self.class.primary_key]\n end", "def generate\n base_name = camel_case identifier.to_s\n decorate_klass_name base_name\n end", "def master_class\n association.active_record\n end", "def class_name; end", "def class_name; end", "def java_type\n Jrodb::Model.type_map[self]\n end", "def exists?(classname, id)\n #Make sure the given data are in the correct types.\n classname = classname.to_sym\n id = id.to_i\n\n #Check if ID-cache is enabled for that classname. Avoid SQL-lookup by using that.\n if @ids_cache_should.key?(classname)\n if @ids_cache[classname].key?(id)\n return true\n else\n return false\n end\n end\n\n #If the object currently exists in cache, we dont have to do a lookup either.\n return true if @objects.key?(classname) and obj = @objects[classname].get!(id) and !obj.deleted?\n\n #Okay - no other options than to actually do a real lookup.\n begin\n table = @args[:module].const_get(classname).table\n row = @args[:db].single(table, {@args[:col_id] => id})\n\n if row\n return true\n else\n return false\n end\n rescue Errno::ENOENT\n return false\n end\n end", "def __id__() end", "def id?\n true\n end", "def class_name_id object\n return object.class.to_s.split(/(?=[A-Z])/).join('-').downcase\n end", "def result_for(id)\n Sequel::SchemaSharding::Finder.instance.lookup(self.implicit_table_name, id)\n end", "def default_key\n :\"#{self[:name]}_id\"\n end", "def class_name\n # normally is the classname of the association target\n @class_name ||= options[:join_class_name]\n end", "def target_class(database_record)\n target_reflection(database_record).klass\n end", "def pg_class_relname(type, opts)\n ds = metadata_dataset.from(:pg_class).where(:relkind=>type).select(:relname).server(opts[:server]).join(:pg_namespace, :oid=>:relnamespace)\n ds = filter_schema(ds, opts)\n m = output_identifier_meth\n if defined?(yield)\n yield(ds)\n elsif opts[:qualify]\n ds.select_append{pg_namespace[:nspname]}.map{|r| Sequel.qualify(m.call(r[:nspname]).to_s, m.call(r[:relname]).to_s)}\n else\n ds.map{|r| m.call(r[:relname])}\n end\n end" ]
[ "0.71521866", "0.63399816", "0.60104936", "0.5906077", "0.57766384", "0.57685393", "0.5752798", "0.5685372", "0.56263345", "0.5620079", "0.56127894", "0.56062007", "0.55897456", "0.556686", "0.55571985", "0.5555988", "0.55535656", "0.5545961", "0.5529576", "0.55188483", "0.55015314", "0.5497635", "0.5497635", "0.5486452", "0.54845697", "0.54844743", "0.54689723", "0.5464709", "0.5452158", "0.54422146", "0.5442066", "0.5431457", "0.54269344", "0.54232496", "0.5417297", "0.5407094", "0.54069257", "0.5406842", "0.53984714", "0.53978175", "0.5389928", "0.5369102", "0.5368783", "0.5368282", "0.5368282", "0.53515774", "0.5346706", "0.5343394", "0.5331984", "0.53317815", "0.5329086", "0.53188664", "0.5317709", "0.5314792", "0.5314792", "0.52934337", "0.5290943", "0.5290943", "0.5287894", "0.5280832", "0.5277204", "0.5272913", "0.5268075", "0.52671164", "0.52556515", "0.525532", "0.525532", "0.525116", "0.5249246", "0.5246713", "0.5243728", "0.524192", "0.5237394", "0.52353084", "0.5232755", "0.52264273", "0.52248853", "0.5222505", "0.52181065", "0.52153516", "0.5214645", "0.5214645", "0.5208692", "0.5207837", "0.5207837", "0.5204468", "0.5203501", "0.5203117", "0.5201164", "0.5201164", "0.5200699", "0.5199152", "0.51975965", "0.51965576", "0.5188923", "0.5185086", "0.51817673", "0.51811403", "0.5180533", "0.5180181" ]
0.7205548
0
registers a derived class and its descendants in the current class class_name: name of derived class (the one calling cti_register_descendants on this class) descendants: the descendants of the derived class
def cti_register_descendants(class_name, descendants = {}) @cti_descendants ||= {} @cti_descendants[class_name] = descendants if cti_derived_class? # call up the chain. This will also cause the register_ascendants callbacks self.superclass.cti_register_descendants(self.name, @cti_descendants) end # call back to calling class @cti_ascendants ||= [] class_name.constantize.cti_register_ascendants(@cti_ascendants + [ self.name ]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cti_register_ascendants(ascendants)\n @cti_ascendants = ascendants\n end", "def register_derived_type(name_prefix, options={})\n options = {\n :also_matches => [],\n :entity_class => @entity_class\n }.merge!(options)\n options[:also_matches].push(*self.matches_names)\n name = @plus_suffix ? \"#{name_prefix}+#{plus_suffix}\" : name_prefix\n self.class.register(name, options)\n end", "def append_class(name); end", "def append_class(name); end", "def class_names\n descendants.map(&:name)\n end", "def add_class(name); end", "def add_class(name); end", "def boot_classes\n classes = space.classes\n type_names.each do |name , vars|\n cl = object_with_type Parfait::Class\n cl.instance_type = @types[name]\n @types[name].object_class = cl\n @types[name].instance_methods = object_with_type Parfait::List\n cl.instance_methods = object_with_type Parfait::List\n #puts \"instance_methods is #{cl.instance_methods.class}\"\n cl.name = name\n classes[name] = cl\n end\n # superclasses other than default object\n supers = { :Object => :Kernel , :Kernel => :Value,\n :Integer => :Value , :BinaryCode => :Word }\n type_names.each do |classname , ivar|\n next if classname == :Value # has no superclass\n clazz = classes[classname]\n super_name = supers[classname] || :Object\n clazz.set_super_class_name super_name\n end\n end", "def class_hierarchy base_class: '', system_classes: nil\n#\t\t@actual_class_hash = get_classes('name', 'superClass') #if requery || @all_classes.blank?\n\t\tfv = ->( s )\t{ \t@actual_class_hash.find_all{|x| x['superClass']== s}.map{|v| v['name']} }\n\t\tfx = ->( v ) {\t\tfv[v.strip].map{|x| ar = fx[x]; ar.empty? ? x : [x, ar]} }\n\t\tif system_classes.present?\n\t\t\tfx[ base_class.to_s ]\n\t\telse\n\t\t\tfx[ base_class.to_s ] - system_classes() - [ [\"OIdentity\", [\"ORole\", \"OUser\"]]] - [ [\"OShape\",[\"OGeometryCollection\",\"OLineString\", \"OMultiLineString\", \"OMultiPoint\", \"OMultiPolygon\", \"OPoint\", \"OPolygon\", \"ORectangle\"] ] ]\n\t\tend\n\tend", "def add_class class_type, given_name, superclass = '::Object'\n # superclass +nil+ is passed by the C parser in the following cases:\n # - registering Object in 1.8 (correct)\n # - registering BasicObject in 1.9 (correct)\n # - registering RubyVM in 1.9 in iseq.c (incorrect: < Object in vm.c)\n #\n # If we later find a superclass for a registered class with a nil\n # superclass, we must honor it.\n\n # find the name & enclosing context\n if given_name =~ /^:+(\\w+)$/ then\n full_name = $1\n enclosing = top_level\n name = full_name.split(/:+/).last\n else\n full_name = child_name given_name\n\n if full_name =~ /^(.+)::(\\w+)$/ then\n name = $2\n ename = $1\n enclosing = @store.classes_hash[ename] || @store.modules_hash[ename]\n # HACK: crashes in actionpack/lib/action_view/helpers/form_helper.rb (metaprogramming)\n unless enclosing then\n # try the given name at top level (will work for the above example)\n enclosing = @store.classes_hash[given_name] ||\n @store.modules_hash[given_name]\n return enclosing if enclosing\n # not found: create the parent(s)\n names = ename.split('::')\n enclosing = self\n names.each do |n|\n enclosing = enclosing.classes_hash[n] ||\n enclosing.modules_hash[n] ||\n enclosing.add_module(RDoc::NormalModule, n)\n end\n end\n else\n name = full_name\n enclosing = self\n end\n end\n\n # fix up superclass\n if full_name == 'BasicObject' then\n superclass = nil\n elsif full_name == 'Object' then\n superclass = '::BasicObject'\n end\n\n # find the superclass full name\n if superclass then\n if superclass =~ /^:+/ then\n superclass = $' #'\n else\n if superclass =~ /^(\\w+):+(.+)$/ then\n suffix = $2\n mod = find_module_named($1)\n superclass = mod.full_name + '::' + suffix if mod\n else\n mod = find_module_named(superclass)\n superclass = mod.full_name if mod\n end\n end\n\n # did we believe it was a module?\n mod = @store.modules_hash.delete superclass\n\n upgrade_to_class mod, RDoc::NormalClass, mod.parent if mod\n\n # e.g., Object < Object\n superclass = nil if superclass == full_name\n end\n\n klass = @store.classes_hash[full_name]\n\n if klass then\n # if TopLevel, it may not be registered in the classes:\n enclosing.classes_hash[name] = klass\n\n # update the superclass if needed\n if superclass then\n existing = klass.superclass\n existing = existing.full_name unless existing.is_a?(String) if existing\n if existing.nil? ||\n (existing == 'Object' && superclass != 'Object') then\n klass.superclass = superclass\n end\n end\n else\n # this is a new class\n mod = @store.modules_hash.delete full_name\n\n if mod then\n klass = upgrade_to_class mod, RDoc::NormalClass, enclosing\n\n klass.superclass = superclass unless superclass.nil?\n else\n klass = class_type.new name, superclass\n\n enclosing.add_class_or_module(klass, enclosing.classes_hash,\n @store.classes_hash)\n end\n end\n\n klass.parent = self\n\n klass\n end", "def create_class_tree(classtree = ClassTreeNode.new(Kernel),\n ignore = [ClassTreeNode, ObjectDescriber, ObjectBrowser, ObjectBrowser::UI, ObjectBrowser::UI::DescriptionFactory])\n ObjectSpace.each_object do | x |\n classnode = classtree\n x.class.ancestors.reverse[1..-1].inject(classtree){ | classnode, klass | classnode.add_class(klass) }.add_object(x)\n end \n classtree\n end", "def instantiate_subclasses(klass); end", "def makena_classes\n Rails.application.eager_load!\n pass = ActiveRecord::Base.descendants.map{|a| a.to_s}\n pass.shift\n pass\n end", "def register_class(name, clazz)\n register(name, Component::Descriptor.new(clazz))\n end", "def define_classes klasses\n klasses.each do |klassname|\n klass = klassname.gsub(/\\b('?[a-z])/) { $1.capitalize } #make uppercase\n #could check to see if not already define but at the minute not important\n #if (eval \"defined? #{klass}\") != \"constant\"\n eval \"class #{klass} < DynAttrClass \\n end\"\n #end\n end\nend", "def register(type, cls); end", "def descendants(klass, generations=nil)\n subclass = []\n \n ObjectSpace.each_object(Class) do |c|\n next if c == klass\n \n ancestors = c.ancestors[0 .. (generations || -1)]\n subclass << c if ancestors.include?(klass)\n\n ancestors = c.singleton_class.ancestors[0 .. (generations || -1)]\n subclass << c if ancestors.include?(klass)\n end\n\n if klass.instance_of?(Module)\n # descendants of module are also modules which include the module\n ObjectSpace.each_object(Module) do |c|\n next if c == klass\n\n ancestors = c.ancestors[0 .. (generations || -1)]\n subclass << c if ancestors.include?(klass)\n end\n end\n\n subclass.uniq\n end", "def inherited(descendant)\n super\n DescendantsTracker.setup(descendant)\n add_descendant(descendant)\n end", "def classes(name = nil)\n find_children_of_type(\"Class\", name)\n end", "def instantiate_subclasses(klass)\n klass.descendants.sort.map do |c|\n c.new(config)\n end\n end", "def instantiate_subclasses(klass)\n klass.descendants.sort.map do |c|\n c.new(config)\n end\n end", "def register(name, klass)\n @registry[name] = klass\n end", "def register(name, klass)\n registry[name.to_sym] = klass\n end", "def in_klass name\n @class_stack.unshift name\n yield\n @class_stack.shift\n end", "def class_set class_name, data\n\t\t\t\[email protected] do\t\t\t\t\t\n\t\t\t\t\tnamespace = Module.namespace_for class_name\n\t\t\t\t\tnamespace = namespace ? namespace.to_s : nil\n\t\t\t\t\tfound = true\n\t\t\t\t\tproviders.each do |p|\n\t\t\t\t\t\tnext unless !namespace or p.class_exist?(namespace)\n\t\t\t\t\t\tp.class_set class_name, data\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\t\traise \"Namespace '#{namespace}' doesn't exist!\" unless found\n\t\t\t\tend\n\t\t\tend", "def in_klass name\n if Sexp === name then\n name = case name.sexp_type\n when :colon2 then\n name = name.flatten\n name.delete :const\n name.delete :colon2\n name.join(\"::\")\n when :colon3 then\n name.last.to_s\n else\n raise \"unknown type #{name.inspect}\"\n end\n end\n\n @class_stack.unshift name\n\n with_new_method_stack do\n yield\n end\n ensure\n @class_stack.shift\n end", "def build_descendant(name, namespace: parent_namespace)\n namespace.const_set(name, Class.new(self))\n end", "def register(name, klass)\n Registry.instance.register(name, klass)\n end", "def register(subclass)\n p = subclass.new\n yield p\n p.setup\n @known << p\n end", "def in_class(name)\n name = class_name_from_sexp(name) if name.kind_of?(Sexp)\n @class_stack.unshift name\n yield\n @class_stack.shift\n end", "def register_inheritance_handler\n synchronize do\n\n return if defined?(Object.inherited_with_lumber_registry)\n\n Object.class_eval do\n\n class << self\n alias_method :inherited_without_lumber_registry, :inherited\n\n def inherited(subclass)\n inherited_with_lumber_registry(subclass)\n end\n\n def inherited_with_lumber_registry(subclass)\n inherited_without_lumber_registry(subclass)\n\n # Add a logger to 'subclass' if it is directly in the registry\n # No need to check full inheritance chain LoggerSupport handles it\n # Also prevent rails from subsequently overriding our logger when rails\n # is loaded after registering logger inheritance\n if Lumber::InheritanceRegistry[subclass.name]\n subclass.send(:include, Lumber.logger_concern)\n end\n end\n\n end\n\n end\n\n end\n end", "def register_klass(sym, klass)\n @klasses ||= {}\n @klasses[sym] = klass\n end", "def in_class(name)\n @class_stack.unshift(name)\n yield\n @class_stack.shift\n end", "def instantiate_subclasses(klass)\n klass.descendants.select { |c| !safe || c.safe }.tap do |result|\n result.sort!\n result.map! { |c| c.new(config) }\n end\n end", "def add_nested_classes(klass)\n (klass.definition['nested_classes'] || {}).map do |name, schema|\n initialize!({:class_name => name, :schema => schema}, klass)\n end.each {|sub_class| klass._base.setup_attribute_type(sub_class) }\n end", "def inherited(klass)\n return unless klass.name\n\n type = klass.name.gsub(/([A-Z])/) { |a| \"_#{a.downcase}\" }.gsub(\"::\", \"/\")[1..-1].intern\n klass.star_type(type)\n end", "def store_inherited(klass, descendant)\n (@@direct_descendants[klass] ||= []) << descendant\n end", "def load_classes class_path_list\n class_path_list.each do |path|\n add_class path\n end\n end", "def register(as_type, klass, constuctor_args = {})\n fail \"Registry key #{as_type} already taken - please use a different one because all subclass keys are shared\" if @@class_registry.key?(as_type.to_sym)\n @@class_registry[as_type.to_sym] = { klass: klass, args: constuctor_args }\nend", "def cti_all_descendants\n result = []\n block = Proc.new do |klass, descendants|\n result << klass\n descendants.each(&block)\n end\n @cti_descendants ||= {}\n @cti_descendants.each(&block)\n result\n end", "def collectRecursive(contNT, childclass)\n\t\[email protected] { |c|\n\t\t\t(childclass.is_a?(Class) && c.is_a?(childclass)) ||\n\t\t\t\t(childclass.is_a?(NonTerminal) && c.is_a?(NTermInst) && c.nonTerminal == childclass) } +\n\t\t\[email protected] { |c| c.is_a?(NTermInst) && c.nonTerminal == contNT }.inject([]) { |old,obj| old+obj.collectRecursive(contNT, childclass) }\n\tend", "def class_hierarchy\n @class_hierarchy ||= process_ontology_hierarchy\n end", "def register(klass)\n raise TypeError, \"Can only register classes\" unless klass.is_a? Class\n raise ArgumentError, \"To register, a class must have TYPE defined\" unless klass.const_defined? :TYPE\n registered[klass::TYPE] = klass\n end", "def store_inherited(klass, descendant)\n (@@direct_descendants[klass] ||= DescendantsArray.new) << descendant\n end", "def add_classes(*args)\n args.each {|x| self.add_class(x) }\n return self\n end", "def _subclasses\n @_subclasses ||= []\n end", "def register_all(*including_sub_type, access_tokens: {})\n register(*@@to_register[\"\"])\n including_sub_type.each do |sub_type|\n register(*@@to_register[sub_type.to_s])\n end\n set_access_tokens(access_tokens)\n end", "def extend_class(name, &definition)\n raise ArgumentError, \"name is not a Symbol\" unless name.is_a?(Symbol)\n raise ArgumentError, \"definition is nil\" unless definition\n raise ArgumentError, \"Class #{name} not defined\" unless class_definition(name)\n @class_extensions[name] = ClassExtension.new(name, base, definition)\n end", "def inherited(base)\n klasses << base\n end", "def register_terminus_class(klass)\n setup_instance_loading klass.indirection_name\n instance_hash(klass.indirection_name)[klass.name] = klass\n end", "def add_class(*names)\n classes = class_names + names\n\n unless classes.empty?\n `#@native.className = #{classes.uniq.join ' '}`\n end\n\n self\n end", "def inherited( subclass )\n\t\tkeys = [ subclass.name, subclass.name.downcase, subclass ]\n\n\t\t# Handle class names like 'FooBar' for 'Bar' factories.\n\t\tif subclass.name.match( /(?:.*::)?(\\w+)(?:#{self.factory_type})/i )\n\t\t\tkeys << Regexp.last_match[1].downcase\n\t\telse\n\t\t\tkeys << subclass.name.sub( /.*::/, '' ).downcase\n\t\tend\n\n\t\tkeys.uniq.each {|key|\n\t\t\t#PluginFactory::log :info, \"Registering %s derivative of %s as %p\" %\n\t\t\t#\t[ subclass.name, self.name, key ]\n\t\t\tself.derivatives[ key ] = subclass\n\t\t}\n\t\tsuper\n\tend", "def resolve\n @super_class = @snapshot.id2class @super_id\n # all classes but java.lang.Object\n @super_class.add_subclass self if @super_class \n @snapshot.java_lang_class.add_instance self\n end", "def terminus_classes(indirection_name)\n setup_instance_loading indirection_name\n instance_loader(indirection_name).files_to_load.map do |file|\n File.basename(file).chomp(\".rb\").intern\n end\n end", "def get_subclass( class_name )\n\t\treturn self if ( self.name == class_name || class_name == '' )\n\t\tif class_name.is_a?( Class )\n\t\t\treturn class_name if class_name <= self\n\t\t\traise ArgumentError, \"%s is not a descendent of %s\" % [class_name, self]\n\t\tend\n\n\t\tclass_name = class_name.to_s\n\n\t\t# If the derivatives hash doesn't already contain the class, try to load it\n\t\tunless self.derivatives.has_key?( class_name.downcase )\n\t\t\tself.load_derivative( class_name )\n\n\t\t\tsubclass = self.derivatives[ class_name.downcase ]\n\t\t\tunless subclass.is_a?( Class )\n\t\t\t\traise PluginError,\n\t\t\t\t\t\"load_derivative(%s) added something other than a class \"\\\n\t\t\t\t\t\"to the registry for %s: %p\" %\n\t\t\t\t\t[ class_name, self.name, subclass ]\n\t\t\tend\n\t\tend\n\n\t\treturn self.derivatives[ class_name.downcase ]\n\tend", "def on_class(class_node); end", "def listMethods(className, beginning,max_depth=1,curr=0)\r\n\t\[email protected] { |curFile|\r\n\t\t\tnext if (!FileTest.exist?(curFile))\r\n\r\n\t\t\t@classSearched = classByName(className)\r\n\t\t\tif @classSearched == nil\r\n\t\t\t\tsearchForMethods(curFile,className,className,true,true)\r\n\t\t\t\t@classSearched = classByName(className)\r\n\r\n\t\t\t\tif ( @classSearched!= nil)\r\n\t\t\t\t\tsearchForMethods(curFile, className, beginning)\r\n\t\t\t\t\tif ( @classSearched.inherits!= nil&& curr<max_depth)\r\n\t\t\t\t\t\[email protected] { |ih|\r\n\t\t\t\t\t\t\tlistMethods(ih,beginning,max_depth,curr+1)\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\r\n\t\t\t@missingClasses += @blacklist\r\n\t\t\[email protected]\r\n\t\t}\r\n\t\t#find the tag , then , find the parent\r\n\tend", "def register(type_name, klass = nil, **options, &block)\n registry.register(type_name, klass, **options, &block)\n end", "def registered\n (@klasses ||= []).dup\n end", "def add_class(name)\n @catalog.add_class(name) unless name == \"\"\n end", "def inherited( subclass )\n\t\tplugin_class = Pluggability.plugin_base_class( subclass )\n\n\t\tPluggability.logger.debug \"%p inherited by %p\" % [ plugin_class, subclass ]\n\t\tkeys = [ subclass ]\n\n\t\t# If it's not an anonymous class, make some keys out of variants of its name\n\t\tif subclass.name\n\t\t\tkeys += plugin_class.make_derivative_names( subclass )\n\t\telse\n\t\t\tPluggability.log.debug \" no name-based variants for anonymous subclass %p\" % [ subclass ]\n\t\tend\n\n\t\tkeys.compact!\n\t\tkeys.uniq!\n\n\t\t# Register it under each of its name variants\n\t\tkeys.each do |key|\n\t\t\tPluggability.log.debug \"Registering %s derivative of %s as %p\" %\n\t\t\t\t[ subclass.name, plugin_class.name, key ]\n\t\t\tplugin_class.derivatives[ key ] = subclass\n\t\tend\n\n\t\t# Add a name attribute to it\n\t\tclass << subclass\n\t\t\tattr_reader :plugin_name\n\t\tend\n\t\tsubclass.instance_variable_set( :@plugin_name, keys.last )\n\n\t\tsuper\n\tend", "def create_class(classname, superclass); end", "def inherited(base)\n subclasses << base\n super(base)\n end", "def objects_of_class(name)\n find_all { |r| name === r['class'] }\n end", "def find_direct_superclasses\n return @superclasses unless @superclasses.nil?\n query = \"SELECT ?s WHERE{ #{@term.to_ntriples} <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?s }\"\n selection = Jekyll::JekyllRdf::Helper::RdfHelper::sparql.\n query(query).map{ |solution| solution.s.to_s}\n @superclasses = selection\n return selection\n end", "def add(klass)\n @known_classes << klass\n end", "def subclasses\n @subclasses ||= []\n end", "def define_class(class_name, superclazz=Object)\n clazzDef = ClassDef.new\n clazzDef.class_name = class_name\n clazzDef.class_ancestors = superclazz\n return clazzDef\n end", "def inherited(target)\n registry << target\n end", "def all_classes_implementing(selector)\n self.all_classes.select { |klass| klass.includes_selector?(selector) }\n end", "def class_tree\n @class_tree ||= generate_class_tree\n end", "def fill_model(classnode = ::ObjectBrowser::create_class_tree(), parent = nil)\n node = insert_node(parent, :class, classnode.klass.to_s, \"#<#{classnode.klass.id.to_s(16)}>\", classnode.klass)\n classnode.objects.each do | object |\n insert_node(node, :object, \"#<#{object.id.to_s(16)}>\", \"#<#{object.id.to_s(16)}>\", object)\n end\n classnode.subclasses.to_a.sort_by{|k,s| k.to_s}.each do | klass, subclass | fill_model(subclass, node) end\n end", "def subclasses\n @subclasses ||= []\n end", "def register_submodel(klass)\n if klass.singleton_class?\n raise ArgumentError, \"cannot register a singleton class\"\n end\n\n if !klass.definition_location\n klass.definition_location = \n if MetaRuby.keep_definition_location?\n caller_locations\n else Array.new\n end\n end\n\n submodels << WeakRef.new(klass)\n if m = supermodel\n m.register_submodel(klass)\n end\n end", "def collect_class_names_from_subtree(node_id:)\n {\n method: \"DOM.collectClassNamesFromSubtree\",\n params: { nodeId: node_id }.compact\n }\n end", "def inheritance(class_def)\n \t_IDENTIFIER4 = nil\n\n\n\n\n # 47:7: EXTENDS IDENTIFIER\n match(:EXTENDS)\n _IDENTIFIER4 = @input.look_ahead(1)\n match(:IDENTIFIER)\n class_def.add_parent(_IDENTIFIER4.text)\n\n\n\n end", "def add_class class_name\n each do |el|\n next unless el.respond_to? :get_attribute\n classes = el.get_attribute('class').to_s.split(\" \")\n el.set_attribute('class', classes.push(class_name).uniq.join(\" \"))\n end\n self\n end", "def classes=(ary)\n `for(var result=[],i=0,l=ary.length;i<l;++i){result.push(ary[i].__value__);}`\n `this.__native__.className=result.join(' ')`\n return ary\n end", "def add_class(new_class)\n @classes << new_class\n end", "def subclasses; end", "def subclasses; end", "def add_class(class_name)\n @fragment.children.each do |c|\n c['class'] = ((c['class']||'').split(' ') + [class_name]).join(' ')\n end\n end", "def add(classes)\n classes = classes.to_s.split(' ')\n classes.each { |cls| super cls }\n self\n end", "def inherits(*names)\n names.each do |name|\n minor = self.class[name]\n next if minor == self\n parents << minor\n end\n\n parents.uniq!\n end", "def add_class(id, name, super_id, classloader_id, signers_id, \n protection_domain_id, instance_size)\n end", "def subclasses\n @subclasses ||= Set.new\n end", "def classes(name = nil)\n if name\n classes.find(:name => name)\n else\n @classes.flatten\n end\n end", "def generate\n classes = registry.all(:class)\n classes.each do |c|\n data = methods(c)\n output(data, c.to_s)\n end\n end", "def inherited( subclass )\n\t\tsuper\n\t\tStrelka::Discovery.log.info \"%p inherited by discoverable class %p\" % [ self, subclass ]\n\t\tStrelka::Discovery.add_inherited_class( subclass )\n\tend", "def add_node(name,superclass)\n cls = @nodes[name]\n if cls\n return cls\n end\n @node_container ||= add_module(NormalModule, \"__nodes__\")\n cls = @node_container.add_class(PuppetNode, name, superclass)\n @nodes[name] = cls if !@done_documenting\n cls\n end", "def compile_class(scope, name,superclass, *exps)\n @e.comment(\"=== class #{name} ===\")\n\n superc = @classes[superclass]\n\n cscope = ClassScope.new(scope, name, @vtableoffsets, superc)\n\n @e.evict_regs_for(:self)\n\n # FIXME: Need to be able to handle re-opening of classes\n exps.each do |l2|\n l2.each do |e|\n if e.is_a?(Array) \n if e[0] == :defm\n cscope.add_vtable_entry(e[1]) # add method into vtable of class-scope to associate with class\n\n e[3].depth_first do |exp|\n exp.each do |n| \n cscope.add_ivar(n) if n.is_a?(Symbol) and n.to_s[0] == ?@ && n.to_s[1] != ?@\n end\n end\n\n elsif e[0] == :call && e[1] == :attr_accessor\n # This is a bit presumptious, assuming noone are stupid enough to overload\n # attr_accessor, attr_reader without making them do more or less the same thing.\n # but the right thing to do is actually to call the method.\n #\n # In any case there is no actual harm in allocating the vtable\n # entry.`\n #\n # We may do a quick temporary hack to synthesize the methods,\n # though, as otherwise we need to implement the full define_method\n # etc.\n arr = e[1].is_a?(Array) ? e[2] : [e[2]]\n arr.each {|entry|\n cscope.add_vtable_entry(entry.to_s[1..-1].to_sym) \n }\n end\n end\n end\n end\n @classes[name] = cscope\n @global_scope.globals << name\n sscope = name == superclass ? nil : @classes[superclass]\n ssize = sscope ? sscope.klass_size : nil\n ssize = 0 if ssize.nil?\n compile_exp(scope, [:assign, name.to_sym, [:sexp,[:call, :__new_class_object, [cscope.klass_size,superclass,ssize]]]])\n @global_constants << name\n\n # In the context of \"cscope\", \"self\" refers to the Class object of the newly instantiated class.\n # Previously we used \"@instance_size\" directly instead of [:index, :self, 1], but when fixing instance\n # variable handling and adding offsets to avoid overwriting instance variables in the superclass,\n # this broke, as obviously we should not be able to directly mess with the superclass's instance\n # variables, so we're intentionally violating encapsulation here.\n\n compile_exp(cscope, [:assign, [:index, :self, 1], cscope.instance_size])\n\n # We need to store the \"raw\" name here, rather than a String object,\n # as String may not have been initialized yet\n compile_exp(cscope, [:assign, [:index, :self, 2], name.to_s])\n\n exps.each do |e|\n addr = compile_do(cscope, *e)\n end\n\n @e.comment(\"=== end class #{name} ===\")\n return [:global, name]\n end", "def find(name)\n @@subclasses.fetch(name.to_s, nil)\n end", "def class_names op, deep_inheritance=false\n raise \"#{self.class}.class_names not implemented\"\n end", "def populate_inheritance_heirarchy\n apps_and_templates = appTemplates + templates\n apps_and_templates.each do |temp| \n temp.attributes[:parent].to_s != '' ? app_or_temp = temp.attributes[:parent] :\n temp.attributes[:template].to_s != '' ? app_or_temp = temp.attributes[:template]:\n next\n next if app_or_temp == \"what the fuck?\"\n # if temp.attributes[:parent].is_a? String or temp.attributes[:template].is_a? String\n if not app_or_temp.empty?\n parent_template = self.templates.find { |template| template.name.downcase == app_or_temp.downcase }\n temp.child_of << parent_template\n parent_template.parent_of << temp\n end\n end \n end", "def process_classes(klass_hash, scope)\n interpolate_array(klass_hash['classes'], scope) +\n get_classes_from_groups(\n interpolate_array(klass_hash['class_groups'], scope), scope\n )\n end", "def attach_outer_class_methods!(inherited = false)\n outer_module = Object.const_get(outer_module_name(name))\n outer_module.methods(inherited).each do |m|\n attach_function m\n end\n end", "def classes\n [self]\n end", "def class_name=(name)\n %x{\n for (var i = 0, length = self.length; i < length; i++) {\n self[i].className = name;\n }\n }\n self\n end", "def subclass(klass, paths: nil, description: nil)\n raise \"Missing description\" unless description\n\n subclass = Class.new(klass)\n subclass.define_singleton_method(:description) { description }\n subclass.define_method(:inspect) { description } if description\n\n ::Simple::Httpd::Reloader.attach(subclass, paths: Array(paths))\n\n subclass\n end", "def defined_classes\n # TODO: check content type before scanning\n content.scan(/\\s*class\\s+([A-Za-z0-9_\\.]*)/).flatten\n end" ]
[ "0.6021408", "0.5671427", "0.5635377", "0.5635377", "0.55555415", "0.54864746", "0.54864746", "0.5434053", "0.5428377", "0.535379", "0.5239922", "0.5221086", "0.52199346", "0.5209481", "0.51835346", "0.51779824", "0.5171605", "0.51612014", "0.5150061", "0.5140055", "0.5140055", "0.5138312", "0.51266766", "0.5106144", "0.50997376", "0.5084943", "0.5068217", "0.505776", "0.5052992", "0.50422245", "0.501316", "0.50069535", "0.5002172", "0.49994835", "0.4994672", "0.49695188", "0.49531874", "0.49487478", "0.49451894", "0.4939052", "0.49254543", "0.49221537", "0.49119115", "0.49019995", "0.48975366", "0.48868775", "0.48864806", "0.48857316", "0.48777837", "0.48749298", "0.48722723", "0.48682484", "0.48640803", "0.48539218", "0.48236457", "0.48163873", "0.48159853", "0.4806269", "0.48045185", "0.480435", "0.4796816", "0.47867683", "0.47839516", "0.47809252", "0.47509032", "0.4742005", "0.4741334", "0.4738385", "0.47372642", "0.47352841", "0.47329423", "0.47320047", "0.47279376", "0.47185558", "0.47172126", "0.4711557", "0.47108307", "0.4709633", "0.47030935", "0.46837795", "0.46837795", "0.46804255", "0.46786556", "0.46770817", "0.46735206", "0.46721447", "0.46679235", "0.46668926", "0.46534353", "0.4650669", "0.4644674", "0.4643536", "0.4643266", "0.4642418", "0.4634001", "0.46292883", "0.46243134", "0.46233544", "0.46223947", "0.46107772" ]
0.83949983
0
registers the ascendants of the current class. Called on this class by the parent class. ascendants: array of ascendants. The first element is the highest level class, derived classes follow, the last element is the parent of this class.
def cti_register_ascendants(ascendants) @cti_ascendants = ascendants end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cti_register_descendants(class_name, descendants = {})\n @cti_descendants ||= {}\n @cti_descendants[class_name] = descendants\n if cti_derived_class?\n # call up the chain. This will also cause the register_ascendants callbacks\n self.superclass.cti_register_descendants(self.name, @cti_descendants)\n end\n # call back to calling class\n @cti_ascendants ||= []\n class_name.constantize.cti_register_ascendants(@cti_ascendants + [ self.name ])\n end", "def ascendants(*of_type, &block)\n if root?\n []\n else\n __filter_node_list([parent] + parent.ascendants, *of_type, &block)\n end\n end", "def ascendants\n paths = []\n path = @path\n paths << self\n while (r = chop_basename(path))\n path = r.first\n break if path.empty?\n\n paths << self.class.new(del_trailing_separator(path))\n end\n paths\n end", "def descendants\n Base.descendants\n end", "def ascend(&block)\n paths = ascendants\n paths.each(&block) if block\n paths\n end", "def descendents\n ObjectSpace.each_object(Class).select do |object|\n object < self\n end\n end", "def descendants\n self.class.hierarchy_descendants(self)\n end", "def descendants\n @descendants ||= Set.new\n end", "def self_and_descendants\n [self] + self.descendants\n end", "def ancestors_of klass\n ancestors = []\n unexamined = [klass]\n seen = []\n loop do\n break if unexamined.empty?\n current = unexamined.shift\n seen << current\n stores = classes[current]\n break unless stores and not stores.empty?\n klasses = stores.map do |store|\n store.ancestors[current]\n end.flatten.uniq\n klasses = klasses - seen\n ancestors.push(*klasses)\n unexamined.push(*klasses)\n end\n ancestors.reverse\n end", "def cti_all_descendants\n result = []\n block = Proc.new do |klass, descendants|\n result << klass\n descendants.each(&block)\n end\n @cti_descendants ||= {}\n @cti_descendants.each(&block)\n result\n end", "def class_names\n descendants.map(&:name)\n end", "def ancestors_of klass\n ancestors = []\n\n unexamined = [klass]\n seen = []\n\n loop do\n break if unexamined.empty?\n current = unexamined.shift\n seen << current\n\n stores = classes[current]\n\n next unless stores and not stores.empty?\n\n klasses = stores.flat_map do |store|\n store.ancestors[current] || []\n end.uniq\n\n klasses = klasses - seen\n\n ancestors.concat klasses\n unexamined.concat klasses\n end\n\n ancestors.reverse\n end", "def descendants\n self.class.descendants_of(self)\n end", "def flatten_hierarchy c=self\n result = [c]\n c.subclasses.each do |s|\n result += flatten_hierarchy(s)\n end\n result\n end", "def descendants\n children + children.map(&:descendants).flatten\n end", "def descendants\n records = fetch_self_and_descendants - [self]\n\n ActsAsOrderedTree::Relation::Preloaded.new(self.class).\n where(:id => records.map(&:id).compact).\n extending(Arrangeable).\n records(records)\n end", "def self_and_descendants\n records = fetch_self_and_descendants\n\n ActsAsOrderedTree::Relation::Preloaded.new(self.class).\n where(:id => records.map(&:id)).\n extending(Arrangeable).\n records(records)\n end", "def each_inheritance(&block)\n @nodes.values.sort.each do |node|\n if node.super_class_node\n block.call node, node.super_class_node\n end\n end\n end", "def self_and_descendants\n res = [self] + self.descendants\n return res.uniq\n end", "def descendants\n _descendants = children(true)\n children.each do |child|\n _descendants = _descendants + child.descendants\n end\n _descendants\n end", "def all_ancestors(ancestors=[])\n # Assumes only one parent\n result = []\n c = self\n while c && c.parent_groups\n result += c.parent_groups\n c = c.parent_groups[0]\n end\n result\n end", "def descendants\n children + children.map(&:children).flatten\n end", "def class_hierarchy\n @class_hierarchy ||= process_ontology_hierarchy\n end", "def descendants\n _descendants.flatten.uniq\n end", "def descendants_with_active_validation\n [].tap do |descendants|\n k = base_class.superclass\n while k.respond_to?(:active_validation) && k.instance_methods.include?(:manifest)\n descendants << k\n k = k.superclass\n end\n end\n end", "def descendants\n ascendants.reverse\n end", "def all_nodes\n [self] + descendants\n end", "def descendants\n children.inject([]) { |m,child|\n m << child\n m += child.descendants\n }\n end", "def makena_classes\n Rails.application.eager_load!\n pass = ActiveRecord::Base.descendants.map{|a| a.to_s}\n pass.shift\n pass\n end", "def inherited(descendant)\n super\n DescendantsTracker.setup(descendant)\n add_descendant(descendant)\n end", "def inherits(*names)\n names.each do |name|\n minor = self.class[name]\n next if minor == self\n parents << minor\n end\n\n parents.uniq!\n end", "def ascendants(result = nil, depth = 0)\n \n if (result.nil?)\n result = Hash.new\n end\n \n parents.each do |par|\n node = Array.new\n node[0] = par\n par_spice = par.spice\n if (!par_spice.nil? && par_spice.length > 0)\n # TBD: I know there is a Ruby way to copy an array but can't look it up on the plane - just copy myself for now\n spouse_list = Array.new\n par_spice.each do |s|\n spouse_list << s\n end\n node[1] = spouse_list\n end\n result[node] = depth\n par.ascendants(result, depth + 1)\n end \n \n return result\n \n end", "def descendents\n\n\t\t #children.preload(:parent).each do |child| child.descendents end\n\t\t children.each do |child|\n\t [child] + child.descendents\n\t end\n end", "def descendants_r(*args)\n pending = [self]\n des = []\n while !pending.empty?\n e = pending.pop\n e.children(*args).each do |c|\n if !des.include?(c)\n des << c\n pending.push(c)\n end\n end\n end\n des\n end", "def descendants\n self.subfolders.collect do |s|\n [s] + s.descendants\n end.flatten\n end", "def descendants\n @descendants\n end", "def subclasses\n @subclasses ||= []\n end", "def generate_class_tree_level(parent='')\n $all.map { |klass|\n if parent == klass['parentname']\n [\n klass['name'],\n \"classes/#{klass['fullname']}.html\", # klass.path, \n '',\n generate_class_tree_level(klass['fullname'])\n ]\n else\n nil\n end\n }.compact\nend", "def ancestors\n (parent ? parent.ancestors : []) << self\n end", "def subclasses\n @subclasses ||= []\n end", "def observed_descendants\n observed_classes.sum([]) { |klass| klass.descendants }\n end", "def descendants(klass, generations=nil)\n subclass = []\n \n ObjectSpace.each_object(Class) do |c|\n next if c == klass\n \n ancestors = c.ancestors[0 .. (generations || -1)]\n subclass << c if ancestors.include?(klass)\n\n ancestors = c.singleton_class.ancestors[0 .. (generations || -1)]\n subclass << c if ancestors.include?(klass)\n end\n\n if klass.instance_of?(Module)\n # descendants of module are also modules which include the module\n ObjectSpace.each_object(Module) do |c|\n next if c == klass\n\n ancestors = c.ancestors[0 .. (generations || -1)]\n subclass << c if ancestors.include?(klass)\n end\n end\n\n subclass.uniq\n end", "def descendants(reload = false)\n @descendants = nil if reload\n reload = true if !@descendants\n reload ? find_descendants(self) : @descendants\n end", "def self_and_ancestors\n # 1. recursively load ancestors\n nodes = []\n node = self\n\n while node\n nodes << node\n node = node.parent\n end\n\n # 2. first ancestor is a root\n nodes.reverse!\n\n # 3. create fake scope\n ActsAsOrderedTree::Relation::Preloaded.new(self.class).\n where(:id => nodes.map(&:id).compact).\n extending(Arrangeable).\n records(nodes)\n end", "def ancestors\n model_base_class.scoped(:conditions => ancestor_conditions, :order => :ancestry_string)\n end", "def ancestors\n @ancestors ||= [self] + (self.parent.try(:ancestors) || [])\n end", "def descendants\n \t descendants = []\n \t self.children.each { |child|\n \t descendants += [child] if child.permitted?\n \t descendants += child.descendants\n \t } unless self.children.empty?\n \t descendants \n \tend", "def listMethods(className, beginning,max_depth=1,curr=0)\r\n\t\[email protected] { |curFile|\r\n\t\t\tnext if (!FileTest.exist?(curFile))\r\n\r\n\t\t\t@classSearched = classByName(className)\r\n\t\t\tif @classSearched == nil\r\n\t\t\t\tsearchForMethods(curFile,className,className,true,true)\r\n\t\t\t\t@classSearched = classByName(className)\r\n\r\n\t\t\t\tif ( @classSearched!= nil)\r\n\t\t\t\t\tsearchForMethods(curFile, className, beginning)\r\n\t\t\t\t\tif ( @classSearched.inherits!= nil&& curr<max_depth)\r\n\t\t\t\t\t\[email protected] { |ih|\r\n\t\t\t\t\t\t\tlistMethods(ih,beginning,max_depth,curr+1)\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\r\n\t\t\t@missingClasses += @blacklist\r\n\t\t\[email protected]\r\n\t\t}\r\n\t\t#find the tag , then , find the parent\r\n\tend", "def superclasses(c)\n result = [c]\n while s = c.superclass #rubocop:disable Lint/AssignmentInCondition\n result << s\n c = s\n end\n result\n end", "def class_hierarchy base_class: '', system_classes: nil\n#\t\t@actual_class_hash = get_classes('name', 'superClass') #if requery || @all_classes.blank?\n\t\tfv = ->( s )\t{ \t@actual_class_hash.find_all{|x| x['superClass']== s}.map{|v| v['name']} }\n\t\tfx = ->( v ) {\t\tfv[v.strip].map{|x| ar = fx[x]; ar.empty? ? x : [x, ar]} }\n\t\tif system_classes.present?\n\t\t\tfx[ base_class.to_s ]\n\t\telse\n\t\t\tfx[ base_class.to_s ] - system_classes() - [ [\"OIdentity\", [\"ORole\", \"OUser\"]]] - [ [\"OShape\",[\"OGeometryCollection\",\"OLineString\", \"OMultiLineString\", \"OMultiPoint\", \"OMultiPolygon\", \"OPoint\", \"OPolygon\", \"ORectangle\"] ] ]\n\t\tend\n\tend", "def descendants\n \t\tres=children\n \t\tchildren.each {|c| res += c.descendants}\n \t\treturn res.uniq\n \tend", "def subclasses\n @subclasses ||= Set.new\n end", "def descendants\n model_base_class.scoped(:conditions => descendant_conditions)\n end", "def descendants\n list = []\n children.each do |child|\n list << child\n list.concat(child.descendants)\n end\n list\n end", "def descendants\n list = []\n children.each do |child|\n list << child\n list.concat(child.descendants)\n end\n list\n end", "def descendants(*args)\n return call_ancestry_method(:descendants) if use_ancestry?\n\n Relationship.resources(descendant_rels(*args))\n end", "def process_descendants_and_self\n descendants.reverse.each { |item| yield(item) }\n yield self\n end", "def parents(*classes)\n result = []\n ancestor = self.parent\n until ancestor.nil?\n # Filter ancestors by class\n if classes.nil? || classes.empty? || classes.include?(ancestor.class)\n # If a block is given, it must return true for the ancestor to be included\n result.push(ancestor) unless block_given? && !yield(ancestor)\n end\n ancestor = ancestor.parent\n end\n result\n end", "def create_class_tree(classtree = ClassTreeNode.new(Kernel),\n ignore = [ClassTreeNode, ObjectDescriber, ObjectBrowser, ObjectBrowser::UI, ObjectBrowser::UI::DescriptionFactory])\n ObjectSpace.each_object do | x |\n classnode = classtree\n x.class.ancestors.reverse[1..-1].inject(classtree){ | classnode, klass | classnode.add_class(klass) }.add_object(x)\n end \n classtree\n end", "def descendants(*args, &blk)\n res = []\n each{|c|\n res += c.descendants(*args, &blk) if c.is_a? XML\n }\n res\n end", "def descendants\n return [] if new_record?\n tree_search_class.where(tree_path_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def class_tree\n @class_tree ||= generate_class_tree\n end", "def ancestors_r(*args)\n # fetch all parents\n pending = [self]\n ans = []\n while !pending.empty?\n e = pending.pop\n e.parents(*args).each do |p|\n if !ans.include?(p)\n ans << p\n pending.push(p)\n end\n end\n end\n ans\n end", "def ancestors\n @ancestors ||= parent ? parent.ancestors + [parent] : []\n end", "def instantiate_subclasses(klass)\n klass.descendants.sort.map do |c|\n c.new(config)\n end\n end", "def instantiate_subclasses(klass)\n klass.descendants.sort.map do |c|\n c.new(config)\n end\n end", "def add_nested_classes(klass)\n (klass.definition['nested_classes'] || {}).map do |name, schema|\n initialize!({:class_name => name, :schema => schema}, klass)\n end.each {|sub_class| klass._base.setup_attribute_type(sub_class) }\n end", "def store_inherited(klass, descendant)\n (@@direct_descendants[klass] ||= []) << descendant\n end", "def store_inherited(klass, descendant)\n (@@direct_descendants[klass] ||= DescendantsArray.new) << descendant\n end", "def sti_list(klass)\n (klass.descendants << klass).sort_by(&:name)\n end", "def descendants\n tree.tap(&:shift)\n end", "def netzke_ancestors\n if self == Netzke::Base\n []\n else\n superclass.netzke_ancestors + [self]\n end\n end", "def populate_inheritance_heirarchy\n apps_and_templates = appTemplates + templates\n apps_and_templates.each do |temp| \n temp.attributes[:parent].to_s != '' ? app_or_temp = temp.attributes[:parent] :\n temp.attributes[:template].to_s != '' ? app_or_temp = temp.attributes[:template]:\n next\n next if app_or_temp == \"what the fuck?\"\n # if temp.attributes[:parent].is_a? String or temp.attributes[:template].is_a? String\n if not app_or_temp.empty?\n parent_template = self.templates.find { |template| template.name.downcase == app_or_temp.downcase }\n temp.child_of << parent_template\n parent_template.parent_of << temp\n end\n end \n end", "def each\n @descendants.each { |model| yield model }\n self\n end", "def ancestors_upto(top = nil, hierarchy_order: nil)\n return super unless use_traversal_ids_for_ancestors_upto?\n\n # We can't use a default value in the method definition above because\n # we need to preserve those specific parameters for super.\n hierarchy_order ||= :desc\n\n # Get all ancestor IDs inclusively between top and our parent.\n top_index = top ? traversal_ids.find_index(top.id) : 0\n ids = traversal_ids[top_index...-1]\n ids_string = ids.map { |id| Integer(id) }.join(',')\n\n # WITH ORDINALITY lets us order the result to match traversal_ids order.\n from_sql = <<~SQL\n unnest(ARRAY[#{ids_string}]::bigint[]) WITH ORDINALITY AS ancestors(id, ord)\n INNER JOIN namespaces ON namespaces.id = ancestors.id\n SQL\n\n self.class\n .from(Arel.sql(from_sql))\n .order('ancestors.ord': hierarchy_order)\n end", "def supers\n klass = self.class\n supers = Array.new\n while(klass)\n supers << klass\n klass = klass.superclass\n end\n\n supers\n end", "def convert_class_list_to_graph()\n class_list.each do |c|\n node = graph_add_or_find_node(c)\n ancestors = generate_ancestor_list(c)\n process_ancestor_list(ancestors, node)\n end\n end", "def subclasses\n if block_given?\n ::Class.all do |c|\n yield c if c < self\n end\n else\n enum_for :subclasses\n end\n end", "def self_and_ancestors\n \t\tres = [self] + self.ancestors\n \t\treturn res.uniq\n \tend", "def descendants\n model_base_class.where(descendant_conditions)\n end", "def ancestors\n self.class.ancestors_of(self)\n end", "def ancestors\n ancestors = []\n current_ancestor = self\n \n while !current_ancestor.nil?\n \n if current_ancestor.respond_to?(:parent)\n ancestors << current_ancestor\n current_ancestor = current_ancestor.parent\n else\n current_ancestor = nil\n end\n \n end\n \n ancestors\n end", "def descendants\n if elements\n elements.map{|e| [e] + e.descendants}.flatten\n else\n []\n end\n end", "def fill_model(classnode = ::ObjectBrowser::create_class_tree(), parent = nil)\n node = insert_node(parent, :class, classnode.klass.to_s, \"#<#{classnode.klass.id.to_s(16)}>\", classnode.klass)\n classnode.objects.each do | object |\n insert_node(node, :object, \"#<#{object.id.to_s(16)}>\", \"#<#{object.id.to_s(16)}>\", object)\n end\n classnode.subclasses.to_a.sort_by{|k,s| k.to_s}.each do | klass, subclass | fill_model(subclass, node) end\n end", "def to_array\n parents = []\n\n top_array = [self]\n c_arr = top_array\n\n self.class.base_class.each_with_level(descendants.includes(:link => :linkable)) do |menu, level|\n case level <=> parents.count\n when 0 # same level\n # set current array as new sibling array containing menu\n c_arr = [menu] \n\n # and push current array (the new sibling array) to current parent\n parents.last[1] << c_arr \n\n when 1 # descend\n # push a child array if the current level does no thave one\n c_arr << [] if c_arr.length == 1\n \n # and push the sibling array into that array\n c_arr[1] << [menu]\n\n # push the current array to be the current parent\n parents << c_arr\n\n # and reset the current as the new child array\n c_arr = c_arr[1].last\n\n when -1 # ascend\n # pop parents up to the parent of the new menu\n parents.pop while parents.count > level\n\n # and proceed to add new sibling as though level had been 0\n c_arr = [menu]\n parents.last[1] << c_arr\n end\n end\n\n top_array\n end", "def ancestors_until_node_not_ancestor_of(klass)\n\t\t\tif !self.parent || !self.node.class.ancestors.include?(klass)\n\t\t\t\treturn []\n\t\t\tend\n\n\t\t\t[self] + self.parent.ancestors_until_node_not_ancestor_of(klass)\n\t\tend", "def class_chain(obj_class)\n return [nil] if obj_class.nil?\n\n last = class_chain(obj_class.superclass)\n [obj_class] + last\nend", "def ancestors(*args)\n return call_ancestry_method(:ancestors) if use_ancestry?\n\n Relationship.resources(ancestor_rels(*args))\n end", "def print_ancestors(obj)\n current_super_class = obj.class.superclass\n until current_super_class.nil?\n puts current_super_class\n current_super_class = current_super_class.superclass\n end\nend", "def superclasses(c)\n result = [c]\n while s = c.superclass\n result << s\n c = s\n end\n result\n end", "def index\n @descendants = Descendant.all\n end", "def self_and_ancestors\n ancestors + [self]\n end", "def flatten_parent_features(ast_class_name, class_lut, inheritance_graph, parent_attributes, parent_methods)\n\n\t# Update the object with flattened lists\n\tast_class = class_lut[ast_class_name]\n\tast_class.parent_attributes = parent_attributes\n\tast_class.parent_methods = parent_methods\n\n\tattributes = ast_class.attributes\n\tmethods = ast_class.methods\n\n\t# Set class field of methods (used by implementation map)\n\tfor method in methods\n\t\tmethod.associated_class = ast_class_name\n\tend\n\n\t# Recurse on children\n\tif inheritance_graph.has_key? ast_class_name\n\t\tfor child in inheritance_graph[ast_class_name]\n\t\t\tflatten_parent_features(child.name, class_lut, inheritance_graph, (parent_attributes + attributes), (parent_methods + methods))\n\t\tend\n\tend\nend", "def flatten_parent_features(ast_class_name, class_lut, inheritance_graph, parent_attributes, parent_methods)\n\n\t# Update the object with flattened lists\n\tast_class = class_lut[ast_class_name]\n\tast_class.parent_attributes = parent_attributes\n\tast_class.parent_methods = parent_methods\n\n\tattributes = ast_class.attributes\n\tmethods = ast_class.methods\n\n\t# Set class field of methods (used by implementation map)\n\tfor method in methods\n\t\tmethod.associated_class = ast_class_name\n\tend\n\n\t# Recurse on children\n\tif inheritance_graph.has_key? ast_class_name\n\t\tfor child in inheritance_graph[ast_class_name]\n\t\t\tflatten_parent_features(child.name, class_lut, inheritance_graph, (parent_attributes + attributes), (parent_methods + methods))\n\t\tend\n\tend\nend", "def ancestors() end", "def self_and_descendents\n [self] + descendents\n end", "def all_children(scope = {})\n full_set(scope) - [self]\n end", "def self_and_ancestors\n ancestors + [self]\n end", "def process_self_and_descendants\n yield self\n descendants.each { |item| yield(item) }\n end" ]
[ "0.75792086", "0.6220952", "0.6211236", "0.59619945", "0.5942822", "0.59396935", "0.5916648", "0.58827436", "0.58755416", "0.5776554", "0.57473123", "0.5700165", "0.56992865", "0.56892216", "0.5669219", "0.56331426", "0.5626764", "0.5602407", "0.55936044", "0.55617607", "0.5556353", "0.55552447", "0.55532897", "0.55095977", "0.5487385", "0.54722637", "0.5467351", "0.54666823", "0.54657155", "0.54544383", "0.5445616", "0.54341084", "0.54319227", "0.5424646", "0.5409032", "0.53911823", "0.5380725", "0.53724927", "0.536524", "0.53626895", "0.53583074", "0.5334686", "0.53201485", "0.53077084", "0.52960056", "0.5294599", "0.5294423", "0.52865547", "0.528539", "0.5278202", "0.52729845", "0.52628684", "0.52600825", "0.5251297", "0.52488947", "0.52488947", "0.5243048", "0.52420855", "0.52407897", "0.52399296", "0.523889", "0.5215165", "0.52063435", "0.5204615", "0.51877433", "0.518247", "0.518247", "0.5180037", "0.51713777", "0.5166761", "0.51641077", "0.51636255", "0.5158421", "0.51522684", "0.5140516", "0.51394176", "0.5133284", "0.51297", "0.5128305", "0.5119616", "0.51192164", "0.51147306", "0.51119274", "0.5097701", "0.509712", "0.5095005", "0.50781494", "0.5073352", "0.5073185", "0.5071777", "0.5071016", "0.507005", "0.50644815", "0.50510645", "0.50510645", "0.50382304", "0.50342715", "0.5029003", "0.5025746", "0.5024885" ]
0.7134154
1
returns a list of all descendants
def cti_all_descendants result = [] block = Proc.new do |klass, descendants| result << klass descendants.each(&block) end @cti_descendants ||= {} @cti_descendants.each(&block) result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def descendants\n children + children.map(&:descendants).flatten\n end", "def descendants\n _descendants.flatten.uniq\n end", "def descendants\n children + children.map(&:children).flatten\n end", "def descendants\n list = []\n children.each do |child|\n list << child\n list.concat(child.descendants)\n end\n list\n end", "def descendants\n list = []\n children.each do |child|\n list << child\n list.concat(child.descendants)\n end\n list\n end", "def descendants\n _descendants = children(true)\n children.each do |child|\n _descendants = _descendants + child.descendants\n end\n _descendants\n end", "def descendants\n @descendants\n end", "def descendants\n \t\tres=children\n \t\tchildren.each {|c| res += c.descendants}\n \t\treturn res.uniq\n \tend", "def descendants\n children.inject([]) { |m,child|\n m << child\n m += child.descendants\n }\n end", "def descendants\n Base.descendants\n end", "def descendants\n @descendants ||= Set.new\n end", "def descendants\n node, nodes = self, []\n node.children.each { |child|\n # Check for circular dependencies\n if !nodes.include?(child)\n nodes += [child]\n nodes += child.descendants\n end\n } unless node.children.empty?\n nodes\n end", "def descendants\n self.class.descendants_of(self)\n end", "def descendants\n node, nodes = self, []\n node.children.each { |child|\n # Check for circular dependenciess\n if !nodes.include?(child)\n nodes += [child]\n nodes += child.descendants\n end\n } unless node.children.empty?\n nodes\n end", "def descendants\n self.class.hierarchy_descendants(self)\n end", "def descendants\n if elements\n elements.map{|e| [e] + e.descendants}.flatten\n else\n []\n end\n end", "def descendants\n desc = []\n children.each do |tc|\n desc << tc\n desc += tc.descendants if tc.parent?\n end\n desc\n end", "def descendants\n \t descendants = []\n \t self.children.each { |child|\n \t descendants += [child] if child.permitted?\n \t descendants += child.descendants\n \t } unless self.children.empty?\n \t descendants \n \tend", "def descendants\n self.subfolders.collect do |s|\n [s] + s.descendants\n end.flatten\n end", "def descendants\n ascendants.reverse\n end", "def descendants\n return [] if new_record?\n tree_search_class.where(tree_path_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def descendants\n tree.tap(&:shift)\n end", "def descendants\n tree.children_of(id)\n end", "def all_nodes\n [self] + descendants\n end", "def descendants_r(*args)\n pending = [self]\n des = []\n while !pending.empty?\n e = pending.pop\n e.children(*args).each do |c|\n if !des.include?(c)\n des << c\n pending.push(c)\n end\n end\n end\n des\n end", "def descendants(*args, &blk)\n res = []\n each{|c|\n res += c.descendants(*args, &blk) if c.is_a? XML\n }\n res\n end", "def descendants\n without_self self_and_descendants\n end", "def descendents\n\n\t\t #children.preload(:parent).each do |child| child.descendents end\n\t\t children.each do |child|\n\t [child] + child.descendents\n\t end\n end", "def descendants_and_self\r\n result = [self]\r\n children.each { |child| result << child.descendants_and_self }\r\n result.flatten!\r\n return result\r\n end", "def descendants\n without_self self_and_descendants\n end", "def descendants\n records = fetch_self_and_descendants - [self]\n\n ActsAsOrderedTree::Relation::Preloaded.new(self.class).\n where(:id => records.map(&:id).compact).\n extending(Arrangeable).\n records(records)\n end", "def self_and_descendants\n res = [self] + self.descendants\n return res.uniq\n end", "def descendants\n base_and_descendants.where.not(id: descendants_base.select(:id))\n end", "def descendants(*of_type, &block)\n if leaf?\n []\n else\n __filter_node_list(children + children.collect_concat {|child| child.descendants}, *of_type, &block)\n end\n end", "def descendants_bfs(options={})\n desc_nodes = []\n each_level_nodes(options) do |nodes|\n desc_nodes += nodes\n end\n return desc_nodes\n end", "def show_all_children_info\n descendants.map(&:to_s)\n end", "def descendants(label = nil)\n Pipeline.dsl(self).descendants(label)\n end", "def hierarchy_descendants(entity)\n ret = []\n arr = entity.children\n return arr if arr.empty?\n ret << arr\n arr.each {|child_item|\n ret << self.hierarchy_descendants(child_item) unless child_item.nil? \n }\n ret.flatten.compact\n end", "def all_children\n children(all: true)\n end", "def ascendants(*of_type, &block)\n if root?\n []\n else\n __filter_node_list([parent] + parent.ascendants, *of_type, &block)\n end\n end", "def all_children_deep(flag=nil)\n\t\tarr = []\n\t\tall_children(flag).each do |c|\n\t\t\tarr << c\n\t\t\tc.all_children_deep(flag).each do |cc|\n\t\t\t\tarr << cc\n\t\t\tend\n\t\tend\t\t\t\n\t\tarr\n\tend", "def descendants\n model_base_class.where(descendant_conditions)\n end", "def descendants\n without_self(self_and_descendants)\n end", "def all_questions_descendants\n # source .descendants is very fast with no db hits! why? How can we use it? It's type is ActiveRecord::Association::CollectionProxy\n ([source] + source.descendants)\n end", "def descendants\n Especie.where(\"#{Especie.attribute_alias(:ancestry_ascendente_directo)} LIKE '%,?,%'\", id).where.not(id: id)\n end", "def self_and_descendants\n [self] + self.descendants\n end", "def all_children\n find_all_children_with_dotted_ids\n end", "def descendents\n respond_to?(:values) ? values.map { |d| d.branch }.flatten : []\n end", "def index\n @descendants = Descendant.all\n end", "def find_all_parents\n end", "def descendants(*args)\n return call_ancestry_method(:descendants) if use_ancestry?\n\n Relationship.resources(descendant_rels(*args))\n end", "def grand_children\n []\n end", "def descendant_ids\n descendants.map(&:id)\n end", "def descendants(label = nil)\n append(Traverse.new(:out, label))\n end", "def descendants(tree=false,reload=false)\n return nil if is_leaf? || self.id_path.blank?\n #when tree is true, the descendants are collected in the same order a tree scan would produce\n if tree\n @descendants = self.class.find(:all, :conditions => \"id_path like '#{self.id_path},%'\", :order => \"id_path asc\") if @descendants.nil? || reload\n else\n @descendants = self.class.find(:all, :conditions => \"id_path like '#{self.id_path},%'\", :order => \"level asc, name asc\") if @descendants.nil? || reload\n end\n\n @descendants\n end", "def get_results(with_root = false)\n ret = []\n\n # Iterate over all occupied descendants and create chain data\n @occupied_descendants.each do |node|\n ret << [node.data, node.get_chain(with_root)]\n end\n\n # Return\n ret\n end", "def children\n self.node.children.collect(&:content)\n end", "def get_all_children(catalog)\n catalog.descendant_catalogs\n end", "def descendant_rels(*args)\n options = args.extract_options!\n rels = relationships.flat_map(&:descendants).uniq\n Relationship.filter_by_resource_type(rels, options)\n end", "def ancestors\n itr = self\n res = []\n until itr.top_level?\n itr = itr.parents.first\n res << itr\n end\n res\n end", "def descendants\n model_base_class.scoped(:conditions => descendant_conditions)\n end", "def all_children(scope = {})\n full_set(scope) - [self]\n end", "def all_children\n @all_children ||= children + children.inject([]) {|records, child| records + child.all_children}\n end", "def descendants_to(*node_types)\n elements.map{|e|\n if node_types.include? e.class\n e\n elsif e.elements\n e.descendants_to *node_types\n else\n []\n end\n }.flatten\n end", "def descendants_to_reload\n d = []\n v = visible_children\n if v.size > 0\n v.each do |c|\n # only do this stuff for jqgrid widgets, assume that other widgets should be left alone\n if defined?(c.jqgrid_id) && defined?(c.select_on_load) && defined?(c.descendants_to_reload)\n if c.select_on_load\n d += c.descendants_to_reload\n end\n d += [c.jqgrid_id]\n end\n end\n end\n return d\n end", "def get_children\n return children\n end", "def children\n node.children\n end", "def get_all_child_lists\n child_check\n \n if @all_child_terms.nil? and @all_child_names.nil?\n @all_child_terms = []\n @all_child_names = []\n \n self.children.each do |child|\n @all_child_terms.push( child.term )\n @all_child_terms.push( child.all_child_terms )\n @all_child_names.push( child.term_name )\n @all_child_names.push( child.all_child_names )\n end\n \n @all_child_terms = @all_child_terms.flatten.uniq\n @all_child_names = @all_child_names.flatten.uniq\n end\n end", "def ascendants\n paths = []\n path = @path\n paths << self\n while (r = chop_basename(path))\n path = r.first\n break if path.empty?\n\n paths << self.class.new(del_trailing_separator(path))\n end\n paths\n end", "def children\n _children\n end", "def children\n list = NodeSet.new(document)\n document.decorate(list)\n\n first = self.child\n return list unless first # Empty list\n\n list << first unless first.blank?\n while first = first.next\n list << first unless first.blank?\n end\n list\n end", "def class_names\n descendants.map(&:name)\n end", "def descendants(pat=nil, *rest, &blk)\n res = []\n @contents.each{|c|\n if pat.nil? or pat === c\n if rest == []\n res << c\n yield c if block_given?\n else\n res += c.children(*rest, &blk)\n end\n end\n if c.is_a? XML\n res += c.descendants(pat, *rest, &blk)\n end\n }\n res\n end", "def descend(&block)\n paths = descendants\n paths.each(&block) if block\n paths\n end", "def children\n self.class.children(self) \n end", "def descendants(&block)\n return to_enum __method__ unless block_given?\n return if @struct.child_list.null?\n child = self.class.new(@struct.child_list)\n block[child]\n child.descendants(&block)\n while child = child.next_peer\n block[child]\n child.descendants(&block)\n end\n end", "def children\n []\n end", "def children\n []\n end", "def children\n []\n end", "def all_child_names\n get_all_child_lists\n return @all_child_names\n end", "def get_children\n return @children\n end", "def generate_ancestor_list(c)\n c.ancestors.find_all { |a| a != c }\n end", "def ancestors\n node_ancestors.map(&:ancestor)\n end", "def all_children\n reload\n nodes = []\n queue = children.to_a\n until queue.empty?\n node = queue.pop\n nodes.push(node)\n queue += node.children.to_a\n queue.flatten!\n end\n nodes\n end", "def descendants_affected\n descendants\n end", "def children_until_node_not_ancestor_of(klass)\n\t\t\tif !self.node.class.ancestors.include?(klass)\n\t\t\t\treturn []\n\t\t\tend\n\n\t\t\t[self] + self.children.collect { |i|\n\t\t\t\ti.children_until_node_not_ancestor_of(klass)\n\t\t\t}\n\t\tend", "def children\n []\n end", "def descendant_ids_bfs(options={})\n desc_ids = []\n each_level_ids(options) do |level_ids|\n desc_ids += level_ids\n end\n return desc_ids\n end", "def children\n []\n end", "def children\n []\n end", "def children()\n bag.ls(path).map { |pat| bag.get(pat) }.compact\n end", "def observed_descendants\n observed_classes.sum([]) { |klass| klass.descendants }\n end", "def descendants_ids(ignore_permissions = false)\n \t descendants_ids = [] \n \t self.children.each { |child|\n \t descendants_ids += [child.id] if ignore_permissions or child.permitted?\n \t descendants_ids += child.descendants_ids\n \t } unless self.children.empty?\n \t descendants_ids\n \tend", "def to_ary\n @descendants.dup\n end", "def children\n children = []\n\n unless leaf?\n zipper = down\n children << zipper\n\n until zipper.last?\n zipper = zipper.next\n children << zipper\n end\n end\n\n children\n end", "def children\n out_edges.each{|e| e.dest}\n end", "def descendent_names\n self_and_descendents.map(&:name).flatten \n end", "def all_groups\r\n result = []\r\n self.groups.each { |group| result << group.descendants_and_self }\r\n result.flatten!\r\n result.uniq!\r\n return result\r\n end", "def descendants(reload = false)\n @descendants = nil if reload\n reload = true if !@descendants\n reload ? find_descendants(self) : @descendants\n end", "def all_children(special=nil)\n full_set(special) - [self]\n end" ]
[ "0.86860335", "0.86547303", "0.86041355", "0.85932326", "0.85932326", "0.8562172", "0.8545913", "0.8516754", "0.84689844", "0.83004344", "0.8266972", "0.8158597", "0.81469303", "0.81283695", "0.81117445", "0.80980814", "0.80784917", "0.80660635", "0.80194086", "0.7998634", "0.79196864", "0.773961", "0.770064", "0.7660782", "0.7640526", "0.763539", "0.76122504", "0.75704974", "0.7553865", "0.7531893", "0.7470012", "0.7433372", "0.73867387", "0.73398745", "0.73367536", "0.73177254", "0.73137236", "0.7230572", "0.71303904", "0.7033709", "0.70195156", "0.6957459", "0.6931109", "0.69057506", "0.6903873", "0.68911535", "0.6884443", "0.6876104", "0.68513626", "0.6819114", "0.68182456", "0.6805725", "0.6797684", "0.6784542", "0.67786723", "0.6756668", "0.67475814", "0.674607", "0.6725036", "0.67144555", "0.6698349", "0.66964906", "0.6695164", "0.66885954", "0.66880226", "0.66868836", "0.6681605", "0.66765285", "0.6675169", "0.66709805", "0.6649445", "0.664428", "0.6635398", "0.66249084", "0.6620569", "0.661853", "0.66107625", "0.66107625", "0.66107625", "0.66022223", "0.65976155", "0.6592742", "0.6585196", "0.65757", "0.6570254", "0.65657455", "0.65607494", "0.6555386", "0.65529823", "0.65529823", "0.6542041", "0.6538094", "0.65358824", "0.6534295", "0.6526184", "0.6512196", "0.6500486", "0.65003586", "0.64991677", "0.64972174" ]
0.7454846
31
this method is only used in testing. It returns the number of rows present in the real database table, not the number of rows present in the view (as returned by count)
def cti_table_count result = connection.execute("SELECT COUNT(*) FROM #{DBViewCTI::Names.table_name(self)};") result[0]['count'].to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def row_count \r\n assert_exists\r\n return rows.length\r\n end", "def count\n @rows.count\n end", "def rows_count\n @rows.size\n end", "def row_count\n @rows.length;\n end", "def numberOfRowsInTableView(view)\n # Return the number of items.\n @entries ? @entries.length : 0\n end", "def rows_count\n @values.count\n end", "def num_rows\n return 0 if rows.nil?\n rows.size\n end", "def number_of_rows_in_table( aTableView)\n @values.length\n end", "def internalRepItemCount\n return @delegate.rowCount\n end", "def rows_count\n wait\n $browser.find_elements(:xpath, \"#{@locator}/tbody/tr\").size()\n end", "def length\n $tracer.trace(format_method(__method__))\n return @rows.length\n end", "def getrowcount\n @rowcount = @db.execute(\"select count(*) from #{@tablename}\").to_s\nend", "def count ; @count ||= table.count end", "def row_count\n return 0 if @list.nil?\n @list.length\n end", "def row_count\n return 0 if @list.nil?\n @list.length\n end", "def numberOfRowsInTableView(tblView)\n @videoCollection.count\n end", "def size\n unless @size\n rows = database.view(VIEW_NAME, reduce: true, key: [0, id])['rows'] rescue []\n @size = rows.first ? rows.first['value'] : 0\n end\n @size\n end", "def size\n @db.get_first_value( \"SELECT COUNT(*) FROM #{TABLE_NAME};\" ).to_i\n end", "def num_rows()\n return self.length\n end", "def count\n Dynamoid.adapter.count(table_name)\n end", "def count\n Dynamoid.adapter.count(table_name)\n end", "def length\n @rows.length\n end", "def record_count\n return nil unless @rows\n @rows.size - 1 # Don't include the header row\n end", "def get_table_rowcount( table_name )\r\n return execute_scalar( \"select coalesce(count(*), 0) as count from #{table_name};\" )\r\n end", "def size\n @rows.size\n end", "def column_count\r\n assert_exists\r\n arr_rows = rows\r\n return arr_rows[0].column_count\r\n end", "def numberOfRowsInTableView_(view)\n\t\treturn 0 if @customers.nil?\n\t return @customers.length\n\tend", "def numberOfRowsInTableView_(view)\n\t\treturn 0 if @customers.nil?\n\t return @customers.length\n\tend", "def numberOfRowsInTableView_(view)\n \tif view == @copies_table\n return 0 if @copies.nil?\n return @copies.length\n elsif view == @items_table\n\t return 0 if @items.nil?\n\t return @items.length\n\t end\n end", "def numberOfRowsInTableView_(view)\n \tif view == @copies_table\n return 0 if @copies.nil?\n return @copies.length\n elsif view == @items_table\n\t return 0 if @items.nil?\n\t return @items.length\n\t end\n end", "def count\n self.all.count\n end", "def row_size\n @rows.size\n end", "def destroyed_rows_count\n @destroyed_rows_codes.count\n end", "def created_rows_count\n @created_rows_codes.count\n end", "def column_count\n is_container? ? get_content_param_by_key( :model_count_in_row ) : 0\n end", "def tableView(tableView, numberOfRowsInSection:section)\n if tableView == self.fakeTableView\n 0\n else\n self.fetchControllerForTableView(tableView).sections[section].numberOfObjects\n end \n end", "def count\n @count ||=\n begin\n # self.sql sets self.model_class.\n this_sql = sql(:count => true)\n model_class.connection.\n query(this_sql).\n first.first\n end\n end", "def db_query__show_tables__count\n db_query_transform__count db_query__show_tables\n end", "def total_records_created\n successful_rows.inject(t = 0) { |t, i| t += processed_rows[i].persisted_objects.size }\n end", "def count\n @all.size\n end", "def row_count\n result = get_filtered_dataset true\n\n result['data'].first.values.first\n end", "def edited_rows_count\n @edited_rows_codes.count\n end", "def edited_rows_count\n @edited_rows_codes.count\n end", "def edited_rows_count\n @edited_rows_codes.count\n end", "def count\n raise \"View#count cannot be used with group options\" if query[:group]\n if can_reduce?\n row = reduce.skip(0).limit(1).rows.first\n row.nil? ? 0 : row.value\n else\n limit(0).total_rows\n end\n end", "def numberOfRowsInTableView(table)\n \tif @current_tasks\n \t @current_tasks.size\n \telse\n \t 0\n\t end\n end", "def count\n query.count\n end", "def count\n query.count\n end", "def count_records(params, columns)\n 0\n end", "def count_records(params, columns)\n 0\n end", "def number_of_columns\n return rows.first.length unless rows.empty?\n raise Error, 'your table needs some rows'\n end", "def count_columns\n fields.size\n end", "def retrieved_records\n results.count\n end", "def length\n table_ = [keyspace, table].compact.join '.'\n statement = \"SELECT COUNT (*) FROM #{table_} ;\"\n result = session.execute(statement)\n result.first['count']\n end", "def count\n @count ||= @query.count\n end", "def total_rows\n execute['total_rows']\n end", "def count(view = :all, *args, &block)\n if view == :all\n return super({}, *args) \n end\n \n if has_view?(view)\n query = args.shift || {}\n result = view(view, {:reduce => true}.merge(query), *args, &block)['rows']\n \n return result.first['value'] unless result.empty?\n end\n 0\n end", "def processed_rows\n edited_rows_count + created_rows_count\n end", "def count_view(options)\n search_fields = search_fields(options)\n \n if database.version > 0.8\n view_name = get_view_name(search_fields)\n else\n view_name = get_view_name(search_fields, \"count\")\n end\n \n options[:return_json] = true\n result = generic_view(view_name, find_by_function(search_fields), count_documents_function, options)\n \n result['rows'].first['value'] rescue 0\n end", "def numberOfRowsInTableView(tableView)\n @filtered_files ? @filtered_files.size : 0\n end", "def total_count\n @all.size\n end", "def count\n if @count\n @count - @deleted_entries.cardinality\n else\n determine_count\n end\n end", "def row_count\n row_index.length - 1\n end", "def count\n all.count\n end", "def size()\n #This is a stub, used for indexing\n end", "def size()\n #This is a stub, used for indexing\n end", "def records_count\n @klass.all.size\n end", "def get_row_count\n result = get_filtered_dataset true\n\n return result['data'].first.values.first\n end", "def size\n\n fetch_all(:count => true)\n end", "def getUntappdCount\n db.execute(\"SELECT count(*) FROM #{@untappdTable}\")[0][0]\n end", "def size\n loaded? ? @records.length : count\n end", "def numberOfRowsInTableView(tableView)\n filteredData.size\n end", "def column_count\r\n assert_exists\r\n arr_cells = cells\r\n return arr_cells.length\r\n end", "def count\n @ole.Count\n end", "def count\n @ole.Count\n end", "def count\n @ole.Count\n end", "def count\n @ole.Count\n end", "def count\n @ole.Count\n end", "def count\n @ole.Count\n end", "def count\n @ole.Count\n end", "def count\n @ole.Count\n end", "def total_records\n record.records.count\n end", "def numberOfRowsInTableView(sender)\n accounts.size\n end", "def size\n @table.size\n end", "def size\n loaded? ? @records.length : count\n end", "def size\n @table.size\n end", "def column_count\n visible_column_names().count\n end", "def count\n all.size\n end", "def tableView(tableView, numberOfRowsInSection:section)\n @items.size\n end", "def count_records\n count = scoped.count\n\n # If there's nothing in the database and @target has no new records\n # we are certain the current target is an empty array. This is a\n # documented side-effect of the method that may avoid an extra SELECT.\n @target ||= [] && loaded! if count == 0\n\n count\n end", "def inUse\n\n # initial value\n result = false\n # make connection to db\n sql = ActiveRecord::Base.connection();\n \n # test if in use\n #count, dummy = sql.execute(\"SELECT COUNT(*), 0 FROM enclavequarters WHERE enclave_id=#{self.id}\").fetch_row\n count = sql.select_value(\"SELECT COUNT(*) FROM enclavequarters WHERE enclave_id=#{self.id}\")\n result = (count.to_i > 0) ? true : false\n \n result\n\n end", "def questionings_count\n respond_to?(:questionings_count_col) ? (questionings_count_col || 0).to_i : questionings.count\n end", "def count\n Driver.client[coll_name].find.count\n end", "def size\n @records.size\n end", "def count\n @count\n end", "def count\n @count\n end", "def count\n @count\n end", "def count\n @data.size\n end", "def size\n table.size\n end", "def length; @records.length; end" ]
[ "0.7950203", "0.784802", "0.75352746", "0.75290674", "0.73810005", "0.7303065", "0.7288592", "0.7246807", "0.71132594", "0.70948905", "0.70739824", "0.70682526", "0.7064147", "0.7055987", "0.7055987", "0.7052614", "0.70374", "0.70149523", "0.7009896", "0.69776714", "0.69776714", "0.69239444", "0.6920521", "0.6906458", "0.69048434", "0.68959206", "0.68435293", "0.68435293", "0.68260413", "0.68260413", "0.6809073", "0.6790047", "0.67678446", "0.67602605", "0.6746559", "0.67373085", "0.67317396", "0.6716512", "0.67144585", "0.6704761", "0.6689726", "0.66849804", "0.66849804", "0.66849804", "0.6678438", "0.66776145", "0.66738427", "0.66738427", "0.6642538", "0.6642538", "0.6637042", "0.66134214", "0.6608533", "0.6605739", "0.6595993", "0.6560414", "0.6555246", "0.6540137", "0.65323174", "0.6523159", "0.652023", "0.65124834", "0.6494017", "0.64883065", "0.64207006", "0.64207006", "0.64202636", "0.64200735", "0.6416649", "0.6413066", "0.641206", "0.6393209", "0.63849443", "0.6382904", "0.6382904", "0.6382904", "0.6382904", "0.6382904", "0.6382904", "0.6382904", "0.6382904", "0.63700545", "0.63607204", "0.6357738", "0.6353089", "0.63431966", "0.6329774", "0.6326532", "0.6308524", "0.630486", "0.6300391", "0.62947905", "0.62940353", "0.62808913", "0.6270583", "0.6270583", "0.6270583", "0.6267032", "0.62584484", "0.6256874" ]
0.6769851
32
Verify if has a virtual machine topic associated with this class.
def has_topic [email protected]? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_topic?\n ! (topic.nil? || topic_name.nil?)\n end", "def has_vm?(vm_cid)\n @telemetry_manager.monitor('initialize') do\n _init_azure\n end\n with_thread_name(\"has_vm?(#{vm_cid})\") do\n @telemetry_manager.monitor('has_vm?', id: vm_cid) do\n vm = @vm_manager.find(InstanceId.parse(vm_cid, _azure_config.resource_group_name))\n !vm.nil? && vm[:provisioning_state] != 'Deleting'\n end\n end\n end", "def has_topics?\n !self.topics.empty?\n end", "def has_vm?(vm_id)\n with_thread_name(\"has_vm?(#{vm_id})\") do\n begin\n @logger.info(\"Checking if VM with id = #{vm_id} exists...\")\n vm = @vm_manager.get_virtual_machine(vm_id)\n !vm.nil? ? true : false\n rescue => e\n @logger.error(e)\n false\n end\n end\n end", "def kbHasTopic _obj, _args\n \"_obj kbHasTopic _args;\" \n end", "def is_vm?\n cmd = \"VBoxManage showvminfo \\\"#{@vbox_name}\\\"\"\n _, stderr, _ = Open3.capture3(cmd)\n if stderr.include? 'Could not find a registered machine named'\n raise \"Virtual Machine #{@vbox_name} does not exist\"\n end\n end", "def own_topic?(topic)\n topic.read_attribute(:user_id) == self.id\n end", "def multivm?\n vms.length > 1\n end", "def validate_topic\n errors.add(:topic_id, 'Topic not presence') if Topic.find_by_id( self[:topic_id] ) == nil\n end", "def vm_ready?(_pool_name, _vm_name)\n raise(\"#{self.class.name} does not implement vm_ready?\")\n end", "def vm_ready?(_pool_name, _vm_name)\n raise(\"#{self.class.name} does not implement vm_ready?\")\n end", "def can_read_forem_topic? topic\n true\n end", "def vm_ok?\n unless @vm\n warn 'No VM initialized'\n return false\n end\n inf = vm_info\n # wait while vm is waiting for instantiating\n while [0, 1, 2].include? inf['VM']['LCM_STATE'].to_i\n sleep 10\n inf = vm_info\n end\n inf['VM']['STATE'].to_i == 3 # state 3 - VM is running\n end", "def slotAvailable?(topic_id)\n SignUpTopic.slotAvailable?(topic_id)\n end", "def slotAvailable?(topic_id)\n SignUpTopic.slotAvailable?(topic_id)\n end", "def slotAvailable?(topic_id)\n SignUpTopic.slotAvailable?(topic_id)\n end", "def forum?\n !params[:topic_id].nil?\n end", "def has_vm?(server_id)\n with_thread_name(\"has_vm?(#{server_id})\") do\n server = @openstack.with_openstack { @openstack.compute.servers.get(server_id) }\n !server.nil? && !%i[terminated deleted].include?(server.state.downcase.to_sym)\n end\n end", "def validate_topic_input(forum, subject, message)\n raise Impostor::TopicError.new(\"forum not set\") unless forum\n raise Impostor::TopicError.new(\"subject not set\") unless subject\n raise Impostor::TopicError.new(\"message not set\") unless message\n true\n end", "def can_create_forem_topics? forum\n true\n end", "def topic\n load\n @topic\n end", "def system_vocab?\n # currently determined by whether it has a special key, which cannot be set by user defined CV's\n key.present? && SystemVocabs.database_key_known?(key)\n end", "def provisioned?(vm_name='default', provider='virtualbox')\n File.exist?(\".vagrant/machines/#{vm_name}/#{provider}/action_provision\")\n end", "def invm?\n @is_invm\n end", "def hypervchk(session)\n vm = false\n sfmsvals = registry_enumkeys('HKLM\\SOFTWARE\\Microsoft')\n if sfmsvals and sfmsvals.include?(\"Hyper-V\")\n vm = true\n end\n if not vm\n if registry_getvaldata('HKLM\\HARDWARE\\DESCRIPTION\\System','SystemBiosVersion') =~ /vrtual/i\n vm = true\n end\n end\n if not vm\n srvvals = registry_enumkeys('HKLM\\HARDWARE\\ACPI\\FADT')\n if srvvals and srvvals.include?(\"VRTUAL\")\n vm = true\n end\n end\n if not vm\n srvvals = registry_enumkeys('HKLM\\HARDWARE\\ACPI\\RSDT')\n if srvvals and srvvals.include?(\"VRTUAL\")\n vm = true\n end\n end\n\n if vm\n report_note(\n :host => session.session_host,\n :type => 'host.hypervisor',\n :data => { :hypervisor => \"MS Hyper-V\" },\n :update => :unique_data\n )\n print_good(\"This is a Hyper-V Virtual Machine\")\n return \"MS Hyper-V\"\n end\n end", "def check_for_posts\n if self.posts.any?\n errors[:base] << \"cannot delete Topic tag when posts are using it!\"\n return false\n else\n return true\n end\n end", "def provisioned?(vm_name='default', provider='virtualbox')\n File.exist?(\".vagrant/machines/#{vm_name}/#{provider}/action_provision\")\nend", "def usable?(machine, raise_error=false)\n end", "def provisioned?(vm_name=\"default\", provider=\"virtualbox\")\n File.exist?(\".vagrant/machines/#{vm_name}/#{provider}/action_provision\")\nend", "def vm_exists?(pool_name, vm_name)\n !get_vm(pool_name, vm_name).nil?\n end", "def vm_exists?(pool_name, vm_name)\n !get_vm(pool_name, vm_name).nil?\n end", "def running\n\t @vm_running = Virtualmachine.isrunning\n end", "def validate_create(topic)\n true\n end", "def vm_exists?(uuid)\n end", "def topic\n @_topic ||= request.env['loudmouth_map'][:topic_model].singularize.downcase\n end", "def topic=(value)\n @topic = value\n end", "def topic=(value)\n @topic = value\n end", "def topic=(value)\n @topic = value\n end", "def vboxchk(session)\n vm = false\n vboxprocs = [\n \"vboxservice.exe\",\n \"vboxtray.exe\"\n ]\n session.sys.process.get_processes().each do |x|\n vboxprocs.each do |p|\n if p == (x['name'].downcase)\n vm = true\n end\n end\n end\n if not vm\n srvvals = registry_enumkeys('HKLM\\HARDWARE\\ACPI\\DSDT')\n if srvvals and srvvals.include?(\"VBOX__\")\n vm = true\n end\n end\n if not vm\n srvvals = registry_enumkeys('HKLM\\HARDWARE\\ACPI\\FADT')\n if srvvals and srvvals.include?(\"VBOX__\")\n vm = true\n end\n end\n if not vm\n srvvals = registry_enumkeys('HKLM\\HARDWARE\\ACPI\\RSDT')\n if srvvals and srvvals.include?(\"VBOX__\")\n vm = true\n end\n end\n if not vm\n key_path = 'HKLM\\HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port 0\\Scsi Bus 0\\Target Id 0\\Logical Unit Id 0'\n if registry_getvaldata(key_path,'Identifier') =~ /vbox/i\n vm = true\n end\n end\n if not vm\n if registry_getvaldata('HKLM\\HARDWARE\\DESCRIPTION\\System','SystemBiosVersion') =~ /vbox/i\n vm = true\n end\n end\n if not vm\n srvvals = registry_enumkeys('HKLM\\SYSTEM\\ControlSet001\\Services')\n if srvvals and srvvals.include?(\"VBoxMouse\")\n vm = true\n elsif srvvals and srvvals.include?(\"VBoxGuest\")\n vm = true\n elsif srvvals and srvvals.include?(\"VBoxService\")\n vm = true\n elsif srvvals and srvvals.include?(\"VBoxSF\")\n vm = true\n end\n end\n if vm\n report_note(\n :host => session.session_host,\n :type => 'host.info.vm',\n :data => { :hypervisor => \"VirtualBox\" },\n :update => :unique_data\n )\n print_good(\"This is a Sun VirtualBox Virtual Machine\")\n return \"VirtualBox\"\n end\n end", "def is_vmware(machine)\n machine.provider_name.to_s().start_with?('vmware')\n end", "def load_topic\n if @tier && id = topic_param_id\n @topic = @tier.topics.find_by_permalink_and_region_and_active(id)\n @topic_class = @topic.class if @topic\n end\n end", "def load_topic\n if @tier && id = topic_param_id\n @topic = @tier.topics.find_by_permalink_and_region_and_active(id)\n @topic_class = @topic.class if @topic\n end\n end", "def created?(vm_name, provider='virtualbox')\n\tFile.exist?(\".vagrant/machines/#{vm_name}/#{provider}/id\")\nend", "def detect?(machine)\n machine.communicate.test(\"\")\n end", "def machine?\n machine_flag != '0'\n end", "def vagrant_key?(node)\n node.key?('vagrant')\n end", "def vm_exists_silent\n return false unless @state.key?(:id) && !@state[:id].nil?\n\n existing_vm = run_ps ensure_vm_running_ps\n return false if existing_vm.nil? || existing_vm[\"Id\"].nil?\n\n true\n end", "def create_vm(name, &block)\n raise('This function need to be executed after ALL_VM_GROUPS_UP event') unless self.has_topic\n raise(\"The Virtual machine #{name} is not defined in this group\") unless vm(name)\n @topic.create(:virtual_machine, {:label => name}) do |vm|\n vm_topic = vm.resource\n if vm_topic.error?\n error app.inspect\n else\n vm_topic.on_subscribed do\n block.call(vm_topic) if block\n end\n end\n end\n end", "def system_msg?\n posts.first.system_msg? rescue nil\n end", "def topics\n respond_to?(:topic) ? topic : []\n end", "def topic\n team_topic = nil\n\n participants.each do |participant|\n team_topic = participant.topic\n break if team_topic\n end\n\n team_topic\n end", "def topic\n team_topic = nil\n\n participants.each do |participant|\n team_topic = participant.topic\n break if team_topic\n end\n\n team_topic\n end", "def topic\n team_topic = nil\n\n participants.each do |participant|\n team_topic = participant.topic\n break if team_topic\n end\n\n team_topic\n end", "def find_topic(topic)\n @subscription_group.topics.find(topic) || raise(Errors::TopicNotFoundError, topic)\n end", "def can_reply_to_forem_topic? topic\n true\n end", "def topic\n SignedUpTeam.find_by(team_id: id, is_waitlisted: 0).try(:topic_id)\n end", "def vbox_host?\n host = false\n if !virtualization.nil? && (virtualization[\"system\"] == \"vbox\" || virtualization[\"systems\"][\"vbox\"] == \"host\")\n host = true if which(\"VBoxManage\")\n end\n host\n end", "def topic(_name)\n raise 'not implemented'\n end", "def vmwarechk(session)\n vm = false\n srvvals = registry_enumkeys('HKLM\\SYSTEM\\ControlSet001\\Services')\n if srvvals and srvvals.include?(\"vmdebug\")\n vm = true\n elsif srvvals and srvvals.include?(\"vmmouse\")\n vm = true\n elsif srvvals and srvvals.include?(\"VMTools\")\n vm = true\n elsif srvvals and srvvals.include?(\"VMMEMCTL\")\n vm = true\n end\n if not vm\n if registry_getvaldata('HKLM\\HARDWARE\\DESCRIPTION\\System\\BIOS','SystemManufacturer') =~ /vmware/i\n vm = true\n end\n end\n if not vm\n key_path = 'HKLM\\HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port 0\\Scsi Bus 0\\Target Id 0\\Logical Unit Id 0'\n if registry_getvaldata(key_path,'Identifier') =~ /vmware/i\n vm = true\n end\n end\n if not vm\n vmwareprocs = [\n \"vmwareuser.exe\",\n \"vmwaretray.exe\"\n ]\n session.sys.process.get_processes().each do |x|\n vmwareprocs.each do |p|\n if p == (x['name'].downcase)\n vm = true\n end\n end\n end\n end\n\n if vm\n report_note(\n :host => session.session_host,\n :type => 'host.info.vm',\n :data => { :hypervisor => \"VMware\" },\n :update => :unique_data\n )\n print_good(\"This is a VMware Virtual Machine\")\n return \"VMWare\"\n end\n end", "def topic\n return @topic\n end", "def topic\n return @topic\n end", "def should_install_vagrant?\n vagrant_v_output = run_command('vagrant -v')[:output]\n installed_version = vagrant_v_output.match(/^Vagrant ([0-9.]+)\\s*$/)[1]\n SemVersion.new(VAGRANT_VERSION) > SemVersion.new(installed_version)\n rescue Errno::ENOENT\n true\n end", "def has_vuln?(name)\n ::ApplicationRecord.connection_pool.with_connection {\n Mdm::Vuln.find_by_name(name)\n }\n end", "def topic\n return @topic\n end", "def my_topic\n @published_topics = current_user.topics.published\n @unpublished_topics = current_user.topics.unpublished\n end", "def student_team_requirements_met?\n # checks if the student has a team\n return false if @student.team.nil?\n # checks that the student's team has a topic\n return false if @student.team.topic.nil?\n\n # checks that the student has selected some topics\n @student.assignment.topics?\n end", "def find_topic\n @topic = current_user.topics.find(params[:topic_id])\n end", "def find_topic\n @topic = current_user.topics.find(params[:topic_id])\n end", "def machine_avail?\n\t\tmachine = self.machines.find(:first, :conditions =>\n\t\t\t[\"installed = ? and cid = ?\", false, 'none'])\n\t\tif machine\n\t\t\treturn machine\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend", "def set_class_topic\n @class_topic = ClassTopic.find(params[:id])\n end", "def valid?(home_path)\n return false if !vagrantfile_path\n return false if !vagrantfile_path.directory?\n\n # Create an environment so we can determine the active\n # machines...\n found = false\n env = vagrant_env(home_path)\n env.active_machines.each do |name, provider|\n if name.to_s == self.name.to_s &&\n provider.to_s == self.provider.to_s\n found = true\n break\n end\n end\n\n # If an active machine of the same name/provider was not\n # found, it is already false.\n return false if !found\n\n # Get the machine\n machine = nil\n begin\n machine = env.machine(self.name.to_sym, self.provider.to_sym)\n rescue Errors::MachineNotFound\n return false\n end\n\n # Refresh the machine state\n return false if machine.state.id == MachineState::NOT_CREATED_ID\n\n true\n end", "def is_known\n TargetsXML.has_target(@name)\n end", "def validate_new_topic_result(page)\n raise Impostor::MissingTemplateMethodError.new(\"validate_new_topic_result must be implemented\")\n end", "def monitor_vm\n vms_info('one')\n end", "def published?\n self.targets.map { |tgt| File.exist?(File.join(\n self.publish_path, self.to_s, tgt)) }.all?\n end", "def machine_readable?\n @prompt == :machine\n end", "def find_topic\n @topic = Topic.find(params[:topic_id]) if params[:topic_id]\n end", "def food_upvote?(topic)\n\ttopic == \"food\"\nend", "def has_rss_log?\n !!self.class.reflect_on_association(:rss_log)\n end", "def set_tag_topic\n @tag_topic = TagTopic.find(params[:id])\n end", "def has_notify?(forum)\n current_forum = Forum.find(forum)\n if current_forum.messages.count > this.current_length\n this.display = true\n end\n end", "def rvm?\n\t\t\tFile.exists?(RvmPow::RVM_BINARY)\n\t\tend", "def set_topic\n @topic = Topic.find(params[:topic_id])\n end", "def topic\n @topic ||= client.topic config.topic\n end", "def topic(topic_name, &proc)\n t = create_topic(topic_name)\n proc.call(t) if proc\n t\n end", "def can_reply_to?(topic) false end", "def paused?(topic, partition)\n pause = pause_for(topic, partition)\n pause.paused? && !pause.expired?\n end", "def vm_by_name(name)\n vms = get('VM', :by_name_label, name)\n if vms.any?\n UltraVM::VM.new(self, vms.first)\n else\n false\n end\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def ctrl?\n @ctrl\n end", "def kafka_running?\n jps = capture('sudo jps -l')\n jps.include? 'kafka.Kafka'\n end", "def pmc?\n Committee.load_committee_info # ensure data is there\n Committee.pmcs.include? self\n end", "def assert_topic_body_for(topic, present: true)\n if present\n assert_match markdown(topic.content), response.body\n else\n assert_no_match markdown(topic.content), response.body\n end\n end", "def already_thanked?(topic)\n notification = Notification.thanked_by(self.id, topic.id)\n !notification.empty?\n end", "def has_video?(locale=I18n.locale.to_sym)\n !featured_video(locale).nil?\n end", "def set_topic\n @topic = Admin::Topic.find(params[:id])\n end", "def set_topic\n @movie = Movie.find(params[:movie_id])\n\t @topic = Topic.find(params[:id])\n end", "def valid_for_publish\n\t\tvalid = true\n \tif structural_set.nil?\n \t\terrors << \"Structural Set> Error: No set selected\"\n\t\t\tvalid = false\n \tend\n\t\tvalid\n \tend" ]
[ "0.6546054", "0.6461766", "0.6359832", "0.62185943", "0.60365605", "0.5915271", "0.58648807", "0.58195835", "0.57955754", "0.5719867", "0.5719867", "0.55917275", "0.55597305", "0.549184", "0.549184", "0.549184", "0.5355411", "0.532926", "0.5327082", "0.5322511", "0.5300242", "0.52963626", "0.52716476", "0.5252688", "0.52190167", "0.52127814", "0.5189561", "0.51869416", "0.5185531", "0.5175915", "0.5175915", "0.5167008", "0.51662725", "0.51507396", "0.5122623", "0.5120438", "0.5114538", "0.5114538", "0.5112786", "0.5095035", "0.50788736", "0.50788736", "0.5072082", "0.50348485", "0.5026242", "0.5025881", "0.5019959", "0.49705356", "0.49582577", "0.49578732", "0.49553302", "0.49553302", "0.49553302", "0.4952816", "0.49456048", "0.49379787", "0.49154583", "0.49056828", "0.490371", "0.4892543", "0.4892543", "0.48850128", "0.48842162", "0.48816693", "0.48705786", "0.4866894", "0.48637292", "0.48637292", "0.48600966", "0.48343265", "0.48245418", "0.4818407", "0.48182097", "0.48114106", "0.4805932", "0.47913253", "0.47910404", "0.4789559", "0.47876236", "0.47593096", "0.4759064", "0.47586864", "0.47583178", "0.47565627", "0.47452363", "0.47439888", "0.4740326", "0.47349444", "0.47282994", "0.47282994", "0.4728062", "0.47269624", "0.47246766", "0.47239476", "0.47210312", "0.47207722", "0.4717012", "0.4702098", "0.4700973" ]
0.6783201
1
Associate the topic reference when the subscription is received from OmfEc::FlowVisor::FlowVisor::create
def associate_topic(topic) @topic = topic self.__log_messages end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscribe!(topic)\n subscriptions.create!( :topic_id => topic.id )\n end", "def create_topic!\n fora.post_new_topic\n end", "def associate_topic(topic)\n self.synchronize do\n @topic = topic\n end\n end", "def subscribe(_topic, **)\n raise 'not implemented'\n end", "def subscribe_to(topic)\n StreamUser.create(:user => self, :stream_message => topic.stream_messages.last, :source => 'followed') if topic.stream_messages.last\n subscriptions << Subscription.new(:topic => topic)\n end", "def create_topic payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post TOPICS, payload )\n\t\t\t\tend", "def auto_subscribe_topic\n fail NotImplementedError, 'To be implemented by the concrete topic posts controller.'\n end", "def create\n @topic = Topic.find params[:topic_id]\n @reference = @topic.references.new(reference_params)\n\n if @reference.save\n redirect_to topic_path(@topic) , notice: 'Reference was successfully created.'\n else\n render :new\n end\n end", "def topic=(value)\n @topic = value\n end", "def create\n @topic = Topic.create(topic_params)\n current_user.topics.push(@topic)\n \n respond_with @topic\n end", "def after_create_path\n url_for(@topic)\n end", "def topic=(value)\n @topic = value\n end", "def topic=(value)\n @topic = value\n end", "def topic!(topic)\n @session.chanserv.topic(self.name, topic)\n end", "def create_topic\n raise NotImplementedError.new\n end", "def create_topic\n @debate.create_topic(params[:topic])\n redirect_to :action => \"index\"\n end", "def create_topic\r\n @debate.create_topic(params[:topic])\r\n redirect_to :action => \"index\"\r\n end", "def create\n topic = Topic.find(sub_topic_params[:topic_id])\n @sub_topic = topic.sub_topics.build(sub_topic_params)\n\n respond_to do |format|\n if @sub_topic.save\n format.html { redirect_to @sub_topic, notice: 'Sub topic was successfully created.' }\n format.json { render :show, status: :created, location: @sub_topic }\n else\n format.html { render :new }\n format.json { render json: @sub_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_topic\n t = Topic.create(title: new_topic) if new_topic.present?\n t.update_column(:user_id, self.user_id)\n t.save\n self.topic = t\n end", "def set_rel_topic_sub_topic\n @rel_topic_sub_topic = RelTopicSubTopic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:topic_id])\n end", "def topic( name, &block )\n destination( name, :topic, @topics, &block )\n end", "def topic( name )\n Qup::Adapter::Kestrel::Topic.new( @addr, name )\n end", "def receive_topic name\n @topic = sanitize_location_name name\n end", "def create_pubsub_topic topic_id\n pubsub = Google::Cloud::Pubsub.new project: @project_id\n topic = pubsub.create_topic topic_id\n policy = topic.policy do |p|\n p.add \"roles/pubsub.publisher\",\n \"serviceAccount:[email protected]\"\n end\n @topics << topic\n topic\n end", "def setup(&block)\n @_topic = self.instance_eval(&block)\n end", "def topic\n @topic ||= client.topic config.topic\n end", "def set_sub_topic\n @sub_topic = SubTopic.find(params[:id])\n end", "def create\n @topic = current_user.topics.new(topic_params)\n @topic.subscriber = @user\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to [@user, @topic], notice: '成功新增' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def topic(name)\n pubsub.topic(name) || create_topic(name)\n end", "def set_topic\n @topic = Admin::Topic.find(params[:id])\n end", "def create\n @topic = current_user.topics.build(params[:topic])\n\n respond_to do |format|\n if @topic.save\n flash[:notice] = 'Topic was successfully created.'\n format.html { redirect_to(@topic) }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n # since our the reference new path contains the topic's id\n # we can use params[:topic_id] to get that id\n @topic = Topic.find params[:topic_id]\n\n # This is similar to Reference.new, BUT it creates the new reference\n # in the context of a Topic object and sets the foreign key\n @reference = @topic.references.new\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def topic(topic_name, &proc)\n t = create_topic(topic_name)\n proc.call(t) if proc\n t\n end", "def create\n @topic = current_user.topics.build(params[:topic])\n @encounter = Encounter.find(session[:encounter_key])\n\n\n respond_to do |format|\n if @topic.save\n session[:topic_key] = @topic.id\n format.html { redirect_to encounter_path(@encounter), notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @topic = Topic.new\n end", "def create\n @topic = current_user.topics.build(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def create_topic(topic, opts = {})\n raise \"Topic can't be nil or empty\" if topic.nil? || topic.to_s.empty?\n opts = opts.dup\n opts[:communicator] = self\n topic = topic.to_s\n if topic.start_with? 'amqp:'\n # absolute address\n unless topic.start_with? @address_prefix\n raise \"Cannot subscribe to a topic from different domain (#{topic}) - #{@address_prefix}\"\n end\n opts[:address] = topic\n topic = topic.split(@address_prefix).last\n else\n opts[:address] = @address_prefix + topic\n end\n OmfCommon::Comm::AMQP::Topic.create(topic, opts)\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def set_topic\n @topic = Topic.find(params[:id])\n end", "def new_topic(forum, subject, message)\n @topic.new_topic(forum, subject, message)\n end", "def subscribe_to_topic(topic, device)\n raise NotImplementedError.new\n end", "def create \n\t@topic = Topic.new(params[:topic]) \n\[email protected] = !(current_user.role.contributor?)\n\[email protected]_id = current_user.id \n\trespond_to do |format|\n\t if @topic.save\n\t\tif params[:avatar] && params[:avatar][:avatar_img]\n\t\t @avatar = Avatar.create(:avatar_img => params[:avatar][:avatar_img], :topic_id => @topic.id)\n\t\tend\n\t\tif params[:commit] == \"Lagre\"\n\t\t format.html { redirect_to edit_topic_path(@topic), notice: I18n.t(\"topics.create_flash\") }\n\t\t format.json { render json: edit_topic_path(@topic), status: :created, location: @topic }\n\t\telse\n\t\t format.html { redirect_to topic_path(@topic), notice: I18n.t(\"topics.create_flash\") }\n\t\t format.json { render json: @topic, status: :created, location: @topic }\n\t\tend\n\t else \n\t\[email protected]\n\t\[email protected] \n\t\tformat.html { render action: \"new\" }\n\t\tformat.json { render json: @topic.errors, status: :unprocessable_entity }\n\t end\n\tend\n end", "def create\n @topic = current_user.topics.build(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_topic\n @topic = Topic.friendly.find(params[:topic_id])\n end", "def topic()\n Sensit::Api::Topic.new @http_client\n end", "def subscribe_to_topic(tokens, topic)\n make_topic_mgmt_request(tokens, topic, \"batchAdd\")\n end", "def set_subtopic\n @subtopic = Subtopic.find(params[:id])\n end", "def log_create\n TopicCreate.create!(:topic_id => self.id)\n end", "def create\n @subtopic = Subtopic.new(subtopic_params)\n\n respond_to do |format|\n if @subtopic.save\n format.html { redirect_to @subtopic, notice: 'Subtopic was successfully created.' }\n format.json { render :show, status: :created, location: @subtopic }\n else\n format.html { render :new }\n format.json { render json: @subtopic.errors, status: :unprocessable_entity }\n end\n end\n end", "def setup\n topics.map do |t|\n topic_name = t[:name] || t['name']\n sub_opts = t.reject { |k, _| k.to_sym == :name }\n PubSubClient.upsert_subscription(topic_name, subscription_name(topic_name), sub_opts)\n end\n end", "def publish\n topic = find_topic\n TagPublisher.new(topic).publish\n redirect_to topic\n end", "def set_topic(target, topic)\n adapter.set_topic(target, topic)\n end", "def set_subtopic\n @subtopic = Subtopic.friendly.find(params[:id])\n end", "def topic\n if @topic\n @topic\n else\n connected do\n fiber = Fiber.current\n callbacks = {}\n [331, 332, 403, 442].each do |numeric|\n callbacks[numeric] = @thaum.on(numeric) do |event_data|\n topic = event_data[:params].match(':(.*)').captures.first\n fiber.resume topic\n end\n end\n\n raw \"TOPIC #{@name}\"\n @topic = Fiber.yield\n callbacks.each do |type, callback|\n @thaum.callbacks[type].delete(callback)\n end\n\n @topic\n end\n end\n end", "def create\n @topic = @category.topics.new(topic_params)\n authorize @topic\n\n if @topic.save\n render 'api/v1/topics/show', status: :created\n else\n render json: @topic.errors, status: :unprocessable_entity\n end\n end", "def create\n @subtopic = Subtopic.new(params[:subtopic])\n\n respond_to do |format|\n if @subtopic.save\n format.html { redirect_to @subtopic, notice: 'Subtopic was successfully created.' }\n format.json { render json: @subtopic, status: :created, location: @subtopic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subtopic.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_document_topic_sub_topic\n @document_topic_sub_topic = DocumentTopicSubTopic.find(params[:id])\n end", "def topic\n load\n @topic\n end", "def create\n @topic = Topic.new(topic_params)\n @topic.active = true\n\n respond_to do |format|\n if @topic.save!\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_subscription topic, subscription_name, options = {}\n updated_option = construct_create_subscription_options topic, subscription_name, options\n subscriber.create_subscription(**updated_option)\n end", "def set_user_topic\n @user_topic = UserTopic.find(params[:id])\n end", "def auto_initialize!\n client\n topic\n end", "def topic(name)\n Kazoo::Topic.new(self, name)\n end", "def create\n @document_topic_sub_topic = DocumentTopicSubTopic.new(document_topic_sub_topic_params)\n\n respond_to do |format|\n if @document_topic_sub_topic.save\n format.html { redirect_to @document_topic_sub_topic, notice: 'Document topic sub topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @document_topic_sub_topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @document_topic_sub_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @topic = Topic.new(published_at: Time.now)\n end", "def create_if_necessary!\n if topic.blank?\n @topic = pubsub.create_topic(topic_name).tap do |topic|\n raise error, \"Unable to create topic #{topic_name}\" if topic.nil?\n end\n end\n\n @subscription = @topic.find_subscription(subscription_name) || @topic.create_subscription(subscription_name)\n @subscription.tap do |subscription|\n raise Error, \"Unable to create subscription #{subscription_name}\" if subscription.nil?\n\n # Default subscription expiry is 31 days. We want none of that.\n subscription.expires_in = nil unless pubsub.project_id == EMULATOR.fetch(:project_id)\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n @topic.author = current_user\n\n respond_to do |format|\n if @topic.save\n flash[:notice] = \"Topic was successfully created.\"\n format.html { redirect_to(@topic) }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_topic(description)\n topic = Topic.new\n topic.title = description\n topic.user = self\n topic.save\n end", "def topic_create(topic)\n @topic = topic\n @board = topic.board\n @user = topic.author\n @mail = @user.email\n @link = board_topic_url(@board, @topic)\n @greeting = \"Hi\"\n\n @subject = \"您已成功在Board: #{@board.name}內新增了一篇Topic~\"\n\n mail to: @mail, subject: @subject\n end", "def create\n @topic = Topic.new(params[:topic])\n @topic.user_id = current_user.id\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.69654727", "0.693385", "0.6924505", "0.672404", "0.6632238", "0.6606716", "0.64954007", "0.6471134", "0.6466183", "0.64106846", "0.6328354", "0.6328129", "0.6328129", "0.63221544", "0.6273144", "0.62435305", "0.6236382", "0.6221248", "0.6206416", "0.61934483", "0.61639106", "0.61631036", "0.6153188", "0.6151853", "0.6149349", "0.61492544", "0.61476094", "0.61444414", "0.61430734", "0.6129263", "0.6124638", "0.6110165", "0.60996515", "0.6086276", "0.6086276", "0.6085987", "0.60853446", "0.60843855", "0.6073014", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.60616", "0.6046227", "0.60429335", "0.60429335", "0.6036466", "0.6035488", "0.6023032", "0.60219127", "0.6018897", "0.60057104", "0.5993292", "0.5984107", "0.5976098", "0.5973081", "0.5972818", "0.5957369", "0.5956208", "0.5952521", "0.59508705", "0.5947206", "0.59407693", "0.5938242", "0.5936084", "0.5935884", "0.5935227", "0.59343195", "0.5932105", "0.5931539", "0.5923711", "0.59103215", "0.5907665", "0.5898951", "0.5897726", "0.5896521", "0.58858275" ]
0.68802303
3
helper method to avoid hitting the API more than necessary when checking whether there are any messages
def check_for_new_messages messages = twitter.direct_messages(:since_id => last_message_retrieved) @num_messages = messages.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_message?\n has_message\n # && messages.count > 0\n end", "def has_messages?\n\t\t\treturn !(messages.empty?)\n\t\tend", "def check_for_messages\n @message_unviewed = Message.all(:recipient_id => current_user.id, :viewed => false, :opportunity => Opportunity.all(:active => true))\n if @message_unviewed != []\n flash.now[:warning] = 'You have unread messages'\n end\n end", "def msg_exists(msg) \n not msg.nil? and not msg.empty?\n end", "def new_message_check\n if(!current_user.nil?)\n ids = Message.where(user_received_id: current_user.id, read: false).pluck(:user_sent_id).uniq\n if ids.count > 0\n ids = Message.where(user_received_id: current_user.id, read: false).pluck(:user_sent_id).uniq\n render text: '{\"unread\":\"true\", \"ids\":[' + ids.join(',') + ']}'\n else\n render text: '{\"unread\":\"false\"}'\n end\n else \n render text: '{\"unread\":\"false\"}'\n end\n end", "def empty?\n @messages.empty?\n end", "def check_message(params)\n unless params[:message].blank?\n continue(params)\n else\n fail(:no_message_given)\n end\n end", "def my_messages\n my_mesgs = Message.includes(:user).where(receiver_id: @current_user.id).order(created_at: :desc)\n if my_mesgs.any?\n render json: my_mesgs, :include => {\n :user => {\n :only => [:id, :firstname, :lastname]\n }\n },\n status: :ok\n else\n render json: {\n status: 'no-content',\n message: 'You don\\'t have any message yet',\n data: []\n },\n status: :no_content\n end\n end", "def empty?\n @messages.empty?\n end", "def empty?\n @messages.empty?\n end", "def any?\n messages.count.positive?\n end", "def has_unread_messages?\n received_messages.count > 0\n end", "def members_not_responding\n memb = sent_messages.map { |sm| (sm.msg_status || -1) < MessagesHelper::MsgDelivered ? sm.member : nil }.compact\n end", "def current_user_hasmsg?\n response = get_current_user_meta('hasmsg')\n return false unless response\n\n response['query']['userinfo']['messages'] == ''\n end", "def test_get_existing_message_id\n id = Message.all.first&.id\n return if id.nil?\n\n get \"/messages/#{id}\"\n assert last_response.ok?\n assert_equal 'application/vnd.api+json', last_response.headers['Content-Type']\n\n response_body = JSON.parse last_response.body\n data = response_body['data']\n\n verify_message Message[data['id']], data\n end", "def valid_response?(message)\n return true\n end", "def good_message(message)\n return unless message[:service] == :groupme && message[:group]\n\n text = message[:text]\n attachments = message[:attachments]\n\n (text && !text.empty?) || !convert_attachments(attachments).empty?\n end", "def check_message_status(messageId)\n begin\n endpoint = \"/restapi/v1.0/account/~/extension/~/message-store/\" + messageId.to_s\n resp = $platform.get(endpoint)\n puts (\"Message status: \" + resp.body['messageStatus'])\n if (resp.body['messageStatus'] == \"Queued\")\n sleep(2)\n check_message_status(resp.body['id'])\n end\n rescue StandardError => e\n puts (e)\n end\nend", "def check_single_data(data:, message:)\n crit_msg(message) if data\n end", "def process_msgs\n end", "def matches_message?(message)\n match_message(message).any?\n end", "def isAllowMessage(request)\n return httpRequest('check_message',request)\n end", "def has_message_id?\n !fields.select { |f| f.responsible_for?('Message-ID') }.empty?\n end", "def message_exists?(response)\n response.respond_to?(:name) && response.name == 'EXISTS'\n end", "def system_msg?\n posts.first.system_msg? rescue nil\n end", "def check_for_spamming\n #first check if it is a new conversation\n if !params[:message][:conversation_id]\n if current_user.conversations.recent.count < 5 #max 5 new convos/hour\n false\n else\n true\n end\n else\n false #limit_replies\n end\n end", "def get_chat_messages\n # get chat messages\n chats = Message.includes(:user).where(receiver_id: @current_user.id, user_id: params[:user_id], request_id: params[:request_id]).or(Message.includes(:user).where(user_id: @current_user.id, receiver_id: params[:user_id], request_id: params[:request_id])).order(created_at: :asc)\n if chats.any?\n render json: chats, :include => {\n :user => {\n :only => [:id, :firstname, :lastname]\n },\n },\n status: :ok\n else\n render json: {\n status: 'no-content',\n message: 'No chat on this request yet'\n },\n status: :no_content\n end\n end", "def check_warnings\n @messages = {}\n @messages[:expired_card] = MESSAGES[:expired_card] if cards.any?(&:expired?) # { |card| card.expired? }\n @messages[:empty_wallet] = MESSAGES[:empty_wallet] if @cards.length < 1\n @messages.length > 0\n end", "def message_notifications\n notifications = Message.where(receiver_id: @current_user.id, read_status: 0)\n if notifications\n render json: {\n status: 'success',\n message: 'Your notifications',\n data: notifications.length()\n },\n status: :ok\n end\n end", "def get_safebox_messages(safebox_guid)\n handle_error { sendsecure_connection.get(\"api/v2/safeboxes/#{safebox_guid}/messages.json\") }\n end", "def message?\n false\n end", "def inbox\n if Store.verify_key_and_secret(params[:api_key], params[:api_secret])\n @store = Store.find_by(nabp: params[:nabp])\n if @store.nil?\n render :text => \"Store with that nabp #{params[:nabp]} number not found\" and return\n else\n @messages = @store.messages\n render layout: false\n end\n else\n render :text => \"API Key and secret not valid\"\n end\n #render layout: false\n end", "def __messages__\n defined?(messages) ? Array[*messages] : nil\n end", "def check\n result = @inner.check\n @message = @inner.message\n\n !result\n end", "def messages()\n []\n end", "def is_text_message?(message)\n !message.text.nil?\nend", "def messages\n end", "def messages\n end", "def warning?\n messages && messages.length > 0\n end", "def message?\n #errors.on(:message) != nil\n errors[:message] != nil\n end", "def get_all\n if @messages = Message.all\n render json: @messages\n else\n render json: \"Error!\"\n end\n\n end", "def check_wallet_warnings\n @messages = {}\n # do we have cards?\n @messages[:expired_card] = MESSAGES[:expired_card] if cards.any?(&:expired?)\n @messages[:empty_wallet] = MESSAGES[:empty_wallet] if @cards.length < 1\n # always true, dont stop other callbacks\n true\n end", "def find_all_messages\n if self.forsale\n return Message.where('seller_item_id == ?', self.id)\n elsif self.wanted\n return Message.where('buyer_item_id == ?', self.id)\n else\n return nil\n end\n end", "def test!\n begin\n send_message!(:recipient_number => '_', :body => '')\n rescue Excon::Errors::Error\n false\n rescue MessageRejectedError\n true\n else\n false # Gateway is being weird, should never accept that message\n end\n end", "def check_true(msg, lang)\n # use entries in BotResponse with seq=10xx to identify call type\n m = BotResponse.where(lang: lang).where(\"seq >= ?\", 1100).where(\"seq < ?\", 1200).to_a # Mappings\n result = \"\" # \n m.each do |item|\n item[\"message\"].split(\",\").each do |word|\n if msg.strip.downcase.include?(word.strip.downcase)\n result = item[\"identifier\"].to_s\n break\n end\n end\n if result != \"\"\n break\n end\n end\n if result == \"true\"\n return true\n else\n return false\n end\n end", "def messages; end", "def messages; end", "def messages; end", "def get_unread_by_chain\n chain_name = fix_special_character(params[:chain_name])\n if chain_name=='' || chain_name.nil?\n render :status=>412, :json=>{:status=>:failed, :error=>\"Chain name is require\"}\n return\n else\n @messages = Notifications.get_unread_message_by_chain(chain_name, @user.email)\n end\n end", "def index\n @response_messages = @request_message.response_messages\n respond_to do |format|\n format.html { raise ActionController::RoutingError.new('Not Found') }\n format.json {}\n end\n end", "def fetch_conversation_if_exists\n # all members phone numbers should be included to do a proper lookup\n numbers = parsed_phones + [inviter.phone_normalized]\n inviter.conversations.find_by_phones(numbers).first\n end", "def expected_messages_received?\n count >= expected\n end", "def exclude_sent\n @message.sent? and return render :show\n end", "def messages\n @messages ||= []\n end", "def check_params\n params['message'].to_i > 30\n end", "def msg_sent?\n true\n end", "def check_message_list(t)\n bot_user = BotUser.where(name: 'Smooch').last\n bot = t.team_bot_installations.find_by_user_id bot_user.id\n bot ? bot.settings['smooch_project_id'] : nil\nend", "def me?\n @msg.me?\n end", "def find_all_messages\n\t\tif self.forsale\n\t\t\treturn Message.where('seller_item_id == ?', self.id) \n\t\telsif self.wanted \n\t\t\treturn Message.where('buyer_item_id == ?', self.id) \n else \n\t \t\treturn nil \t\n\t end \n\tend", "def can_receive_updates\n @user = User.where(email: params[:email])\n params[:message]\n if @user.present?\n render json: @user.unblocked_subscribers.page(params[:page]).per(params[:per_page]).distinct\n else\n render json: {message: 'User Not Found'}, status: 404\n end\n end", "def status\n return nil if self.nexmo_message_id.nil?\n\n client = NexmoClientFactory.client\n client.get_message(nexmo_message_id)\n end", "def send_messages\n if Message.send_messages()\n render json: {status: :ok}\n else\n render json: \"Error\"\n end\n end", "def message_count\n 0\n end", "def new_message\n @new_message = false\n @message_num = 0\n @new_requests = Array.new\n if !current_user.nil?\n @current_user_profile = UserProfile.find(current_user.id)\n @user_name = @current_user_profile.username\n # checking if there are importance request message?\n @current_user_profile.items.each do |it|\n it.borrow_requests.each do |req|\n if !req.read_status\n @new_message = true\n @message_num = @message_num + 1\n @new_requests << req.id\n #flash[:notice] = \"You have new requset\"\n elsif req.return_status == 0 && req.borrow_date <= Date.today && req.approval\n @new_message = true\n @message_num = @message_num + 1\n @new_requests << req.id\n #flash[:notice] = \"have items need to be deliverd today\"\n elsif req.return_status == 1\n @new_message = true\n @message_num = @message_num + 1\n @new_requests << req.id\n #flash[:notice] = \"You item returned\"\n end\n end\n end\n @current_user_profile.borrow_requests.each do |req|\n if ((req.approval && req.return_status == 3) || (!req.borrower_read_status))\n @new_message = true\n @message_num = @message_num + 1\n @new_requests << req.id\n #flash[:notice] = \"deliverd check received?\"\n elsif req.return_status == 4 && req.return_date <= Date.today\n @new_message = true\n @message_num = @message_num + 1\n @new_requests << req.id\n #flash[:notice] = \"Return!!!\"\n end\n end\n end\n end", "def check_for_big_messages\n if message_size > user_thread.options[:max_email_size]\n Log.librato(:count, \"system.process_uid.big_message\", 1)\n user_thread.update_user(:last_uid => uid)\n return false\n else\n return true\n end\n end", "def messages_blocked\n return @messages_blocked\n end", "def availability_check_response(_msg_id, data)\n if false\n response = JSON.parse(data)\n # TODO: format of fifi_ready value is not defined yet\n status = response['result'] == 'ok' && response['fifi_ready'].to_i == 1 ? STATUS_AVAILABLE : STATUS_UNAVAILABLE\n\n if status == STATUS_UNAVAILABLE\n logger.warn(\"Source #{source_id} is unavailable. Reason: #{response['message']}\")\n end\n\n update_source(source_id, status)\n else\n # woohoo, always successful\n update_source(source_id, STATUS_AVAILABLE)\n end\n end", "def flash_messages?; flash.any?; end", "def messages\n @messages ||= []\n end", "def messages\n @messages ||= []\n end", "def messages\n @messages ||= ''\n end", "def should_store_message?(params)\n (settings.ignore_regex.nil? || !params[:text].match(settings.ignore_regex)) &&\n (settings.reply_regex.nil? || !params[:text].match(settings.reply_regex)) &&\n (ENV['SLACK_USER'].nil? || ENV['SLACK_USER'] == params[:user_name] || ENV['SLACK_USER'] == params[:user_id])\nend", "def new_messages\n self.messages.where(mailgun_reply_to_id: nil) \n end", "def process_message_response\n # Is this email confirming receipt of a previous message? \n msg_id = find_message_id_tag(:subject=>@subject, :body=>@body)\n#puts \"**** body=#{@body}, msg_id=#{msg_id}\"\n if msg_id \n # Does the \"confirmed message\" id actually match a message?\n message = Message.find_by_id(msg_id)\n if message\n msg_tag = message_id_tag(:id => msg_id, :action => :confirm_tag) # e.g. !2104\n search_target = Regexp.new('[\\'\\s\\(\\[]*' + \"#{Regexp.escape(msg_tag)}\" + '[\\'\\s\\.,\\)\\]]*')\n # The main reason to strip out the tag (like !2104) from the message is that it may be the\n # first part of the response, if there is one; e.g. \"!2104 Kafanchan\" replying to a message\n # requesting location. \n user_reply = first_nonblank_line(@body)\n#puts \"**** user_reply='#{user_reply}'\"\n user_reply = user_reply.sub(search_target, ' ').strip if user_reply\n # Mark all members with this email address as having responded to this message\n @possible_senders.each do |a_member|\n message.process_response(:member => a_member, :text => user_reply, :mode => 'email')\n end\n else\n msg_tag = message_id_tag(:id => msg_id, :action => :create, :location => :body)\n Notifier.send_generic(@from_address, I18n.t('error_msg.invalid_confirmation')).deliver\n end\n end\n end", "def empty?(response); end", "def test!\n begin\n send_message!(:recipient_email => '_', :subject => 'meh')\n rescue Excon::Errors::Error, Timeout::Error\n false\n rescue MessageRejectedError, RecipientRejectedError\n true\n else\n false # Gateway is being weird, should never accept that message\n end\n end", "def valid_keys?(message)\n [:sender, :sent_to, :type, :uid] - message.keys == []\n end", "def index\n @messages = @conversation.messages.includes(:user).order('created_at ASC').page(1)\n\n conversation_user = ConversationUser.find_by(conversation: @conversation, user: current_user)\n @message = conversation_user.messages.build\n\n authorize @message\n @other = @conversation.users.find_by('users.id != ?', current_user.id)\n end", "def get_new_messages\n get_messages_link_and_content\n end", "def check_fax_message_status(messageId)\n begin\n endpoint = \"/restapi/v1.0/account/~/extension/~/message-store/\" + messageId.to_s\n resp = $platform.get(endpoint)\n puts (\"Message status: \" + resp.body['messageStatus'])\n if (resp.body['messageStatus'] == \"Queued\")\n sleep(10)\n check_fax_message_status(resp.body['id'])\n end\n rescue StandardError => e\n puts (e)\n end\nend", "def read_all_messages\n post(\"/api/read_all_messages\")\n end", "def get_messages\n \tuser = User.find(params[:user_id]);\n \tif user\n \t\tmessages = Message.where(message_type: user.user_type)\n \t\tconversation = Conversation.where(request_id: params[:request_id])\n texts = []\n conversation.each{ |msg| texts.push(Message.find_by(id: msg.message_id) ? Message.find(msg.message_id) : {})}\n \t\trender json: {messages: messages, conversation: conversation, texts: texts}\n \telse\n\t\trender json: {error: 'User not found.'}\n \tend\n end", "def is_empty()\n @requests.empty?\n end", "def no_more_offers?\n message = first('#message')\n message && message.text == \"Come back later for more offers.\"\n end", "def wont_be_empty(msg=nil)\n EmptyAssay.refute!(self, :message=>msg, :backtrace=>caller)\n end", "def show\n @message = Message.find(params[:id])\n\n @inbox = current_user.inbox_message.where('status = 0').count\n Message.read_message(@message,current_user.id)\n end", "def valid?(message)\n super do |_|\n # only care that it's an HTTP request\n message[:message][:request] &&\n message[:message][:connection]\n end\n end", "def count_messages\r\n @messages.size\r\n end", "def call\n @message.spam?\n end", "def show\n unless params[:conversation_id]\n render json: { success: 'no', msg: 'not enough info' }\n return\n end\n if !Direct.exists?(conversation_id: params[:conversation_id]) & !Group.exists?(conversation_id: params[:conversation_id])\n render json: { success: 'no', msg: 'convo does not exist' }\n return\n end\n unless Message.exists?(conversation_id: params[:conversation_id])\n render json: { success: 'no', msg: 'no messages' }\n return\n end\n\n allMsgs = Array.new\n Message.where(conversation_id: params[:conversation_id]).find_each do |message|\n senderNickname = UserProfile.find_by(user_id: message.sender_id).nick_name\n senderEmail = User.find_by(user_id: message.sender_id).email\n output = { :conversation_id => message.conversation_id, :sender_nickname => senderNickname , :sender_email => senderEmail, :message_body => message.message_body, :updated_at => message.updated_at }\n\n allMsgs.push(output)\n end\n\n render json: { success: 'ok', messageList: allMsgs }\n end", "def messaging\n end", "def index\n @messages = @conversation.messages\n @messages.where(\"user_id != ? AND read = ?\", current_user.id, false).update_all(read: true)\n if @conversation.sender == current_user\n @msg_not = @conversation.recipient\n else\n @msg_not = @conversation.sender\n end\n if current_user != @conversation.sender \n if current_user != @conversation.recipient\n redirect_to conversations_path\n end\n end\n @message = @conversation.messages.new\n end", "def handle_bogus_message(message)\n # This needs a good solution\n end", "def poll!\n find_and_process_next_available(messages)\n end", "def read_messages\n @useConversations = Message.where(\"user_id = (?)\", current_user.id).pluck(:conversation_id)\n if @useConversations.count > 0\n @useConversations = @useConversations.uniq # Unique\n @useConversations = @useConversations.map(&:inspect).join(', ')\n #@updatemsg = Message.where(\"user_id != (?) and conversation_id IN (?)\", current_user.id, @useConversations).update_all(:mark_as_read => true)\n @updatemsg = Message.where(\"user_id != #{current_user.id} and conversation_id in (#{@useConversations})\").update_all(:mark_as_read => true)\n session[:mark_messages] = 0 # Mark as read messages\n end\n end", "def is_valid_message?(params)\n settings.environment == :development || (params[:token] == ENV['OUTGOING_WEBHOOK_TOKEN'] && params[:bot_id].nil?)\nend", "def last_is_from_buyer?\n not status.messages.where('messages.id != ?', id).order('created_at DESC').first.try(:from_owner?)\n end", "def feedback_loop(msg)\n\n fbl = msg.parts.find { |x| x.content_type == \"message/feedback-report\" }\n unless fbl.nil?\n\n line = msg.to_s.split(\"\\n\").find { |x| x.start_with?(\"X-Rhombus-Subscriber-UUID:\") }\n unless line.nil?\n uuid = line.split(\":\")[1].strip\n s = EmailSubscriber.find_by(uuid: uuid)\n unless s.nil?\n s.update_attributes(reported_spam: true, last_error: fbl.body.to_s) unless @dry_run\n @logger.info s.email + \" reported spam\"\n return true\n end\n end\n\n end\n\n false\n end", "def messages\n @messages ||= parse_messages(@raw_messages)\n end", "def is_request? msg\n msg && msg[:req_id]\n end" ]
[ "0.73932064", "0.71648556", "0.68863493", "0.6635649", "0.6629527", "0.6470104", "0.6430322", "0.64266336", "0.6348264", "0.6348264", "0.63257617", "0.6306825", "0.6305746", "0.63001496", "0.6268742", "0.6239971", "0.6135803", "0.6118827", "0.6095308", "0.6074208", "0.60671574", "0.6062674", "0.6051536", "0.6044552", "0.60344017", "0.60232717", "0.60089815", "0.6000735", "0.59773344", "0.59675443", "0.5964123", "0.5960941", "0.5957827", "0.5934086", "0.59248954", "0.59199464", "0.5902222", "0.5902222", "0.590074", "0.5886609", "0.58822733", "0.587968", "0.5859144", "0.5847504", "0.5841832", "0.58389187", "0.58389187", "0.58389187", "0.58322626", "0.5808753", "0.5802265", "0.57904375", "0.5789626", "0.57828295", "0.5776522", "0.5770213", "0.57483643", "0.5741577", "0.5731971", "0.571838", "0.5712255", "0.57114506", "0.5689976", "0.56897813", "0.5685419", "0.5677459", "0.56670034", "0.5661546", "0.5656496", "0.5656496", "0.5655868", "0.56542283", "0.5652876", "0.5645273", "0.56415737", "0.5632708", "0.5629063", "0.5628292", "0.5624824", "0.56197923", "0.5615931", "0.5612582", "0.56091416", "0.5604886", "0.559602", "0.55912125", "0.5589861", "0.55730754", "0.55675304", "0.55615467", "0.55611974", "0.5559401", "0.5553449", "0.5551805", "0.55455124", "0.55449337", "0.5542369", "0.554233", "0.55415803", "0.5532468" ]
0.5970666
29
the sum from 1 to n (inclusive of n).
def sum_to(num) if num == 0 return num elsif num < -1 return nil end num + sum_to(num - 1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_to(n)\n (1..n).reduce(0) do |sum, value|\n sum + value\n end\nend", "def sum(n)\n end", "def sum(n)\n result = 0\n n.each do |number|\n result = result + number\n end\n return result\n end", "def sum_to(n)\n n > 1 ? n + sum_to(n - 1) : n < 1 ? [].first : 1\n end", "def summation(n)\n sum = 0\n (1..n).each { |num| sum += num }\n return sum\nend", "def summation(n)\n #iterate through numbers less than or equal to n and add them up\n sum = 0\n\n (1..n).each { |num| sum += num }\n return sum\nend", "def summation(n)\n sum = 0\n (1..n).each { |num| sum += num }\n return sum\nend", "def sum_to(n)\n return nil if n < 0\n return 0 if n == 0\n \n n += sum_to(n-1)\n end", "def sum_to(n)\n return nil if n <= 0 #negatives and 0\n return 1 if n == 1 #base step\n #inclusive step 1 + sum_to(n)\n n + sum_to(n - 1)\nend", "def sum(n=16) end", "def get(n=0)\n sum = 0\n (0...n).each do |i|\n sum += i\n end\n return sum\n end", "def sum_integers_up_to(n)\n sum = 0\n for i in 1..n\n sum += i\n end\n sum\nend", "def sum(n)\n return 1 if n == 1\n\n n + sum(n - 1)\nend", "def sum_to(n)\n return nil if n<0\n return 1 if n==1\n sum_to(n-1) + n\nend", "def sum_to(n)\n return nil if n < 1\n return 1 if n == 1\n sum_to(n - 1) + n\nend", "def sum_to(min=1, n)\n if n > 0\n return min if min == n \n min + sum_to(min + 1, n)\n end\nend", "def sum_to(n)\n return nil if n < 1\n return 1 if n == 1\n\n n + sum_to(n - 1) \nend", "def sum_to(n)\n return n if n == 1 || n == 0\n return nil if n < 0\n n + sum_to(n - 1)\nend", "def sum_to(n)\n return 1 if n == 1\n return nil if n<1\n n + sum_to(n-1)\nend", "def sum_terms(n)\n (1..n).reduce(0) {|sum, val| sum += (val * val + 1)}\n end", "def sum_integers_up_to(n)\n (n * ( n + 1 ) ) / 2\nend", "def sum_of_n(n)\n # your code here\n # result = []\n # if n >= 0\n # ary = (0..n).to_a\n # else\n # ary = (n..0).to_a.reverse\n # end\n # ary.each_with_index do |_numb, index|\n # somme = 0\n # result << somme += ary[0..index].sum + somme\n # end\n # result\n sum = 0\n (n.negative? ? 0.downto(n) : 0.upto(n)).map do |number|\n sum += number\n end\nend", "def sum_to(n)\n return nil if n < 1\n return n if n == 1\n n + sum_to(n - 1)\nend", "def summation(num)\n (1..num).reduce(:+)\nend", "def sum_of_n(n)\n key = 0\n answer = (0..n.abs).to_a.map { |num| key += num }\n n < 0 ? (answer.map { |n| n * (-1) }) : answer\nend", "def sum_to(n)\n return n if n == 1\n n + sum_to(n-1)\nend", "def compute_sum(number)\n (1..number).reduce(:+)\nend", "def sum_to(n)\n\n if n < 1\n return nil\n elsif n == 1\n return 1\n end\n\n n + sum_to(n - 1)\nend", "def sum_to(n)\n return 1 if n == 1\n return nil if n <= 0\n n + sum_to(n-1)\nend", "def sum_to(n)\n return 1 if n == 1\n return nil if n < 1\n n += sum_to(n - 1)\nend", "def sum_to(n)\n return nil if n < 0\n return 0 if n == 0\n n + sum_to(n-1)\nend", "def sum_to(n)\n return nil if n < 0\n return n if n == 1\n\n n + sum_to(n - 1)\nend", "def sum(n)\n s = BigDecimal.new(\"1\")\n sig = 1\n\n 1.upto(n) do |i|\n sig *= -1\n s += (1.0 / (2*i + 1)) * sig\n end\n\n 4 * s\nend", "def sum_to(n)\n return nil if n < 1\n return n if n == 1\n \n n + sum_to(n - 1)\nend", "def sum_to(n)\n if n == 1\n return 1\n elsif n < 1\n return nil\n end\n\n n + sum_to(n - 1)\nend", "def sum_to(n)\n return nil if n < 0\n return n if n == 0\n n += sum_to(n - 1)\nend", "def compute_sum(number)\n (1..number).inject(:+)\nend", "def sum_to(n)\n return nil if n < 0\n return n if n <= 1\n n + sum_to(n - 1) #if n > 0\nend", "def sum_to(n)\n return n if n == 0\n return nil if n < 0\n n + sum_to(n - 1)\nend", "def summation(num)\n sum = (0..num).inject(:+)\n return sum\nend", "def rec_sum(n)\n if n == 0\n return 0\n else\n return n + rec_sum(n-1)\n end\nend", "def square_of_sum(n)\n sum = 0\n (1..n).each {|i| sum = sum + i}\n sum * sum\n end", "def sum(n, m)\n if n > m\n return 0\n else\n return sum(n+1, m) + n\n end\nend", "def sum_term n\n (1..n).reduce(0) { |acc, curr| acc += (curr ** 2 + curr + 1)}\nend", "def sumn(n)\n result = 0\n 1.upto(n) { |e| result += e }\n puts \"Sum of #{n} numbers is #{result}\"\nend", "def sum n\n\tbegin\n\tn.reduce(:+)\n\trescue \n\t\tn.map!{|x| x.is_a?(Array) ? x.reduce(:+) : x }\n\t\tsum n\n\tend\n\tp n.reduce(:+)\nend", "def sum_numbers(arr, n)\n sum = 0\n index = 0\n\n arr.each do |i|\n if index != n \n sum += i\n else\n return sum\n end\n\n index += 1\n end\nend", "def sum_to_n(n)\n # Your Code Here!\nend", "def trinum n\n temp = 0\n for i in 1..n\n temp = temp + i\n end\n return temp\nend", "def sum_of_amicable_numbers(n)\r\n amicable_numbers(n).reduce(:+)\r\nend", "def sum_of_n_consecutive_numbers (n)\n n*(n+1)/2\nend", "def sum_to(n)\n # if n < 2\n # 1\n # else\n # n + sum_to(n-1)\n # end\n return 1 if n < 2\n n + sum_to(n - 1)\nend", "def sum_of_primes(n)\n Prime.first(n).inject(0, :+)\nend", "def sum_prime(n)\n\ti = 0\n\tp = 1\n\tsum = 0\n#\tprimes = []\n\n\tuntil p == n\n\t\tp += 1\n\t\tif is_prime?(p)\n#\t\t\tprimes << p\n\t\t\tsum += p\n\t\t\ti += 1\n\t\tend\n\tend\n\n\treturn sum\n\t#return primes.reduce(:+)\nend", "def square_sum_up_to n=100\r\n (n * (n + 1) / 2)**2\r\nend", "def compute_sum(number)\n total = 0\n 1.upto(number) { |value| total += value }\n total\nend", "def summation(num)\n sum = 0\n (0..num).each do |v|\n sum += v\n end\n return sum\nend", "def compute_sum(n)\n i = 1\n num = 0\n\n loop do\n num += i\n i += 1\n break if i > n\n end\n num\nend", "def sum(number)\n total = 0\n 1.upto(number) {|v| total += v }\n total\nend", "def square_of_sums\n return (@n * (@n + 1) / 2)**2\n end", "def geometricSeriesSum(x, n)\n return (power(x, n + 1) - 1) / (x - 1)\nend", "def sum(number)\n a = (1..number).to_a\n puts a.inject(:+)\nend", "def sum_terms(n)\n # your code here\n (1..n).inject(&:+)\nend", "def solution(n)\n sum = 0\n (1...n).each do |elem|\n sum += elem if elem % 3 == 0 or elem % 5 == 0\n end\n sum\nend", "def sum_of_squares(n)\n sum = 0\n (1..n).each {|i| sum = sum + (i*i)}\n sum\n end", "def multisum(n)\n sum = 0\n (1..n).each do |x|\n sum += x if (x % 3 == 0) || (x % 5 == 0)\n end\n sum\nend", "def first_even_numbers_sum(n)\n return 2 if n == 1\n 2 * n + first_even_numbers_sum(n-1)\n end", "def sum_of_all_primes(n)\n sum = 0\n (1..n).each do |x|\n if prime? x\n sum += x\n end \n end \n sum\n end", "def sum_terms(n)\n (1..n).map {|x| x**2+1 }.reduce(0,:+) if n >= 0\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n - 1) + fibs_sum(n - 2) + 1\nend", "def sum_numbers(arr, n)\n c = arr.n[0]+n[1]+n[2]+n[3].sum\nend", "def total (n=64)\n (2**n)-1\n end", "def exp_sum(n, hash = {0=>1, 1=>1})\n\tif n > 1\n\t\tcalc_array = []\n\t\tpent_arr = calc_pent(n)\n\t\tlen = pent_arr.length\n\t\tcount = 0\n\t\twhile count < len\n\t\t\tpent_at_bat = pent_arr.pop\n\t\t\tnum_to_part = n - pent_at_bat\n\t\t\tif hash.has_key? (num_to_part)\n\t\t\t\tcalc_array.unshift(hash[num_to_part])\n\t\t\telsif num_to_part > -1\n\t\t\t\tnew_val = exp_sum(num_to_part, hash)\n\t\t\t\thash[num_to_part] = new_val\n\t\t\t\tcalc_array.unshift(new_val)\n\t\t\tend \n\t\t\tcount += 1\n\t\tend\n\t\tsum_array(calc_array)\n\telsif n < 0\n\t\treturn 0\n\telse \n\t\treturn 1\n\tend\nend", "def sum_terms(n)\n (1..n).inject(0){|product, n| product + n * n + 1}\nend", "def addition(number)\n (1..number).reduce(:+)\nend", "def square_sums(n)\n Array(1..n).sum**2\nend", "def fibs_sum(n)\n return 1 if n == 1 || n == 2\n sum = 0\n sum += (fibs_sum(n - 1) + fibs_sum(n - 2))\n \n \nend", "def sum_of_all_integers(num)\n (0..num).sum\nend", "def summation(num)\r\n puts 1.upto(num).reduce(0, :+)\r\nend", "def sumOf(n)\n i = 0\n multiples = []\n while i < n do\n if i % 3 == 0 || i % 5 == 0\n multiples.push(i)\n end\n i += 1\n end\n multiples.inspect\n multiples.reduce(:+)\nend", "def sum_up_to_squared n=100\r\n (2 * n + 1) * (n + 1) * n / 6\r\nend", "def tail_sum(n, total = 0)\n return total if n == 0\n\n tail_sum(n - 1, total + n)\nend", "def fib_sum(n)\n return n if ( 0..1 ).include? n\n ( fib_sum( n - 1 ) + fib_sum( n - 2 ) )\nend", "def sum_recursive(num)\n # can also compute sum with symbol (1..5).inject(:+)\n (1..num).inject { |sum, n| sum + n }\nend", "def sum(n)\n\n s = 0\n\n for i in 1...n\n if i % 3 == 0 || i % 5 == 0\n s += i\n end\n end\n\n return s\n\nend", "def SimpleAdding(num)\n\n # code goes here\n range_sum = *(1..num)\n return range_sum.inject(:+)\n \nend", "def find_missing_number(array, n)\n sum = (1..n).reduce(:+) # sum from 1 to n\n array.each do |el|\n sum -= el\n end\n return sum\nend", "def twisted(n)\n sum = 0\n while n > 0\n sum += map(n)\n n -= 1\n end\n sum\nend", "def sum_n_primes(n)\n primes = []\n i = 2\n while primes.size < n\n primes << i if prime?(i)\n i += 1\n end\n primes.sum\nend", "def compute_sum(int)\n sum = 0\n 1.upto(int) { |i| sum += i }\n sum\nend", "def suma(n, d)\n if(@d == d)\n @n += n\n @n, @d = reducir(@n, @d)\n else\n new_d = lcm(@d, d)\n new_n = ((new_d / @d) *@n ) + ((new_d / d) *n ) \n @n, @d = reducir(new_n,new_d)\n end\n return @n,@d\n end", "def sum\n inject(0) { |acc, i| acc + i }\n end", "def first_even_numbers_sum(n)\n\nend", "def first_even_numbers_sum(n)\n\nend", "def compute_sums(n)\n return compute1_sum if n == 1\n pivot_index = n/2-1\n target_value = total_value/3\n num_souvenirs = souvenirs.size\n\n indexes = []\n skip = false\n while indexes = next_indexes(indexes, n, skip)\n skip = false\n val = nil\n sum(*indexes) do |arr, i|\n val = sum(*indexes[0..pivot_index]) + sum(*indexes[pivot_index+1..-1])\n arr[i] = val\n print \"indexes: #{indexes}, val=#{val}, sum(#{indexes[0..pivot_index].inspect})=#{sum(*indexes[0..pivot_index])}, sum(#{indexes[pivot_index+1..-1]})=#{sum(*indexes[pivot_index+1..-1])}\"\n print \"good indexes found=#{indexes}, pivot=#{pivot_index}\" if val == target_value\n @good_sums << i+1 if val == target_value\n skip = val > target_value\n end\n end\n end", "def fibs_sum(n) # my version\n return 1 if n == 1\n return 2 if n == 2\n\n current = single_fib(n)\n current += fibs_sum(n - 1)\nend", "def triangular( n )\n sum = 0\n (1..n).each { |num| sum += num }\n sum\nend" ]
[ "0.8519351", "0.8480083", "0.8300971", "0.8294192", "0.82304156", "0.8198482", "0.8193413", "0.8165357", "0.81279874", "0.8060312", "0.8057663", "0.80410767", "0.79839236", "0.7944503", "0.78839034", "0.7855229", "0.7763933", "0.7757589", "0.7756247", "0.775055", "0.7749765", "0.77405053", "0.7733267", "0.7725996", "0.77231497", "0.77038556", "0.76843506", "0.7673232", "0.76704586", "0.7663807", "0.76538724", "0.76523083", "0.7622451", "0.7588755", "0.7582414", "0.7570484", "0.7559812", "0.749998", "0.74935955", "0.7475206", "0.74544585", "0.7416253", "0.7400498", "0.7395694", "0.7343235", "0.73244923", "0.73113936", "0.73021233", "0.7297642", "0.72937495", "0.72912055", "0.72773355", "0.7273058", "0.726024", "0.7254771", "0.7239595", "0.72350967", "0.723349", "0.718577", "0.7183234", "0.7165994", "0.71448493", "0.71264976", "0.71244615", "0.70834816", "0.7079064", "0.70766324", "0.70730853", "0.70699567", "0.7069716", "0.7069716", "0.7069716", "0.7069716", "0.7061835", "0.7056126", "0.7050974", "0.7031509", "0.70279145", "0.70253944", "0.7012648", "0.70080626", "0.70071965", "0.69696546", "0.6953749", "0.6950389", "0.6937754", "0.6933558", "0.69325894", "0.69294775", "0.6917569", "0.691311", "0.6908473", "0.6905382", "0.69022375", "0.6898073", "0.6891217", "0.6883846", "0.6883846", "0.68810135", "0.6870125", "0.6863599" ]
0.0
-1
=> returns nil Write a function add_numbers(nums_array) that takes in an array of Fixnums and returns the sum of those numbers. Write this method recursively.
def add_numbers(arr) if arr == [] return nil elsif arr[0] == arr[-1] return arr[0] end arr[-1] + add_numbers(arr[0...-1]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_numbers(nums_array)\n\treturn nil if nums_array.length == 0\n\n\treturn nums_array.first if nums_array.length == 1\n\n\treturn nums_array.shift + add_numbers(nums_array)\nend", "def add_numbers(num_array)\n return num_array[0] if num_array.length <= 1\n sum = num_array[0]\n sum += add_numbers(num_array[1..-1])\nend", "def add_numbers(nums_array = nil)\r\n return nil if nums_array.nil?\r\n return nums_array[0] if nums_array.length == 1\r\n nums_array[0] + add_numbers(nums_array[1..-1])\r\n end", "def add_numbers(nums_array)\n return 0 if nums_array.length == 0\n\n first = nums_array.shift\n\n first + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n return nums_array.first if nums_array.length == 1 #=> base case if the array is length 1 then just return the first element\n return nil if nums_array.length < 1 #=> return nil if the array length is less than 1\n \n nums_array.pop + add_numbers(nums_array) #=> inductive/recursive case taking the sum of the array and #pop the the last ele each time\nend", "def add_numbers(nums_array)\n return nums_array.first if nums_array.length == 1 || nums_array.empty?\n nums_array.last + add_numbers(nums_array[0...-1])\n end", "def add_numbers(nums_array)\n if nums_array.empty? \n 0\n else \n n = nums_array.pop\n return n + add_numbers(nums_array)\n end \nend", "def add_numbers(nums_array)\n return nil if nums_array.length == 0\n\n return nums_array.first if nums_array.length == 1\n\n nums_array.first + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return nums_array[0] if nums_array.size ==1\n return nil if nums_array.empty?\n\n nums_array[0] + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return nil if nums_array.empty?\n return nums_array.pop if nums_array.length == 1\n return nums_array.pop + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n return nil if nums_array.empty?\n return nums_array[0] if nums_array.length == 1\n nums_array[0] + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return nil if nums_array.empty?\n first_elem = nums_array.first\n return first_elem if nums_array.length == 1\n first_elem + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return nums_array[0] if nums_array.length <= 1\n nums_array[0] +add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return nil if nums_array.empty?\n return nums_array.pop if nums_array.length == 1\n return nums_array.pop + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n return nums_array[0] if nums_array.length <= 1\n n = nums_array[0] + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n nums_array.inject { |sum, el| sum + el }\nend", "def add_numbers(num_array = nil)\n return nil if num_array.nil?\n return num_array[0] if num_array.length == 1\n num_array[0] + add_numbers(num_array[1..-1])\nend", "def add_numbers(num_array)\n num_array.count > 1 ? num_array.first + add_numbers(num_array.drop(1)) : num_array.first\n end", "def add_numbers(nums_array)\n return nil if nums_array.empty?\n return nums_array.pop if nums_array.length == 1\n\n nums_array.pop + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n return nil if nums_array.length < 1\n return nums_array.first if nums_array.length == 1\n nums_array[0] + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n if nums_array.length == 1\n return nums_array.last\n elsif nums_array.empty?\n return nil\n end\n\n nums_array.pop + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n return nums_array.first if nums_array.length <= 1\n nums_array.shift + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n return nil if nums_array.empty?\n return nums_array[0] if nums_array.length == 1\n add_numbers(nums_array[1..-1]) + nums_array[0]\nend", "def add_numbers(nums_array)\n return nums_array[0] if nums_array.length < 2\n nums_array[0] + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return nums_array[0] if nums_array.length < 2\n nums_array[0] + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return nums_array.first if nums_array.length <= 1\n\n nums_array.pop + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n # Base Case: Is the array empty?\n return nums_array[0] if nums_array.length <= 1\n nums_array.shift + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n return nums_array[0] if nums_array.length <= 1\n nums_array.pop + add_numbers(nums_array)\nend", "def add_numbers(arr)\n return nil if arr.length < 1\n return arr[0] if arr.length == 1\n arr[0] += add_numbers(arr[1..-1])\n end", "def add_numbers(nums_array)\n return nums_array.first if nums_array.length <= 1\n last = nums_array.pop\n last + add_numbers(nums_array)\nend", "def add_all_numbers(array)\n array.inject(:+)\nend", "def sum_numbers(numbers)\r\n # Your code here\r\n #initalize the sum\r\n sum = 0\r\n #iterate through every element of a given array\r\n numbers.each do |number|\r\n #add the previous sum and next number in the array\r\n sum += number\r\n end\r\n \r\n return sum\r\nend", "def add_nums_iterative(arr)\n return nil if arr.length == 0\n total = 0\n arr.each do |num|\n total += num\n end\n total\nend", "def RecursiveSum(arrayofNumbers) \n \n # Base Case: If the array is empty, return 0. \n \n if arrayofNumbers? \n return 0\n \n # Recursive code: Adding each element to the variable by calling the method. \n \n else\n Sum = arrayofNumbers.pop \n return Sum + RecursiveSum(arrayofNumbers) \n end\nend", "def add_nums(arr)\n return nil if arr.length == 0\n return arr[0] if arr.length == 1\n arr[0] + add_nums(arr[1..-1])\nend", "def add_numbers(arr_of_ints)\n return arr_of_ints[0] if arr_of_ints.length <= 1\n arr_of_ints[0] + add_numbers(arr_of_ints[1..-1])\nend", "def add_numbers(arr)\n return arr[0] if arr.length <= 1\n arr[0] + add_numbers(arr[1..-1])\nend", "def add_array_numbers(array)\n result = array.sum\n # .sum cannot be used on a string, only integars and floats\n return result\nend", "def sum_array(numbers)\n return numbers.sum()\nend", "def rec_sum(nums)\n\nend", "def rec_sum(nums)\n\nend", "def add_numbers(array)\n#add first in array to next in array. replace next in array\n#until array.length < 1\n return array[0] if array.length <= 1\n num1, num2 = array.pop, array.pop\n sum = num1.to_i + num2.to_i\n array.unshift(sum)\n add_numbers(array)\nend", "def add_numbers(arr)\n return arr[0] if arr.length == 1\n return nil if arr.length == 0\n tot = arr.pop + add_numbers(arr)\nend", "def add_numbers(nums_array)\n #if array has >1 element, then take first element and then ...\n return nums_array.first if nums_array.length <= 1\n nums_array.first + add_numbers(nums_array[1..-1])\nend", "def sum(numbers)\n numbers.reduce(&:+)\n end", "def sum_nums(num)\n\t\n\tnumbers = []\n\tnum_sum = num\n\t\nuntil numbers.length == num_sum\n\tnumbers.push(num)\n\tnum = num - 1\nend\n return\tnumbers.inject(:+)\nend", "def total(array_of_numbers)\n sum = 0\n array_of_numbers.each do |num|\n sum += num\n end\n return sum\nend", "def sum_array(numbers)\n total = 0\n for number in numbers\n total = total + number\n end\n return total\nend", "def add_numbers(arr)\n return nil if arr.empty?\n return arr[0] if arr.length == 1\n arr.shift + add_numbers(arr)\nend", "def add(*nums) \r\n p @result.class\r\n for num in nums\r\n if num.class == Array\r\n #loop through the array and sum the elements\r\n for x in num\r\n @result += x.to_f\r\n end\r\n else\r\n @result += num.to_f# @result = @result + num\r\n end\r\n end\r\n self\r\n end", "def sum_array( numbers )\r\n numbers.inject(0, :+)\r\nend", "def add(numbers)\n numbers.inject { |sum, n| sum + n }\n end", "def total(array_of_numbers)\n return array_of_numbers.reduce(:+)\nend", "def sum(nums)\n\treturn 0 if nums == []\n\tnums.reduce(:+)\nend", "def add_numbers(arr)\n return arr.first if arr.length <= 1\n\n arr.pop + add_numbers(arr)\nend", "def sum_array(array)\n sum = 0\n array.each do |number|\n sum += number\n end\n sum\nend", "def sum array\n\tsum = 0\n\tarray.each do |number|\n\t\tsum = sum + number\n\tend\n\tsum\nend", "def sum_array(array)\n sum = 0\n array.each do |num|\n sum = sum + num\n end\n sum\nend", "def sum_array(array_num)\n\nend", "def sum_array(array)\n sum = 0\n\n array.each do |number|\n sum += number\n end\n\n return sum\nend", "def sum(array)\n sum = 0\n\n array.each { |number|\n sum += number\n }\n\n return sum\nend", "def sum(array_of_integers)\n # TODO\nend", "def sum(nums)\n return 0 if nums.empty?\n nums[0] + sum_rec(nums[1..-1])\nend", "def sum_nums(num)\n (1..num).inject(&:+)\nend", "def sum_array(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend", "def sum_rec(num_array)\n return 0 if num_array.empty?\n\n num[0] + sum_rec(num_array.drop(1))\nend", "def sum_array(array)\n return array.sum\n\n # sum_total_of_array = 0\n # for number in array\n # sum_total_of_array += number\n # end\n # return sum_total_of_array\nend", "def arr_sum(array)\n sum = 0 # Declares initial value for variable 'sum' as 0\n array.each do |i| # Begin iterating each item of arr\n sum += i # add each number in array to the next item, continue until items exhausted\n end\n return sum # Returns new sum value\nend", "def sum_array(array)\n sum = 0\n array.each do |num|\n sum+=num\n end\n sum\nend", "def sum_array(array)\n sum = 0\n array.each{ |num| sum += num }\n sum\nend", "def sum(nums)\n nums.reduce(&:+)\nend", "def sum_numbers (numbers)\n\n numbers.sum\n \nend", "def recursive_sum(nums)\n return 0 if nums.empty?\n\n return nums.pop + recursive_sum(nums)\nend", "def sum_of_sums(numbers)\n numbers_to_add = Array.new\n numbers.each_index do |index|\n numbers_to_add += numbers[0..index]\n end\n numbers_to_add.reduce(:+)\nend", "def sum(nums)\n total = 0\n nums.each do |n|\n total+= n\n end\n return total\nend", "def sum_array(array)\n total = 0\n array.each do |num|\n total += num\n end\n total\nend", "def add_elements(decimal_array)\n total = 0\n decimal_array.each do |number|\n total += number\n end\n return total\nend", "def sum(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend", "def sum_rec(numbers)\n return 0 if numbers.empty?\n num = numbers.pop\n num + sum_rec(numbers)\nend", "def summing_method(single_digit_array)\n summed_array = single_digit_array.sum\nend", "def sum1(array)\r\n sum = 0\r\n array.each do |number|\r\n sum += number\r\n end\r\n sum\r\nend", "def sum_numbers(numbers) # new method that takes 1 parameter\r\n array_total = 0 #beginning the sum at clean 0\r\n if numbers == [] # when provided an empty array default return is 0\r\n return nil #changed return value to nil\r\n else\r\n for number in numbers #iterating through array\r\n array_total += number #then adding that number to the total\r\n end\r\n return array_total\r\n end\r\nrescue Exception => e\r\n puts e.class, \"Invalid Input\"\r\nend", "def sum arr\n sum_array = 0 \n arr.each { |x| sum_array = sum_array + x } \n return sum_array\nend", "def my_sum(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend", "def sum(numbers)\n\ttotal = 0\n\tnumbers.each do |number|\n\t\ttotal += number if number.is_a? Integer\n\tend\n\ttotal\nend", "def sum_digits(array)\n return array.inject(:+) #explanation? combines all elements of array by applying binary operation, same as reduce\n # array.reduce do |product = 0, n| \n # product + n\n # end\n end", "def sum_array(array)\n sum = 0\n array.each do |x|\n sum += x\n end\n return sum\nend", "def sum(numbers)\n\tresult = 0\n\tnumbers.collect do |i|\n\tresult += i if i.is_a? Integer\n\tend\n\tresult\nend", "def sum(array)\n\ttotal = 0\n\tfor number in array #could do each do instead of for loop\n\t\ttotal += number\n\tend\n\treturn total\nend", "def numbers_sum(input_array)\n output = input_array[0] + input_array[1] # Sums the first array's input with the second array's input\n return output\nend", "def add_array(array)\n sum = 0\n for i in array do\n sum += i\n end\n sum\nend", "def sum_numbers (numbers)\n # Your code here\nend", "def sum_of_sums(array)\n sum = 0\n sum_array = array.map { |x| sum += x }\n sum_array.inject(:+)\nend", "def compute_sum(numbers)\n sum = 0\n numbers.each do |number|\n sum += number\n end\n return sum\nend", "def compute_sum(numbers)\n sum = 0\n numbers.each do |number|\n sum += number\n end\n return sum\nend", "def sum(numbers)\r\n numbers.reduce(0, :+)\r\nend", "def sum_rec(nums)\n return 0 if nums.empty?\n nums[0] + sum_rec(nums[1..-1])\nend", "def sum_of_big_numbers(array_of_integers)\n # TODO\nend", "def sum(array)\n sum = 0\n array.each { |n| sum += n } \n sum\nend", "def total(nums)\n nums.inject(:+)\nend" ]
[ "0.8548478", "0.838794", "0.8363098", "0.8339928", "0.8326567", "0.82845324", "0.8196909", "0.8178786", "0.8177713", "0.81563497", "0.812071", "0.80956376", "0.80920756", "0.8082502", "0.8068438", "0.8059388", "0.805778", "0.8055099", "0.8045769", "0.7996468", "0.7970453", "0.796772", "0.79212224", "0.79160357", "0.79160357", "0.7894212", "0.78685266", "0.7846272", "0.781087", "0.77807325", "0.7771449", "0.77521837", "0.7643258", "0.7637916", "0.7596346", "0.7595064", "0.7590946", "0.7586895", "0.75690407", "0.753856", "0.753856", "0.75376797", "0.75357527", "0.75157386", "0.74749017", "0.74574554", "0.74501276", "0.7434681", "0.73946875", "0.73897046", "0.73855656", "0.7384789", "0.7377918", "0.7372506", "0.73543084", "0.73504883", "0.7346909", "0.7338001", "0.73368675", "0.7331338", "0.72953737", "0.7273039", "0.72502106", "0.72359496", "0.72358537", "0.72144395", "0.7207896", "0.72071636", "0.71937555", "0.71920556", "0.7186381", "0.7174567", "0.71590596", "0.71584064", "0.7153341", "0.71440923", "0.71434784", "0.71399933", "0.7132703", "0.712104", "0.7118825", "0.7098973", "0.7093404", "0.7088377", "0.7085057", "0.7057547", "0.70527655", "0.7043708", "0.7040985", "0.703552", "0.7028499", "0.7024606", "0.7020029", "0.70145476", "0.70145476", "0.70109177", "0.7009525", "0.7009513", "0.7008191", "0.7002278" ]
0.7525197
43
=> returns 5040 Write a function ice_cream_shop(flavors, favorite) that takes in an array of ice cream flavors available at the ice cream shop, as well as the user's favorite ice cream flavor. Recursively find out whether or not the shop offers their favorite flavor.
def ice_cream_shop(flavors, favorite) return true if flavors[-1] == favorite return false if flavors.empty? ice_cream_shop(flavors[0...-1], favorite) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ice_cream_shop(flavors, favorite)\n # Base step\n return false if flavors.empty?\n return true if flavors[0] == favorite\n # Recursive Step\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors == []\n return true if flavors[0] == favorite\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.empty?\n return true if flavors[0] == favorite\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return true if flavors[0] == favorite\n return false if flavors.length < 1\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.length == 0\n\n flavors[0] == favorite ? true : ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return true if favorite == flavors[0]\n return false if flavors.length <= 1\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return true if flavors.first == favorite\n return false if flavors.empty?\n\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.empty?\n return true if flavors.first == favorite\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return true if flavors.last == favorite\n return false if flavors.length == 1 || flavors.empty?\n ice_cream_shop(flavors[0...-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.length.zero?\n\n return flavors.first == favorite if flavors.length == 1\n\n flavors.first == favorite || ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n\treturn false if flavors.empty?\n\n\treturn true if flavors.first == favorite\n\n\t_, *remaining = flavors\n\n\treturn ice_cream_shop(remaining, favorite)\nend", "def ice_cream_shop(flavors,favorite)\n return true if flavors[0] == favorite\n return false if flavors.length < 1\n ice_cream_shop(flavors[1..-1],favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.empty?\n return true if flavors.pop == favorite\n ice_cream_shop(flavors[0...-1],favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return true if flavors[0] == favorite\n return false if flavors.length <= 1\n\n ice_cream_shop(flavors[1..-1],favorite)\nend", "def ice_cream_shop(flavors, favorite)\n if flavors.empty?\n return false\n end\n\n return true if favorite == flavors.pop\n ice_cream_shop(flavors, favorite)\nend", "def ice_cream_shop(flavors, favorite)\n checker = flavors.pop\n return true if checker == favorite\n return false if flavors.length == 0\n ice_cream_shop(flavors, favorite)\nend", "def ice_cream_shop(flavors, favorite) \n offers = flavors[0] == favorite \n return offers if offers == true\n return offers if flavors.length <= 1\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.empty?\n return true if flavors.pop == favorite\n return ice_cream_shop(flavors, favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return true if flavors.pop == favorite\n return false if flavors.length == 1 || flavors.empty?\n ice_cream_shop(flavors, favorite)\nend", "def ice_cream_shop(flavors,favorite)\r\n return false if flavors.length == 0\r\n return true if flavors[0] == favorite\r\n ice_cream_shop(flavors[1..-1],favorite)\r\nend", "def ice_cream_shop(flavors, favorite)\n return favorite == flavors[0] if flavors.length <= 1\n flavors[0] == favorite || ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return true if flavors.first == favorite\n ice_cream_shop(flavors[1..-1],favorite) until flavors.first == nil\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.length == 0 #=> returns false if flavors arrray is empty\n last_flavor = flavors.pop #=> #pop the last flavor from the array \n return true if last_flavor == favorite #=> checking if the last flavor equals the favorite flavor is so return true\n # above is base case\n\n ice_cream_shop(flavors, favorite) #=> recusive case check the flavors array again with one less flavor now that since #pop was called\nend", "def ice_cream_shop(flavor, favorite)\n return false if flavor.empty?\n return flavor[0] == favorite if flavor.length == 1\n return flavor[0] == favorite || ice_cream_shop(flavor[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n flavors.empty? ? false : flavors.first == favorite ? true : ice_cream_shop(flavors.drop(1), favorite)\n end", "def ice_cream_shop(flavors, favorite)\n return false if flavors.empty?\n # favorite == flavors[0] if flavors.length == 1 #错的\n return true if favorite == flavors[0]\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.empty?\n if flavors[0] == favorite && flavors.length == 1\n return true\n else\n pick_one_flavors = flavors.sample\n flavors.delete(pick_one_flavors) unless pick_one_flavors == favorite\n ice_cream_shop(flavors, favorite)\n end\nend", "def ice_cream_shop(flavors, favorite)\n flavors.select{|word| word == favorite }.empty? == false \nend", "def ice_cream_shop(arr, favorite)\n\n return false if arr.length == 0 \n\n if favorite == arr.pop \n return true\n else\n ice_cream_shop(arr, favorite)\n end\nend", "def ice_cream_shop(arr,flav)\n return true if arr[-1] == flav\n return false if arr.length == 0\n arr.pop\n ice_cream_shop(arr,flav)\nend", "def is_fav_food(person, test_food)\n fav_snacks = person[:favourites][:snacks]\n for snack in fav_snacks\n if snack == test_food\n return true\n end\n end\n return false\nend", "def favourites\n\t\tfavourites = Partay.get('http://shoponline.tescolotus.com/api/v1/favorites/by-category?page=1&sortby=Relevance&issecure=False', :headers => {'Content-Type' => 'application/json','language' => 'en-GB', 'region' => 'TH', 'userId' => access_token, 'Host' => 'r.tesco.com.my'})\n\t\tfavourites_counter = JSON(favourites)\n\t\tself.favourite_count(JSON(favourites_counter)[\"pageInformation\"][\"totalCount\"])\n\t\tif fav_count >= 1\n\t\t\tputs \"Your favourites count is:#{fav_count}\"\n\t\telse\n\t\t\traise \"There are no products in your favourites list.\"\n\t\tend\n\tend", "def describe_favorites(games)\n for game in games\n puts \"Favorite Game: #{game}\"\n end\nend", "def likes_to_eat(person, food)\n\n for x in person[:favourites][:snacks]\n if x == food\n return true\n end\n end\n return false\nend", "def get_favorites\n @user = User.find(self.id)\n return Shop.where(id: \n { :$in => @user.favorite_places })\n .each { |shop| pp \"#{shop.picture}, #{shop.name}, #{shop.email}, #{shop.city}, #{shop.location}\"}\n end", "def favorite_beverage_list(name, favorite_beverage)\n puts \"#{name}'s favorite beverage is #{favorite_beverage}!\"\nend", "def bakery_num( num_of_people, fav_food ) # defines a method called bakery_num that takes two parameters, num_of_peope, fav_food\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} # Hash of avaialble foods and associated counts\n \n pie_qty = 0\n cake_qty = 0 # quantity of the foods equals to 0 \n cookie_qty = 0\n \n has_fave = false # Initializes our has_fave tood to false\n\n my_list.each_key do |key| # iterating over my_list keys to do a comparison \n if key == fav_food # Favorite food comparison\n has_fave = true # confirms fav_food is in the list \n end\n # has_fave = true if key == fav_food\n end\n \n if has_fave == false # my_list does not contain fav_food \n raise ArgumentError.new(\"You can't make that food\") # Raise error if fav_food was not found\n else # Fav_food was in the list\n fav_food_qty = my_list[fav_food] #.values_at(fav_food)[0] # if in the list, return the quantity on hand *** refactor\n if num_of_people % fav_food_qty == 0 # Checks if num_of_people is evenly divisable by the fav_food_qty\n num_of_food = num_of_people / fav_food_qty # returns num_of_food eq to number of people / fav foods \n return \"You need to make #{num_of_food} #{fav_food}(s).\" # Return favorite food along with quantity\n else #num_of_people % fav_food_qty != 0 # num_of_people was not evenly divisable by fav_food_qty\n while num_of_people > 0 # while num_of_people is greater than zero \n if num_of_people / my_list[\"pie\"] > 0 # At least more people than the quantity of pie will feed \n pie_qty = num_of_people / my_list[\"pie\"] # quantity of pie is equal the number of people divided by my_list of pie \n num_of_people = num_of_people % my_list[\"pie\"] # number of people ramaining after distributing pies\n elsif num_of_people / my_list[\"cake\"] > 0 # At least more people than the quantity of cake \n cake_qty = num_of_people / my_list[\"cake\"] # quantity of cake is equal to the number of people divided by qty of people cake will feed\n num_of_people = num_of_people % my_list[\"cake\"] # number of people remaining after distributing cakes \n else # num_of_people is less than both qty that pie and cake will feed\n cookie_qty = num_of_people # cookie quantity is equal to the number of people \n num_of_people = 0 # Set num_of_people to 0 in order to end the loop\n end # Ending if-else conditions\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n end\n end\nend", "def find_the_cheese(snacks)\n cheeses = %w(gouda cheddar camembert)\n snacks.find do |maybe_cheese|\n cheeses.include?(maybe_cheese)\n end\nend", "def food_tastes(person, food)\n return person[:favourites][:things_to_eat].include?(food)\nend", "def favorited?(user, coffeeshop)\n coffeeshop.users.each do |coffeeshop_user|\n return true if coffeeshop_user == user\n end\n return false\n end", "def favourite_foods(person, food)\n return person[:favourites][:things_to_eat].include?(food)\nend", "def favorite_recipes\n favorites.each do |f|\n f.recipe\n end\n end", "def likes_to_eat(person, food)\n food_array = person[:favourites][:snacks]\nreturn food_array.include?food\nend", "def any_apples?\n # code to check if tree has any oranges goes here\n @apples.length > 0\n end", "def likes_to_eat(person, food)\nreturn person[:favourites][:snacks].include?(food)\nend", "def favorite_brewery\n favorite :brewery\n end", "def true_for_food(hash, item)\n food= hash[:favourites][:things_to_eat]\n\n for i in hash\n if i == food\n\n return \"Yes I like this food\"\n end\n end\n return \"No I don't like this\"\n end", "def describe_favorites(*games)\n for game in games\n puts \"Favorite Game: #{game}\"\n end\nend", "def has_favourite_shop?(shop_id)\n return self.user_favourite_shops.find_by(shop_id: shop_id)\n end", "def find_the_cheese(ingredients)\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n ingredients.detect {|item| cheese_types.include?(item)}\n #ingredients.find {|item| cheese_types.include?(item)}\n #ingredients.each {|item| return item if cheese_types.include?(item)}\n #else\n #return nil\nend", "def every_favourite_food(people)\n #Create a empty array to save all the strings\n all_food = \"\"\n #For loop to iterate person in the array people\n for person in people\n #For loop to iterate in snacks in person\n for snacks in person[:favourites][:snacks]\n #adds new items to the array\n p snacks\n all_food += snacks += \" \"\n end\n end\n all_food.chop!\n return all_food\nend", "def bakery_num( num_of_people, fav_food ) # defines a method called bakery_num that takes two parameters, num_of_peope, fav_food\n serving_sizes = { \"pie\" => 8, \"cake\" => 6, \"cookie\" => 1 } # Hash of available foods and associated counts\n food_quantities = { \"fav_food\" => 0, \"pie\" => 0, \"cake\" => 0, \"cookie\" => 0 } # Hash of food quantities\n\n # Raise error if serving sizes doesn't contain food\n raise ArgumentError.new(\"You can't make that food\") if !serving_sizes.has_key? (fav_food)\n\n # Returns the necessary number of food items needed to satisfy each serving if the \n # number of people attending is evenly divisible by the quantity of the passed favorite food.\n return \"You need to make #{num_of_people / serving_sizes[fav_food]} #{fav_food}(s).\" if num_of_people % serving_sizes[fav_food] == 0\n\n # Loop through each key in food_quantities to determine how many of each food item is needed.\n food_quantities.each do |key, value|\n if key == \"fav_food\" \n food_quantities[key] = num_of_people / serving_sizes[fav_food] # Setting \"fav_food\" property for future use in food_quantities\n food_quantities[fav_food] = food_quantities[key]\n num_of_people = num_of_people % serving_sizes[fav_food] # Setting remaining amount of people left after fav_food is determined.\n elsif num_of_people / serving_sizes[key] > 0 # key is not fav_food and number of remaining people divided by the next food item serving size is greater than zero\n food_quantities[key] = num_of_people / serving_sizes[key] # Setting count for additional food items needed for remaining people\n num_of_people = num_of_people % serving_sizes[key] # Setting number of remaining people after the additional food item\n end # Ending conditional\n end # Ending .each loop\n\n return \"You need to make #{food_quantities[\"pie\"]} pie(s), #{food_quantities[\"cake\"]} cake(s), and #{food_quantities[\"cookie\"]} cookie(s).\"\nend", "def find_the_cheese(food)\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n food.find do |item|\n cheese_types.include?(item)\n end\n end", "def find_the_cheese(food)# code an argument here\n # the array below is here to help\n # check if elements in food are included in cheese_types\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n food.find do |i|\n if !cheese_types.include?(i)\n nil\n else\n true\n end\n end\nend", "def is_favorite?\n\t favorite?\n\tend", "def favorite_brewery\n favorite :brewery\n end", "def view_all_favorites(customer)\n customer_favs = customer.favorites # get favorites from customer\n\n get_res_id = customer_favs.map do |fav_res| # get restaurant IDs from favorites\n fav_res.restaurant_id\n end\n\n get_res = Restaurant.all.select do |res| # get restaurants from their IDs\n get_res_id.include?(res.id)\n end\n\n res_names = get_res.map do |res| # get names from restaurants\n res.name\n end\n\n new_res = res_names.each_with_index do |fav_res_name, index|\n puts \"#{index + 1}. #{fav_res_name}\"\n end\n # favorite_restaurants = Restaurant.where(id: customer.favorites.map(&:restaurant_id))\n # puts favorite_restaurants.map(&:name)\n main_menu($customer)\nend", "def favorite_check user, img\n user.favorites.each do |fav|\n if fav.image_id == img.id\n return true\n end\n end\n\n return false\n end", "def find_the_cheese(food)\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n food.find do |item|\n cheese_types.find do |cheese|\n item == cheese\n end\n end\nend", "def ice_cream_shop(arr, str)\n return false if arr.empty?\n if arr[0] != str \n ice_cream_shop(arr[1..-1], str)\n else \n true\n end \n end", "def fruit([])\n\nend", "def get_basket(variety)\n basket_with_space = find_basket_with_space()\n basket_with_same_variety = basket_with_space.find { |b| b.apples.first.variety == variety && b.apples.size > 0 }\n if basket_with_same_variety.nil?\n # return some other completely empty basket\n basket_with_space.find { |b| b.apples.size == 0 }\n else\n # return basket with same variety of apples\n basket_with_same_variety\n end\nend", "def bake_cake servings\n\t#in the beginning the oven is off, and the bowl is empty\n\toven_on = false\n\tbowl = \"\"\n\t#Step 1: turn on the oven\n\n\tputs \"Is the oven on? \" + oven_on.to_s\n\n\t#Step 2: add flour, add eggs, add sugar\n\n\tputs \"The bowl currently has: \" + bowl #should have all ingredients listed with the right quantities!\n\t\nend", "def bakery_num(num_of_people, fav_food) # this is defining bakery_num and takes 2 inputs\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} # creates hash, keys are baked goods, values are how many you can feed\n pie_qty = 0 # sets pie_qty to zero\n cake_qty = 0\n cookie_qty = 0\n \n has_fav = false # rename?\n\n my_list.each_key do |k| # iterates through each key in my_list\n if k == fav_food # if they key matches fav_food input\n has_fav = true # change has_fav to true\n end\n end\n \n if has_fav == false # If food isn't in stock/ isn't found\n raise ArgumentError.new(\"You can't make that food\")\n \n else\n fav_food_qty = my_list.values_at(fav_food)[0] # quantity of people favorite food can feed\n \n if num_of_people % fav_food_qty == 0 # if num_of_people can be divided evenly by fav_food_qty\n num_of_food = num_of_people / fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n \n else\n num_of_fav_food = num_of_people / fav_food_qty\n num_of_people = num_of_people % fav_food_qty\n \n while num_of_people > 0\n cake_qty = num_of_people / my_list[\"cake\"]\n if num_of_people % my_list[\"cake\"] > 0\n cookie_qty = num_of_people\n num_of_people = 0\n end \n end\n \n if fav_food == \"pie\"\n pie_qty = num_of_fav_food\n elsif fav_food == \"cake\"\n cake_qty = num_of_fav_food\n else\n cookie_qty = num_of_fav_food\n end\n\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n \n \n end \n end\nend", "def find_the_cheese(potentially_cheesy_items)\n cheeses = %w(gouda cheddar camembert)\n\n potentially_cheesy_items.find do |maybe_cheese|\n cheeses.include?(maybe_cheese)\n end\nend", "def user_favourites(current_user, product)\n Favourite.where(user_id: current_user, product_id: product) > 0\n end", "def person_cheers_song(pl, favourite_song)\n \n for tune in pl\n if tune == favourite_song\n return \"yaaay!\"\n else \n return \"didn't find my favourite\" \n end \n end \n end", "def find_the_cheese(array)\n cheeses = %w[gouda cheddar camembert]\n\n array.find do |cheese_flavor|\n cheeses.include?(cheese_flavor)\n end\nend", "def find_the_cheese(foods) # code an argument here\n # the array below is here to help\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n\n cheese_types.find do |cheese|\n foods.include?(cheese)\n end\n\nend", "def find_the_cheese(foods)\n foods.find{ |cheese| cheese == \"cheddar\" || cheese == \"gouda\" || cheese ==\n \"camembert\"}\nend", "def view_favorites\n #current_user will call favorites method to see the list of favorites table in database\n favorite_array = Favorite.where(user_id:current_user.id)\n \n favorite_array.each do |favorite|\n puts Brewery.find(favorite.brewery_id).name\n puts Brewery.find(favorite.brewery_id).street\n puts Brewery.find(favorite.brewery_id).city\n puts Brewery.find(favorite.brewery_id).state\n end \n # current_user.favorites\n end", "def favorited?(test_image)\n favorites.where(image_id: test_image.id).any?\n end", "def like_food?(food, person)\n person[:favourites][:things_to_eat].include?(food)\nend", "def favorites(action=nil)\n my.favorites(action)\n end", "def select_by_flavors \n\n selections = @@prompt.multi_select(\"Select flavors. Returns a list of all dishes that include those flavors.\", Flavor.active_flavor_names, cycle: true)\n # if dish's flavors - selections == 0, then that dish should be included! \n # iterate through all the dishes \n dishes_to_return = []\n # push that dish to dishes_to_return if that dish's flavors match our selections array \n Dish.all.select{ |dish| \n dish_flavor_array = dish.flavors.map{|flavor|flavor.name} \n if selections - dish_flavor_array == [] && selections != []\n dishes_to_return << dish \n # binding.pry\n end \n if selections == []\n system 'clear'\n puts \"Please select at least one flavor\"\n select_by_flavors\n end\n }\n # print each dish that matches \n if dishes_to_return.length == 0 \n puts \"There are no dishes matching those flavors\"\n if @@prompt.yes?(\"Would you like to search again?\")\n system 'clear'\n select_by_flavors\n else\n main_menu\n end \n else \n puts \"These dishes match those flavors: \"\n dishes_to_return.map{|dish| dish.print_dish}\n if @@prompt.yes?(\"Would you like to search again?\")\n system 'clear'\n select_by_flavors\n else\n main_menu\n end\n end \n end", "def bakery_num(num_of_people, fav_food) #Defining a function that takes two parameters\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} #Declaring a my_list hash\n pie_qty = 0 # Assigning three other variables \n cake_qty = 0\n cookie_qty = 0\n \n has_fave = false #setting a default value of false \n\n my_list.each_key do |k| #looping through the keys of my_list\n if k == fav_food #An if statement, where the condition is comapred to one of the parameters\n has_fave = true #If true, declaring a has_fave to true \n fav_food = k #Assigning fav_food to that key\n end\n end\n if has_fave == false #If no matec ==> error\n raise ArgumentError.new(\"You can't make that food\")\n else\n fav_food_qty = my_list.values_at(fav_food)[0] #If match ==> find value from Hash \n if num_of_people % fav_food_qty == 0 #Module of the first function parameter, number of people by fav food quantity\n num_of_food = num_of_people / fav_food_qty #If true, get portions \n return \"You need to make #{num_of_food} #{fav_food}(s).\" #return an order \n else num_of_people % fav_food_qty != 0 #redundant but if not \n while num_of_people > 0 \n if num_of_people / my_list[\"pie\"] > 0 #if there are more people than pies\n pie_qty = num_of_people / my_list[\"pie\"] #This gets portions\n num_of_people = num_of_people % my_list[\"pie\"] #this gets amount of people for leftovers \n elsif num_of_people / my_list[\"cake\"] > 0 #If the number of people is not rgeater than pies, we go into cakes\n cake_qty = num_of_people / my_list[\"cake\"]\n num_of_people = num_of_people % my_list[\"cake\"]\n else\n cookie_qty = num_of_people\n num_of_people = 0\n end\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n end\n end\nend", "def favourite_food name\r\n\tif name == \"Lister\"\r\n\t\treturn \"vindaloo\"\r\n\tend\r\n\r\n\tif name == \"Rimmer\"\r\n\t\treturn \"mashed potatoes\"\r\n\tend\r\n\r\n\t\"hard to say...maybe fired plantain?\"\r\nend", "def grill_cheese(bread, cheese, cheese_num, melt)\n # If cheese_num is greater than 3 cheese slices you want it extra cheesy.\n if cheese_num > 3\n # Patty melt instead of grilled cheese sando.\n if melt == true\n puts \"We got one extra cheesy #{cheese} patty melt on #{bread}, coming right up!\"\n else\n puts \"We got one extra cheesy #{cheese} grilled cheese on #{bread}, coming right up!\"\n end\n # For less cheesey sandwich\n else\n # Patty melt instead of grilled cheese sando.\n if melt == true\n puts \"We got one cheesy #{cheese} patty melt on #{bread}, coming right up!\"\n else\n puts \"We got one cheesy #{cheese} grilled cheese on #{bread}, coming right up!\"\n end\n end\nend", "def apple_picker(fruits)\n apple_array = []\n fruits.each do |fruit|\n if fruit == \"apple\"\n apple_array << fruit\n end\n end\n apple_array\nend", "def find_the_cheese(ingredients)\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n #I originally did it this way, but the instructions said to use \"include?\"\n #ingredients.detect { |ingredient| ingredient == cheese_types[0] || ingredient == cheese_types[1] || ingredient == cheese_types[2]}\n ingredients.find do |ingredient|\n cheese_types.include?(ingredient)\n end\nend", "def favorite\n puts FAVE\n end", "def bakery_num(num_of_people, fav_food) #defining method bakery_num, which takes 2 arguments\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1, \"pudding\" => 2, \"bunt cake\" => 4, \"mega-cupcakes\" => 3} #creates hash my_list, key is food, value is number\n pie_qty = cake_qty = cookie_qty = has_fave = 0 \n \n\n my_list.each_key do |k| #iterating through array my_list\n if k == fav_food #tests if each item in array my_list = fav_food\n has_fave = 1 #if test above passes, set has_fave to true\n # fav_food = k #if test above passes, set fav_food to k\n end\n end\n \n if has_fave == 0 #if fav_food is not a key, end program\n raise ArgumentError.new(\"You can't make that food\")\n else #if fav_food is a key\n fav_food_qty = my_list.values_at(fav_food)[0] #set fav_food_qty equal to the value of fav_food\n if num_of_people % fav_food_qty == 0 \n num_of_food = num_of_people / fav_food_qty #if num_of_people is evenly divisible by fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n \n #num_of_food = num_of_people / fav_food_qty #then perform division by integer\n #return \"You need to make #{num_of_food} #{fav_food}(s).\" #return \"You need to make (num_of_food) (fav_food)s\"\n else num_of_people % fav_food_qty != 0 #redundant else\n while num_of_people > 0 #while num_of_people is greater than 0\n if num_of_people / my_list[\"pie\"] > 0 #if num_of_people divided by value of pie is greater than 0\n pie_qty = num_of_people / my_list[\"pie\"] #set pie_qty equal to num_of_people divided by value of pie in hash\n num_of_people = num_of_people % my_list[\"pie\"] #set num_of_people equal to the remainder of num_of_people divided by value of pie in hash\n elsif num_of_people / my_list[\"cake\"] > 0 #if num_of_people divided by hash value of cake is greater than 0\n cake_qty = num_of_people / my_list[\"cake\"] #set cake_qty equal to num_of_people divided by hash value of cake\n num_of_people = num_of_people % my_list[\"cake\"] #set num_of_people equal to the remainder of num_of_people divided by value of cake in hash\n else\n cookie_qty = num_of_people #set cookie_qty equal to num_of_people\n num_of_people = 0 #set num_of_people equal to 0\n end\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\" #print out\n end\n end\n \nend", "def bakery_num(num_of_people, fav_food) #defines the method and accepts arguments num_of_people and fav_food\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} \n pie_qty = 0 #declaring variables at 0\n cake_qty = 0 #declaring variables at 0\n cookie_qty = 0 #declaring variables at 0\n \n has_fave = false\n\n my_list.each_key do |k| #iterates through the keys in my_list\n if k == fav_food #checks if passed argument fav_food is in the hash as a key\n has_fave = true #sets boolean has_fave to true\n fav_food = k #re-assigns fav_food to the key in the hash\n end\n end\n \n if has_fave == false #if fav_food is not found in the list\n raise ArgumentError.new(\"You can't make that food\") #raise an error\n else\n fav_food_qty = my_list.values_at(fav_food)[0] #declares a variable that is the quantity of fav food argument and sets it equal to first element in the value\n \n if num_of_people % fav_food_qty == 0 #if number of people is divisable by quantity of fav food\n num_of_food = num_of_people / fav_food_qty #number of food is set to number of people divided by fav food quantity\n return \"You need to make #{num_of_food} #{fav_food}(s).\" #returns string concatenated declaring how much of the food to make\n \n else num_of_people % fav_food_qty != 0 #if num of people is not divisable by fav food qty\n while num_of_people > 0 \n if num_of_people / my_list[\"pie\"] > 0 #if number of people divided by number of pies floor is greater than 0 \n pie_qty = num_of_people / my_list[\"pie\"] #sets pie quantity to multiples of number of servings\n num_of_people = num_of_people % my_list[\"pie\"] #num of people reassigned to remainder \n elsif num_of_people / my_list[\"cake\"] > 0 #if number of people divided by number of cakes floor is greater than 0\n cake_qty = num_of_people / my_list[\"cake\"] #sets cake quantity to multiples of number of servings\n num_of_people = num_of_people % my_list[\"cake\"] #num of people reassigned to remainder \n else\n cookie_qty = num_of_people #sets cookie qty to number of people remaining\n num_of_people = 0 #ends the loop if \"cookie else\" is reached\n end\n end\n \n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\" #returns the string, whole combination\n end\n end\nend", "def flavors()\n return get_request(address(\"/flavors/detail\"), @token)\t\n end", "def my_favorites\n\tend", "def bakery_num(num_of_people, fav_food) #defining a method bakery_number. Takes number of people and favorite food as parameters \n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} #hash- my_list that has type of food as a key and amount of food as a value\n pie_qty = 0 # set default quantity to zero \n cake_qty = 0 # set default quantity to zero \n cookie_qty = 0 # set default quantity to zero \n \n ##has_fave = false # setting has_fave to false ##\n\n #my_list.each_key do |k| # we are iterating over my_list key values \n #if k == fav_food # if one of the keys matches fav_food, then...\n #has_fave = true # has_fave is set to true \n ##fav_food = k ##not necessary \n #closed out if statement \n if my_list.has_key?(fav_food) \n fav_food_qty = my_list.values_at(fav_food)[0] \n if num_of_people % fav_food_qty == 0 \n num_of_food = num_of_people / fav_food_qty \n return \"You need to make #{num_of_food} #{fav_food}(s).\" \n else \n case fav_food\n when \"pie\"\n if num_of_people / my_list[\"pie\"] > 0 \n pie_qty = num_of_people / my_list[\"pie\"] \n num_of_people = num_of_people % my_list[\"pie\"] \n elsif num_of_people / my_list[\"cake\"] > 0 \n cake_qty = num_of_people / my_list[\"cake\"] \n num_of_people = num_of_people % my_list[\"cake\"]\n else\n cookie_qty = num_of_people\n num_of_people = 0\n when \"cake\"\n if num_of_people / my_list[\"cake\"] > 0 \n cake_qty = num_of_people / my_list[\"cake\"] \n num_of_people = num_of_people % my_list[\"cake\"]\n else\n cookie_qty = num_of_people\n num_of_people = 0\n when \"cookie\"\n cookie_qty = num_of_people\n num_of_people = 0\n else\n \"You need to pick pie, cake, or cookie\"\n end \n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n end \n end \n else \n raise ArgumentError.new(\"You can't make that food\") # raise argument using a string \n end", "def baskets_full(apple_count)\n puts \"All baskets are full. We couldn't find the place for #{apple_count} apples\"\nend", "def favorite_hashtags\n favorite_stuffs(:hashtags, :text, 3)\n end", "def get_info_on_club(fixture)\n puts \"See when your favourites are playing:(enter favourite club name)\"\n fav_club = gets.chomp\n all_fav_matches = fixture.map do |game|\n if game[:home_team].downcase.include?(fav_club) || game[:away_team].downcase.include?(fav_club)\n game\n end\n end.compact\n\n if all_fav_matches.empty?\n puts \"Did not match the database!\"\n else\n puts all_fav_matches\n end\nend", "def favorite(category, user)\n shows_by_category = user.shows.group_by({|show| show.send(category.downcase + \"_id\")})\n category_count = shows_by_category.each { |k,v| shows_by_category[k] = v.count}\n if category_count.empty?\n \"None.\"\n else\n Object.const_get(category).find(category_count.max_by{|k,v| v}[0]).name\n end\nend", "def view_favorites\n #current_user will call favorites method to see the list of favorites table in database\n \n current_user.breweries.each do |brewery|\n puts \"*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*\"\n puts brewery.name\n puts brewery.street\n puts brewery.city\n puts brewery.state\n puts brewery.phone\n puts \"*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*:*.*\"\n end \n end", "def favorite?\n @favorite\n end", "def favorite?\n @favorite\n end", "def favorite_for(user)\n favs.find_by(user_id: user)\n end", "def check_favorite username, password, slideshow_id\n do_request 'check_favorite', username: username, password: password, slideshow_id: slideshow_id\n end", "def bakery_num(num_of_people, fav_food)\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1}\n pie_qty = 0\n cake_qty = 0\n cookie_qty = 0\n \n has_fave = false\n\n my_list.each_key do |k|\n if k == fav_food\n has_fave = true\n fav_food = k\n end\n end\n if has_fave == false\n raise ArgumentError.new(\"You can't make that food\")\n else\n fav_food_qty = my_list.values_at(fav_food)[0]\n if num_of_people % fav_food_qty == 0\n num_of_food = num_of_people / fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n else num_of_people % fav_food_qty != 0\n while num_of_people > 0\n if num_of_people / my_list[\"pie\"] > 0\n pie_qty = num_of_people / my_list[\"pie\"]\n num_of_people = num_of_people % my_list[\"pie\"]\n elsif num_of_people / my_list[\"cake\"] > 0\n cake_qty = num_of_people / my_list[\"cake\"]\n num_of_people = num_of_people % my_list[\"cake\"]\n else\n cookie_qty = num_of_people\n num_of_people = 0\n end\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n end\n end\nend", "def likes?(food)\n\tresult = [\"bananas\", \"eggs\", \"bacon\", \"cheese\"].detect{|x| x == food}\n\t if result.nil?\n\t \tfalse\n\t else\n\t \ttrue\n\t end\nend", "def favoriter?\n true\n end", "def check_fav\n print \"Are they a favorite? (y/n): \"\n user_fav = gets.strip\n if user_fav == \"y\"\n return true\n elsif user_fav == \"n\"\n return false \n else\n puts \"not vaild input\"\n check_fav\n end\nend", "def has_favourite_recipe?(user_id, yummly_id)\n return self.user_favourite_recipes.has_user_favourites_for_recipe?(user_id, yummly_id)\n end" ]
[ "0.8590992", "0.82558006", "0.8204239", "0.81666", "0.8161897", "0.81279457", "0.81017435", "0.8100349", "0.8088837", "0.8081926", "0.8078285", "0.8051026", "0.80349296", "0.80231917", "0.7986425", "0.7960098", "0.7949755", "0.79437864", "0.79287195", "0.79047245", "0.78563404", "0.78242254", "0.7779411", "0.776874", "0.77636874", "0.7542086", "0.73065186", "0.7102285", "0.6899946", "0.60819477", "0.58470494", "0.5684013", "0.55876315", "0.55633104", "0.5539018", "0.55237335", "0.5462282", "0.5449766", "0.54484975", "0.5418715", "0.54172105", "0.54154795", "0.5383142", "0.5378013", "0.53542906", "0.53226763", "0.53211594", "0.531862", "0.5313643", "0.5311422", "0.5302816", "0.5299122", "0.52873564", "0.5276166", "0.52557325", "0.52508557", "0.5217094", "0.52043986", "0.51875514", "0.517693", "0.5169074", "0.5139681", "0.51346236", "0.51229584", "0.51195747", "0.5104076", "0.5102256", "0.5101595", "0.50984144", "0.50876176", "0.5086172", "0.50829023", "0.5078519", "0.50785035", "0.5070826", "0.50695133", "0.50593406", "0.50480807", "0.5046186", "0.5041932", "0.50295717", "0.5003317", "0.49953064", "0.49928904", "0.49832064", "0.4981287", "0.49778077", "0.4971407", "0.4961036", "0.49537775", "0.49456748", "0.49427375", "0.49427375", "0.49354735", "0.4931863", "0.49297982", "0.49284893", "0.4926151", "0.49194264", "0.49189186" ]
0.81376135
5
=> returns false Write a function reverse(string) that takes in a string and returns it reversed.
def reverse(str) return "" if str.empty? reverse(str[1..-1]) + str[0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_string(string)\n answer = string.reverse\n return answer\nend", "def reverse_string(string)\n reverse = string.reverse\n return reverse\nend", "def reverse(string)\nend", "def reverse_string(s)\n s.reverse!\nend", "def reverse(str)\n return str.reverse()\nend", "def reverse(str)\n return str.reverse()\nend", "def reverse_string(string)\n\treturn string.reverse\nend", "def reverse_string(string)\r\n return string.reverse\r\nend", "def reverse(string)\n\tstring.reverse\nend", "def reverse(string)\n\tstring.reverse\nend", "def reverse(string)\n\tstring.reverse\nend", "def reverse(string)\n \n string.reverse!\nend", "def reverse_string(string)\nreturn string.reverse\nend", "def Reverse(str)\n return str.reverse! # Okay, completely useless\nend", "def reverseString(string)\n\nend", "def reverse(string)\n string.reverse\nend", "def reverse(string)\n string.reverse\nend", "def reverse_string input\n input.reverse\nend", "def reverse_string string\n\tstring.reverse\nend", "def reverse_string(str)\nend", "def reverse(s)\nend", "def reverse(s)\n return s.reverse\nend", "def reverse_string str \n str.reverse\nend", "def reverse_string string \n\tstring.reverse\nend", "def reverse_string string\n string.reverse\nend", "def reverse_string(str)\n str.reverse\n end", "def reverse(str)\n str.reverse\nend", "def palindrome (input_string)\n input_string == input_string.reverse\nend", "def isPalindrome(string)\n return string.reverse == string\nend", "def isPalindrome(string)\n string == string.reverse\nend", "def reverse (string)\n # Your code here\nend", "def palindrome (string)\n\n if string.reverse == string\n return true\n else\n return false\n end\n \nend", "def reverse(string)\n return \"\" if string == \"\"\n return string if string.length == 1\n return string[-1] + reverse(string[0..-2])\nend", "def reverse(string)\n return \"\" if string.length == 0\n\n string[-1] + reverse(string[0...-1])\nend", "def reverse_str(str)\n str.reverse\nend", "def reverse(string)\n return string if string.length <= 1\n string[-1] + reverse.string[0...-1]\nend", "def reverse(string)\n return \"\" if string.length == 0\n return string if string.length == 1\n return string[-1] + reverse(string[0..-2])\nend", "def palindrome?(string)\r\n string.reverse == string\r\nend", "def palindrome?(string)\r\n string.reverse == string\r\nend", "def palindrome?(string)\r\n string.reverse == string\r\nend", "def palinodrome?(string)\n string == my_reverse(string)\nend", "def reverse(s)\n s.reverse\nend", "def reverse(string)\n return string if string.empty?\n string.last + reverse(string[0...-1])\nend", "def palindrome(str)\n str == str.reverse\nend", "def palindrome string #func param: string, name: palindrome\n string = string.downcase.scan(/\\w/) #make sure the value is lower case\n string == string.reverse #see if it equals its reverse, and return as boolean statement \nend", "def reverse(string)\n string.length > 1 ? string[-1] + reverse(string[0...-1]) : string\n end", "def is_palindrome(str)\n return str == str.reverse\nend", "def palindrome?(string)\n string.reverse == string\nend", "def palindrome?(string)\n string.reverse == string\nend", "def palindrome?(string)\n string.reverse == string\nend", "def palindrome?(string)\n string == string.reverse\nend", "def reverse(string)\n return string if string.length <= 1\n return string[-1] + reverse(string[0...-1])\nend", "def palindrome('')\n if string == string.reverse\n return true\n else\n puts \"String is not a palindrome\"\n end\nend", "def reverse_string(string1)\n\tstring1.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def reverse(string)\n return string if string.empty?\n string[-1] + reverse(string[0..-2])\nend", "def palindrome?(string)\n if string == string.reverse\n return true\n else \n return false\n end\nend", "def reverse(string)\n return string if string.empty?\n\n reverse(string[1..-1]) + string[0]\nend", "def test(string)\n reverse_string = string.reverse\n if string == reverse_string\n puts \"#{string} is a palindrome\"\n else\n puts \"#{string} is not a palindrome\"\n end\nend", "def reverse(s)\n # raise NotImplementedError, \"Method not implemented\"\n return s.slice(-1) + reverse(s.slice(0, s.length - 1)) unless s.length.zero?\n return \"\" if s.length.zero?\nend", "def reverse(string)\n return string if string.length <= 1\n\n string.slice!(-1) + reverse(string)\nend", "def reverse_string s1\n s1.reverse\nend", "def palindrome?(str)\r\n str == str.reverse\r\nend", "def reverse(string)\n return string if string.length <= 1\n string[-1] + reverse(string[0..-2])\nend", "def reverse(string)\n return string if string.length <= 1\n string[-1] + reverse(string[0..-2])\nend", "def reverse(string)\n return string if string.length <= 1\n string[-1] + reverse(string[0..-2])\nend", "def reverse(string)\n return string if string.length <= 1\n string[-1] + reverse(string[0..-2])\nend", "def reverse(string)\n return string if string.length < 2\n reverse(string[1..-1]) + string[0]\nend", "def is_palindrome(str)\n str.to_s == str.to_s.reverse\nend", "def reverse(s)\n # raise NotImplementedError, \"Method not implemented\"\n if s.length <= 1 # will stop once string is equal to 1 or less\n return s\n else\n return s[-1] + reverse(s[0..-2])\n end\nend", "def reverse(str)\n return \"\" if str == \"\"\n str[-1] + reverse(str[0..-2])\nend", "def palindrome(string)\n\tif string == string.reverse\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def reverse(string)\n return string if string.length <= 1\n return string[-1] + reverse(string[0..-2])\nend", "def palindrome?(str)\n str.reverse == str\nend", "def palindrome?(str)\n str.reverse == str\nend", "def palindrome?(str)\n str.reverse == str\nend", "def palindrome?(str)\n str.reverse == str\nend", "def reverse(string)\n return string if string.length == 0\n reverse(string[1..-1]) + string[0]\nend", "def isPalidrome(str)\n str == str.reverse\nend", "def palindrome string\n if string == string.reverse\n \"#{string} is a palindrome!\"\n else \n \"#{string} is not a palindrome\"\n end \nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend" ]
[ "0.8409786", "0.83785653", "0.8348028", "0.83357584", "0.83330935", "0.83155483", "0.8312992", "0.8283091", "0.82512075", "0.82512075", "0.82512075", "0.8230912", "0.8202319", "0.8174118", "0.81730527", "0.8156594", "0.8156594", "0.8092266", "0.807489", "0.80622864", "0.80581325", "0.8046684", "0.80371904", "0.80302685", "0.80255014", "0.8024871", "0.7986438", "0.798424", "0.79776853", "0.79701734", "0.79692227", "0.79452485", "0.79212284", "0.7898869", "0.78776586", "0.7877052", "0.7872166", "0.7865753", "0.7865753", "0.7865753", "0.783437", "0.78259325", "0.7816389", "0.78081304", "0.7802978", "0.7799894", "0.77966225", "0.77930963", "0.77930963", "0.77930963", "0.77857184", "0.7782051", "0.7781658", "0.77667713", "0.77641624", "0.77641624", "0.77641624", "0.77641624", "0.77641624", "0.77641624", "0.77641624", "0.77641624", "0.77641624", "0.77641624", "0.77641624", "0.77476066", "0.77441734", "0.7742081", "0.77342606", "0.7730645", "0.7727368", "0.77210534", "0.7701599", "0.7701311", "0.7701311", "0.7701311", "0.7701311", "0.7690848", "0.7689806", "0.76896524", "0.7688687", "0.76868725", "0.7676604", "0.76755285", "0.76755285", "0.76755285", "0.76755285", "0.7669406", "0.7667277", "0.7666782", "0.76665705", "0.76665705", "0.76665705", "0.76665705", "0.76665705", "0.76665705", "0.76665705", "0.76665705", "0.76665705", "0.76665705", "0.76665705" ]
0.0
-1
Call 2 other functions and pass them instance variables
def virus_effects puts "#{@state} will lose #{predicted_deaths} people in this outbreak and will spread across the state in #{speed_of_spread} months.\n\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calls; end", "def calls; end", "def call() end", "def call(*args)\n __call__( args )\n end", "def two_method(x,y,z)\n\t\tx + y + z\nend", "def call1\n call2\n call3\nend", "def call(*) end", "def call(*) end", "def call(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def functions\n\n end", "def call(*args)\n instance.call(*args)\n end", "def call1\n call2 # => 222\n call3 # => 333\nend", "def two\n end", "def run_two_procs(a,b)\n a.call\n b.call\nend", "def method1 a,b\n\tputs a\n\tputs b\nend", "def foo (a, b)\n a.call(b)\nend", "def call1\n call2 # => 222\n call3 # => 333\nend", "def _perform(args); end", "def methods() end", "def call\n\n\tend", "def call\n\n\tend", "def run_two_procs(a, b)\n a.call # .call is used to run the proc (block of code)\n b.call\nend", "def method2() end", "def perform(*args); end", "def do_twice(what)\n what.call\n what.call\nend", "def invoke; end", "def call(object); end", "def send_as_functions *args\n args.each {|arg| send_as_function arg}\n self\n end", "def methods=(_arg0); end", "def called_from=(_arg0); end", "def called_from=(_arg0); end", "def first_method(num_1, num_2)\n puts num_1 + num_2\nend", "def first_object(arg1, arg2, arg3)\n \nend", "def do_something(swim, bike, run)\nend", "def runs=(_arg0); end", "def multi(functions)\n\t\t\t\t\t\t\tself.multicaller.call(functions)\n\t\t\t\t\t\tend", "def second\n set_function_and_argument(:second, nil)\n end", "def probers=(_arg0); end", "def twice_do(action) # this parameter will be taking in a proc since we're using .call in body\n action.call\n action.call\nend", "def call\n # implement in subclasses\n end", "def fire _obj, _args\n \"_obj fire _args;\" \n end", "def call\n end", "def call\n end", "def BlocksAndMethods(&argumento)\n\targumento.call\nend", "def call(*args)\n self.exec(*args)\n end", "def method2 a,b = 12\n\tputs \"method2 a = #{a}\"\n\tputs \"method2 b = #{b}\"\nend", "def step_two()\r\nend", "def dispatch(*_arg0); end", "def procasaurus( p1, p2, p3 )\n\tputs p1.call\n\tputs p2.call\n\tputs p3.call\nend", "def call_fns(fns, app)\n fns.each {|fn| app.instance_exec(&fn)}\n end", "def results=(_arg0); end", "def results=(_arg0); end", "def xyz2\n\n end", "def set_functions\n super\n end", "def call(&cont)\n #setup_all\n cont.call\n #teardown_all\n end", "def call(*args)\n\t filtered_args, vm = prepare_call(args)\n\t perform_call(filtered_args, vm)\n\tend", "def two_things(*args)\n arg1, arg2 = args\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend", "def demo(a,b)\n\ta = a+2\n\tb = b+ 3\nend", "def call(args = {})\n check_call_definition!\n check_missing_arguments!(self.class.required_call_arguments, args)\n variables_for!(self.class.call_arguments, args)\n super()\n end", "def foo2(a, ...)\n bar2(a, ...)\nend", "def invoking\n end", "def helper(*args, &block); end", "def greeting(proc_1, proc_2, proc_3)\n puts proc_1.call('good morning')\n puts proc_2.call('hello')\n puts proc_3.call('good evening')\nend", "def call(*args, **kwargs, &block)\n forward(*args, **kwargs, &block)\n end", "def goto_upload_page\r\n (func, title) = get_2_params()\r\n init_globals()\r\n\r\n goto_upload_page1(func, title)\r\nend", "def update!(**args)\n @function = args[:function] if args.key?(:function)\n @interaction = args[:interaction] if args.key?(:interaction)\n @load_indicator = args[:load_indicator] if args.key?(:load_indicator)\n @parameters = args[:parameters] if args.key?(:parameters)\n end", "def call(*params)\n self.send :test, *params\n end", "def test2 &action\n puts \"Testing:\\n\\n\"\n action.call\n end", "def run; new.run; end", "def args(*) end", "def stest_method_1(test); end", "def calculate!\n calculate_amount\n calculate_fee\n calculate_insurance\n calculate_deposit\n end", "def B(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend", "def class_method2\nend", "def s1\n end", "def two_more_things (arg1, arg2)\n puts \"arg1:#{arg1}, arg2:#{arg2}\"\nend", "def call(*args)\n @ctx.instance_exec(args, &action)\n end", "def call(fun, *args)\n call2(nil, fun, *args)\n end", "def method1; end", "def subtrair(*args)\n end", "def common\n \n end", "def initialize(x,y) # defines an instance method for the class\n @x, @y = x, y # Take the two parameters passed, => assign them to instance variables @x @y\n end", "def calculation(a,b, operation)\n operation.call(a,b)\n end", "def method_one; end", "def set_caller_params\n end", "def run(*args); end", "def run(*args); end", "def run(*args); end", "def run(*args); end", "def run(*args); end", "def run(*args); end", "def run(*args); end" ]
[ "0.6464437", "0.6464437", "0.6199258", "0.61759865", "0.61726093", "0.61211383", "0.61062574", "0.61062574", "0.6030778", "0.6011732", "0.5990138", "0.5990138", "0.5990138", "0.5990138", "0.5990138", "0.5990138", "0.5990138", "0.5990138", "0.58861405", "0.5882044", "0.5877706", "0.5877577", "0.5863733", "0.5829345", "0.58194375", "0.5793278", "0.5780184", "0.57064265", "0.56993014", "0.56993014", "0.569071", "0.56843996", "0.5667242", "0.56583726", "0.5575063", "0.5573308", "0.5555043", "0.55518234", "0.5547863", "0.5547863", "0.55466896", "0.55421555", "0.55264103", "0.5486187", "0.54713273", "0.54605526", "0.5456709", "0.5455204", "0.5443157", "0.5413373", "0.54081255", "0.53949904", "0.53870434", "0.5376659", "0.53762895", "0.53748584", "0.5374563", "0.5333755", "0.5324917", "0.5314899", "0.5314899", "0.53118867", "0.53071517", "0.5304429", "0.5302585", "0.5297666", "0.5295659", "0.5295063", "0.52937245", "0.5290705", "0.5287485", "0.52799296", "0.52774334", "0.52762854", "0.52491844", "0.5247824", "0.52475834", "0.52398044", "0.5223641", "0.5223372", "0.52155495", "0.52090806", "0.52044004", "0.5200255", "0.51925814", "0.5182416", "0.5180126", "0.5177695", "0.51752365", "0.5174606", "0.5166588", "0.5164856", "0.5161666", "0.5158944", "0.51549673", "0.51549673", "0.51549673", "0.51549673", "0.51549673", "0.51549673", "0.51549673" ]
0.0
-1
Depending on the Population density, we calulate the number of predicted deaths
def predicted_deaths case @population_density when 0..50 then (@population * 0.05).floor when 51..100 then (@population * 0.1).floor when 101..150 then (@population * 0.2).floor when 151..200 then (@population * 0.3).floor else (@population * 0.4).floor end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n rate = 0.4\n elsif @population_density >= 150\n rate = 0.3\n elsif @population_density >= 100\n rate = 0.2\n elsif @population_density >= 50\n rate = 0.1\n else\n rate = 0.05\n end\n return number_of_deaths = (@population * rate).floor\n end", "def predicted_deaths\n \n # predicted deaths is based on population density\n if @population_density >= 200\n factor = 0.4\n elsif @population_density >= 150\n factor = 0.3\n elsif @population_density >= 100\n factor = 0.2\n elsif @population_density >= 50\n factor = 0.1\n else\n factor = 0.05\n end\n\n @number_of_deaths = (@population * factor).floor\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n @number_of_deaths = (@population * factor).floor\n if @population_density >= 200\n factor = 0.4\n elsif @population_density >= 150\n factor = 0.3\n elsif @population_density >= 100\n factor = 0.2\n elsif @population_density >= 50\n factor = 0.1\n else\n factor = 0.05\n end\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density < 50\n number_of_deaths = (@population * 0.05).floor\n else\n multiplier = (@population_density/50).floor\n number_of_deaths = (@population * (multiplier * 0.1)).floor\n end\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n return number_of_deaths\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density <= 50\n number_of_deaths = (@population * 0.05).floor\n else\n multipler_var = (@population_density / 50) * 0.1\n number_of_deaths = (@population * multipler_var).floor\n end\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n if @population_density >= 200\r\n @number_of_deaths = (@population * 0.4).floor\r\n elsif @population_density >= 150\r\n @number_of_deaths = (@population * 0.3).floor\r\n elsif @population_density >= 100\r\n @number_of_deaths = (@population * 0.2).floor\r\n elsif @population_density >= 50\r\n @number_of_deaths = (@population * 0.1).floor\r\n else\r\n @number_of_deaths = (@population * 0.05).floor\r\n end\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n @number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n @number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n @number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n @number_of_deaths = (@population * 0.1).floor\n else\n @number_of_deaths = (@population * 0.05).floor\n end\n end", "def predicted_deaths()\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4)\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3)\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2)\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1)\n else\n number_of_deaths = (@population * 0.05)\n end\n\n end", "def predicted_deaths(population_density, population)\n # predicted deaths is solely based on population density\n case @population_density\n when 200..Float::INFINITY\n rate = 0.4\n when 150..199\n rate = 0.3\n when 100..149\n rate = 0.2\n when 50..99\n rate = 0.1\n else rate = 0.05\n end\n\n number_of_deaths = (@population * rate).floor\n\n number_of_deaths\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n end", "def predicted_deaths()\n # predicted deaths is solely based on population density\n case @population_density\n when 200..1000\n @number_of_deaths = (@population * 0.4).floor\n when 150...200\n @number_of_deaths = (@population * 0.3).floor\n when 100...150\n @number_of_deaths = (@population * 0.2).floor\n when 50...100\n @number_of_deaths = (@population * 0.1).floor\n else\n @number_of_deaths = (@population * 0.05).floor\n end\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n rate = 0.4\n elsif @population_density >= 150\n rate = 0.3\n elsif @population_density >= 100\n rate = 0.2\n elsif @population_density >= 50\n rate = 0.1\n else\n rate = 0.05\n end\n \n @number_of_deaths = (@population * rate).floor\n\n \n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n STATE_FORMULA.each do |state_size, calculation|\n if @population_density >= calculation[:pop_density]\n return number_of_deaths = (@population * calculation[:deaths]).floor\n end\n end\n number_of_deaths = (@population * 0.05).floor\n end", "def predicted_deaths\n \n # predicted deaths is solely based on population density \n \n death_rate = (@population_density / 500).round(1) \n death_rate = 0.4 if @population_density >= 250\n death_rate = 0.1 if @population_density < 50\n \n (@population * death_rate).floor\n\n end", "def predicted_deaths(population_density, population)\n # predicted deaths is solely based on population density\n\n n = [50, 100, 150, 200]\n \n if @population_density >= n[3]\n coefficient = n[3]/500.0\n elsif @population_density >= n[2]\n coefficient = n[2]/500.0\n elsif @population_density >= n[1]\n coefficient = n[1]/500.0\n elsif @population_density >= n[0]\n coefficient = n[0]/500.0\n else\n coefficient = 0.05\n end\n \n number_of_deaths = (@population * coefficient).floor\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200; number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150; number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100; number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50; number_of_deaths = (@population * 0.1).floor\n else number_of_deaths = (@population * 0.05).floor\n end\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n # if @population_density >= 50 \n # number_of_deaths = (@population / 500).floor\n # else\n # number_of_deaths = (@population * 0.05).floor\n # end\n \n if @population_density >= 200\n (@population * 0.4).floor\n elsif @population_density >= 150\n (@population * 0.3).floor\n elsif @population_density >= 100\n (@population * 0.2).floor\n elsif @population_density >= 50\n (@population * 0.1).floor\n else\n (@population * 0.05).floor\n end\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n @population * 0.4\n elsif @population_density >= 150\n @population * 0.3\n elsif @population_density >= 100\n @population * 0.2\n elsif @population_density >= 50\n @population * 0.1\n else\n @population * 0.05\n end\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n multiplier = 0.4\n elsif @population_density >= 150\n multiplier = 0.3\n elsif @population_density >= 100\n multiplier = 0.2\n elsif @population_density >= 50\n multiplier = 0.1\n else\n multiplier = 0.05\n end\n (@population * multiplier).floor\n end", "def predicted_deaths#(population_density, population, state)\r\n # predicted deaths is solely based on population density\r\n number_of_deaths = (@population * 0.4).floor if @population_density >= 200\r\n \r\n number_of_deaths = (@population * 0.3).floor if @population_density >= 150\r\n \r\n number_of_deaths = (@population * 0.2).floor if @population_density >= 100\r\n \r\n number_of_deaths = (@population * 0.1).floor if @population_density >= 50\r\n \r\n number_of_deaths = (@population * 0.05).floor if @population_density >= 0\r\n \r\n # end\r\n # print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n if @population_density >= 50\n multiplication_factor = (@population_density.fdiv(50)).floor.fdiv(10)\n # (density / 50), rounded down to int, then divided by 10\n # ex: 200 / 50 = 4, 4/10 = 0.4\n # ex: 185 / 50 = 3.7, rounded to 3, 3/10 = 0.3\n else # if population density < 50\n multiplication_factor = 0.05\n end\n \n \n \n number_of_deaths = (@population * multiplication_factor).floor\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n number_of_deaths = 0\n density_hash = {200 => 0.4, 150 => 0.3, 100 => 0.2, 50 => 0.1,0 => 0.05}\n density_hash.each_key { |key|\n if @population_density >= key\n number_of_deaths = (@population * density_hash[key]).floor\n end\n }\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n\n\n if @population_density >= 200\n rate = 0.4\n elsif @population_density >= 150\n rate = 0.3\n elsif @population_density >= 100\n rate = 0.2\n elsif @population_density >= 50\n rate = 0.1\n else\n rate = 0.05\n end\n number_of_deaths = (@population * rate).floor\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n if @population_density >= 200\n rate = 0.4\n elsif @population_density >= 150\n rate = 0.3\n elsif @population_density >= 100\n rate = 0.2\n elsif @population_density >= 50\n rate = 0.1\n else\n rate = 0.05\n end\n\n (@population * rate).floor\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n\n if @population_density >= 200\n death_rate = 0.4\n elsif @population_density >= 150\n death_rate = 0.3\n elsif @population_density >= 100\n death_rate = 0.2\n elsif @population_density >= 50\n death_rate = 0.1\n else\n death_rate = 0.05\n end\n \n (@population * death_rate).floor\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n death_multiplier = {0 => 0.05, 50 => 0.1, 100 => 0.2, 150 => 0.3, 200 => 0.4}\n death_multiplier.each do |density, multiplier|\n if @population_density >= density\n @number_of_deaths = (@population * multiplier).floor\n end\n \n end\n # if @population_density >= 200\n # number_of_deaths = (@population * 0.4).floor\n # elsif @population_density >= 150\n # number_of_deaths = (@population * 0.3).floor\n # elsif @population_density >= 100\n # number_of_deaths = (@population * 0.2).floor\n # elsif @population_density >= 50\n # number_of_deaths = (@population * 0.1).floor\n # else\n # number_of_deaths = (@population * 0.05).floor\n # end\n print \"#{@state} will lose #{@number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n if @population_density >= 200\n number_of_deaths = num_death_setter(0.4)\n elsif @population_density >= 150\n number_of_deaths = num_death_setter(0.3)\n elsif @population_density >= 100\n number_of_deaths = num_death_setter(0.2)\n elsif @population_density >= 50\n number_of_deaths = num_death_setter(0.1)\n else\n number_of_deaths = num_death_setter(0.5)\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths #(population_density, population, state)\r\n # predicted deaths is solely based on population density\r\n if @population_density >= 200\r\n multiplier = 0.4\r\n elsif @population_density >= 150\r\n multiplier = 0.3\r\n elsif @population_density >= 100\r\n multiplier = 0.2\r\n elsif @population_density >= 50\r\n multiplier = 0.1\r\n else\r\n multiplier = 0.05\r\n end\r\n number_of_deaths = (@population * multiplier).floor\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n factor = 0.4\n elsif @population_density >= 150\n factor = 0.3\n elsif @population_density >= 100\n factor = 0.2\n elsif @population_density >= 50\n factor = 0.1\n else\n factor = 0.05\n end\n number_of_deaths = (@population * factor).floor\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n\n\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density < 200 && @population_density >= 50\n number_of_deaths = (@population * (@population_density.to_i/50) * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak!!!\\n\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n density = [200, 150, 100, 50, 0]\n multiplier = [0.4, 0.3, 0.2, 0.1, 0.05]\n density.length.times do |x|\n @population_density >= density[x]\n @number_of_deaths = (@population * multiplier[x]).floor \n end\n# if @population_density >= 200\n# number_of_deaths = (@population * 0.4).floor\n# elsif @population_density >= 150\n# number_of_deaths = (@population * 0.3).floor\n# elsif @population_density >= 100\n# number_of_deaths = (@population * 0.2).floor\n# elsif @population_density >= 50\n# number_of_deaths = (@population * 0.1).floor\n# else\n# number_of_deaths = (@population * 0.05).floor\n# end\n\n print \"#{@state} will lose #{@number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n case @population_density\n when 0...50 then number_of_deaths = calc_density(0.05)\n when 50...100 then number_of_deaths = calc_density(0.1)\n when 100...150 then number_of_deaths = calc_density(0.2)\n when 150...200 then number_of_deaths = calc_density(0.3)\n else number_of_deaths = calc_density(0.4)\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths #(population_density, population, state)\r\n # predicted deaths is solely based on population density\r\n # case @population_density\r\n # \twhen @population_density >= 200 then number_of_deaths = (@population * 0.4).floor\r\n # \twhen @population_density >= 150 then number_of_deaths = (@population * 0.3).floor\r\n # end\r\n \r\n if @population_density >= 200\r\n number_of_deaths = (@population * 0.4).floor\r\n elsif @population_density >= 150\r\n number_of_deaths = (@population * 0.3).floor\r\n elsif @population_density >= 100\r\n number_of_deaths = (@population * 0.2).floor\r\n elsif @population_density >= 50\r\n number_of_deaths = (@population * 0.1).floor\r\n else\r\n number_of_deaths = (@population * 0.05).floor\r\n end\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n \r\n \r\n\r\n if @population_density >= 200\r\n x = 0.4\r\n\r\n elsif @population_density >= 150\r\n x = 0.3\r\n elsif @population_density >= 100\r\n x = 0.2\r\n\r\n elsif @population_density >= 50\r\n x = 0.1\r\n\r\n else\r\n x = 0.05\r\n end\r\n number_of_deaths = (@population * x).floor \r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n if @population_density >= 200\n death_multiplier = 0.4\n elsif @population_density >= 150\n death_multiplier = 0.3\n elsif @population_density >= 100\n death_multiplier = 0.2\n elsif @population_density >= 50\n death_multiplier = 0.1\n else\n death_multiplier = 0.05\n end\n\n number_of_deaths = (@population * death_multiplier).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n if @population_density >= 200\n multiplier = 0.4\n elsif @population_density >= 150\n multiplier = 0.3\n elsif @population_density >= 100\n multiplier = 0.2\n elsif @population_density >= 50\n multiplier = 0.1\n else\n multiplier = 0.05\n end\n number_of_deaths = (@population * multiplier).floor\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n fractions = [0.4, 0.3, 0.2, 0.1, 0.05]\n density = [200, 150, 100, 50, 0]\n \n index = 0\n while index < density.length\n if @population_density >= density[index]\n number_of_deaths = (@population * fractions[index]).floor\n break\n end\n index += 1\n end\n \n # if @population_density >= density[0]\n # number_of_deaths = (@population * fractions[0]).floor\n # elsif @population_density >= density[1]\n # number_of_deaths = (@population * fractions[1]).floor\n # elsif @population_density >= density[2]\n # number_of_deaths = (@population * fractions[2].floor\n # elsif @population_density >= density[3]\n # number_of_deaths = (@population * fractions[3]).floor\n # else\n # number_of_deaths = (@population * fractions[4]).floor\n # end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n # as population density increases, it affects the percent of the population that will die. The higher the population density, the higher number of deaths. \n y = case @population_density\n when (0..49) then 0.05\n when (50..99) then 0.1\n when (100..149) then 0.2 \n when (150..199) then 0.3\n else 0.4\n end \n (@population * y).floor\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n\r\n coefficient = case @population_density\r\n when 200..15000 then 0.4\r\n when 150..199 then 0.3\r\n when 100..149 then 0.2\r\n when 50..99 then 0.1\r\n else 0.05\r\n end\r\n\r\n number_of_deaths = @population * coefficient\r\n print \"#{@state} will lose #{number_of_deaths.floor} people in this outbreak\"\r\n\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n death_quotient = 1\n if @population_density >= 200\n death_quotient = 0.4\n elsif @population_density >= 150\n death_quotient = 0.3\n elsif @population_density >= 100\n death_quotient = 0.2\n elsif @population_density >= 50\n death_quotient = 0.1\n else\n death_quotient = 0.05\n end\n\n number_of_deaths = (@population * death_quotient).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n death_rate = 0.4\n elsif @population_density >= 150\n death_rate = 0.3\n elsif @population_density >= 100\n death_rate = 0.2\n elsif @population_density >= 50\n death_rate = 0.1\n else\n death_rate = 0.05\n end\n \n number_of_deaths = (@population * death_rate).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n case @population_density\n # predicted deaths is solely based on population density\n when @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n when @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n when @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n when @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths#(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = death_percentage(0.4)\n elsif @population_density >= 150\n number_of_deaths = death_percentage(0.3)\n elsif @population_density >= 100\n number_of_deaths = death_percentage(0.2)\n elsif @population_density >= 50\n number_of_deaths = death_percentage(0.1)\n else\n number_of_deaths = death_percentage(0.05)\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n case @population_density\n when @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n when @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n when @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n when @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 50\n number_of_deaths = (@population * (@population_density / 50).floor * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 50\n number_of_deaths = (@population * (@population_density / 50).floor * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n\n number_of_deaths = case\n when @population_density >= 200\n @population * 0.4\n when @population_density >= 50\n @population * 0.1 * (@population_density.to_i/50)\n else\n @population * 0.05\n end\n\n print \"#{@state} will lose #{number_of_deaths.floor} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n death_factor = if @population_density >= 200\n 0.4\n elsif @population_density >= 150\n 0.3\n elsif @population_density >= 100\n 0.2\n elsif @population_density >= 50\n 0.1\n else\n 0.05\n end\n\n number_of_deaths = (@population * death_factor).floor\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density < 200 && @population_density >= 50\n number_of_deaths = (@population * ((@population_density/50).floor*0.1)).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\r\n \r\n # predicted deaths is solely based on population density\r\n \r\n if @population_density >= 200\r\n n = 0.4\r\n\r\n elsif @population_density >= 150\r\n n = 0.3\r\n\r\n elsif @population_density >= 100\r\n n = 0.2\r\n\r\n elsif @population_density >= 50\r\n n = 0.1\r\n\r\n else\r\n n = 0.05\r\n\r\n end\r\n \r\n number_of_deaths = (@population * n).floor\r\n\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n death_loss = 0.4\n elsif @population_density >= 150\n death_loss = 0.3\n elsif @population_density >= 100\n death_loss = 0.2\n elsif @population_density >= 50\n death_loss = 0.1\n else\n death_loss = 0.05\n end\n\n number_of_deaths = (@population * death_loss).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths(population_density, population, state)\n \n number_of_deaths = (@population * 0.05).floor if @population_density < 50\n number_of_deaths = (@population * 0.1).floor if @population_density >= 50\n number_of_deaths = (@population * 0.2).floor if @population_density >= 100\n number_of_deaths = (@population * 0.3).floor if @population_density >= 150\n number_of_deaths = (@population * 0.4).floor if @population_density >= 200\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n case @population_density\n when 0..49\n multiplier_factor = 0.05\n when 50..99\n multiplier_factor = 0.1\n when 100..149\n multiplier_factor = 0.2\n when 150..199\n multiplier_factor = 0.3\n else\n multiplier_factor = 0.4\n end\n \n number_of_deaths = (@population * multiplier_factor).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n x = 0.4\n elsif @population_density >= 150\n x = 0.3\n elsif @population_density >= 100\n x = 0.2\n elsif @population_density >= 50\n x = 0.1\n else\n x = 0.05\n end\n\n\tnumber_of_deaths = (@population * x).floor\n\t\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n if @population_density > 200\r\n number_of_deaths = (@population * 0.4).floor\r\n elsif @population_density <= 200 && @population_density >= 50\r\n number_of_deaths = @population * ((@population_density/50) * 0.1).floor\r\n else\r\n number_of_deaths = (@population * 0.05).floor\r\n end\r\n\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density < 50\n number_of_deaths = (@population * 0.05).floor\n else\n number_of_deaths = (@population*((@population_density/50).floor)*(0.1)).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n factor = 0.4\n elsif @population_density >= 150\n factor = 0.3\n elsif @population_density >= 100\n factor = 0.2\n elsif @population_density >= 50\n factor = 0.1\n else\n factor = 0.05\n end\n\n number_of_deaths = (@population * factor).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n if @population_density >= 200\r\n death_factor = 0.4\r\n elsif @population_density >= 150\r\n death_factor = 0.3\r\n elsif @population_density >= 100\r\n death_factor = 0.2\r\n elsif @population_density >= 50\r\n death_factor = 0.1\r\n else\r\n death_factor = 0.05\r\n end\r\n number_of_deaths = (@population * death_factor).floor\r\n\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths(@population_density, @population, @state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if (@population_density >= 50) && (@population_density < 200)\n death_rate = ((@population_density / 50).floor).to_f\n number_of_deaths = ((death_rate / 10) * @population).to_i\n elsif @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density > 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density <= 200 && @population_density >= 50\n number_of_deaths = (@population * (@population_density/50 * 0.1)).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n\r\n if @population_density >= 200\r\n multiplier = 0.4\r\n elsif @population_density >= 150\r\n multiplier = 0.3\r\n elsif @population_density >= 100\r\n multiplier = 0.2\r\n elsif @population_density >= 50\r\n multiplier = 0.1\r\n else\r\n multiplier = 0.05\r\n end\r\n\r\n number_of_deaths = (@population * multiplier).floor\r\n\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n if @population_density < 50\n \tnumber_of_deaths = (@population * 0.05).floor\n elsif @population_density < 100\n \tnumber_of_deaths = (@population * 0.1).floor\n elsif @population_density < 150\n \tnumber_of_deaths = (@population * 0.2).floor\n elsif @population_density < 200\n \tnumber_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 200\n \tnumber_of_deaths = (@population * 0.4).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n \n case @population_density\n when @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n when @population_density>= 150\n number_of_deaths = (@population * 0.3).floor\n when @population_density>= 100\n number_of_deaths = (@population * 0.2).floor\n when @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n death_factor = case @population_density.floor\n when 0..49\n 0.05\n when 50..99\n 0.1\n when 100..149\n 0.2\n when 150..199\n 0.3\n else\n 0.4\n end\n number_of_deaths = (@population * death_factor).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if population_density >= 200\n death_constant = 0.4\n elsif population_density >= 150\n death_constant = 0.3\n elsif population_density >= 100\n death_constant = 0.2\n elsif population_density >= 50\n death_constant = 0.1\n else\n death_constant = 0.05\n end\n\n number_of_deaths = (population * death_constant).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n factor = case @population_density\r\n when 0...50 then 0.05\r\n when 50...100 then 0.1\r\n when 100...150 then 0.2\r\n when 150...200 then 0.3\r\n else 0.4\r\n end\r\n number_of_deaths = (@population * factor).floor\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n percentage = 0.4\n elsif @population_density >= 150\n percentage = 0.3\n elsif @population_density >= 100\n percentage = 0.2\n elsif @population_density >= 50\n percentage = 0.1\n else\n percentage = 0.05\n end\n \n number_of_deaths = (@population * percentage).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density \r\n if @population_density >= 200\r\n number_of_deaths = (@population * 0.4).floor\r\n elsif @population_density < 50\r\n number_of_deaths = (@population * 0.05).floor\r\n else\r\n increment = (@population_density/50).floor\r\n number_of_deaths=(@population * (increment * 0.1)).floor\r\n end\r\n\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n case when @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n when @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n when @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n when @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n when\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n if @population_density >= 200\r\n number_of_deaths = (@population * 0.4)\r\n elsif @population_density >= 150\r\n number_of_deaths = (@population * 0.3)\r\n elsif @population_density >= 100\r\n number_of_deaths = (@population * 0.2)\r\n elsif @population_density >= 50\r\n number_of_deaths = (@population * 0.1)\r\n else\r\n number_of_deaths = (@population * 0.05)\r\n end\r\n\r\n print \"#{@state} will lose #{number_of_deaths.floor} people in this outbreak\"\r\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n number_of_deaths=0\r\n density=[200,150,100,50,0]\r\n death_percentage=[0.4, 0.3, 0.2, 0.1, 0.05]\r\n\r\n density.each_index do |index|\r\n if @population_density >= density[index]\r\n number_of_deaths = (@population * death_percentage[index]).floor\r\n break\r\n end\r\n end\r\n=begin\r\n if @population_density >= 200\r\n number_of_deaths = (@population * 0.4).floor\r\n elsif @population_density >= 150\r\n number_of_deaths = (@population * 0.3).floor\r\n elsif @population_density >= 100\r\n number_of_deaths = (@population * 0.2).floor\r\n elsif @population_density >= 50\r\n number_of_deaths = (@population * 0.1).floor\r\n else\r\n number_of_deaths = (@population * 0.05).floor\r\n end\r\n=end\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n multiplier = 0.4\n elsif @population_density >= 150\n multiplier = 0.3\n elsif @population_density >= 100\n multiplier = 0.2\n elsif @population_density >= 50\n multiplier = 0.1\n else\n multiplier = 0.05\n end\n number_of_deaths = (@population * multiplier).floor\n \n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n float = 0.4\n elsif @population_density >= 150\n float = 0.3\n elsif @population_density >= 100\n float = 0.2\n elsif @population_density >= 50\n float = 0.1\n else\n float = 0.05\n end\n\n number_of_deaths = (@population * float).floor\n \n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n if @population_density >= 200\r\n number_of_deaths = (@population * 0.4).floor\r\n elsif @population_density >= 150\r\n number_of_deaths = (@population * 0.3).floor\r\n elsif @population_density >= 100\r\n number_of_deaths = (@population * 0.2).floor\r\n elsif @population_density >= 50\r\n number_of_deaths = (@population * 0.1).floor\r\n else\r\n number_of_deaths = (@population * 0.05).floor\r\n end\r\n\r\n # number_of_deaths = @population * ((@population_density / 50).floor / 10)\r\n\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths\r\n # predicted deaths is solely based on population density\r\n case @population_density\r\n when 200..Float::INFINITY\r\n rate = 0.4\r\n when 150..199\r\n rate = 0.3\r\n when 100..149\r\n rate = 0.2\r\n when 50..99\r\n rate = 0.2\r\n else\r\n rate = 0.05\r\n end\r\n\r\n number_of_deaths = (@population * rate).floor\r\n\r\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\r\n\r\n end", "def predicted_deaths\n case @population_density\n when 0 .. 49 then number_of_deaths = (@population * 0.05).floor\n when 50 .. 99 then number_of_deaths = (@population * 0.1).floor\n when 100 .. 149 then number_of_deaths = (@population * 0.2).floor\n when 150 .. 200 then number_of_deaths = (@population * 0.3).floor\n else number_of_deaths = (@population * 0.4).floor\n end\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n 0.4\n elsif @population_density >= 150\n 0.3\n elsif @population_density >= 100\n 0.2\n elsif @population_density >= 50\n 0.1\n else\n 0.05\n end\n\n end", "def predicted_deaths#(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n elsif @population_density >= 100\n number_of_deaths = (@population * 0.2).floor\n elsif @population_density >= 50\n number_of_deaths = (@population * 0.1).floor\n else\n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n factor = 0.4\n elsif @population_density >= 150\n factor = 0.3\n elsif @population_density >= 100\n factor = 0.2\n elsif @population_density >= 50\n factor = 0.1\n else\n factor = 0.05\n end\n\n number_of_deaths = (@population * factor).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n factor = 0.4\n elsif @population_density >= 150\n factor = 0.3\n elsif @population_density >= 100\n factor = 0.2\n elsif @population_density >= 50\n factor = 0.1\n else\n factor = 0.05\n end\n\n number_of_deaths = (@population * factor).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths(population_density)\n # predicted deaths is solely based on population density\n \n pop = @population_density\n case pop \n when pop >= 200 \n number_of_deaths = (@population * 0.4).floor\n when pop >= 150 \n number_of_deaths = (@population * 0.3).floor\n when pop >= 100 \n number_of_deaths = (@population * 0.2).floor\n when pop >= 50 \n number_of_deaths = (@population * 0.1).floor \n else \n number_of_deaths = (@population * 0.05).floor\n end\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths#(population_density, population, state)\n # predicted deaths is solely based on population density\n factor = case population_density\n when 0...50 then 0.05\n when 50...100 then 0.1\n when 100...150 then 0.2\n when 150...200 then 0.3\n else 0.4 \n end\n number_of_deaths = (population * factor).floor\n\n print \"#{state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n multiplier = 0.4\n elsif @population_density >= 150\n multiplier = 0.3\n elsif @population_density >= 100\n multiplier = 0.2\n elsif @population_density >= 50\n multiplier = 0.1\n else\n multiplier = 0.05\n end\n\n number_of_deaths = (@population * multiplier).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n num = 0.4\n elsif @population_density >= 150\n num = 0.3\n elsif @population_density >= 100\n num = 0.2\n elsif @population_density >= 50\n num = 0.1\n else\n num = 0.05\n end\n\n number_of_deaths = (@population * num).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end", "def predicted_deaths\n # predicted deaths is solely based on population density\n if population_density >= 200\n num = 0.4\n elsif @population_density >= 150\n num = 0.3\n elsif @population_density >= 100\n num = 0.2\n elsif @population_density >= 50\n num = 0.1\n else\n num = 0.05\n end\n number_of_deaths = (@population * num).floor\n\n print \"#{@state} will lose #{number_of_deaths} people in this outbreak\"\n\n end" ]
[ "0.87548697", "0.87026584", "0.8673577", "0.86581117", "0.86520076", "0.8647558", "0.8605097", "0.859665", "0.8595221", "0.85898817", "0.8535275", "0.8535275", "0.8486009", "0.84841055", "0.8457516", "0.844626", "0.84384036", "0.8395974", "0.8314984", "0.8262793", "0.82552826", "0.8254332", "0.82500035", "0.824227", "0.82391346", "0.8231129", "0.82191384", "0.8214498", "0.82129866", "0.81806505", "0.8174985", "0.81644046", "0.8162769", "0.8162467", "0.8153176", "0.81456715", "0.8144316", "0.81424874", "0.813219", "0.8129966", "0.81259096", "0.8122007", "0.8110267", "0.81096214", "0.81086236", "0.81079733", "0.8100189", "0.80980676", "0.80980676", "0.8090499", "0.80887854", "0.808803", "0.80877554", "0.8086344", "0.80850637", "0.8082463", "0.80770904", "0.8074519", "0.8074286", "0.8073793", "0.8071233", "0.80687064", "0.8068016", "0.80648994", "0.8064107", "0.80613226", "0.8060704", "0.80605286", "0.80600566", "0.80598104", "0.80597246", "0.8058506", "0.8058506", "0.80547965", "0.8053986", "0.8050625", "0.8050251", "0.80425924", "0.80405456", "0.80402476", "0.8039316", "0.8039316", "0.8039316", "0.8039316", "0.8039316", "0.8037159", "0.8036922", "0.803658", "0.803645", "0.8031983", "0.8030872", "0.80298984", "0.80219537", "0.8014596", "0.80141187", "0.80141187", "0.8010788", "0.8009957", "0.8009721", "0.8006562", "0.80064374" ]
0.0
-1
Calculate how long the virus will take to spread based on pop density
def speed_of_spread #in months # We are still perfecting our formula here. The speed is also affected # by additional factors we haven't added into this functionality. case @population_density when 0..50 then 2.5 when 51..100 then 2 when 101..150 then 1.5 when 151..200 then 1 else 0.5 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def speed_of_spread(population_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 150\n speed = 1\n elsif @population_density >= 100\n speed = 1.5\n elsif @population_density >= 50\n speed = 2\n else\n speed = 2.5\n end\n\n speed\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n end", "def speed_of_spread\n if @population_density >= 200\n speed = 0.5\n else @population_density < 200\n multiplier = (@population_density/50).floor\n speed = 2.5 - (multiplier * 0.5)\n end\n end", "def speed_of_spread(population_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n case @population_density\n when 200..Float::INFINITY\n speed += 0.5\n when 150..199\n speed += 1\n when 100..149\n speed += 1.5\n when 50..99\n speed += 2\n else speed += 2.5\n end\n\n speed\n\n end", "def speed_of_spread() # in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n return speed\n end", "def speed_of_spread #(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n\r\n if @population_density >= 200\r\n speed = 0.5\r\n elsif @population_density >= 150\r\n speed = 1\r\n elsif @population_density >= 100\r\n speed = 1.5\r\n elsif @population_density >= 50\r\n speed = 2\r\n else\r\n speed = 2.5\r\n end\r\n\r\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n \r\n\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n # speed = 0.0\n\n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n\n if @population_density >= 200\n @speed += 0.5\n elsif @population_density >= 150\n @speed += 1\n elsif @population_density >= 100\n @speed += 1.5\n elsif @population_density >= 50\n @speed += 2\n else\n @speed += 2.5\n end\n\n end", "def calc_density(percent)\n (@population * percent).floor\n\n end", "def speed_of_spread(population_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n \n\n end", "def size\n\n @population_density/50\n\n mod_factor = 0.0\n if @population_density >= 200\n mod_factor = 4.0\n elsif @population_density >= 150\n mod_factor = 3.0\n elsif @population_density >= 100\n mod_factor = 2.0\n elsif @population_density >= 50\n mod_factor = 1.0\n else\n mod_factor = 0.5\n end\n return mod_factor\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n @speed = speed\n end", "def speed_of_spread \n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n @speed = 0.0\n # REFACTOR: Rename speed variable to time or months.\n \n\n if @population_density >= 200\n @speed += 0.5\n elsif @population_density >= 150\n @speed += 1\n elsif @population_density >= 100\n @speed += 1.5\n elsif @population_density >= 50\n @speed += 2\n else\n @speed += 2.5\n end\n end", "def speed_of_spread\n # (population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 150\n speed = 1\n elsif @population_density >= 100\n speed = 1.5\n elsif @population_density >= 50\n speed = 2\n else\n speed = 2.5\n end\n end", "def speed_of_spread\r\n # in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density <= 50\n speed += 2.5\n else\n months = 2.5 - ((@population_density.floor / 50) * 0.5)\n speed += months\n end\n end", "def speed_of_spread(population_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n pop = @population_density\n case pop \n when pop >= 200 \n speed += 0.5\n when pop >= 150 \n speed += 1\n when pop >= 100 \n speed += 1.5\n when pop >= 50 \n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def pop_density(population, area)\n return population/area\nend", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n \n\n end", "def speed_of_spread#(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n # puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread\r\n #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n end", "def speed_of_spread\n more_dense = @population_density >= 200\n dense = @population_density >= 150\n medium_dense = @population_density >= 100\n low_dense = @population_density >= 50#in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n if more_dense\n speed += 0.5\n elsif dense\n speed += 1\n elsif medium_dense\n speed += 1.5\n elsif low_dense\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n if @population_density >= 200\n @number_of_months += 0.5\n elsif @population_density >= 150\n @number_of_months += 1\n elsif @population_density >= 100\n @number_of_months += 1.5\n elsif @population_density >= 50\n @number_of_months += 2\n else\n @number_of_months += 2.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n case @population_density\n when (0..49)\n 2.5\n when (50..99)\n 2\n when (100..149)\n 1.5\n when (150..199)\n 1\n else #(200+)\n 0.5\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n case @population_density\n when 0..50 then 2.5\n when 51..100 then 2\n when 101..150 then 1.5\n when 151..200 then 1\n else 0.5\n end\n\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density > 200\n speed += 0.5\n elsif @population_density <= 200 && @population_density >= 50\n speed = (@population_density/50 =+.5)\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def population_density; end", "def proportion_total_sd_ep_wor(prop, sam, pop)\n fsc=((pop - sam).to_f / ( sam - 1))\n Math::sqrt(fsc*pop*prop*(1-prop))\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n ## Refactored for Release: 8\n if @population_density >= 200\n 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n # puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n case @population_density\r\n when 200..Float::INFINITY\r\n speed = 0.5\r\n when 150..199\r\n speed = 1\r\n when 100..149\r\n speed = 1.5\r\n when 50..99\r\n speed = 2\r\n else\r\n speed = 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread(@population_density, @state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 2.5\n\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 50 && @population_density < 200\n speed = speed - ((@population_density / 50).floor / 2.0)\n #subtracts 0.5 from speed for every 50 pop density rounding down.\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread # REFACTOR\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n when @population_density >= 200 then speed += 0.5\n when @population_density >= 150 then speed += 1\n when @population_density >= 100 then speed += 1.5\n when @population_density >= 50 then speed += 2\n else speed += 2.5\nend", "def speed_of_spread(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if population_density >= 200\n speed += 0.5\n elsif population_density >= 150\n speed += 1\n elsif population_density >= 100\n speed += 1.5\n elsif population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n\r\n if @population_density >= 200\r\n speed = 0.5\r\n elsif @population_density >= 150\r\n speed = 1\r\n elsif @population_density >= 100\r\n speed = 1.5\r\n elsif @population_density >= 50\r\n speed = 2\r\n else\r\n speed = 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread#(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.5\n density = 200\n\n while @population_density <= density\n density -= 50\n speed += 0.5\n end\n\n # speed = 0\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread \n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread() #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n case true\n when @population_density >= 200 then speed += 0.5\n when @population_density >= 150 then speed += 1\n when @population_density >= 100 then speed += 1.5\n when @population_density >= 50 then speed += 2\n else speed += 2.5\n end\n end", "def speed_of_spread\n #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread#(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if population_density >= 200\n speed += 0.5\n elsif population_density >= 150\n speed += 1\n elsif population_density >= 100\n speed += 1.5\n elsif population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread\n speed = 0.0\n density_hash = {200=> 0.5, 150=> 0.5, 100=> 1.5, 50=> 2, 0=> 2.5}\n density_hash.each do |key, value|\n if @population_density >= key\n speed += value\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n return\n end\n end\n end", "def density\n if @population_density >= 200\n 0.4\n elsif @population_density >= 150\n 0.3\n elsif @population_density >= 100\n 0.2\n elsif @population_density >= 50\n 0.1\n else\n 0.05\n end\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n STATE_FORMULA.each do |state_size, calculation|\n if @population_density >= calculation[:pop_density]\n return speed += calculation[:speed]\n end\n end\n speed += 2.5\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n @speed = 0.5\n elsif @population_density >= 150\n @speed = 1\n elsif @population_density >= 100\n @speed = 1.5\n elsif @population_density >= 50\n @speed = 2\n else\n @speed = 2.5\n end\n\n \n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n#we can remove this and have it print within virus_effects so that this method does one thing\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread() #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n @speed = 0.0\n\n case @population_density\n when 200..1000\n @speed += 0.5\n when 150...200\n @speed += 1\n when 100...200\n @speed += 1.5\n when 50...100\n @speed += 2\n else\n @speed += 2.5\n\n end\n\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n # speed = 0.0\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 150\n speed = 1\n elsif @population_density >= 100\n speed = 1.5\n elsif @population_density >= 50\n speed = 2\n else\n speed = 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n end", "def speed_of_spread#(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n index = 0\n density = [200, 150, 100, 50, 0]\n speed = [0.5, 1, 1.5, 2, 2.5]\n\n while index < density.length\n if @population_density >= density[index]\n puts \" and will spread across the state in #{speed[index]} months.\\n\\n\"\n break\n end\n index += 1\n end\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n\n end", "def speed_of_spread#(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n speed += 0.5 if @population_density >= 200\n speed += 1 if @population_density >= 150\n speed += 1.5 if @population_density >= 100\n speed += 2 if @population_density >= 50\n speed += 2.5 if @population_density < 50\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n case when @population_density >= 200\n speed += 0.5\n when @population_density >= 150\n speed += 1\n when @population_density >= 100\n speed += 1.5\n when @population_density >= 50\n speed += 2\n when\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 2.5\r\n\r\n 4.times do |i|\r\n if population_density >= 50*(i+1)\r\n speed -= 0.5\r\n end\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100 \r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread(population_density, state) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n multiples_of_fifty = (population_density / 50).to_i\n speed = 0.5\n if population_density < 200\n speed = 2.5 - (multiples_of_fifty * speed)\n end\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 50 && @population_density < 200\n speed = 2.5 - (0.5)*(@population_density.to_i / 50.to_i).to_f\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n @months_to_spread = 0.0\n\n if @population_density >= 200\n @months_to_spread += 0.5\n elsif @population_density >= 150\n @months_to_spread += 1\n elsif @population_density >= 100\n @months_to_spread += 1.5\n elsif @population_density >= 50\n @months_to_spread += 2\n else\n @months_to_spread += 2.5\n end\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n @months_to_spread = 0.0\n\n if @population_density >= 200\n @months_to_spread += 0.5\n elsif @population_density >= 150\n @months_to_spread += 1\n elsif @population_density >= 100\n @months_to_spread += 1.5\n elsif @population_density >= 50\n @months_to_spread += 2\n else\n @months_to_spread += 2.5\n end\n\n end", "def speed_of_spread(state_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n hash = {200=>0.5, 150=>1, 100=>1.5, 50=>2}\n\n hash.each do |density, float|\n if @population_density >= density\n speed = float\n else\n speed = 2.5\n end\n speed\n end\n\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end", "def speed_of_spread(population_density, state) #in months\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 2.5\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n #ATTEMPTED REFACTOR\n # (0..@population_density).inject do |sum, num |\n # if sum >= 50\n # sum = 0\n # speed -= 0.5\n # end\n # end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 2.5\n\n thresholds = [50,100,150,200]\n\n thresholds.each do |threshold|\n\n if @population_density >= threshold\n speed -= 0.5\n end\n\n end\n\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread(population_density, state) #in months\n speed = 0.0 # forces float\n\n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else \n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end", "def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n\n if @population_density >= 200\n speed += 0.5\n else\n speed += 2.5 - ((@population_density / 50).floor * 0.5)\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n end" ]
[ "0.73655224", "0.7360035", "0.73489755", "0.72912955", "0.7284357", "0.72813475", "0.72813475", "0.7150867", "0.71429205", "0.7132044", "0.7114529", "0.7097571", "0.7092514", "0.70803714", "0.7067229", "0.7067229", "0.7067229", "0.7066761", "0.7059718", "0.7051508", "0.70467484", "0.70260686", "0.70260686", "0.7017037", "0.70082337", "0.6992497", "0.6971823", "0.6947409", "0.69067895", "0.68975633", "0.6887273", "0.68828523", "0.688046", "0.6879077", "0.68679297", "0.6863077", "0.6853345", "0.68520844", "0.6842198", "0.6840574", "0.6833691", "0.68267685", "0.6817487", "0.68136686", "0.6795767", "0.67847097", "0.67793226", "0.67694443", "0.6769345", "0.6768813", "0.6765913", "0.6765913", "0.6765913", "0.6765913", "0.67589325", "0.6752761", "0.67470926", "0.67418545", "0.6719667", "0.6719667", "0.6699068", "0.6694692", "0.6690172", "0.66896546", "0.668869", "0.6685083", "0.6684755", "0.66816515", "0.66804767", "0.6672704", "0.665606", "0.66462606", "0.66433233", "0.662156", "0.6620102", "0.6616403", "0.6598937", "0.6592005", "0.6591652", "0.6589119", "0.65865827", "0.65794796", "0.6574919", "0.6574919", "0.65737087", "0.6572376", "0.6572376", "0.6572376", "0.6572376", "0.6572376", "0.6572376", "0.6572376", "0.65703803", "0.65703803", "0.65703803", "0.65703803", "0.65676886", "0.6555342", "0.6541333", "0.65408" ]
0.6885476
31
adapted from SICP section 1.2
def square(n) n * n end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def alg; end", "def if_ins(i,spl); end", "def strauss; end", "def ein; end", "def cops; end", "def cops; end", "def cops; end", "def ri(p,i,n,a,s)\n j = 0\n v = nil\n h = nil\n k = nil\n while i > 0\n k = n-j-1\n h = b(k)\n v = b(j) * h\n i -= v\n j += 1\n end\n i += v\n j -= 1\n p[a-1] = j + 1 + s\n y = (i-1-((i-1)/h)*h) + 1\n w = (i-y) / h + 1\n\n if j > 1\n ri(p,w,j,a+1,s) \n elsif j == 1\n p[a] = s+1\n end\n\n if k > 1\n ri(p,y,k,a+j+1,s+j+1)\n elsif k==1\n p[a+j] = s+j+2\n end\n end", "def rassoc(p0) end", "def primordial; end", "def hcf(i,j)\n \nend", "def lh(t, s, c)\n\n end", "def solution\n (1..40).inject(:*) / (1..20).inject(:*)**2\nend", "def tr(p0, p1) end", "def r(p,n,a,s)\n j = p[a-1] - s - 1\n v = 0\n i = 0\n for i in 0..(j-1) do\n v += b(i) * b(n-i-1)\n end\n v +\n (j <= 1 ? 0 : b(n-j-1) * (r(p,j,a+1,s) - 1)) +\n (n-j-1 <= 1 ? 1 : r(p,n-j-1,a+j+1,s+j+1))\n end", "def _reduce_585(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def g(acc,elt)\n acc/elt\nend", "def _reduce_693(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def h(x)\n 2*x - @n - 1\n end", "def _reduce_590(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def _reduce_588(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def recessive k, m, n\n all = k + m + n\n mix = m + n\n total = 4.0 * triangle(all) # 2 * squareish all = 2 * 2 * triangle all\n\n lhs = triangle n\n mid = n * mix - n\n rhs = triangle mix\n\n 1 - (lhs+mid+rhs) / total\n end", "def _reduce_430(val, _values, result)\n result = new_dsym val[1]\n \n result\nend", "def upc_a_with_composite_symbology; end", "def _reduce_591(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\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 _reduce_585(val, _values, result)\n result = [:dot, val[0][1]]\n\n result\nend", "def s2(n)\n n*(n+1)*(2*n+1)/6\nend", "def _reduce_593(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def g_(acc,elt)\n elt/acc\nend", "def p9\n\ta, x = 1, 1000\n\tloop do\n\t\tb = (2.0 * x * a - x ** 2.0) / (2.0 * a - 2.0 * x)\n\t\tif (b % 1).zero?\n\t\t\tc = (a ** 2 + b ** 2) ** 0.5\n\t\t\tputs triplet = [a,b,c].to_a\n\t\t\treturn triplet.reduce(:*)\n\t\tend\n\t\ta += 1\n\tend\nend", "def e2w(n, m)\n# n = (n+0.938272)*(n+0.938272) - n*n\n n+m\nend", "def _reduce_724(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def solve\n return ((1..40).inject(:*) / ((1..20).inject(:*) ** 2))\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 _reduce_712(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def _reduce_711(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def isp; end", "def isp; end", "def sub_c\n end", "def exercise_1113 (matrix)\n end", "def _reduce_696(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def lcts(array)\nend", "def _reduce_591(val, _values, result)\n result = [:dot, val[0][1]]\n\n result\nend", "def frac (k, c, s)\n #\n ans = []\n tile = ['G', 'L']\n possible_source_sequences = tile.repeated_permutation(k).to_a\n seq = possible_source_sequences.dup\n for i in (2..c)\n seq = seq.map.with_index { |e, i| e.map { |ee| ee = (ee == 'G') ? 'G'*k : possible_source_sequences[i].join('') }}\n seq = seq.map { |e| e.join('').split('') }\n end\n\n for ii in (1..s)\n ss = seq.transpose\n ssl = ss.map { |e| e.count('L') }\n\n fewest_lead = ssl.min\n index_fewest_lead = ssl.find_index(fewest_lead)\n ans.push(index_fewest_lead)\n break if fewest_lead == 1\n tmp = []\n ss[index_fewest_lead].each.with_index { |e, i| tmp.push(seq[i]) if e == 'L'}\n seq = tmp\n return ['IMPOSSIBLE'] if ii == s and fewest_lead != 1\n end\n\n return ans.collect { |e| e + 1 }\nend", "def _reduce_699(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def flatlandSpaceStations(n,c,m)\r\n answer = 0\r\n cc = c.sort()\r\n\r\n for i in (0..cc.size-2) do\r\n answer = [answer,(cc[i+1]-cc[i])/2].max\r\n end\r\n answer = [answer, cc[0], n-1 - cc[-1]].max\r\nend", "def _reduce_589(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def csr; sparam(5); end", "def calc_imc(a, p)\n\taqd = (a * a) / 10000\n\timc = p / aqd\n\tr_imc(imc)\nend", "def _reduce_597(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\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 d(x)\n 2 * ( l(x) + h(x) ) - 1\n end", "def problem_78\n n = 1\n p_cache = [1]\n\n generate = lambda do |k|\n ret = 0\n sign = 0\n Integer.generalized_pentagonals do |gp|\n if k < gp\n false # Need to exit ruby1.8, can't break...\n else\n if sign >= 0\n ret += p_cache[k-gp]\n else\n ret -= p_cache[k-gp]\n end\n sign += (sign == 1) ? -3 : 1 # 4 states + + - -\n end\n end\n p_cache[k] = ret % 100_000_000\n ret\n end\n\n p = 1\n loop do\n r = generate.call(p)\n# puts \"#{p} #{generate.call(p)}\"\n break if r % 1_000_000 == 0\n p += 1\n end\n p\nend", "def matz; end", "def _reduce_473(val, _values, result)\n result = s(:lasgn, val[0])\n \n result\nend", "def solution(n)\n\tval = 0.0\n\tval += 1.0 unless n[0].zero?\n\tval += 2.0 unless n[1].zero?\n\tval += 4.0 unless n[2].zero?\n\tval += 8.0 unless n[3].zero?\n val\n\t\nend", "def getSwifts epsPF, epsPN, sigF, sigN\n\t rtn = Array.new\n\t #first get eps_o using the solver\n\t eps_o = solve(epsPF, epsPN, sigF, sigN)\n\t rtn << eps_o\n\t #back solve for n\n\t n = eps_o + epsPN\n\t rtn << n\n\t #back solve for k\n\t k = sigF / ((eps_o + epsPF)**n)\n\t rtn << k\n\t rtn\n\tend", "def _reduce_439(val, _values, result)\n result = new_dsym val[1]\n \n result\nend", "def solution4(input)\n end", "def tx__x(n, x); 2.0 - tdist(n, x) * 2.0; end", "def f(n, x)\n # $count += 1\n if n == 0\n x <= 0 ? 0 : 1\n elsif x <= 1\n 0\n elsif 1 < x && x <= 1 + $a[n - 1]\n f(n - 1, x - 1)\n elsif x == 2 + $a[n - 1]\n $p[n - 1] + 1\n elsif 2 + ($a[n - 1]) < x && x <= 2 + 2 * $a[n - 1]\n $p[n - 1] + 1 + f(n - 1, x - 2 - $a[n - 1])\n else\n 2 * $p[n - 1] + 1\n end\nend", "def tdist(n, t); p_t(n, t); end", "def sumOfGroup(k)\n return k**3\n \n#Given the fact that Sn=(A1+An)*n/2\n#Given the fact that An= A1+(n-1)d\n#Given the problme that A1 = n(n-1) +1 \n#Then Sn = n*n*n\n\nend", "def lb(t, s, c)\n\n end", "def upc_e_with_composite_symbology; end", "def _reduce_699(val, _values, result)\n result = [:dot, val[0][1]]\n\n result\nend", "def lcs_phase_two(arr)\n return arr.max if arr.max < 0 #edge case\n\n current = 0\n largest = 0\n\n arr.each do |ele|\n current += ele\n current = 0 if current < 0 #bookmark\n largest = current if largest < current\n end\n\n largest\nend", "def sum_of_cubes(a, b)\n=begin \n sum = 0\n (a..b).each do |n|\n sum += n*n*n\n end\n sum\n=end \n (a..b).reduce(0) { |a, b| a + b ** 3 }\nend", "def _reduce_684(val, _values, result)\n result = [ @builder.kwnilarg(val[0][0], val[0][1]) ]\n \n result\nend", "def _reduce_656(val, _values, result)\n result = [ @builder.kwnilarg(val[0], val[1]) ]\n \n result\nend", "def bs(a, b)\n if (b - a) == 1\n if a == 0\n pab = 1\n qab = 1\n else\n pab = ((6 * a)-5) * ((2 * a)-1) * ((6 * a)-1)\n qab = (a * a) * (a * $c3)\n end\n\n tab = pab * (13591409 + (545140134 * a))\n\n if a & 1 == 1\n tab = -tab\n end\n else\n m = 0\n m = ((a + b) / 2).round(0)\n\n pam, qam, tam = bs(a, m)\n pmb, qmb, tmb = bs(m, b)\n\n pab = pam * pmb\n qab = qam * qmb\n tab = qmb * tam + pam * tmb\n end\n return pab, qab, tab\nend", "def erlang_c(m, u)\n d = power_fact(m, u)\n s = 1.0\n (1..(m - 1)).each do |k|\n s += power_fact(k, u)\n end\n d / (d + (1 - u / m) * s)\n end", "def _reduce_427(val, _values, result)\n result = new_dsym val[1]\n \n result\nend", "def _reduce_659(val, _values, result)\n result = [ @builder.kwnilarg(val[0], val[1]) ]\n \n result\nend", "def minimize; end", "def _reduce_479(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def make_lut_flat prob_dist\n lut = []\n pt = 0.0\n prob_dist.map do |ch,pr|\n lut << ((pt*IM).ceil ... ((pt+pr)*IM).ceil).map{ ch }\n pt += pr\n end\n lut.flatten!\nend", "def index(p0) end", "def index(p0) end", "def hw11_3()\n p = [0, 2]\n q = [15, 6]\n n = 23\n a = 1\n current = {:r => p, :a => 1, :b => 0}\n for i in (0..20)\n print \"$R_#{i}$ & (#{current[:r][0]}, #{current[:r][1]}) & #{current[:a]} & #{current[:b]} \\\\\\\\\\n\"\n if current[:r][1] < 9\n if current[:r][0] == p[0] && current[:r][1] == p[1]\n current[:r] = ec_double_point(current[:r][0], current[:r][1], n, a)\n else\n current[:r] = ec_add_point(current[:r][0], current[:r][1], p[0], p[1], n)\n end\n current[:a] += 1\n elsif current[:r][1] < 17\n current[:r] = ec_add_point(current[:r][0], current[:r][1], q[0], q[1], n)\n current[:b] += 1\n else\n current[:r] = ec_double_point(current[:r][0], current[:r][1], n, a)\n current[:a] *= 2\n current[:b] *= 2\n end\n end\n\n puts 27 * 4 % 29\n print ec_multiply_point(11, 9, 23, 1, 7)\n print \"\\n\"\n print ec_multiply_point(15, 6, 23, 1, 3)\nend", "def sk! ; k! ; s! ; end", "def dft(inv,array)\r\n elem = Array.new\r\n array.each{|e| elem.push( Complex.new(e,0) ) }\r\n ret=Array.new\r\n n=elem.size\r\n a=Math::PI*2.0/n\r\n a=-a if inv \r\n n.times{|i|\r\n ret[i]=Complex.new(0,0)\r\n n.times{|j|\r\n ret[i] = ret[i] + ( elem[j] * Complex.new(Math.cos(a*i*j),-Math.sin(a*i*j)) )\r\n }\r\n ret[i] = ret[i] * (1.0/n) if inv\r\n }\r\n return ret\r\nend", "def nth_octagonal(nth)\n nth * (3 * nth - 2)\nend", "def _reduce_524(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n\n result\nend", "def _reduce_653(val, _values, result)\n result = [ @builder.kwnilarg(val[0], val[1]) ]\n \n result\nend", "def algorithm=(_); end", "def algorithm=(_); end", "def algorithm=(_); end", "def algorithm=(_); end", "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 sw(t, s, c)\n\n end", "def _reduce_522(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n\n result\nend", "def sor(n, a, b, x0, w, error, n_max)\n n = n - 1\n\n x = Array.new(n + 1)\n for k in (0..n_max)\n sumatoria = (1..n).inject(0) { |sum, j| sum + a[0][j] * x0[j] }\n x[0] = (1 - w) * x0[0] + w * (b[0] - sumatoria).fdiv(a[0][0])\n\n (1..n - 1).each do |i|\n sumatoria_1 = (0..i - 1).inject(0) { |sum, j| sum + a[i][j] * x[j] }\n sumatoria_2 = (i + 1..n).inject(0) { |sum, j| sum + a[i][j] * x0[j] }\n x[i] = (1 - w) * x0[i] + w * (b[i] - sumatoria_1 - sumatoria_2).fdiv(a[i][i])\n end\n\n sumatoria = (0..n - 1).inject(0) { |sum, j| sum + a[n][j] * x[j] }\n x[n] = (1 - w) * x0[n] + w * (b[n] - sumatoria).fdiv(a[n][n])\n\n resta = x.map.with_index { |xi, i| xi - x0[i] }\n modulo = Math::sqrt(resta.inject(0) { |sum, i| sum + i ** 2 })\n if modulo < error\n puts \"Una solucion aproximada es X = #{x}.\"\n return x\n end\n\n x0.replace(x)\n end\n\n puts \"Se alcanzo el numero maximo de iteraciones n_max pero no la tolerancia.\"\nend", "def calcpi()\n\n pi = 0.0\n rep = $PI_ITER\n \n while rep >= 0\n \n pi += 1.0 / pow(16.0, rep) * (4.0 / (8.0 * rep + 1.0) - 2.0 / (8.0 * rep + 4.0) - 1.0 / (8.0 * rep + 5.0) - 1 / (8.0 * rep + 6.0))\n rep -= 1\n\t\t\n end\n\t\n return pi\nend", "def ctr; sparam(3); end" ]
[ "0.61594343", "0.5719489", "0.56951886", "0.5690199", "0.56839776", "0.56839776", "0.56839776", "0.5676464", "0.56716794", "0.5665984", "0.5606352", "0.55877817", "0.5523351", "0.5517822", "0.5509652", "0.54813147", "0.54780513", "0.5471747", "0.5448934", "0.54439324", "0.54437596", "0.54322594", "0.54189765", "0.54078525", "0.54065734", "0.5398402", "0.5397492", "0.53923947", "0.53810453", "0.53670913", "0.53642726", "0.53595346", "0.53557235", "0.53395903", "0.5334024", "0.53323233", "0.53264934", "0.53241146", "0.53241146", "0.5319862", "0.5314562", "0.53137493", "0.53086376", "0.53086376", "0.53086376", "0.53086376", "0.53086376", "0.53077275", "0.5307192", "0.5307154", "0.5298349", "0.52914715", "0.5276194", "0.5273803", "0.5273008", "0.5269356", "0.5268642", "0.5260451", "0.52512044", "0.5246524", "0.5244314", "0.52425766", "0.52368605", "0.5232657", "0.52216256", "0.5214683", "0.52142525", "0.5211645", "0.52041376", "0.52013236", "0.5193711", "0.5187108", "0.5185862", "0.51661634", "0.5164834", "0.5158812", "0.5158708", "0.51576704", "0.5153724", "0.5152793", "0.5145826", "0.5145483", "0.5141671", "0.5138892", "0.5138892", "0.5129369", "0.5129264", "0.5126399", "0.5125529", "0.51222163", "0.51213", "0.5119331", "0.5119331", "0.5119331", "0.5119331", "0.51173514", "0.51163346", "0.5115974", "0.51122105", "0.5112154", "0.5110776" ]
0.0
-1
Creates and initializes a new instance of the AdaptiveNetworkHardenings class.
def initialize(client) @client = client end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize( config={} )\n\t\t\t# Node Metadata\n\t\t\t@uuid = config[:uuid] || nil\n\t\t\t# Network Variables\n\t\t\t@host = config[:host] || '127.0.0.1'\n\t\t\t@port = config[:port] || '3333'\n\t\t\t@name = config[:name] || config[:host]\n\t\t\t@description = config[:description] || @name\n\n\t\t\t@socket = config[:socket] || nil\n\t\t\t@status = :disconnected\n\t\t\t@ssl_on = config[:ssl_on] || false\n\n\t\t\t# Storage values\n\t\t\t@hive_version\t= config[:hive_version]\n\t\t\t@created_at\t= config[:created_at]\n\t\t\t@updated_at\t= config[:updated_at]\n\t\t\t@latency\t= config[:latency]\n\t\t\t@known_peers\t= config[:known_peers]\n\n\t\t\t# Lists\n\t\t\t@networks = []\n\n\t\t\t# Runtime stats\n\t\t\t@stats = {\n\t\t\t\t:connect_attempt => nil,\n\t\t\t\t:connect_success => nil,\n\t\t\t\t:lastread => nil,\n\t\t\t\t:lastwrite => nil\n\t\t\t}\n\n\t\t\t# Log Iniitalization\n\t\t\t#\tswdebug \"Swarm node:#{uuid} initialized.\"\n\n\t\t\treturn self\n\t\tend", "def initialize(height, branching_factor, approx)\n @height = height #get inputs\n @height_count = height\n @branching_factor = branching_factor#get inputs\n @approx = approx#get inputs\n @node_array = []#initialise empty array of nodes\n @node_type = true # set to build daughters first\n get_t_value#get random t_value\n @root_node = RootNode.new\n @root_node.t_value = @t_value # give starting t value to buid tree from\n @node_array << @root_node# to be checked in further building of tree\n build_connecting_nodes(@root_node,@branching_factor)#build first daughters\n @node_type = !@node_type #change to enter next values of interior nodes\n @height_count = @height_count-1 #one layer done\n build_rest_of_tree()\n end", "def initialize\n @id = self.class.uid\n @connections = Connections.new({}, {}, {})\n @error = Error.new(0.0, 0.0, 0.0)\n @trace = Trace.new({}, {}, {})\n\n @state = @old = @activation = 0.0\n @selfconnection = Synaptical::Connection.new(self, self, 0.0)\n @squash = Synaptical::Squash::Logistic\n @neighbors = {}\n @bias = rand * 0.2 - 0.1\n end", "def new\n @host = Host.new\n end", "def initialize(weight, capacity)\n @weight, @capacity = weight, capacity\n end", "def initialize(capacity)\n @capacity = capacity\n @hash = {}\n @dlink = DLinkedList.new capacity\n end", "def initialize( floating_points: false )\n @weights = []\n @max_weight = BASE_WEIGHT\n @floating_points = floating_points\n end", "def initialize(network_structure)\n @structure = network_structure\n @initial_weight_function = lambda { |n, i, j| ((rand 2000)/1000.0) - 1}\n @propagation_function = lambda { |x| 1/(1+Math.exp(-1*(x))) } # lambda { |x| Math.tanh(x) } #\n @derivative_propagation_function = lambda { |y| y*(1-y) } # lambda { |y| 1.0 - y**2 } #\n @disable_bias = false\n @learning_rate = 0.25\n @momentum = 0.1\n end", "def initialize\n @ballot = Nps.configuration.ballot_adaptor.new\n end", "def initialize(backend, server, weight)\n @backend = backend\n @server = server\n @weight = weight\n end", "def initialize\n @hostname = Socket.gethostname()\n @dns_port = 53\n @ttl = 7200\n @priority = 1\n @weight = 5\n @resolver = nil\n @ipv4 = nil\n @ipv6 = nil\n @sleep_time = 60\n @max_dns_response_time=10\n @zone = \"\"\n @transport = :udp\n end", "def createPowerEfficient\n stations = createSpaceStation\n \n return PowerEfficientSpaceStation.new(stations[0])\n end", "def initialize\n super\n @height = 1.60\n @weight = 52\n @id_bis = 0\n @type1 = 1\n @type2 = 1\n @base_hp = @base_atk = @base_dfe = @base_spd = @base_ats = @base_dfs = 1\n @ev_hp = @ev_atk = @ev_dfe = @ev_spd = @ev_ats = @ev_dfs = 0\n @move_set = []\n @tech_set = []\n @evolution_level = 0\n @evolution_id = 0\n @special_evolution = nil\n @exp_type = 1\n @base_exp = 100\n @base_loyalty = 0\n @rareness = 0\n @female_rate = 60\n @abilities = [0, 0, 0]\n @breed_groupes = [15, 15]\n @breed_moves = []\n @master_moves = []\n @hatch_step = 1_000_000_000\n @items = [0, 0, 0, 0]\n @baby = 0\n end", "def construct_advertisement\n msg = Protocol::PromotionAdvertisement.new\n msg.ctime = DateTime.now\n msg.guid = @driver.guid\n msg.name = @driver.name\n msg.connection_count = @supernode_table.size\n Routing.update_advertisement_from_routing(msg,@driver.routing)\n msg\n end", "def initialize(config)\n require File.join(File.dirname(__FILE__), \"neural_net\")\n ActiveRecord::Base.establish_connection(config)\n Persistence.setup_database(ActiveRecord::Base.connection)\n @nn = Searching::SearchNet.new(config)\n @weights = [\n [1.0, :location_score ],\n [1.0, :frequency_score],\n [1.0, :page_rank_score],\n [1.0, :link_text_score]\n ]\n end", "def initialize options = {}\n @scripts = {}\n @networks = []\n @config_path = options[:config_path]\n @environment = options[:environment] || ENVIRONMENT\n @verbose = options[:verbose] == true\n\n raise ConfigError, 'missing config file path in :config_path option' unless @config_path\n\n load_config!\n\n networks = @config['blur']['networks']\n\n if networks&.any?\n networks.each do |network_options|\n @networks.<< Network.new network_options, self\n end\n end\n\n trap 2, &method(:quit)\n end", "def initialize args = {}\n hash_make args, Network::ARG_SPECS\n \n # ensure that all sample rates match given rate\n @blocks.each do |block_name, block|\n if block.sample_rate != @sample_rate\n raise ArgumentError, \"block sample rate #{block.sample_rate} does not match network sample rate #{@sample_rate}\"\n end\n end\n \n @links.each do |link|\n link.activate\n end\n end", "def gen_airspan_config\n # first of all we declare the main switch element\n # and all the sources/sinks that we're going to use\n config = \"switch :: EtherSwitch; \\\nfrom_bs :: FromDevice(#{@bsif}, PROMISC true); \\\nto_bs :: ToDevice(#{@bsif}); \\\nfrom_net :: FromDevice(#{@netif}, PROMISC true); \\\nto_net :: ToDevice(#{@netif}); \"\n\n # then the two filter compounds for whitelisting\n # clients based on their mac address\n filter_first_output = []\n filter_second_output = []\n network_filter = 'filter_from_network :: { '\n bs_filter = 'filter_from_bs :: { '\n i = 1\n @mobiles.each_key do |mac|\n network_filter << \"filter_#{i} :: HostEtherFilter(#{mac}, DROP_OWN false, DROP_OTHER true); \"\n bs_filter << \"filter_#{i} :: HostEtherFilter(#{mac}, DROP_OWN true, DROP_OTHER false); \"\n filter_first_output << \"filter_#{i}[0]\"\n filter_second_output << \"filter_#{i}[1]\"\n i += 1\n end\n network_filter << 'input -> filter_1; '\n network_filter << filter_first_output.join(', ') << ' -> output; '\n network_filter << filter_second_output.join(' -> ') << ' -> Discard; } '\n bs_filter << 'input -> filter_1; '\n bs_filter << filter_second_output.join(', ') << ' -> output; '\n bs_filter << filter_first_output.join(' -> ') + ' -> Discard; } '\n config << network_filter << bs_filter\n\n # finally we plug everything into the switch\n config << \"from_net -> filter_from_network -> [0]switch[0] -> Queue -> to_net; \\\nfrom_bs -> filter_from_bs -> [1]switch[1] -> Queue -> to_bs;\"\n end", "def initialize_host\n self.host = (Host.find(:name => settings['host']) || Host.new(:name => settings['host']))\n\n current_host_group_names = (host.host_groups || []).map(&:name)\n current_template_names = (host.templates || []).map(&:name)\n\n host_groups_to_add, templates_to_add = [], []\n\n (self.host_groups || []).each do |hg|\n host_groups_to_add << hg unless current_host_group_names.include?(hg.name)\n end\n\n (self.templates || []).each do |t|\n templates_to_add << t unless current_template_names.include?(t.name)\n end\n\n host.host_groups = ((host.host_groups || []) + host_groups_to_add).flatten.compact.uniq\n host.templates = ((host.templates || []) + templates_to_add).flatten.compact.uniq\n host.save\n host\n end", "def setup_network(word_ids, url_ids)\n # value lists\n @word_ids = word_ids\n @hidden_ids = get_all_hidden_ids(word_ids, url_ids)\n @url_ids = url_ids\n\n # node outputs\n @all_in = @word_ids.map { |w| 1.0 }\n @all_hidden = @hidden_ids.map { |h| 1.0 }\n @all_out = @url_ids.map { |u| 1.0 }\n\n # create weights matrices\n @weights_in = word_ids.map do |word_id|\n hidden_ids.map do |hidden_id|\n get_strength(word_id, hidden_id, 0)\n end\n end\n\n @weights_out = hidden_ids.map do |hidden_id|\n url_ids.map do |url_id|\n get_strength(hidden_id, url_id, 1)\n end\n end\n end", "def initialize(hardware_type, options = {})\n @hardware_type = hardware_type\n\n unless HARDWARE_TYPES.include?(@hardware_type) then\n raise NotValidHardware.new(\"The requested hardware type is non-existant or not defined.\")\n end\n unless options[:ip] then\n raise ArgumentError.new(\"An IP address for reaching the device is required.\")\n end\n\n @config = options[:config] || UBNT::Configuration.new(@hardware_type)\n @ip = options[:ip] || \"192.168.1.20\"\n @user = options[:user] || \"ubnt\"\n @password = options[:password] || \"ubnt\"\n\n @static_arp_needed = (true if options[:static_arp_needed]) || false\n @mac = options[:mac] || nil\n @management_interface = options[:management_interface] || nil\n if @static_arp_needed and not ( @mac and @management_interface ) then raise ArgumentError(\"A device that needs static ARP also needs a MAC and management interface\")\n\n @ssh_connection = nil\n end\n end", "def initialize(graph, damping_factor = 0.85, iterations = 100)\n @graph = graph.to_h\n # { :p1 => [:p2], :p2 => [:p1,:p3], :p3 => [:p2] }\n @outlinks = Hash.new { |_, key| @graph[key].size }\n # { :p1 => 1, :p2 => 2, :p3 => 1 }\n @inlinks = Hash.new { |_, key| inlinks(key) }\n # { :p1 => [:p2], :p2 => [:p1,:p3], :p3 => [:p2] }\n @ranks = Hash.new(1.0 / @graph.size)\n # { :p1 => 1/3, :p2 => 1/3, ... }\n @sinknodes = @graph.select { |_, v| v.empty? }.keys\n # sinknodes aka dead-ends, have no outlink at all\n\n @damper = damping_factor\n @iterations = iterations\n end", "def initialize(eth_type: nil, ipv4_destination: nil, ipv4_source: nil,\n ipv6_source: nil, ipv6_destination: nil, ipv6_flabel: nil,\n ipv6_ext_header: nil, ethernet_destination: nil, ethernet_source: nil,\n in_port: nil, in_physical_port: nil, ip_protocol_num: nil, ip_dscp: nil,\n ip_ecn: nil, tcp_source_port: nil, tcp_destination_port: nil,\n udp_source_port: nil, udp_destination_port: nil, icmpv4_type: nil,\n icmpv4_code: nil, icmpv6_type: nil, icmpv6_code: nil,\n arp_op_code: nil, arp_source_ipv4: nil, arp_target_ipv4: nil,\n arp_source_hardware_address: nil, arp_target_hardware_address: nil,\n vlan_id: nil, vlan_pcp: nil, sctp_destination: nil, sctp_source: nil,\n mpls_label: nil, mpls_tc: nil, mpls_bos: nil, tunnel_id: nil,\n metadata: nil, metadata_mask: nil)\n @eth_type = eth_type\n @ipv4_dst = ipv4_destination\n @ipv4_src = ipv4_source\n @ipv6_dst = ipv6_destination\n @ipv6_src = ipv6_source\n @ipv6_flabel = ipv6_flabel\n @ipv6_ext_hdr = ipv6_ext_header\n @ethernet_dst = ethernet_destination\n @ethernet_src = ethernet_source\n @in_port = in_port\n @in_phy_port = in_physical_port\n @ip_proto = ip_protocol_num\n @ip_dscp = ip_dscp\n @ip_ecn = ip_ecn\n @tcp_src_port = tcp_source_port\n @tcp_dst_port = tcp_destination_port\n @udp_dst_port = udp_destination_port\n @udp_src_port = udp_source_port\n @icmpv4_type = icmpv4_type\n @icmpv4_code = icmpv4_code\n @icmpv6_type = icmpv6_type\n @icmpv6_code = icmpv6_code\n @arp_op_code = arp_op_code\n @arp_src_ipv4 = arp_source_ipv4\n @arp_tgt_ipv4 = arp_target_ipv4\n @arp_src_hw_addr = arp_source_hardware_address\n @arp_tgt_hw_addr = arp_target_hardware_address\n @vlan_id = vlan_id\n @vlan_pcp = vlan_pcp\n @sctp_dst = sctp_destination\n @sctp_src = sctp_source\n @mpls_label = mpls_label\n @mpls_tc = mpls_tc\n @mpls_bos = mpls_bos\n @tunnel_id = tunnel_id\n @metdata = metadata\n @metadata_mask = metadata_mask\n end", "def build_network()\r\n @layers = []\r\n # Create the hidden layers, num_per_hiddenX(num_inputs+1) matrices.\r\n # The +1 accounts for a bias vector that is horizontally concatenated\r\n # upon creation of the layer.\r\n @num_hidden_layers.times do\r\n # Add a new layer (bias vector is concatenated in the creation\r\n # method).\r\n @layers << build_layer(@max_weight, @num_per_hidden, @num_inputs)\r\n end\r\n # Create output layer, an num_outputsX(num_per_hidden+1) matrix\r\n # (again, +1 accounts for the bias).\r\n @layers << build_layer(@max_weight, @num_outputs, @num_per_hidden)\r\n # Calculate weights\r\n weights # produces attribute @weights upon first invocation\r\n @num_weights = @weights.size\r\n end", "def wireless\n @wireless ||= Wireless.new self\n end", "def wireless\n @wireless ||= Wireless.new self\n end", "def initialize(def_capacity=DEFAULT_CAPACITY)\n @bikes = []\n @def_capacity = def_capacity\n @broken_bikes = []\n end", "def initialize\n\n @connection_options = Baton.configuration.connection_opts\n @amqp_hosts = Baton.configuration.amqp_host_list\n\n logger.info \"Connecting to AMQP host: #{@connection_options[:host]}\"\n\n @connection = AMQP.connect(@connection_options)\n @channel = AMQP::Channel.new(@connection)\n @channel.auto_recovery = true\n\n # Not everything needs an input exchange, default to the \"\" exchange if there isn't\n # one defined in the config (monitors for example)\n Baton.configuration.exchange = '' if Baton.configuration.exchange.nil?\n\n # Create the exchanges\n @exchange_in = channel.direct(Baton.configuration.exchange)\n @exchange_out = channel.direct(Baton.configuration.exchange_out)\n\n # Attach callbacks for error handling\n @connection.on_tcp_connection_loss(&method(:handle_tcp_failure))\n @connection.on_skipped_heartbeats(&method(:handle_tcp_failure))\n @channel.on_error(&method(:handle_channel_exception))\n end", "def initialize width, height, cycle_detection = true, seed_network = nil\n \n @randomizer = proc {rand(2)}\n \n @cycle_detection_enabled = cycle_detection\n \n @width = width\n @height = height\n\n if seed_network\n self.network = seed_network\n else\n generate_network\n end\n \n reset_history\n \n end", "def initialize\n @check_model = nil\n @use_airbrake = false\n end", "def initialize(opts={})\n self.learning_rate_param = opts[:learning_rate] || 0.20\n\n self.input_size = opts[:input]\n opts[:hidden] = [opts[:hidden]] unless opts[:hidden].is_a? Array\n self.hidden_size = opts[:hidden] || [@input_size] # default: one hidden layer, same size as input layer\n self.output_size = opts[:output] || @input_size\n self.num_layers = opts[:hidden].count\n\n create_layers!\n end", "def prepare_network\n @neural_net = RubyFann::Standard.new(num_inputs: @nuerons_number,\n hidden_neurons: [(2 * @nuerons_number) / 3],\n num_outputs: @nuerons_number)\n end", "def initialize(network_range)\n @network_range = network_range\n generate_pool\n end", "def initialize(host, port)\n @addon = Addon.new host, port\n @cmd = Cmd.new host, port\n @echo = Echo.new host, port\n @espf = Espf.new host, port\n @print = Print.new host, port\n @setting = Setting.new host, port\n @supervision = Supervision.new host, port\n end", "def initialize(opts = {})\n @opts = opts.with_indifferent_access\n @hydra = Typhoeus::Hydra.new(max_concurrency: 80) # hail hydra\n end", "def createBetaPowerEfficient\n stations = createSpaceStation\n \n return BetaPowerEfficientSpaceStation.new(stations[0])\n end", "def initialize(opts)\n\t\t\t\t# self.config = objectify_opts if opts.is_a?(Hash)\n\t\t\t\tself.config = opts.dup\n\t\t\t\tself.colony ||= []\n\t\t\t\tself.bee = SwarmP2P::Bee.new(config)\n\t\t\t\tconfig.colonies.each{ |net_opts|\n\t\t\t\t\tadd_colony(bee,net_opts)\n\t\t\t\t}\n\t\t\tend", "def initialize(demands=0, numChanges=2, duration=120)\n @duration=duration\n @numChanges=numChanges\n @maxBitrate=5000\n \n @receiverApps = Orbit::ApplicationContainer.new\n @itgManagers = Orbit::ApplicationContainer.new\n @daemons = Orbit::ApplicationContainer.new\n\n self.DefProperties\n\n @algo=property.algo.to_s\n @maxChannelChanges=property.maxNumChannelChanges\t\n \n #if (property.demands!=nil)\n @demands=Array.new\n property.demands.to_s.split(\",\").each do |demand|\n\t@demands << Float(demand)\n end\n #end\n \n if (property.initialDemands.to_s!=\"\")\n @initial_demands=Array.new\n property.initialDemands.to_s.split(\",\").each do |demand|\n\t@initial_demands << Float(demand)\n end\n end\n\n if (property.dontassign.to_s!=\"\")\n\t@assign=false\n else\n\t@assign=true\n end\n\n @extraDelay=0\n if (property.extraDelay.to_s!=\"\")\n\t@extraDelay=property.extraDelay\n end\n \n @protocols=property.protocol.to_s.split(\",\")\n \n end", "def initialize(endpoint, adapter, options = nil)\n @endpoint = endpoint\n @adapter = adapter\n @serializer = (options && options[:serializer]) || self.class.serializer\n @links_parser = (options && options[:links_parser]) || Sawyer::LinkParsers::Hal.new\n @allow_undefined_methods = (options && options[:allow_undefined_methods])\n end", "def initialize(neural_inputs: nil,\n neural_outputs: nil,\n neural_hidden: nil,\n parameters: NeatSettings.new,\n &block)\n super(self)\n @gaussian = Distribution::Normal.rng\n @population_history = []\n @evolver = Evolver.new self\n @expressor = Expressor.new self\n\n @neuron_catalog = Neuron::neuron_types.clone\n @neural_inputs = neural_inputs\n @neural_outputs = neural_outputs\n @neural_hidden = neural_hidden\n\n # Default classes for population and operators, etc.\n @population_class = NEAT::Population\n @evaluator_class = NEAT::Evaluator\n @expressor_class = NEAT::Expressor\n @evolver_class = NEAT::Evolver\n\n # Handle the parameters parameter. :-)\n @parms = unless parameters.kind_of? String\n parameters\n else # load it from a file\n open(parameters, 'r') { |fd| YAML::load fd.read }\n end\n block.(self) unless block.nil?\n end", "def initialize opts={}\n @recycle_count = 0\n @recycle_limit = opts[:recycle_limit] || 3\n @deck = opts[:deck] || PlayingCards.std_deck(KlondikeCard).shuffle\n @discard = CardArray.new\n homes = {\n :hearts => KlondikeHome.new,\n :diamonds => KlondikeHome.new,\n :spades => KlondikeHome.new,\n :clubs => KlondikeHome.new\n }\n @stacks = (1..7).collect do |st|\n ks = KlondikeStack.new\n st.times {ks.push d.shift}\n ks\n end\n end", "def build_network_object\n OOLog.info(\"network_address: #{@address}\")\n address_space = Azure::ARM::Network::Models::AddressSpace.new\n address_space.address_prefixes = [@address]\n\n ns_list = Array.new\n for i in 0..@dns_list.length-1\n OOLog.info('dns address[' + i.to_s + ']: ' + @dns_list[i].strip)\n ns_list.push(@dns_list[i].strip)\n end\n dhcp_options = Azure::ARM::Network::Models::DhcpOptions.new\n if ns_list != nil\n dhcp_options.dns_servers = ns_list\n end\n\n subnet = AzureNetwork::Subnet.new(@creds, @subscription)\n subnet.sub_address = @sub_address\n subnet.name = @name\n sub_nets = subnet.build_subnet_object\n\n virtual_network_properties =\n Azure::ARM::Network::Models::VirtualNetworkPropertiesFormat.new\n virtual_network_properties.address_space = address_space\n virtual_network_properties.dhcp_options = dhcp_options\n virtual_network_properties.subnets = sub_nets\n\n virtual_network = Azure::ARM::Network::Models::VirtualNetwork.new\n virtual_network.location = @location\n virtual_network.properties = virtual_network_properties\n\n virtual_network\n end", "def initialize(n, h, w)\n @name = n # The @ symbol beforehand defines an instance variable\n @height = h\n @weight = w\n end", "def initialize(prefix, environment, node_ip, graphite_hosts, datacenter, environment_name)\n @prefix = prefix\n @environment = environment\n @node_ip = node_ip\n @graphite_hosts = graphite_hosts\n @datacenter = datacenter\n @environment_name = environment_name\n end", "def initialize(capacity = DEFAULT_CAPACITY)\n @capacity = capacity\n @bikes = []\n\n # @bikes << Bike.new\n end", "def initialize(length, times, hosts, name)\n\t\t@length = length\n\t\t@times = times\n\t\t@hosts = hosts\n\t\t@name = name\n\tend", "def initialize()\n @remote_host = \"192.168.1.1\"\n @rsa_key = \"~/.ssh/router_rsa\"\n @dns_source = \"http://www.netflixdnscodes.com\"\n end", "def initialize\n @cards = full_deck.shuffle\n @used = []\n @inhand = []\n @hands = []\n end", "def initialize(adapter)\n @adapter = Nunes::Adapter.wrap(adapter)\n end", "def initialize\n # Set default values for external dependencies.\n @para_erc_learner = ParadigmErcLearning.new\n @feature_learner = FeatureValueLearning.new\n @grammar_tester = GrammarTest.new\n end", "def initialize(name, comment, properties, attributes, input, output, in_out,\n stat, temp, networks)\n @name = name\n @comment = comment\n @properties = properties\n @attributes = attributes\n @input = input\n @output = output\n @in_out = in_out\n @stat = stat\n @temp = temp\n @networks = networks\n end", "def initialize(n, h, w)\n @name = n\n @height = h\n @weight = w\n end", "def initialize(n, h, w)\n @name = n\n @height = h\n @weight = w\n end", "def initialize(options = { })\n\t\t\t# Assumes that there is a file called \"tuneable.txt\" in a \"data\" subdirectory of\n\t\t\t# the superdirectory of this script\n\t\t\tdefault_tuneable_file = File.open(File.dirname(File.expand_path(__FILE__)) + \"/../data/tuneable.txt\")\n @options = options\n self.prime_weights =\toptions[:prime_weights] || PRIMES.dup\n @pc_only = \toptions[:pc_only] || false\n @tuneable_file = \toptions[:tuneable_file] || default_tuneable_file\n \n pattern = /(\\d+)\\/(\\d+)/\n # Reads in the entire list of tuneable intervals from a file\n File.open(@tuneable_file) do |intervals|\n @tuneable = intervals.readlines.inject([]) do |tuneable, line|\n\t\t\t\t\t# If the line doesn't contain a matching pattern, it skips over that line by\n\t\t\t\t\t# returning the unaltered memo.\n\t\t\t\t\tpattern =~ line ? (tuneable << HD::Ratio[$1.to_i, $2.to_i]) : tuneable\n end\n end\n end", "def SetUpNodes\n \n @nodes.each do |node|\n\n if node.type==\"R\" or node.type==\"A\" or node.type==\"G\"\n \t\n\tSetMode(node)\n\n\tEnforceChannels(node)\n\t\n\tSetEssid(node) # after this stage, with omf-5.4 the wlan interface is created.\n\t\n\tSetWifiPower(node)\n\n\tSetMtu(node)\n\t\n\tSetIp(node)\n\t\n\tNode(node.id).exec(\"sysctl -w net.ipv4.conf.all.send_redirects=0\")\n \n EnforceRates(node)\n\t\n end\n #final settings\n #self.GetGroupInterface(node, ifn).txqueuelen=\"10\"\n end\n end", "def initialize (capacity=DEFAULT_CAPACITY)\n\tplane = Plane.new\n\t@planes = [] \n\t@capacity = capacity\n\tend", "def initialize( alpha=2.0, beta=0.5, default_weight=2.0 )\n @model = Model.new\n @alpha = alpha\n @beta = beta\n @default_weight = default_weight\n end", "def initialize(inputNodes, hiddenNodes, outputNodes, learningRate=0.3, momentum=0.2)\n # Make sure we add the bias node to the input\n @inputNodes = inputNodes + 1\n @hiddenNodes = hiddenNodes\n @outputNodes = outputNodes\n\n @learningRate = learningRate\n @momentum = momentum\n\n @w_1 = NeuralNetwork::create_matrix(@inputNodes, @hiddenNodes, 0.0)\n @w_2 = NeuralNetwork::create_matrix(@hiddenNodes, @outputNodes, 0.0)\n \n # Randomize the values of Nthe nodes [-0.5, 0.5]\n @w_1.map! { |arr| arr.map { |v| rand(-0.5..0.5) } }\n @w_2.map! { |arr| arr.map { |v| rand(-0.5..0.5) } }\n\n # It helps to store the current state of node activations\n @activation_input = [1.0] * @inputNodes\n @activation_hidden = [1.0] * @hiddenNodes\n @activation_output = [1.0] * @outputNodes\n\n @din = NeuralNetwork::create_matrix(@inputNodes, @hiddenNodes, 0.0)\n @dout = NeuralNetwork::create_matrix(@hiddenNodes, @outputNodes, 0.0)\n\n puts \"\\n================================================================================================\\n[+]Weights from input to hidden nodes [#{@inputNodes}x#{@hiddenNodes}] has been initialized with small random values\"\n puts \"[+]Weights from hidden to output nodes [#{@hiddenNodes}x#{@outputNodes}] has been nitialized to small random values\\n================================================================================================\\n\"\n\n puts \"Neural network initialized with values \\n \\t Input Nodes:[{#{@inputNodes}]\\t Hidden Nodes: [#{@hiddenNodes}]\\t Output Nodes: [#{@outputNodes}]} \\n--------------------------------------------------------------------------------\\n\"\n puts \"\"\n\n end", "def initialize(capacity=DEFAULT_CAPACITY)\n @capacity = capacity\n @bikes = []\n end", "def initialize(n, h, w) #changed name to n; added h & w\n @name = n\n @height = h\n @weight = w\n end", "def new\n @emergencium = Emergencium.new\n end", "def initialize\n @consistency_checker = ConsistencyChecker.new\n @grammar_tester = GrammarTest.new\n @fsf_learner = FewestSetFeatures.new\n @mmr_learner = MaxMismatchRanking.new\n @step_type = INDUCTION\n end", "def initialize(nodes, edges)\n super()\n self.nodes = nodes\n self.edges = edges.map { |e| Edge.new(e[0], e[1], e[2]) }\n\n self.build\n end", "def initialize(bandwidth: 1.0, max_iter: 500, tol: 1e-4)\n super()\n @params = {\n bandwidth: bandwidth,\n max_iter: max_iter,\n tol: tol\n }\n end", "def initialize(n, h, w)\r\n @name = n #@ symbol is called an instance variable\r\n @height = h\r\n @weight = w\r\n end", "def initialize\n @mode = game_set_mode\n @turn_obj = Turn.new\n @solution_obj = Solution.new\n @human_solution_obj = HumanSolution.new\n @computer_solve_obj = ComputerSolver.new\n end", "def initialize(adapter); end", "def initialize( real_domains = false, skip_mx_test = false )\n @use_real_domains = real_domains\n @skip_mx_test = skip_mx_test\n @random_sld_patterns = DefaultWeightedRandomSldPatterns\n @random_sld_letters = DefaultRandomSldLetters\n @random_sld_consonants = DefaultRandomSldConsonants\n @random_sld_vowels = DefaultRandomSldVowels\n end", "def initialize\n @silent = false\n self.deck = create_deck\n self.player = Player.new\n self.player.strategy = Strategy.new(self) #default player strategy\n self.dealer = Dealer.new(\"Dealer\")\n self.dealer.strategy = DealerStrategy.new(self)\n\n @last_hand = false\n end", "def initialize(config, remote_host, remote_port)\n @config = config\n @remote_nodes = []\n @local_node = Node.new(@config[\"local_host\"], @config[\"local_port\"])\n @need_token = false\n @has_token = false\n @ricart_agrawala = RicartAgrawala.new(self)\n join_network(remote_host, remote_port)\n start_server\n end", "def initialize(azure_config, spec)\n unless spec.is_a?(Hash)\n raise ArgumentError, 'Invalid spec, Hash expected, ' \\\n \"'#{spec.class}' provided\"\n end\n\n @logger = Bosh::Clouds::Config.logger\n @azure_config = azure_config\n @networks = []\n @vip_network = nil\n\n logger.debug \"networks: '#{spec}'\"\n spec.each_pair do |name, network_spec|\n network = nil\n network_type = network_spec['type'] || 'manual'\n\n case network_type\n when 'dynamic'\n network = DynamicNetwork.new(@azure_config, name, network_spec)\n\n when 'manual'\n network = ManualNetwork.new(@azure_config, name, network_spec)\n\n when 'vip'\n cloud_error(\"More than one vip network for '#{name}'\") if @vip_network\n @vip_network = VipNetwork.new(@azure_config, name, network_spec)\n\n else\n cloud_error(\"Invalid network type '#{network_type}' for Azure, \" \\\n \"can only handle 'dynamic', 'vip', or 'manual' network types\")\n end\n\n # @networks[0] is always the primary network.\n #\n # The network with 'default: [\"gateway\"]' will be the primary network.\n # For single network, 'default: [\"gateway\"]' can be ignored, it will automatically picked as primary network.\n #\n unless network.nil?\n if network.has_default_gateway?\n # make it the first network, so that it is the Primary\n @networks.insert(0, network)\n else\n @networks.push(network)\n end\n end\n end\n\n cloud_error('At least one dynamic or manual network must be defined') if @networks.empty?\n end", "def initialize(settings={}, &block)\n @context = settings[:context]\n @target = settings[:target]\n @label = settings[:label]\n @setup = settings[:setup]\n @skip = settings[:skip]\n @tags = settings[:tags]\n\n @advice = @context ? @context.advice.dup : TestAdvice.new\n\n @tests = []\n @domain = domain_class.new(self)\n\n validate_settings\n\n evaluate(&block)\n end", "def initialize(capacity = DEFAULT_CAPACITY)\n @capacity = capacity\n @bikes = []\n end", "def initialize(n,h,w)\n @name = n #@name -- > Instance variable - scoped at the object level.\n #It is a variable that exists as long as the object instance exists\n @height = h\n @weight = w\n end", "def initialize(name, capacity)\n @name = name\n @capacity = capacity\n @passengers = []\n end", "def initialize(name, opts={})\n super(name, opts)\n @weight = opts[:weight] || 1.0\n @assumed_probability = opts[:assumed_probability] || 0.1\n\n end", "def initialize(name)\n super\n @can_add = BattlerRequirement.new\n @can_remove = BattlerRequirement.new\n\n # @exp = {}\n # 100.times{|n| @exp[n] = n * 5 } #TODO find better calc\n # @exp_multiplicator = 1.0\n end", "def initialize(capacity)\n @cache = {}\n @size = 0\n @capacity = capacity\n @head = DLinkedNode.new\n @tail = DLinkedNode.new\n @head.next = @tail\n @tail.prev = @head\n end", "def create_host_only_network(options)\n end", "def initialize(hosts, options)\n @seeds = hosts.map{ |host| Node.new(host, options) }\n @peers = []\n @options = options\n end", "def initialize(capacity = DEFAULT_CAPACITY)\n @bikes = []\n @capacity = capacity\n end", "def initialize(ethernet_connections,serial_connections,mpg=nil,respond_to_queries=nil)\n\t\t$redis = Redis.new\n\t\tself.class.log(\"Initializing AstmServer\")\n\t\tself.ethernet_connections = ethernet_connections\n\t\tself.serial_connections = serial_connections\n\t\tself.server_ip = server_ip || \"127.0.0.1\"\n\t\tself.server_port = server_port || 3000\n\t\tself.respond_to_queries = respond_to_queries\n\t\tself.serial_port = serial_port\n\t\tself.serial_baud = serial_baud\n\t\tself.serial_parity = serial_parity\n\t\tself.usb_port = usb_port\n\t\tself.usb_baud = usb_baud\n\t\tself.usb_parity = usb_parity\n\t\t$mappings = JSON.parse(IO.read(mpg || self.class.default_mappings))\n\tend", "def initialize( backend = nil, config = {} )\n backend ||= :memory\n \n begin\n adapter = RG::Adapters.const_get(\"#{backend.to_s.capitalize}Adapter\")\n @adapter = adapter.new(config)\n rescue LoadError\n Raise \"Cannot find the backend #{backend}\"\n end\n \n end", "def initialize(adapter)\n self.adapter = adapter\n end", "def initialize(capacity = DEFAULT_CAPACITY)\n @bikes = []\n @capacity = capacity\n end", "def initialize(capacity = DEFAULT_CAPACITY)\n @bikes = []\n @capacity = capacity\n end", "def initialize(capacity = DEFAULT_CAPACITY)\n @bikes = []\n @capacity = capacity\n end", "def new\n @device_autoconf_rule = DeviceAutoconfRule.new\n end", "def initialize\n @name = ''\n @public = ''\n @description = ''\n @nspath = ''\n @cis = Mash.new\n @relations = Mash.new\n end", "def initialize(weight, maximum_holding_weight)\n @weight = weight\n @maximum_holding_weight = maximum_holding_weight\n @ingredients = []\n end", "def initialize(name, description=\"\")\n @mutex, @condition = Mutex.new, ConditionVariable.new\n @hosts = {}\n @unused_hosts = []\n @name, @description = name, description\n @dead_hosts = []\n @hostnames = []\n end", "def initialize(bandwidth)\n @points = []\n @min = 0\n @max = 0\n\n @bandwidth = bandwidth\n\n @cache = {}\n end", "def create(network_spec)\n\n #@logger = bosh::Clouds::Config.logger\n # Need to reset between each call so that this class is stateless between jobs\n @network = nil\n @vip_network = nil\n\n networks = []\n network_spec.each_pair do |name, spec|\n #raise bosh::Registry::ConfigError \"'#{spec['type']}' network spec provided is invalid\"\n network_type = spec['type'] || 'dynamic'\n case network_type\n when 'dynamic'\n next if (@network)\n @network = DynamicNetwork.new(@vnet_manager, spec['cloud_properties'])\n check_affinity_group(@network.affinity_group)\n networks << @network\n\n when 'vip'\n next if (@vip_network)\n @vip_network = VipNetwork.new(@vnet_manager, spec['cloud_properties'])\n networks << @vip_network\n\n else\n raise Bosh::Registry::ConfigError \"Invalid network type '#{network_type}' for Azure, \" \\\n \"can only handle 'dynamic' or 'vip' network types\"\n end\n\n # Create the network(s) if they dont exist\n networks.each do |network|\n network.provision\n end\n end\n end", "def setup\n @subject = Fog::Compute[:google].servers\n @factory = ServersFactory.new(namespaced_name)\n @servers = ServersFactory.new(namespaced_name)\n @disks = DisksFactory.new(namespaced_name)\n end", "def initialize(spec)\n super()\n\n @spec = spec\n\n @checkout_timeout = ( spec.config[:checkout_timeout] ||\n spec.config[:wait_timeout] || 5.0 ).to_f # <= 3.2 supports wait_timeout\n @reaper = Reaper.new self, spec.config[:reaping_frequency]\n @reaping = !! @reaper.run\n\n # default max pool size to 5\n if spec.config[:pool]\n @size = spec.config[:pool].to_i\n else\n if defined? Rails.env && ( (! Rails.env.development? && ! Rails.env.test?) rescue nil )\n logger && logger.debug(\"pool: option not set, using default size: 5\")\n end\n @size = 5\n end\n\n # The cache of reserved connections mapped to threads\n @reserved_connections = ThreadSafe::Map.new(:initial_capacity => @size)\n\n @connections = []\n @automatic_reconnect = true\n\n @available = Queue.new self\n\n initial_size = spec.config[:pool_initial] || 0\n initial_size = @size if initial_size == true\n initial_size = (@size * initial_size).to_i if initial_size <= 1.0\n # NOTE: warn on onitial_size > size !\n prefill_initial_connections if ( @initial_size = initial_size.to_i ) > 0\n\n if frequency = spec.config[:validate_frequency]\n require 'active_record/bogacs/validator' unless self.class.const_defined?(:Validator)\n @validator = Validator.new self, frequency, spec.config[:validate_timeout]\n if @validator.run && @reaping\n logger && logger.info(\"pool: validator configured alongside with reaper\")\n end\n end\n end", "def __setup__(capacity=MIN_SIZE, max=MAX_ENTRIES, size=0)\n @capacity = capacity\n @mask = capacity - 1\n @max_entries = max\n @size = size\n @entries = Entries.new capacity\n end", "def initialize(weight, fake_functions=nil)\n @max_random_weight = weight\n @fake_functions_collection = fake_functions\n end", "def initialize(adapter)\n @adapter = adapter\n end", "def initialize(_name, _race, _class, _abilities, _equipment, _hp, _alignment, _background, _currency: {},\n\t\t_personality_traits: \"\", _ideals: \"\", _bonds: \"\", _flaws: \"\", _height: \"\", _weight: \"\", _age: \"\", _eyes: \"\", _skin: \"\", _hair: \"\")\n\n\t\t@name = _name\n\t\t@race = _race\n\t\t@classes = []\n\t\t@classes << _class\n\t\t@abilities = _abilities\n\t\t@feats = []\n\n\t\t@currency = {}\n\t\t@currency[:copper] = _currency.fetch(:copper, 0)\n\t\t@currency[:silver] = _currency.fetch(:silver, 0)\n\t\t@currency[:gold] = _currency.fetch(:gold, 0)\n\t\t@currency[:electrum] = _currency.fetch(:electrum, 0)\n\t\t@currency[:platinum] = _currency.fetch(:platinum, 0)\n\n\t\t@equipment = _equipment\n\n\t\t@hit_points = _hp\n\t\t@current_hp = @hit_points\n\t\t@temp_hp = 0\n\t\t@experience = 0\n\n\t\t@alignment = _alignment\n\t\t@background = _background\n\t\t@personality_traits = _personality_traits\n\t\t@ideals = _ideals\n\t\t@bonds = _bonds\n\t\t@flaws = _flaws\n\t\t@height = _height\n\t\t@weight = _weight\n\t\t@age = _age\n\t\t@eyes = _eyes\n\t\t@skin = _skin\n\t\t@hair = _hair\n\n\t\t@@all << self\n\tend", "def initialize (network_id)\n @network_id = network_id\n @node_list = []\n end", "def initialize\n @nodes = []\n @connections = []\n @names = []\n @core_name = nil\n @country = nil\n @core_node = nil\n end" ]
[ "0.5390672", "0.5237181", "0.52342117", "0.5217499", "0.52062607", "0.5202826", "0.51960665", "0.5141007", "0.51036406", "0.5103318", "0.5100264", "0.50961", "0.5092059", "0.50877416", "0.5074276", "0.5055973", "0.5028126", "0.5013355", "0.500928", "0.50073916", "0.49975556", "0.49802086", "0.49753454", "0.49629536", "0.4962325", "0.4962325", "0.4960391", "0.49598995", "0.49595097", "0.4929332", "0.49161583", "0.49128765", "0.4910033", "0.49028566", "0.4902349", "0.48995295", "0.48989457", "0.4898596", "0.4891556", "0.48823273", "0.4879556", "0.48757735", "0.48753232", "0.48695445", "0.486843", "0.48651525", "0.4862623", "0.48605102", "0.48579243", "0.48477727", "0.4844166", "0.48410314", "0.48410314", "0.48304483", "0.48272964", "0.48239753", "0.48118564", "0.4802045", "0.47990057", "0.47976357", "0.47959915", "0.47909525", "0.4778242", "0.47767508", "0.47739384", "0.4773576", "0.47708106", "0.47695655", "0.47693264", "0.4767297", "0.47571006", "0.47547495", "0.47524536", "0.47504961", "0.47468022", "0.47388938", "0.47375274", "0.4735687", "0.47334668", "0.47330633", "0.47314966", "0.47232702", "0.47220317", "0.47187993", "0.4718514", "0.4718514", "0.4718514", "0.47167686", "0.47145844", "0.47125816", "0.47069177", "0.4704101", "0.47029957", "0.47016168", "0.4694271", "0.46902794", "0.46845078", "0.4684311", "0.46824032", "0.468237", "0.4679297" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def record_params params.require(:record).permit() 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 user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n 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 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 user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\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 ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\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 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 url_whitelist; 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 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 permit_request_params\n params.permit(:address)\n end", "def sensitive_params=(params)\n @sensitive_params = params\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 backend_user_params\n params.permit!\n end", "def url_params\n params[:url].permit(:full)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "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 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.6981273", "0.6783789", "0.67460483", "0.6742222", "0.67354137", "0.65934366", "0.65028495", "0.6497783", "0.64826745", "0.6479415", "0.6456823", "0.6440081", "0.63800216", "0.6376521", "0.636652", "0.6319898", "0.6300256", "0.62994003", "0.6293621", "0.6292629", "0.6291586", "0.629103", "0.6282451", "0.6243152", "0.62413", "0.6219024", "0.6213724", "0.62103724", "0.61945", "0.61786324", "0.61755824", "0.6173267", "0.6163613", "0.6153058", "0.61521065", "0.6147508", "0.61234015", "0.61168665", "0.6107466", "0.6106177", "0.6091159", "0.60817343", "0.6071238", "0.6062299", "0.6021663", "0.60182893", "0.6014239", "0.6011563", "0.60080767", "0.60080767", "0.60028875", "0.60005623", "0.59964156", "0.5993086", "0.5992319", "0.5992299", "0.59801805", "0.59676576", "0.59606016", "0.595966", "0.59591126", "0.59589803", "0.5954058", "0.5953234", "0.5944434", "0.5940526", "0.59376484", "0.59376484", "0.5935253", "0.5930846", "0.5926387", "0.59256274", "0.5917907", "0.5910841", "0.590886", "0.59086543", "0.59060425", "0.58981544", "0.5898102", "0.5896809", "0.5895416", "0.58947027", "0.58923644", "0.5887903", "0.58830196", "0.5880581", "0.5873854", "0.58697754", "0.5869004", "0.58669055", "0.5866886", "0.58664906", "0.5864619", "0.58630043", "0.5862495", "0.5861368", "0.5859712", "0.5855544", "0.58551925", "0.5851284", "0.5850602" ]
0.0
-1
View your website's performance. Returns time series data website performance data for the given domain and/or path.
def get_page(opts = {}) data, _status_code, _headers = get_page_with_http_info(opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data\n if @url\n @page = fetch_url(@url)\n @parse_time = parse_dailydev_page\n @page = nil\n self.total_time\n end\n end", "def index\n @htscdts = Htscdt.all\n end", "def performance\n authenticated_post(\"auth/r/stats/perf:1D/hist\")\n end", "def response_time_metrics\n result = {}\n @urls.each do |url|\n result[url[:name]] = get_metrics(url[:path])\n end\n print result\n end", "def get_data\n if @url\n @page = fetch_url(@url)\n @parse_time = parse_today_page\n @page = nil\n self.total_time\n end\n end", "def list\n websites = @logs.records\n @view.show(websites)\n end", "def index\n @performances = Performance.all\n end", "def index\n authorize! :view, Measurement\n\n @measurements = Measurement.all\n\n @sites = Site.all\n @instruments = Instrument.all\n \n respond_to do |format|\n format.html\n format.csv { send_data @measurements.to_csv }\n end\n end", "def export_perf_data_to_graphite(host)\n @logger.perf_output(\"Sending data to Graphite server: \" + @options[:graphite_server])\n\n data = JSON.parse(host.exec(Command.new(\"sadf -j -- -A\"), :silent => true).stdout)\n hostname = host['vmhostname'].split('.')[0]\n\n data['sysstat']['hosts'].each do |host|\n host['statistics'].each do |poll|\n timestamp = DateTime.parse(poll['timestamp']['date'] + ' ' + poll['timestamp']['time']).to_time.to_i\n\n poll.keys.each do |stat|\n case stat\n when 'cpu-load-all'\n poll[stat].each do |s|\n s.keys.each do |k|\n next if k == 'cpu'\n\n socket = TCPSocket.new(@options[:graphite_server], 2003)\n socket.puts \"#{@options[:graphite_perf_data]}.#{hostname}.cpu.#{s['cpu']}.#{k} #{s[k]} #{timestamp}\"\n socket.close\n end\n end\n\n when 'memory'\n poll[stat].keys.each do |s|\n socket = TCPSocket.new(@options[:graphite_server], 2003)\n socket.puts \"#{@options[:graphite_perf_data]}.#{hostname}.memory.#{s} #{poll[stat][s]} #{timestamp}\"\n socket.close\n end\n end\n end\n end\n end\n end", "def get_data(startdate, enddate)\n\t\t\n\t\tdate_range = @analytics::DateRange.new(start_date: startdate, end_date: enddate)\n\t\torder_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING')\n\t\t# metric = @analytics::Metric.new(expression: 'ga:sessions')\n\t\t# metric = @analytics::Metric.new(expression: ['ga:sessions', 'ga:uniquePageviews'])\n\t\t# metric = @analytics::Metric.new\n\t\t# metric.expression = ['ga:sessions', 'ga:uniquePageviews']\n\t\t\n\t\tmetrics = ['ga:pageviews', 'ga:users', 'ga:bounces', 'ga:sessions',\n\t\t\t\t 'ga:avgTimeOnPage', 'ga:newUsers', 'ga:goal1ConversionRate', 'ga:goal1Completions'\n\t\t\t\t ]\n\n\t\t# metrics = ['ga:totalEvents'\n\t\t# \t\t ]\t\t \n\n\n\t\tmetric_type = Array.new\n\t\tmetrics.each do |m|\n\t\t\tmetric = @analytics::Metric.new\n\t\t\tmetric.expression = m\n\t\t\tmetric_type.push(metric)\n\t\tend\n\n\t\tdimensions = ['ga:pagePath', 'ga:pageTitle', 'ga:hostname' ]\n\t\t# dimensions = ['ga:pagePath', 'ga:eventCategory']\n\t\tdimension_type = Array.new\n\t\tdimensions.each do |d|\n\t\t\tdimension = @analytics::Dimension.new\n\t\t\tdimension.name = d\n\t\t\tdimension_type.push(dimension)\n\t\tend\n\n\n\t\t# dimension = @analytics::Dimension.new(name: 'ga:pagePath')\n\n\t\t# dimension_filters = @analytics::DimensionFilterClause.new(\n\t # filters: [\n\t # @analytics::DimensionFilter.new(\n\t # dimension_name: 'ga:pagePath',\n\t # operator: \"IN_LIST\",\n\t # expressions: ['/archives/69839', '/archives/54087', '/archives/68924', '/archives/58437', '/archives/65171', '/archives/64435', '/archives/61533', '/archives/68924',\n\t # \t\t\t\t'/archives/65086', '/archives/64736', '/archives/55244', '/archives/68211'\n\t # ]\n\t # )\n\t # ]\n\t # )\n\n\t\trequest = @analytics::GetReportsRequest.new(\n \t\t\treport_requests: [@analytics::ReportRequest.new(\n \t\t\tview_id: @view_id, \n \t\t\tmetrics: metric_type, \n \t\t\tdimensions: dimension_type,\n \t\t\t# dimension_filter_clauses: [dimension_filters],\n \t\t\t# dimensions: [dimension], \n \t\t\tdate_ranges: [date_range],\n \t\t\torder_bys: [order_by],\n \t\t\tpageSize: 10000\n \t\t\t)]\n\t\t)\n\t\tresponse = @client.batch_get_reports(request)\n\t\tmessageHash = {}\n\n\t\t# handling error \n\t\tif !response.reports.first.data.rows then\n\t\t\t\n\t\t\tkey = \"message\"\n\t\t\tmessageHash[key.to_sym] = \"no data\"\n\t\t \treturn messageHash\n\t\tend\n\n\n\t\tdata_from_google = response.reports.first.data.rows\n\n\t\tkey_array = dimensions + metrics\n\n\t\t# get rid of 'ga:'\n\t\tkey_array.each_with_index do |k, index| \n\t\t\tkey_array[index] = k.gsub(\"ga:\",\"\")\n\t\tend\n\n\t\tkey_array.push('id')\n\t\tkey_array.push('clickCount')\n\n\t\tset_ga_data_array = Array.new\n\n\n\t\tdata_from_google.each_with_index do |r, index|\n\n\t\t\tdatahash = {}\n\t\t\ti = 0;\n\n\t\t\t# setup dimension part\n\t\t\tr.dimensions.each do |d|\n\t\t\t\tdatahash[key_array[i]] = d\n\t\t\t\ti += 1\n\t\t\tend\n\n\t\t\t# setup metrics part\n\t\t\tr.metrics.first.values.each do |m|\n\t\t\t\tdatahash[key_array[i]] = m\n\t\t\t\ti += 1\n\t\t\tend\n\n\t\t\t\n\t\t\t# get aticle data from db\n\t\t\tarticleArr = set_article_data(datahash['hostname'], datahash['pagePath'], startdate, enddate)\n\n\t\t\t# setup id, mcv\n\t\t\tarticleArr.each do |a|\n\t\t\t\tdatahash[key_array[i]] = a\n\t\t\t\ti += 1\n\t\t\tend\n\n\t\t\tset_ga_data_array.push(datahash)\n\n\t\t\t#datahash sample -> { \"pagePath\": \"/archives/69839\", ... , \"goal1Completions\": \"23\", \"id\": 4, \"clickCount\": 0 },\n\t\tend\n\t\t\n\t\treturn set_ga_data_array\n\tend", "def get_perf_data(host, perf_start, perf_end)\n @logger.perf_output(\"Getting perf data for host: \" + host)\n if PERF_SUPPORTED_PLATFORMS.match?(host['platform']) # All flavours of Linux\n host.exec(Command.new(\"sar -A -s #{perf_start.strftime('%H:%M:%S')} -e #{perf_end.strftime('%H:%M:%S')}\"), :acceptable_exit_codes => [0, 1, 2]) if not @options[:collect_perf_data]&.include?('aggressive')\n if (defined? @options[:graphite_server] and not @options[:graphite_server].nil?) and\n (defined? @options[:graphite_perf_data] and not @options[:graphite_perf_data].nil?)\n export_perf_data_to_graphite(host)\n end\n else\n @logger.perf_output(\"Perf (sysstat) not supported on host: \" + host)\n end\n end", "def data_presenter factor\n collection = search\n data_collector collection, factor, params[:duration]\n if request.xhr?\n render partial: 'graph' and return\n end\n end", "def cached_trending\n Rails.cache.fetch(cleaned_query_param, cache_nils: false, :expires_in => 1.hours) do\n request_trending\n #Check for empty array in case there are no trending devs for the specified technology\n unless @data.empty?\n format_trending\n else\n no_trending_devs = { Information: \"There are currently no trending developers in this category\" }\n end\n end\n end", "def get_metrics(path, query={}, headers={})\n url = Client::make_url(URI_TEMPLATE, {:path=>path} )\n response = get( url, query, headers )\n if block_given?\n yield response\n end\n validate_response(url, query, response) \n return JSON.parse( response.content ) \n end", "def get_sites(tlp = true)\n local_copy = File.expand_path(\"#{get_url(true)}#{get_filename(tlp)}\", __FILE__)\n if File.exist? local_copy\n crawl_time = File.mtime(local_copy).httpdate # show time in same format as last-mod\n sites = JSON.parse(File.read(local_copy))\n else\n response = Net::HTTP.get_response(URI(\"#{get_url(false)}#{get_filename(tlp)}\"))\n crawl_time = response['last-modified']\n sites = JSON.parse(response.body)\n end\n return sites, crawl_time\n end", "def date_time_url\n @slowest_time= 0\n print \"\\nTotal requests grouped by the Date/hour\\n\\n\"\n\t\t\n #taking each date&hour\n @count.each do|val1,val2|\n slowest = 0\n \n #searching on each line to find slowest\n $file.each_line do|line|\n\tif line.include? val1\n\t time = line.match /\\d+$/\n\t if time\n\t #finding slowest time\n\t time = time[0].to_i\n\t if time > slowest\n\t slowest = time\n\t end\n\t end\n\tend\n\tslowest = slowest.to_s\n\t#finding slowest url in corresponding date\n\tif line.include? slowest\n\t @url = line.match /https?:\\/\\/[\\S]+/.to_s\n\tend\n\tslowest = slowest.to_i\n end\n \n #checking plural form of request.\n request = \"request\"\n if val1.to_i > 1\n\trequest += \"s\"\n end \n print \"#{ val1 } : #{ val2 } #{ request } \\tSlowest-Time : #{ slowest } \\tSlowest-URL : #{ @url }\\n\\n\"\n \n #finding slowest URL in the log.\n if slowest > @slowest_time\n @slowest_time = slowest\n @slowest_url = @url\n end\n end \n print \"Slowest URL : #{ @slowest_url }\\n\"\n end", "def stats\n year = Analytic.where(\"created_at > ?\", Time.now - 1.year)\n @stats = time_data year\n\n respond_to do |format|\n format.html # stats.html.erb\n format.json { render json: time_data(year, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(year, :hash) }\n end\n end", "def index\n @slowlogexts = Slowlogext.get_all(params[:page])\n end", "def hourly(query)\n get_json(\"#{api_url}/hourly/q/#{parse_query(query)}.#{@options[:format]}\")\n end", "def query(path, query)\n path = relativize_path path\n params = { :apiKey => api_key, :q => query, :format => 'detailed' }\n resp = Precog.get(self, \"/analytics/v#{VERSION}/fs/#{path}\", { 'Content-Type' => 'application/json' }, params)\n output = JSON.parse resp.body\n\n [\n output[\"errors\"].select { |i| !i.nil? }.map { |i| Precog.parse_info i },\n output[\"warnings\"].select { |i| !i.nil? }.map { |i| Precog.parse_info i },\n output[\"data\"]\n ]\n end", "def index\n @reporting_periods = ReportingPeriod.order(date: :desc)\n .includes(:full_reports).page params[:page]\n @data = ::Api::Charts::ReportingPeriod.new(@reporting_periods)\n .reporting_periods_cost_data\n end", "def index\n page = params[:page] || 1\n @metric_speedtests = MetricSpeedtest.page(page)\n end", "def links_with_domain(domain, options = {})\n options = options.clone\n\n parameters = { :url => domain, :t => options[:time] }\n options.merge! parameters\n options.delete :t\n\n objects_from_response(:get, 'api/info.json', options)\n end", "def analytics_for(url)\n UrlAnalytics.new(url).collect_data\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_usage(args= {})\n args = {:day=>\"today\", :type=>\"heat\"}.merge(args)\n result = HTTParty.get( @tstat_ip + '/tstat/datalog', :headers => @headers) \n \n day = result[args[:day]]\n runtime = day[args[:type] + '_runtime']\n\n return runtime\n end", "def index\n @study_spots = StudySpot.all\n\n respond_to do |format|\n format.html\n format.csv { send_data UsageTime.all.to_csv }\n end\n end", "def index\r\n @visits = Visit.fetch_ordered_by_page(params[\"page\"], [], 'started_at DESC')\r\n end", "def index\n @dor_variant_performances = DorVariantPerformance.all\n end", "def parse_dailydev_page\n start = Time.now\n items = @page.search('.ddinfo')\n if items.any?\n items.each do |item|\n desc = item.search('.foot').empty\n desc = item.inner_text.strip\n link_el = item.search('a').select { |item| /\\/deviation\\// === item.attributes['href'] }.first\n link = link_el.attributes['href']\n title = link_el.inner_text\n @daily_data << { :title => title, :desc => desc, :link => link }\n end\n end\n Time.now - start\n end", "def results\n get_domain_data\n end", "def index\n @sensor_data = SensorData.by_time\n end", "def index\n @traffics = Traffic.all\n end", "def index\n @web_data = WebData.all\n end", "def get_commercial_flights_statistics(opts = {})\n data, _status_code, _headers = get_commercial_flights_statistics_with_http_info(opts)\n data\n end", "def skel_daily( path_storage, section_path )\n entry_range = path_storage.find\n first_time, last_time = entry_range.last.created, entry_range.first.created\n start = Time.mktime( first_time.year, first_time.month, first_time.day, 0, 0, 0 ) + 1\n stop = Time.mktime( last_time.year, last_time.month, last_time.day, 23, 59, 59 )\n days = []\n one_day = 24 * 60 * 60\n until start > stop\n day_entries = path_storage.within( start, start + one_day - 1 )\n days << [day_entries.last.created, day_entries] unless day_entries.empty?\n start += one_day\n end\n days.extend Hobix::Enumerable\n days.each_with_neighbors do |prev, curr, nextd| \n page = Page.new( curr[0].strftime( \"%Y/%m/%d\" ), section_path )\n page.prev = prev[0].strftime( \"%Y/%m/%d\" ) if prev\n page.next = nextd[0].strftime( \"%Y/%m/%d\" ) if nextd\n page.timestamp = curr[0]\n page.updated = path_storage.last_updated( curr[1] )\n yield :page => page, :entries => curr[1]\n end\n end", "def company_statistics(options={})\n path = \"#{company_path(options)}/company-statistics\"\n get(path, options)\n end", "def url_dataset_to_times_series_dashboard(dataset, time_series, options={})\n request.path == explore_data_dashboard_path(dataset.owner, dataset) ? explore_time_series_dashboard_path(time_series.time_series_owner, time_series.time_series_permalink, options) : time_series_path(time_series.time_series_owner, time_series.time_series_permalink, options)\n end", "def index\n @time_lines = TimeLine.all\n end", "def index\n @performance_evaluations = PerformanceEvaluation.all\n end", "def stats\n @stats = time_data Episode.all\n @cloud = word_cloud Episode.pluck(:title)\n\n respond_to do |format|\n format.html # stats.html.erb\n format.json { render json: time_data(Episode.all, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(Episode.all, :hash) }\n end\n end", "def views(repo, options = {})\n opts = ensure_api_media_type(:traffic, options)\n get \"#{Repository.path repo}/traffic/views\", opts\n end", "def index\n @site_data = SiteDatum.all\n end", "def index\n retrieve_data_for_graph\n end", "def query_times_graphs\n controller = params[:controller_name]\n action = params[:action_name]\n data = redis(logger: true).zrangebyscore(\"request_timings/total/by_action/#{controller}##{action}\",\n 1.month.ago.to_i, '+inf',\n with_scores: true)\n .map { |y, x| [x.to_f, y.to_f] }\n throw 'No Data' if data.nil? || data.empty?\n smoothed = moving_avg(data)\n final = (params[:raw].present? ? data : smoothed).map { |x, y| [Time.at(x.to_i).to_datetime, y] }\n render json: [\n { name: 'Timings', data: final }\n ]\n end", "def index\n my_tenant_id = (current_user.role == 'admin' ? current_user.tenant_id : nil)\n @all_stats = Stats.new\n @seven_day_stats = Stats.new(tenant_id: my_tenant_id, since: (Time.new - 7.days))\n @resources = build_table_query\n # If no records were found and a search parameter was specified, requery with\n # a ful text search to find partial word matches\n @resources = build_table_query(true) if @resources.empty? && params[:q].present? && params[:q].length > 4\n @publications = InternalDatum.where(data_type: 'publicationName').order(:value).pluck(:value).uniq\n respond_to do |format|\n format.html\n format.csv\n end\n end", "def stats\n Project.hit 15\n Project.hit 32\n @stats = time_data TextMessage.all\n @cloud = word_cloud TextMessage.pluck(:text)\n\n respond_to do |format|\n format.html # stats.html.erb\n format.json { render json: time_data(TextMessage.all, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(TextMessage.all, :hash) }\n end\n end", "def index\n # Add code for when the index view is loaded\n page._event ||= store.events.buffer\n page._competencies = []\n params._time ||= 'future'\n end", "def output(path)\n if @first_pass\n @first_pass = false\n FileUtils.rm_rf path if clean_first\n end\n FileUtils.mkdir_p path\n \n if quick_mode\n posts.chop! 20\n end\n @stats.reset\n \n unless metadata.nil? || !metadata['static'].is_a?(Array)\n stats.record(:site, :static) do\n for dir in metadata['static']\n FileUtils.cp_r File.join(source_dir, dir), File.join(path, dir)\n end\n end\n end\n \n before = Time.now\n Dir.chdir(path) do\n stats.record(:site, :pages) do\n pages.each do |name, page|\n FileUtils.mkdir_p page.output_dir unless File.directory?(page.output_dir)\n if check_mtime\n if File.file?(page.output_path) && File.mtime(page.output_path) > page.source_mtime\n next\n end\n page.load\n end\n File.open(page.output_path, 'w') { |f| f.write page.render }\n end\n end\n \n stats.record(:site, :posts) do\n posts.each do |post|\n FileUtils.mkdir_p post.output_dir unless File.directory?(post.output_dir)\n if check_mtime\n if File.file?(post.output_path) && File.mtime(post.output_path) > post.source_mtime\n next\n end\n post.load\n end\n File.open(post.output_path, 'w') { |f| f.write post.render }\n end\n end\n \n stats.record(:site, :stylesheets) do\n unless stylesheets.nil?\n stylesheets.each do |name, stylesheet|\n FileUtils.mkdir_p stylesheet.output_dir unless File.directory?(stylesheet.output_dir)\n if check_mtime\n if File.file?(stylesheet.output_path) && File.mtime(stylesheet.output_path) > stylesheet.source_mtime\n next\n end\n stylesheet.load\n end\n File.open(stylesheet.output_path, 'w') { |f| f.write stylesheet.render }\n end\n end\n end\n \n stats.record(:site, :indices) do\n unless year_index.nil? && month_index.nil? && day_index.nil?\n posts.each_index do |dir|\n posts = self.posts.from(dir)\n Dir.chdir(dir) do\n context = dir.split('/').collect { |c| c.to_i }\n date_index = case context.length\n when 1\n year_index\n when 2\n month_index\n when 3\n day_index\n else\n nil\n end\n date_index.posts = posts\n date_index.context = Time.local *context\n File.open('index.html', 'w') { |f| f.write date_index.render }\n end\n end\n end\n \n unless tag_index.nil?\n tags.each do |tag|\n tag_index.context = tag.name\n tag_index.posts = tag\n FileUtils.mkdir_p tag.output_dir\n File.open(tag.output_path, 'w') { |f| f.write tag_index.render }\n end\n end\n end\n end\n \n self.stats.display if show_statistics\n end", "def show_site_stats # :nologin: :norobots:\n store_location\n @site_data = SiteData.new.get_site_data\n\n # Add some extra stats.\n @site_data[:observed_taxa] = Name.connection.select_value %(\n SELECT COUNT(DISTINCT name_id) FROM observations\n )\n @site_data[:listed_taxa] = Name.connection.select_value %(\n SELECT COUNT(*) FROM names\n )\n\n # Get the last six observations whose thumbnails are highly rated.\n query = Query.lookup(:Observation, :all,\n by: :updated_at,\n where: \"images.vote_cache >= 3\",\n join: :\"images.thumb_image\")\n @observations = query.results(limit: 6,\n include: { thumb_image: :image_votes })\n end", "def stats\n @stats = time_data Track.all\n @cloud = word_cloud Track.pluck(:artist), split: false, limit: 60\n\n respond_to do |format|\n format.html # stats.html.erb\n format.json { render json: time_data(Track.all, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(Track.all, :hash) }\n end\n end", "def index\n\n require 'net/http'\n require 'json'\n\n @measures = Measure.all.order(\"created_at DESC\")\n weatherData\n\n end", "def index\n @date_time = date_time\n @splitwises = Splitwise.analysis(@date_time)\n end", "def index\n @radio_performances = RadioPerformance.all\n end", "def display_webpage_views\n webpage_views\n puts 'Overall webpage views'\n puts \"\\n\"\n @webpage_views_hash.each do |webpage, view_hash|\n puts webpage\n puts \"#{view_hash.values[0]} unique views\"\n puts \"#{view_hash.values[1]} total views\"\n puts \"\\n\"\n end\n end", "def domain_report(domain)\n DomainReport.new(api_key: @api_key, domain: domain).response\n end", "def raw_stats\n url = URI.parse(stats_url)\n Net::HTTP.start(url.host, url.port) {|http|\n http.request(Net::HTTP::Get.new(url.path))\n }.body\nend", "def view_stats_all\n data = {\n :name => \"Company Views\",\n :pointInterval => 1.day * 1000,\n :pointStart => 1.weeks.ago.at_midnight.to_i * 1000,\n :data => (1.weeks.ago.to_date..Date.today).map{ |date|\n Impression.where(\n \"created_at > ? AND created_at < ? AND action_name = ? AND controller_name = ?\",\n date.at_beginning_of_day,\n date.tomorrow.at_beginning_of_day,\n 'stat_show',\n 'companies'\n ).select{ |impression| impression.action_name == \"stat_show\"}.count\n }\n }\n respond_with data\n end", "def cp_performance_chart_data\n data = ::Api::Charts::CPPerformance.new.cp_performance_all_sectors_data\n\n render json: data.chart_json\n end", "def index\n @sites = Site.all.order(:created_at)\n\n # @debug = scrape_all\n # @debug = scrape 'http://workingnews.blog117.fc2.com/?xml'\n \n # @spreadsheet = GoogleSpreadsheets::Enhanced::Spreadsheet.find('0ArhV7gTgs6Z8dHlSRUF2SzFXWjlkU1V2d29KR2pkdXc')\n # @worksheet = @spreadsheet.worksheets.find_by(title: 'site_rows')\n # @rows = @worksheet.rows\n # @site_rows = Site.site_rows\n \n # 同期実行\n # Site.sync_with_site_rows\n\n # スクレイピング\n # ApplicationController.helpers.scrape_update\n # ApplicationController.helpers.scrape \"http://alfalfalfa.com/index.rdf\"\n\n respond_to do |format|\n if Rails.env.development?\n format.html { render :html => @sites }\n end\n format.json { render :json => @sites.as_json }\n end\n end", "def index\n day = Analytic.where(\"created_at > ?\", Time.now - 1.day).order(\"created_at DESC\")\n @analytics = {}\n @analytics[:projects] = Project.all.order(\"hits DESC\")\n @analytics[:ips] = day.distinct.pluck(:ip)\n @analytics[:visits] = day\n @analytics[:user_agents] = day.distinct.pluck(:user_agent)\n @analytics[:referers] = day.distinct.pluck(:referer)\n @analytics[:total] = Analytic.count\n @analytics[:day] = day.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @analytics, callback: params[:callback] }\n format.xml { render xml: @analytics }\n end\n end", "def ajax_data_load\n\t\t@project = Project.find(params[:project_id])\n\t\t\n\t\t@data = []\n\t\t@data_aggregated = []\n\t\t\n\t\t# if any data is avaiable\n\t\tif not @project.measured_data.empty?\n\t\t \n\t\t # if timespan is given use it to extract data\n \t\tif params.has_key?(:from) and params.has_key?(:to)\n \t\t from_timestamp, to_timestamp = params[:from], params[:to]\n \t\t from_time, to_time = Time.at(from_timestamp.to_f/1000), Time.at(to_timestamp.to_f/1000)\n \t\t \n \t\t# otherwise get all avaiable data\n else \n from_time = @project.measured_data.minimum(:date)\n to_time = @project.measured_data.maximum(:date)\n end\n \n plot_width = params[:plotwidth].to_i\n\t\t\n \t\tinterval = to_time - from_time\n \t\tcalc_resolution = (interval / 60) / (plot_width / 2)\n\t\t\n \t\t# Aufloesung aus gegebenen Aufloesungen waehlen\n \t\tbest_resolution = get_best_resolution(calc_resolution, @project.resolutions.map { |r| r.value })\n\t\t\n\t\t # time hartcodieren... funktioniert mit sql funktion nicht???\n \t\tdb_from = from_time.strftime(\"%Y-%m-%d %H:%M:%S\")\n db_to = to_time.strftime(\"%Y-%m-%d %H:%M:%S\")\n \t\t\n \t\tif best_resolution == 2\n \t\t cond = \"date BETWEEN '#{db_from}' AND '#{db_to}'\"\n \t\t query = @project.measured_data.all(:order => 'date ASC', :conditions => [cond])\n \t\telse\n \t\t cond = \"date BETWEEN '#{db_from}' AND '#{db_to}' AND resolution = #{best_resolution}\"\n \t\t query = @project.approximated_measured_data.all(:order => 'date ASC', :conditions => [cond])\n \t\tend\n\t\t\n \t\tquery.each do |datum|\n datetime = datum.date.to_time.to_i * 1000\n @data << [datetime, datum.value.to_f]\n @data_aggregated << [datetime, datum.aggregated_value.to_f]\n end\n end \n\t\trespond_to do |format|\n\t\t format.json { render json: [@data, @data_aggregated] }\n\t\tend\n\tend", "def performances\n unless @performances\n @performances = Source.all.map do |source|\n SourcePerformance.new(source: source, site: site)\n end\n @performances.sort! {|a,b| b.success_ratio <=> a.success_ratio}\n end\n @performances\n end", "def index\n @daily_visitors = DailyVisitor.all\n end", "def trends\n data = generate_data(data_factory)\n respond_with data\n end", "def analyzeDemandLog()\n demandLogFile = @basePath + \".demandLog.json\" ;\n com = \"../Savs/analyzeDemandLog #{demandLogFile}\" ;\n p [:com, com] ;\n jsonStr = `#{com}` ;\n @demandStat = JSON.load(jsonStr) ;\n return @demandStat ;\n end", "def get_commercial_flights_statistics_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: StatisticsApi.get_commercial_flights_statistics ...'\n end\n # resource path\n local_var_path = '/statistics/flights/commercial'\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[:body] \n\n return_type = opts[:return_type] || 'FlightsStatisticsResponse' \n\n auth_names = opts[:auth_names] || ['bearerToken']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type)\n\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: StatisticsApi#get_commercial_flights_statistics\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def find_perf( path )\n perfs[path]\n end", "def index\n if params[:hour] != nil && params[:hour].to_i > 0\n @tracked_data = TrackedDatum.where(updated_at: params[:hour].to_i.hours.ago..Time.now).all.order(:pageURL)\n else\n @tracked_data = TrackedDatum.all.order(:pageURL)\n end\n end", "def index\n @trial_sites = TrialSite.all\n respond_to do |format|\n format.html\n format.csv { send_data @trial_sites.to_csv }\n format.xls { send_data @trial_sites.to_csv(col_sep: \"\\t\") }\n end\n end", "def index\n @log_load_times = LogLoadTime.all\n end", "def publications_by_subdomain(subdomain)\n rvalue = []\n\n (ActiveFedora::SolrService.query(\"+press_sim:#{subdomain} AND +visibility_ssi:open\", rows: 100_000, sort: \"date_modified_dtsi desc\") || []).each do |solr_doc|\n sm = ::Sighrax.from_solr_document(solr_doc)\n op = ::Opds::Publication.new_from_monograph(sm, true, params[:filterByEntityId])\n rvalue.append(op.to_h) if op.valid?\n end\n\n rvalue\n end", "def index\n pages_initialization\n\n @timeframes = Timeframe.all\n @timeframe_logs = TimeframeLog.where('extract(year from start_date) = ?', Date.today.year).order(created_at: :ASC)\n @next_timeframe_logs = TimeframeLog.where('extract(year from start_date) = ?', Date.today.year + 1)\n @timeframe_logs_advanced_two_years = TimeframeLog.where('extract(year from start_date) = ?', Date.today.year + 2)\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 # Limits due to the current search/filter settings are handled within CurationTableRow\n authorize %i[stash_engine admin_datasets]\n my_tenant_id = (%w[admin tenant_curator].include?(current_user.role) ? current_user.tenant_id : nil)\n @all_stats = Stats.new\n @seven_day_stats = Stats.new(tenant_id: my_tenant_id, since: (Time.new.utc - 7.days))\n\n if request.format.to_s == 'text/csv' # we want all the results to put in csv\n page = 1\n page_size = 1_000_000\n else\n page = @page.to_i\n page_size = @page_size.to_i\n end\n\n search_terms = { params: helpers.sortable_table_params, page: page.to_i, page_size: page_size.to_i }\n\n @datasets = AdminDatasetsPolicy::Scope.new(current_user, StashEngine::AdminDatasets::CurationTableRow, search_terms).resolve\n @publications = StashEngine::Journal.order(:title).map(&:title)\n @pub_name = params[:publication_name] || nil\n\n # paginate for display\n blank_results = (page.to_i - 1) * page_size.to_i\n @datasets = Array.new(blank_results, nil) + @datasets # pad out an array with empty results for earlier pages for kaminari\n @datasets = Kaminari.paginate_array(@datasets, total_count: @datasets.length).page(page).per(page_size)\n\n respond_to do |format|\n format.html\n format.csv do\n headers['Content-Disposition'] = \"attachment; filename=#{Time.new.strftime('%F')}_report.csv\"\n end\n end\n end", "def index\n @slopes = Slope.all\n @slopes = duration(@slopes, params)\n end", "def index\r\n if params[:period]\r\n SignalStrength.switch_data(params[:connection], params[:period])\r\n else\r\n SignalStrength.switch_data(params[:connection], \"daily\")\r\n end\r\n signal = params[:signal] ? params[:signal] : \"%\"\r\n @signal_strengths = SignalStrength.find(:all, :conditions => [\"server_signal LIKE ?\",signal]) \r\n respond_to do |format|\r\n format.html #index.html.erb\r\n format.xml { render :xml => @signal_strengths.to_xml(:dasherize => false) }\r\n end\r\n end", "def index\n @traffics = Traffic.find(:all, :order => \"created_at\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @traffics }\n end\n end", "def stats\n @stats = time_data SolarReading.all\n\n respond_to do |format|\n format.html # stats.html.erb\n format.json { render json: time_data(SolarReading.all, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(SolarReading.all, :hash) }\n end\n end", "def get_statistics\n response = get_siteinfo('statistics')\n ret = {}\n response['query']['statistics'].each { |k, v| ret[k] = v }\n ret\n end", "def index\n @system_overviews = SystemOverview.all\n if @system_overviews.size > 0\n\n data_table = GoogleVisualr::DataTable.new\n data_table.new_column('string', 'Label')\n data_table.new_column('number', 'Value')\n data_table.add_rows(3)\n data_table.set_cell(0, 0, 'Current')\n data_table.set_cell(0, 1, SystemOverview\n .last.currently_running\n .tr('W', '')\n .tr('KW', '')\n .to_i\n )\n opts = { width: 400, height: 120, redFrom: 90, redTo: 100, yellowFrom: 75, yellowTo: 90, minorTicks: 5 }\n @chart = GoogleVisualr::Interactive::Gauge.new(data_table, opts)\n end\n end", "def show\n if params[:export]\n require 'csv'\n str = CSV.generate do |csv|\n @test_run.test_run_logs.each do |t|\n csv << [t.message_type, t.execution_in_microseconds, t.logged_at]\n end\n end\n send_data str, filename: \"test_run_#{@test_run.id}.csv\"\n return\n end\n\n if params[:type]\n @type = params[:type]\n @logs = @test_run.test_run_logs.where(message_type: @type)\n\n return\n\n @logs_graph = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: \"Response Time for #{@type}\")\n f.xAxis(categories: @logs.collect(&:logged_at))\n f.series(name: 'Response time in Microseconds', yAxis: 0, data: @logs.collect(&:execution_in_microseconds))\n\n f.yAxis [\n {title: {text: 'Time in Microseconds', margin: 70}},\n ]\n\n f.legend(align: 'right', verticalAlign: 'top', y: 75, x: -50, layout: 'vertical',)\n f.chart({defaultSeriesType: 'column'})\n end\n end\n end", "def collect_metrics\n\n # Build a set of matchers to match the paths we need to find metrics\n # for.\n path_matchers = []\n @paths.each do |path|\n path_matchers << { :path => matcher_for_path(path) }\n end\n\n # Figure out what metric model to use (Metric or one of the average\n # models).\n metric_model = metric_model_for_timespan\n\n # Build a query to locate the metrics.\n query = metric_model.where(:$or => path_matchers)\n query = query.where(:node_id => @node_id)\n query = query.where(:timestamp.gte => @from)\n query = query.where(:timestamp.lte => @to)\n query = query.sort(:timestamp.asc)\n metrics = query.all\n\n # Return a data set based on the collection of metrics.\n data_set_for_metrics(metrics)\n\n end", "def index\n @timings = Timing.all\n end", "def flowchart\r\n @project = Project.find(params[:project_id])\r\n @foundpages = Page.find(:all, :conditions => { :project_id => @project.id })\r\n render 'flowchart'\r\n end", "def performance(index)\n puts \"\\n#{@testcase.name}\\n\"\n puts \" %-10s %-20s %-8s %s \" % [\"#{@response.runtime.to_s[0..6]}s\", \"[#{result_case}]\", @testcase.request['method'], @response.fully_qualified_path]\n end", "def stats!\n info \"STATS\"\n task \"generate chart\" do\n c = Chart::StatsPerCollection.new\n @dbi.execute( File.read( sql_query(:chart) ) ).each{ |date,collection|\n c.add_one(collection, Date.parse(date).day)\n }\n Chart.new(c).write File.join( @config['settings']['output'], '/chart.jpg' )\n end\n end", "def show\n @site = Site.find_by_site(params[:id])\n @organisation = @site.organisation\n @total_data = WeeklyTotalData.new(@site.weekly_totals, Date.new(2012,10,17)..Date.today, true)\n @most_recent_hit_data = AggregratedMostRecentHitData.new(@site.aggregated_hits, @site.hits.most_recent_hit_on_date)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site }\n end\n end", "def stats\n get_charts\n end", "def get_data\n\t \thydra = Typhoeus::Hydra.hydra\n\n\t \tfirst_url = \"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22#{self.stock_ticker}%22)&format=json%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env\"\n\t \tsecond_url = \"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.keystats%20where%20symbol%20in%20(%22#{self.stock_ticker}%22)&format=json%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env\"\n\t \tthird_url = \"http://www.quandl.com/api/v1/datasets/DMDRN/#{self.stock_ticker}_ALLFINANCIALRATIOS.csv?auth_token=#{ENV['QUANDL_API_TOKEN']}\"\n\t \tfourth_url = \"http://www.quandl.com/api/v1/datasets/PSYCH/#{self.stock_ticker}_I.json?&auth_token=auth_token=#{ENV['QUANDL_API_TOKEN']}&trim_start=#{Chronic.parse(\"last week\").strftime(\"%F\")}&trim_end=#{Chronic.parse(\"today\").strftime(\"%F\")}&sort_order=desc\"\n\n\t \t(((first_url) =~ URI::DEFAULT_PARSER.regexp[:ABS_URI]) == 0) ? first_request = Typhoeus::Request.new(first_url) : (return false)\n\t \tsecond_request = Typhoeus::Request.new(second_url) \n\t \tthird_request = Typhoeus::Request.new(third_url) \n\t \tfourth_request = Typhoeus::Request.new(fourth_url) \n\n\t \thydra.queue first_request\n\t \thydra.queue second_request\n\t \thydra.queue third_request\n\t \thydra.queue fourth_request\n\t \t\n\t \thydra.run\n\n\t\t\tfirst_request.response.options[:response_code] == 200 ? first_response = first_request.response : (return false )\n\t \tsecond_response = second_request.response\n\t \tthird_response = third_request.response \n\t \tfourth_response = fourth_request.response\n\n\t \t@quotes = JSON.parse(first_response.body) if !first_response.body.nil?\n\n\t \t@key_stats = JSON.parse(second_response.body) \n\n\t \tthird_request.response.options[:response_code] == 200 ? @quandl_data = CSV.parse(third_response.body) : @quandl_data = nil\n\n\t \tfourth_request.response.options[:response_code] == 200 ? @psych_data = JSON.parse(fourth_response.body) : @psych_data = nil\n\n\t \t@tradier = $tradier_client.quote(self.stock_ticker)\n\n\t \tmethod(:assign_yahooQuotes).call\n\t \tmethod(:assign_yahooKeyStats).call\n\t \tmethod(:assign_quandlStockData).call\n\t \tmethod(:assign_quandlPsychData).call\n\t \tmethod(:assign_databaseValues).call\n\t \tmethod(:assign_stockProfile).call\n\t \tmethod(:assign_tradierQuote).call\n\n\t end", "def stats\n request :get, \"_stats\"\n end", "def stats\n request :get, \"_stats\"\n end", "def index\n @time_series = TimeSeries.meta_only.by_owner(@owner.id, current_user.id).sorted\n\n @css.push(\"time_series.css\")\n @js.push(\"search.js\")\n\n set_gon_datatables\n\n respond_to do |format|\n format.html\n format.json { render json: @time_series }\n end\n end", "def get_ga_data(yesterday, view_id, ga_key)\n\t\t\n\t\tdate_range = @analytics::DateRange.new(start_date: yesterday, end_date: yesterday)\n\t\torder_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING')\n\t\t\n\t\tmetrics = ['ga:pageviews', 'ga:users', 'ga:newUsers', 'ga:bounces', 'ga:sessions', 'ga:timeOnPage']\n\n\t\tmetric_type = Array.new\n\t\tmetrics.each do |m|\n\t\t\tmetric = @analytics::Metric.new\n\t\t\tmetric.expression = m\n\t\t\tmetric_type.push(metric)\n\t\tend\n\n\t\tdimensions = ['ga:dateHour', 'ga:pagePath']\n\t\tdimension_type = Array.new\n\t\tdimensions.each do |d|\n\t\t\tdimension = @analytics::Dimension.new\n\t\t\tdimension.name = d\n\t\t\tdimension_type.push(dimension)\n\t\tend\n\n\t\trequest = @analytics::GetReportsRequest.new(\n \t\t\treport_requests: [@analytics::ReportRequest.new(\n \t\t\tview_id: view_id, \n \t\t\tmetrics: metric_type,\n \t\t\tdimensions: dimension_type,\n \t\t\t# dimension_filter_clauses: [dimension_filters],\n \t\t\tdate_ranges: [date_range],\n \t\t\torder_bys: [order_by],\n \t\t\tpage_size: 100_000\n \t\t\t)]\n\t\t)\n\t\tresponse = @client.batch_get_reports(request)\n\n\t\t# handling error \n\t\tif !response.reports.first.data.rows then\n\t\t \treturn\n\t\tend\n\n\n\t\tdata_from_google = response.reports.first.data.rows\n\t\t\n\t\t\n\t\tset_ga_data_array = Array.new\n\n\n\t\tdata_from_google.each_with_index do |r, index|\n\n\t\t\t# dimensions = ['ga:dateHour', 'ga:pagePath']\n\t\t\t# metrics = ['ga:pageviews', 'ga:users', 'ga:newUsers', 'ga:bounces', 'ga:sessions', 'ga:avgTimeOnPage']\n\t\t\tdatahash = {}\n\n\t\t\turls_rm_params = r.dimensions[1].split(/\\?/)[0]\n\n\t\t\tarticle = Article.select(:id).find_by(article_url: urls_rm_params)\n\t\t\tnext if !article\n\n\t\t\tarticle_arr = set_ga_data_array.each_with_index.select{|a, index| a['article_id'] == article.id && a['date_hour'] == r.dimensions[0]}\n\n\t\t\tif !article_arr.empty?\n\t\t\t\tarticle_index = article_arr.first[1]\n\t\t\t\tset_ga_data_array[article_index]\n\t\t\t\t\n\t\t\t\tpage_view = set_ga_data_array[article_index]['page_view'].to_i\n\t\t\t\tpage_view_temp = r.metrics.first.values[0].to_i\n\t\t\t\tset_ga_data_array[article_index]['page_view'] = page_view + page_view_temp\n\n\t\t\t\tuser = set_ga_data_array[article_index]['user'].to_i\n\t\t\t\tuser_temp = r.metrics.first.values[1].to_i\n\t\t\t\tset_ga_data_array[article_index]['user'] = user + user_temp\t\t\t\t\n\n\t\t\t\tnew_user = set_ga_data_array[article_index]['new_user'].to_i\n\t\t\t\tnew_user_temp = r.metrics.first.values[2].to_i\n\t\t\t\tset_ga_data_array[article_index]['new_user'] = new_user + new_user_temp\n\n\t\t\t\tbounce = set_ga_data_array[article_index]['bounce'].to_i\n\t\t\t\tbounce_temp = r.metrics.first.values[3].to_i\n\t\t\t\tset_ga_data_array[article_index]['bounce'] = bounce + bounce_temp\n\n\t\t\t\tsession = set_ga_data_array[article_index]['session'].to_i\n\t\t\t\tsession_temp = r.metrics.first.values[4].to_i\n\t\t\t\tset_ga_data_array[article_index]['session'] = session + session_temp\n\n\t\t\t\tavg_time_on_page = set_ga_data_array[article_index]['avg_time_on_page'].to_i\n\t\t\t\tavg_time_on_page_temp = r.metrics.first.values[5].to_i\n\t\t\t\tset_ga_data_array[article_index]['avg_time_on_page'] = avg_time_on_page + avg_time_on_page_temp\n\n\t\t\telse\n\n\t\t\t\tdatahash['article_id'] = article.id\n\n\t\t\t\tdatahash['date_hour'] = r.dimensions[0]\n\n\t\t\t\tpage_view = r.metrics.first.values[0]\n\t\t\t\tdatahash['page_view'] = page_view\n\n\t\t\t\tuser = r.metrics.first.values[1]\n\t\t\t\tdatahash['user'] = user\n\n\t\t\t\tnew_user = r.metrics.first.values[2]\n\t\t\t\tdatahash['new_user'] = new_user\n\n\t\t\t\tbounce = r.metrics.first.values[3]\n\t\t\t\tdatahash['bounce'] = bounce\n\n\t\t\t\tsession = r.metrics.first.values[4]\n\t\t\t\tdatahash['session'] = session\n\n\t\t\t\tavg_time_on_page = r.metrics.first.values[5]\n\t\t\t\tdatahash['avg_time_on_page'] = avg_time_on_page\n\n\t\t\t\tdatahash['created_at'] = Time.zone.now\n\t\t\t\tdatahash['updated_at'] = Time.zone.now\n\n\n\t\t\t\tset_ga_data_array.push(datahash)\n\t\t\tend\n\t\tend\n\n\t\t# avg time on page setup (avt t.o.p in ga doesn't fit to our site so we need to calculate by ourselves)\n\t\t# avg.time on page = time on page / pageviews\n\t\tset_ga_data_array.each do |ga|\n\t\t\ttime_on_page = ga['avg_time_on_page'].to_i\n\t\t\tpv = ga['page_view'].to_i\n\n\t\t\tif time_on_page != 0 && pv != 0\n\t\t\t\tbegin\n\t\t\t\t\tga['avg_time_on_page'] = time_on_page/pv\n\t\t\t\trescue StandardError => e\n\t\t\t\t\tputs e\n\t\t\t\t\tga['avg_time_on_page'] = 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\n\t\treturn set_ga_data_array\n\tend", "def stat_by_url(url, userdics: nil)\n stat_by_web(url, userdics: userdics)\n end", "def stats\n @server.make_json_request('show.stats', tvdbid: @tvdbid)['data']\n end", "def index\n @daily_steps = DailyStep.all\n end", "def track\n url = Rails.env.development? ? \"http://localhost:8000/stat\" : \"http://stats.universit.as/stat\"\n RestClient.get(url, :params => {\n :ip => request.remote_ip,\n :title => request.referrer\n })\n render :js => ''\n end", "def index\n @tv_series = TvSerie.all\n end", "def performance\n @advert = Advert.find(params[:id])\n @start_date = Date.parse(params[:filters][:start_date]) rescue 1.month.ago\n @end_date = Date.parse(params[:filters][:end_date]) rescue Time.now\n report_days = (@end_date-@start_date)/1.day\n @report_data={}\n #generate aggregate data\n\n @report_data['totals'] = {}\n @report_data['totals']['impressions'] = @advert.impressions.between(@start_date,@end_date).count\n @report_data['totals']['clicks'] = @advert.clicks.between(@start_date,@end_date).count\n @report_data['totals']['impressions_day'] = @report_data['totals']['impressions']/report_days\n @report_data['totals']['clicks_day'] = @report_data['totals']['clicks']/report_days\n @report_data['totals']['conversion'] = 100.0*(@report_data['totals']['clicks'].to_f/@report_data['totals']['impressions'].to_f)\n #generate sereies data\n @report_data['series'] = {}\n @report_data['series']['impressions'] = @advert.impressions.between(@start_date,@end_date).by_day\n @report_data['series']['clicks'] = @advert.clicks.between(@start_date,@end_date).by_day\n \n #correlate/merge keys for date series \n @report_data['series']['merge']={}\n @report_data['series']['impressions'].each do |i|\n @report_data['series']['merge'][i.day]||={}\n @report_data['series']['merge'][i.day].update({'impressions'=>i.total})\n end\n @report_data['series']['clicks'].each do |c|\n @report_data['series']['merge'][c.day]||={}\n @report_data['series']['merge'][c.day].update({'clicks'=>c.total})\n end\n @graph_data={}\n \n #raise {'series'=>(@start_date.to_date..@end_date.to_date).collect {|d| d.strftime('%m/%d/%y'@report_data['series']['merge'].keys.inspect\n\n @graph_data['impressions']=(@start_date.to_date..@end_date.to_date).collect do |date|\n @report_data['series']['merge'][date.strftime(\"%Y-%m-%d\")]['impressions'].to_i rescue 0\n end\n @graph_data['clicks']=(@start_date.to_date..@end_date.to_date).collect do |date|\n @report_data['series']['merge'][date.strftime(\"%Y-%m-%d\")]['clicks'].to_i rescue 0\n end\n end", "def slow_sites\n deep_values(\"slow_sites\")\n end" ]
[ "0.5932286", "0.5590722", "0.55699956", "0.532639", "0.5315538", "0.52507335", "0.51862407", "0.5181839", "0.5178521", "0.5126185", "0.5098839", "0.5089095", "0.5041706", "0.50406563", "0.50225323", "0.5006034", "0.5003582", "0.49872133", "0.4968375", "0.49580324", "0.49574068", "0.49526376", "0.4950564", "0.49482498", "0.49456114", "0.49424198", "0.49261448", "0.4917454", "0.48972297", "0.4894048", "0.48837814", "0.48785323", "0.48774207", "0.48677668", "0.48609883", "0.48579594", "0.48527583", "0.48418236", "0.48403025", "0.48348993", "0.48309758", "0.4830037", "0.48291808", "0.48256516", "0.48211676", "0.48168817", "0.48156953", "0.48092198", "0.48022646", "0.47994718", "0.4799322", "0.47982723", "0.4797098", "0.4796884", "0.47926566", "0.47899526", "0.47894678", "0.47832328", "0.4777538", "0.47765377", "0.475364", "0.4753186", "0.47531328", "0.4749789", "0.47446904", "0.4742218", "0.47356793", "0.47335958", "0.47252107", "0.47246876", "0.4723393", "0.47208914", "0.47194996", "0.47192878", "0.47166392", "0.47101063", "0.4703649", "0.4699755", "0.4698523", "0.46973935", "0.46861187", "0.46794072", "0.46742478", "0.46736804", "0.46723443", "0.4670318", "0.46600798", "0.46578482", "0.46560588", "0.46518603", "0.4651267", "0.4651267", "0.4647808", "0.4644935", "0.46372792", "0.46328154", "0.46289977", "0.46257812", "0.46245253", "0.46140346", "0.46107453" ]
0.0
-1
View your website&39;s performance. Returns time series data website performance data for the given domain and/or path.
def get_page_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PublicPerformanceApi.get_page ...' end # resource path local_var_path = '/cms/v3/performance/' # query parameters query_params = opts[:query_params] || {} query_params[:'domain'] = opts[:'domain'] if !opts[:'domain'].nil? query_params[:'path'] = opts[:'path'] if !opts[:'path'].nil? query_params[:'pad'] = opts[:'pad'] if !opts[:'pad'].nil? query_params[:'sum'] = opts[:'sum'] if !opts[:'sum'].nil? query_params[:'period'] = opts[:'period'] if !opts[:'period'].nil? query_params[:'interval'] = opts[:'interval'] if !opts[:'interval'].nil? query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil? query_params[:'end'] = opts[:'_end'] if !opts[:'_end'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'PublicPerformanceResponse' # auth_names auth_names = opts[:debug_auth_names] || ['oauth2'] new_options = opts.merge( :operation => :"PublicPerformanceApi.get_page", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: PublicPerformanceApi#get_page\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data\n if @url\n @page = fetch_url(@url)\n @parse_time = parse_dailydev_page\n @page = nil\n self.total_time\n end\n end", "def performance\n authenticated_post(\"auth/r/stats/perf:1D/hist\")\n end", "def index\n @htscdts = Htscdt.all\n end", "def response_time_metrics\n result = {}\n @urls.each do |url|\n result[url[:name]] = get_metrics(url[:path])\n end\n print result\n end", "def get_data\n if @url\n @page = fetch_url(@url)\n @parse_time = parse_today_page\n @page = nil\n self.total_time\n end\n end", "def index\n @performances = Performance.all\n end", "def list\n websites = @logs.records\n @view.show(websites)\n end", "def data_presenter factor\n collection = search\n data_collector collection, factor, params[:duration]\n if request.xhr?\n render partial: 'graph' and return\n end\n end", "def get_data(startdate, enddate)\n\t\t\n\t\tdate_range = @analytics::DateRange.new(start_date: startdate, end_date: enddate)\n\t\torder_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING')\n\t\t# metric = @analytics::Metric.new(expression: 'ga:sessions')\n\t\t# metric = @analytics::Metric.new(expression: ['ga:sessions', 'ga:uniquePageviews'])\n\t\t# metric = @analytics::Metric.new\n\t\t# metric.expression = ['ga:sessions', 'ga:uniquePageviews']\n\t\t\n\t\tmetrics = ['ga:pageviews', 'ga:users', 'ga:bounces', 'ga:sessions',\n\t\t\t\t 'ga:avgTimeOnPage', 'ga:newUsers', 'ga:goal1ConversionRate', 'ga:goal1Completions'\n\t\t\t\t ]\n\n\t\t# metrics = ['ga:totalEvents'\n\t\t# \t\t ]\t\t \n\n\n\t\tmetric_type = Array.new\n\t\tmetrics.each do |m|\n\t\t\tmetric = @analytics::Metric.new\n\t\t\tmetric.expression = m\n\t\t\tmetric_type.push(metric)\n\t\tend\n\n\t\tdimensions = ['ga:pagePath', 'ga:pageTitle', 'ga:hostname' ]\n\t\t# dimensions = ['ga:pagePath', 'ga:eventCategory']\n\t\tdimension_type = Array.new\n\t\tdimensions.each do |d|\n\t\t\tdimension = @analytics::Dimension.new\n\t\t\tdimension.name = d\n\t\t\tdimension_type.push(dimension)\n\t\tend\n\n\n\t\t# dimension = @analytics::Dimension.new(name: 'ga:pagePath')\n\n\t\t# dimension_filters = @analytics::DimensionFilterClause.new(\n\t # filters: [\n\t # @analytics::DimensionFilter.new(\n\t # dimension_name: 'ga:pagePath',\n\t # operator: \"IN_LIST\",\n\t # expressions: ['/archives/69839', '/archives/54087', '/archives/68924', '/archives/58437', '/archives/65171', '/archives/64435', '/archives/61533', '/archives/68924',\n\t # \t\t\t\t'/archives/65086', '/archives/64736', '/archives/55244', '/archives/68211'\n\t # ]\n\t # )\n\t # ]\n\t # )\n\n\t\trequest = @analytics::GetReportsRequest.new(\n \t\t\treport_requests: [@analytics::ReportRequest.new(\n \t\t\tview_id: @view_id, \n \t\t\tmetrics: metric_type, \n \t\t\tdimensions: dimension_type,\n \t\t\t# dimension_filter_clauses: [dimension_filters],\n \t\t\t# dimensions: [dimension], \n \t\t\tdate_ranges: [date_range],\n \t\t\torder_bys: [order_by],\n \t\t\tpageSize: 10000\n \t\t\t)]\n\t\t)\n\t\tresponse = @client.batch_get_reports(request)\n\t\tmessageHash = {}\n\n\t\t# handling error \n\t\tif !response.reports.first.data.rows then\n\t\t\t\n\t\t\tkey = \"message\"\n\t\t\tmessageHash[key.to_sym] = \"no data\"\n\t\t \treturn messageHash\n\t\tend\n\n\n\t\tdata_from_google = response.reports.first.data.rows\n\n\t\tkey_array = dimensions + metrics\n\n\t\t# get rid of 'ga:'\n\t\tkey_array.each_with_index do |k, index| \n\t\t\tkey_array[index] = k.gsub(\"ga:\",\"\")\n\t\tend\n\n\t\tkey_array.push('id')\n\t\tkey_array.push('clickCount')\n\n\t\tset_ga_data_array = Array.new\n\n\n\t\tdata_from_google.each_with_index do |r, index|\n\n\t\t\tdatahash = {}\n\t\t\ti = 0;\n\n\t\t\t# setup dimension part\n\t\t\tr.dimensions.each do |d|\n\t\t\t\tdatahash[key_array[i]] = d\n\t\t\t\ti += 1\n\t\t\tend\n\n\t\t\t# setup metrics part\n\t\t\tr.metrics.first.values.each do |m|\n\t\t\t\tdatahash[key_array[i]] = m\n\t\t\t\ti += 1\n\t\t\tend\n\n\t\t\t\n\t\t\t# get aticle data from db\n\t\t\tarticleArr = set_article_data(datahash['hostname'], datahash['pagePath'], startdate, enddate)\n\n\t\t\t# setup id, mcv\n\t\t\tarticleArr.each do |a|\n\t\t\t\tdatahash[key_array[i]] = a\n\t\t\t\ti += 1\n\t\t\tend\n\n\t\t\tset_ga_data_array.push(datahash)\n\n\t\t\t#datahash sample -> { \"pagePath\": \"/archives/69839\", ... , \"goal1Completions\": \"23\", \"id\": 4, \"clickCount\": 0 },\n\t\tend\n\t\t\n\t\treturn set_ga_data_array\n\tend", "def cached_trending\n Rails.cache.fetch(cleaned_query_param, cache_nils: false, :expires_in => 1.hours) do\n request_trending\n #Check for empty array in case there are no trending devs for the specified technology\n unless @data.empty?\n format_trending\n else\n no_trending_devs = { Information: \"There are currently no trending developers in this category\" }\n end\n end\n end", "def get_perf_data(host, perf_start, perf_end)\n @logger.perf_output(\"Getting perf data for host: \" + host)\n if PERF_SUPPORTED_PLATFORMS.match?(host['platform']) # All flavours of Linux\n host.exec(Command.new(\"sar -A -s #{perf_start.strftime('%H:%M:%S')} -e #{perf_end.strftime('%H:%M:%S')}\"), :acceptable_exit_codes => [0, 1, 2]) if not @options[:collect_perf_data]&.include?('aggressive')\n if (defined? @options[:graphite_server] and not @options[:graphite_server].nil?) and\n (defined? @options[:graphite_perf_data] and not @options[:graphite_perf_data].nil?)\n export_perf_data_to_graphite(host)\n end\n else\n @logger.perf_output(\"Perf (sysstat) not supported on host: \" + host)\n end\n end", "def index\n @slowlogexts = Slowlogext.get_all(params[:page])\n end", "def index\n authorize! :view, Measurement\n\n @measurements = Measurement.all\n\n @sites = Site.all\n @instruments = Instrument.all\n \n respond_to do |format|\n format.html\n format.csv { send_data @measurements.to_csv }\n end\n end", "def export_perf_data_to_graphite(host)\n @logger.perf_output(\"Sending data to Graphite server: \" + @options[:graphite_server])\n\n data = JSON.parse(host.exec(Command.new(\"sadf -j -- -A\"), :silent => true).stdout)\n hostname = host['vmhostname'].split('.')[0]\n\n data['sysstat']['hosts'].each do |host|\n host['statistics'].each do |poll|\n timestamp = DateTime.parse(poll['timestamp']['date'] + ' ' + poll['timestamp']['time']).to_time.to_i\n\n poll.keys.each do |stat|\n case stat\n when 'cpu-load-all'\n poll[stat].each do |s|\n s.keys.each do |k|\n next if k == 'cpu'\n\n socket = TCPSocket.new(@options[:graphite_server], 2003)\n socket.puts \"#{@options[:graphite_perf_data]}.#{hostname}.cpu.#{s['cpu']}.#{k} #{s[k]} #{timestamp}\"\n socket.close\n end\n end\n\n when 'memory'\n poll[stat].keys.each do |s|\n socket = TCPSocket.new(@options[:graphite_server], 2003)\n socket.puts \"#{@options[:graphite_perf_data]}.#{hostname}.memory.#{s} #{poll[stat][s]} #{timestamp}\"\n socket.close\n end\n end\n end\n end\n end\n end", "def hourly(query)\n get_json(\"#{api_url}/hourly/q/#{parse_query(query)}.#{@options[:format]}\")\n end", "def get_metrics(path, query={}, headers={})\n url = Client::make_url(URI_TEMPLATE, {:path=>path} )\n response = get( url, query, headers )\n if block_given?\n yield response\n end\n validate_response(url, query, response) \n return JSON.parse( response.content ) \n end", "def index\n @dor_variant_performances = DorVariantPerformance.all\n end", "def date_time_url\n @slowest_time= 0\n print \"\\nTotal requests grouped by the Date/hour\\n\\n\"\n\t\t\n #taking each date&hour\n @count.each do|val1,val2|\n slowest = 0\n \n #searching on each line to find slowest\n $file.each_line do|line|\n\tif line.include? val1\n\t time = line.match /\\d+$/\n\t if time\n\t #finding slowest time\n\t time = time[0].to_i\n\t if time > slowest\n\t slowest = time\n\t end\n\t end\n\tend\n\tslowest = slowest.to_s\n\t#finding slowest url in corresponding date\n\tif line.include? slowest\n\t @url = line.match /https?:\\/\\/[\\S]+/.to_s\n\tend\n\tslowest = slowest.to_i\n end\n \n #checking plural form of request.\n request = \"request\"\n if val1.to_i > 1\n\trequest += \"s\"\n end \n print \"#{ val1 } : #{ val2 } #{ request } \\tSlowest-Time : #{ slowest } \\tSlowest-URL : #{ @url }\\n\\n\"\n \n #finding slowest URL in the log.\n if slowest > @slowest_time\n @slowest_time = slowest\n @slowest_url = @url\n end\n end \n print \"Slowest URL : #{ @slowest_url }\\n\"\n end", "def get_sites(tlp = true)\n local_copy = File.expand_path(\"#{get_url(true)}#{get_filename(tlp)}\", __FILE__)\n if File.exist? local_copy\n crawl_time = File.mtime(local_copy).httpdate # show time in same format as last-mod\n sites = JSON.parse(File.read(local_copy))\n else\n response = Net::HTTP.get_response(URI(\"#{get_url(false)}#{get_filename(tlp)}\"))\n crawl_time = response['last-modified']\n sites = JSON.parse(response.body)\n end\n return sites, crawl_time\n end", "def query(path, query)\n path = relativize_path path\n params = { :apiKey => api_key, :q => query, :format => 'detailed' }\n resp = Precog.get(self, \"/analytics/v#{VERSION}/fs/#{path}\", { 'Content-Type' => 'application/json' }, params)\n output = JSON.parse resp.body\n\n [\n output[\"errors\"].select { |i| !i.nil? }.map { |i| Precog.parse_info i },\n output[\"warnings\"].select { |i| !i.nil? }.map { |i| Precog.parse_info i },\n output[\"data\"]\n ]\n end", "def results\n get_domain_data\n end", "def stats\n year = Analytic.where(\"created_at > ?\", Time.now - 1.year)\n @stats = time_data year\n\n respond_to do |format|\n format.html # stats.html.erb\n format.json { render json: time_data(year, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(year, :hash) }\n end\n end", "def parse_dailydev_page\n start = Time.now\n items = @page.search('.ddinfo')\n if items.any?\n items.each do |item|\n desc = item.search('.foot').empty\n desc = item.inner_text.strip\n link_el = item.search('a').select { |item| /\\/deviation\\// === item.attributes['href'] }.first\n link = link_el.attributes['href']\n title = link_el.inner_text\n @daily_data << { :title => title, :desc => desc, :link => link }\n end\n end\n Time.now - start\n end", "def analytics_for(url)\n UrlAnalytics.new(url).collect_data\n end", "def index\n @reporting_periods = ReportingPeriod.order(date: :desc)\n .includes(:full_reports).page params[:page]\n @data = ::Api::Charts::ReportingPeriod.new(@reporting_periods)\n .reporting_periods_cost_data\n end", "def links_with_domain(domain, options = {})\n options = options.clone\n\n parameters = { :url => domain, :t => options[:time] }\n options.merge! parameters\n options.delete :t\n\n objects_from_response(:get, 'api/info.json', options)\n end", "def index\n page = params[:page] || 1\n @metric_speedtests = MetricSpeedtest.page(page)\n end", "def index\r\n @visits = Visit.fetch_ordered_by_page(params[\"page\"], [], 'started_at DESC')\r\n end", "def display_webpage_views\n webpage_views\n puts 'Overall webpage views'\n puts \"\\n\"\n @webpage_views_hash.each do |webpage, view_hash|\n puts webpage\n puts \"#{view_hash.values[0]} unique views\"\n puts \"#{view_hash.values[1]} total views\"\n puts \"\\n\"\n end\n end", "def performances\n unless @performances\n @performances = Source.all.map do |source|\n SourcePerformance.new(source: source, site: site)\n end\n @performances.sort! {|a,b| b.success_ratio <=> a.success_ratio}\n end\n @performances\n end", "def raw_stats\n url = URI.parse(stats_url)\n Net::HTTP.start(url.host, url.port) {|http|\n http.request(Net::HTTP::Get.new(url.path))\n }.body\nend", "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 @performance_evaluations = PerformanceEvaluation.all\n end", "def index\n @web_data = WebData.all\n end", "def stats\n @stats = time_data Episode.all\n @cloud = word_cloud Episode.pluck(:title)\n\n respond_to do |format|\n format.html # stats.html.erb\n format.json { render json: time_data(Episode.all, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(Episode.all, :hash) }\n end\n end", "def index\n @sites = Site.all.order(:created_at)\n\n # @debug = scrape_all\n # @debug = scrape 'http://workingnews.blog117.fc2.com/?xml'\n \n # @spreadsheet = GoogleSpreadsheets::Enhanced::Spreadsheet.find('0ArhV7gTgs6Z8dHlSRUF2SzFXWjlkU1V2d29KR2pkdXc')\n # @worksheet = @spreadsheet.worksheets.find_by(title: 'site_rows')\n # @rows = @worksheet.rows\n # @site_rows = Site.site_rows\n \n # 同期実行\n # Site.sync_with_site_rows\n\n # スクレイピング\n # ApplicationController.helpers.scrape_update\n # ApplicationController.helpers.scrape \"http://alfalfalfa.com/index.rdf\"\n\n respond_to do |format|\n if Rails.env.development?\n format.html { render :html => @sites }\n end\n format.json { render :json => @sites.as_json }\n end\n end", "def get_usage(args= {})\n args = {:day=>\"today\", :type=>\"heat\"}.merge(args)\n result = HTTParty.get( @tstat_ip + '/tstat/datalog', :headers => @headers) \n \n day = result[args[:day]]\n runtime = day[args[:type] + '_runtime']\n\n return runtime\n end", "def show_site_stats # :nologin: :norobots:\n store_location\n @site_data = SiteData.new.get_site_data\n\n # Add some extra stats.\n @site_data[:observed_taxa] = Name.connection.select_value %(\n SELECT COUNT(DISTINCT name_id) FROM observations\n )\n @site_data[:listed_taxa] = Name.connection.select_value %(\n SELECT COUNT(*) FROM names\n )\n\n # Get the last six observations whose thumbnails are highly rated.\n query = Query.lookup(:Observation, :all,\n by: :updated_at,\n where: \"images.vote_cache >= 3\",\n join: :\"images.thumb_image\")\n @observations = query.results(limit: 6,\n include: { thumb_image: :image_votes })\n end", "def index\n my_tenant_id = (current_user.role == 'admin' ? current_user.tenant_id : nil)\n @all_stats = Stats.new\n @seven_day_stats = Stats.new(tenant_id: my_tenant_id, since: (Time.new - 7.days))\n @resources = build_table_query\n # If no records were found and a search parameter was specified, requery with\n # a ful text search to find partial word matches\n @resources = build_table_query(true) if @resources.empty? && params[:q].present? && params[:q].length > 4\n @publications = InternalDatum.where(data_type: 'publicationName').order(:value).pluck(:value).uniq\n respond_to do |format|\n format.html\n format.csv\n end\n end", "def index\n @study_spots = StudySpot.all\n\n respond_to do |format|\n format.html\n format.csv { send_data UsageTime.all.to_csv }\n end\n end", "def company_statistics(options={})\n path = \"#{company_path(options)}/company-statistics\"\n get(path, options)\n end", "def index\n @radio_performances = RadioPerformance.all\n end", "def stats\n @stats = time_data Track.all\n @cloud = word_cloud Track.pluck(:artist), split: false, limit: 60\n\n respond_to do |format|\n format.html # stats.html.erb\n format.json { render json: time_data(Track.all, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(Track.all, :hash) }\n end\n end", "def views(repo, options = {})\n opts = ensure_api_media_type(:traffic, options)\n get \"#{Repository.path repo}/traffic/views\", opts\n end", "def index\n retrieve_data_for_graph\n end", "def stats\n Project.hit 15\n Project.hit 32\n @stats = time_data TextMessage.all\n @cloud = word_cloud TextMessage.pluck(:text)\n\n respond_to do |format|\n format.html # stats.html.erb\n format.json { render json: time_data(TextMessage.all, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(TextMessage.all, :hash) }\n end\n end", "def get_commercial_flights_statistics(opts = {})\n data, _status_code, _headers = get_commercial_flights_statistics_with_http_info(opts)\n data\n end", "def cp_performance_chart_data\n data = ::Api::Charts::CPPerformance.new.cp_performance_all_sectors_data\n\n render json: data.chart_json\n end", "def view_stats_all\n data = {\n :name => \"Company Views\",\n :pointInterval => 1.day * 1000,\n :pointStart => 1.weeks.ago.at_midnight.to_i * 1000,\n :data => (1.weeks.ago.to_date..Date.today).map{ |date|\n Impression.where(\n \"created_at > ? AND created_at < ? AND action_name = ? AND controller_name = ?\",\n date.at_beginning_of_day,\n date.tomorrow.at_beginning_of_day,\n 'stat_show',\n 'companies'\n ).select{ |impression| impression.action_name == \"stat_show\"}.count\n }\n }\n respond_with data\n end", "def url_dataset_to_times_series_dashboard(dataset, time_series, options={})\n request.path == explore_data_dashboard_path(dataset.owner, dataset) ? explore_time_series_dashboard_path(time_series.time_series_owner, time_series.time_series_permalink, options) : time_series_path(time_series.time_series_owner, time_series.time_series_permalink, options)\n end", "def index\n # Add code for when the index view is loaded\n page._event ||= store.events.buffer\n page._competencies = []\n params._time ||= 'future'\n end", "def query_times_graphs\n controller = params[:controller_name]\n action = params[:action_name]\n data = redis(logger: true).zrangebyscore(\"request_timings/total/by_action/#{controller}##{action}\",\n 1.month.ago.to_i, '+inf',\n with_scores: true)\n .map { |y, x| [x.to_f, y.to_f] }\n throw 'No Data' if data.nil? || data.empty?\n smoothed = moving_avg(data)\n final = (params[:raw].present? ? data : smoothed).map { |x, y| [Time.at(x.to_i).to_datetime, y] }\n render json: [\n { name: 'Timings', data: final }\n ]\n end", "def analyzeDemandLog()\n demandLogFile = @basePath + \".demandLog.json\" ;\n com = \"../Savs/analyzeDemandLog #{demandLogFile}\" ;\n p [:com, com] ;\n jsonStr = `#{com}` ;\n @demandStat = JSON.load(jsonStr) ;\n return @demandStat ;\n end", "def get_statistics\n response = get_siteinfo('statistics')\n ret = {}\n response['query']['statistics'].each { |k, v| ret[k] = v }\n ret\n end", "def index\n @traffics = Traffic.all\n end", "def publications_by_subdomain(subdomain)\n rvalue = []\n\n (ActiveFedora::SolrService.query(\"+press_sim:#{subdomain} AND +visibility_ssi:open\", rows: 100_000, sort: \"date_modified_dtsi desc\") || []).each do |solr_doc|\n sm = ::Sighrax.from_solr_document(solr_doc)\n op = ::Opds::Publication.new_from_monograph(sm, true, params[:filterByEntityId])\n rvalue.append(op.to_h) if op.valid?\n end\n\n rvalue\n end", "def output(path)\n if @first_pass\n @first_pass = false\n FileUtils.rm_rf path if clean_first\n end\n FileUtils.mkdir_p path\n \n if quick_mode\n posts.chop! 20\n end\n @stats.reset\n \n unless metadata.nil? || !metadata['static'].is_a?(Array)\n stats.record(:site, :static) do\n for dir in metadata['static']\n FileUtils.cp_r File.join(source_dir, dir), File.join(path, dir)\n end\n end\n end\n \n before = Time.now\n Dir.chdir(path) do\n stats.record(:site, :pages) do\n pages.each do |name, page|\n FileUtils.mkdir_p page.output_dir unless File.directory?(page.output_dir)\n if check_mtime\n if File.file?(page.output_path) && File.mtime(page.output_path) > page.source_mtime\n next\n end\n page.load\n end\n File.open(page.output_path, 'w') { |f| f.write page.render }\n end\n end\n \n stats.record(:site, :posts) do\n posts.each do |post|\n FileUtils.mkdir_p post.output_dir unless File.directory?(post.output_dir)\n if check_mtime\n if File.file?(post.output_path) && File.mtime(post.output_path) > post.source_mtime\n next\n end\n post.load\n end\n File.open(post.output_path, 'w') { |f| f.write post.render }\n end\n end\n \n stats.record(:site, :stylesheets) do\n unless stylesheets.nil?\n stylesheets.each do |name, stylesheet|\n FileUtils.mkdir_p stylesheet.output_dir unless File.directory?(stylesheet.output_dir)\n if check_mtime\n if File.file?(stylesheet.output_path) && File.mtime(stylesheet.output_path) > stylesheet.source_mtime\n next\n end\n stylesheet.load\n end\n File.open(stylesheet.output_path, 'w') { |f| f.write stylesheet.render }\n end\n end\n end\n \n stats.record(:site, :indices) do\n unless year_index.nil? && month_index.nil? && day_index.nil?\n posts.each_index do |dir|\n posts = self.posts.from(dir)\n Dir.chdir(dir) do\n context = dir.split('/').collect { |c| c.to_i }\n date_index = case context.length\n when 1\n year_index\n when 2\n month_index\n when 3\n day_index\n else\n nil\n end\n date_index.posts = posts\n date_index.context = Time.local *context\n File.open('index.html', 'w') { |f| f.write date_index.render }\n end\n end\n end\n \n unless tag_index.nil?\n tags.each do |tag|\n tag_index.context = tag.name\n tag_index.posts = tag\n FileUtils.mkdir_p tag.output_dir\n File.open(tag.output_path, 'w') { |f| f.write tag_index.render }\n end\n end\n end\n end\n \n self.stats.display if show_statistics\n end", "def performance(index)\n puts \"\\n#{@testcase.name}\\n\"\n puts \" %-10s %-20s %-8s %s \" % [\"#{@response.runtime.to_s[0..6]}s\", \"[#{result_case}]\", @testcase.request['method'], @response.fully_qualified_path]\n end", "def index\r\n if params[:period]\r\n SignalStrength.switch_data(params[:connection], params[:period])\r\n else\r\n SignalStrength.switch_data(params[:connection], \"daily\")\r\n end\r\n signal = params[:signal] ? params[:signal] : \"%\"\r\n @signal_strengths = SignalStrength.find(:all, :conditions => [\"server_signal LIKE ?\",signal]) \r\n respond_to do |format|\r\n format.html #index.html.erb\r\n format.xml { render :xml => @signal_strengths.to_xml(:dasherize => false) }\r\n end\r\n end", "def slow_sites\n deep_values(\"slow_sites\")\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 @site_data = SiteDatum.all\n end", "def skel_daily( path_storage, section_path )\n entry_range = path_storage.find\n first_time, last_time = entry_range.last.created, entry_range.first.created\n start = Time.mktime( first_time.year, first_time.month, first_time.day, 0, 0, 0 ) + 1\n stop = Time.mktime( last_time.year, last_time.month, last_time.day, 23, 59, 59 )\n days = []\n one_day = 24 * 60 * 60\n until start > stop\n day_entries = path_storage.within( start, start + one_day - 1 )\n days << [day_entries.last.created, day_entries] unless day_entries.empty?\n start += one_day\n end\n days.extend Hobix::Enumerable\n days.each_with_neighbors do |prev, curr, nextd| \n page = Page.new( curr[0].strftime( \"%Y/%m/%d\" ), section_path )\n page.prev = prev[0].strftime( \"%Y/%m/%d\" ) if prev\n page.next = nextd[0].strftime( \"%Y/%m/%d\" ) if nextd\n page.timestamp = curr[0]\n page.updated = path_storage.last_updated( curr[1] )\n yield :page => page, :entries => curr[1]\n end\n end", "def show(path)\n\t require 'pathname'\n\t\t# change to before filter\n\t\tlogin_filter\n\t\t\n\t\t# round about way of getting the secure url we need\n # path = namespace_path(path)\n\t\tpathname = Pathname.new(path)\n\t\turl = self.list(pathname.dirname.to_s).detect{ |f| f[\"name\"] == pathname.basename.to_s }[\"url\"]\n\t\t\n\t\t#https://dl-web.dropbox.com/get/testing.txt?w=0ff80d5d&sjid=125987568\n\t\t@[email protected](url).content\n\tend", "def index\n\n require 'net/http'\n require 'json'\n\n @measures = Measure.all.order(\"created_at DESC\")\n weatherData\n\n end", "def index\n day = Analytic.where(\"created_at > ?\", Time.now - 1.day).order(\"created_at DESC\")\n @analytics = {}\n @analytics[:projects] = Project.all.order(\"hits DESC\")\n @analytics[:ips] = day.distinct.pluck(:ip)\n @analytics[:visits] = day\n @analytics[:user_agents] = day.distinct.pluck(:user_agent)\n @analytics[:referers] = day.distinct.pluck(:referer)\n @analytics[:total] = Analytic.count\n @analytics[:day] = day.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @analytics, callback: params[:callback] }\n format.xml { render xml: @analytics }\n end\n end", "def stat_by_url(url, userdics: nil)\n stat_by_web(url, userdics: userdics)\n end", "def index\n # Limits due to the current search/filter settings are handled within CurationTableRow\n authorize %i[stash_engine admin_datasets]\n my_tenant_id = (%w[admin tenant_curator].include?(current_user.role) ? current_user.tenant_id : nil)\n @all_stats = Stats.new\n @seven_day_stats = Stats.new(tenant_id: my_tenant_id, since: (Time.new.utc - 7.days))\n\n if request.format.to_s == 'text/csv' # we want all the results to put in csv\n page = 1\n page_size = 1_000_000\n else\n page = @page.to_i\n page_size = @page_size.to_i\n end\n\n search_terms = { params: helpers.sortable_table_params, page: page.to_i, page_size: page_size.to_i }\n\n @datasets = AdminDatasetsPolicy::Scope.new(current_user, StashEngine::AdminDatasets::CurationTableRow, search_terms).resolve\n @publications = StashEngine::Journal.order(:title).map(&:title)\n @pub_name = params[:publication_name] || nil\n\n # paginate for display\n blank_results = (page.to_i - 1) * page_size.to_i\n @datasets = Array.new(blank_results, nil) + @datasets # pad out an array with empty results for earlier pages for kaminari\n @datasets = Kaminari.paginate_array(@datasets, total_count: @datasets.length).page(page).per(page_size)\n\n respond_to do |format|\n format.html\n format.csv do\n headers['Content-Disposition'] = \"attachment; filename=#{Time.new.strftime('%F')}_report.csv\"\n end\n end\n end", "def index\n pages_initialization\n\n @timeframes = Timeframe.all\n @timeframe_logs = TimeframeLog.where('extract(year from start_date) = ?', Date.today.year).order(created_at: :ASC)\n @next_timeframe_logs = TimeframeLog.where('extract(year from start_date) = ?', Date.today.year + 1)\n @timeframe_logs_advanced_two_years = TimeframeLog.where('extract(year from start_date) = ?', Date.today.year + 2)\n end", "def realtime\n render :json=>WebUrl.all.map(&:url).to_json\n end", "def index\n @system_overviews = SystemOverview.all\n if @system_overviews.size > 0\n\n data_table = GoogleVisualr::DataTable.new\n data_table.new_column('string', 'Label')\n data_table.new_column('number', 'Value')\n data_table.add_rows(3)\n data_table.set_cell(0, 0, 'Current')\n data_table.set_cell(0, 1, SystemOverview\n .last.currently_running\n .tr('W', '')\n .tr('KW', '')\n .to_i\n )\n opts = { width: 400, height: 120, redFrom: 90, redTo: 100, yellowFrom: 75, yellowTo: 90, minorTicks: 5 }\n @chart = GoogleVisualr::Interactive::Gauge.new(data_table, opts)\n end\n end", "def get_commercial_flights_statistics_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: StatisticsApi.get_commercial_flights_statistics ...'\n end\n # resource path\n local_var_path = '/statistics/flights/commercial'\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[:body] \n\n return_type = opts[:return_type] || 'FlightsStatisticsResponse' \n\n auth_names = opts[:auth_names] || ['bearerToken']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type)\n\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: StatisticsApi#get_commercial_flights_statistics\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @time_lines = TimeLine.all\n end", "def index\n @sensor_data = SensorData.by_time\n end", "def track\n url = Rails.env.development? ? \"http://localhost:8000/stat\" : \"http://stats.universit.as/stat\"\n RestClient.get(url, :params => {\n :ip => request.remote_ip,\n :title => request.referrer\n })\n render :js => ''\n end", "def Scrap(search)\n short_name = search.gsub(/\\./, ' ')\n short_name.gsub!(/ (DVDRip|LiMiTED|REPACK|720p|FRENCH|UNRATED|iNTERNAL|TRUEFRENCH).*$/, '')\n \n DataLoadFromSite(short_name)\n end", "def index\n @domains = query(DOMAIN, :name)\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @domains }\n end\n end", "def stats\n @stats = time_data SolarReading.all\n\n respond_to do |format|\n format.html # stats.html.erb\n format.json { render json: time_data(SolarReading.all, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(SolarReading.all, :hash) }\n end\n end", "def domain_report(domain)\n DomainReport.new(api_key: @api_key, domain: domain).response\n end", "def index\n @slopes = Slope.all\n @slopes = duration(@slopes, params)\n end", "def stats\n get_charts\n end", "def index\n @date_time = date_time\n @splitwises = Splitwise.analysis(@date_time)\n end", "def trending(options={})\n response = handle_response(self.class.get(\"/trending.json\", :query => options))\n Topsy::Page.new(response,Topsy::Trend)\n end", "def show\n @site = Site.find_by_site(params[:id])\n @organisation = @site.organisation\n @total_data = WeeklyTotalData.new(@site.weekly_totals, Date.new(2012,10,17)..Date.today, true)\n @most_recent_hit_data = AggregratedMostRecentHitData.new(@site.aggregated_hits, @site.hits.most_recent_hit_on_date)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site }\n end\n end", "def index\n @episodes = Episode.all\n @views_chart = get_all_views(@episodes)\n @change_chart = get_all_differences(@episodes)\n end", "def find_perf( path )\n perfs[path]\n end", "def explore\n add_time_series_nav_options(show_title: false)\n\n gon.explore_time_series = true\n gon.explore_time_series_ajax_path = explore_time_series_path(:format => :js)\n gon.embed_ids = @time_series.highlights.embed_ids\n gon.private_user = Base64.urlsafe_encode64(current_user.id.to_s)\n\n # need css for tabbed translations for entering highlight description\n @css.push('tabbed_translation_form.css')\n\n # this method is in application_controller\n # and gets all of the required information\n # and responds appropriately to html or js\n explore_time_series_generator(@time_series)\n\n end", "def index\n @time_series = TimeSeries.meta_only.by_owner(@owner.id, current_user.id).sorted\n\n @css.push(\"time_series.css\")\n @js.push(\"search.js\")\n\n set_gon_datatables\n\n respond_to do |format|\n format.html\n format.json { render json: @time_series }\n end\n end", "def ajax_data_load\n\t\t@project = Project.find(params[:project_id])\n\t\t\n\t\t@data = []\n\t\t@data_aggregated = []\n\t\t\n\t\t# if any data is avaiable\n\t\tif not @project.measured_data.empty?\n\t\t \n\t\t # if timespan is given use it to extract data\n \t\tif params.has_key?(:from) and params.has_key?(:to)\n \t\t from_timestamp, to_timestamp = params[:from], params[:to]\n \t\t from_time, to_time = Time.at(from_timestamp.to_f/1000), Time.at(to_timestamp.to_f/1000)\n \t\t \n \t\t# otherwise get all avaiable data\n else \n from_time = @project.measured_data.minimum(:date)\n to_time = @project.measured_data.maximum(:date)\n end\n \n plot_width = params[:plotwidth].to_i\n\t\t\n \t\tinterval = to_time - from_time\n \t\tcalc_resolution = (interval / 60) / (plot_width / 2)\n\t\t\n \t\t# Aufloesung aus gegebenen Aufloesungen waehlen\n \t\tbest_resolution = get_best_resolution(calc_resolution, @project.resolutions.map { |r| r.value })\n\t\t\n\t\t # time hartcodieren... funktioniert mit sql funktion nicht???\n \t\tdb_from = from_time.strftime(\"%Y-%m-%d %H:%M:%S\")\n db_to = to_time.strftime(\"%Y-%m-%d %H:%M:%S\")\n \t\t\n \t\tif best_resolution == 2\n \t\t cond = \"date BETWEEN '#{db_from}' AND '#{db_to}'\"\n \t\t query = @project.measured_data.all(:order => 'date ASC', :conditions => [cond])\n \t\telse\n \t\t cond = \"date BETWEEN '#{db_from}' AND '#{db_to}' AND resolution = #{best_resolution}\"\n \t\t query = @project.approximated_measured_data.all(:order => 'date ASC', :conditions => [cond])\n \t\tend\n\t\t\n \t\tquery.each do |datum|\n datetime = datum.date.to_time.to_i * 1000\n @data << [datetime, datum.value.to_f]\n @data_aggregated << [datetime, datum.aggregated_value.to_f]\n end\n end \n\t\trespond_to do |format|\n\t\t format.json { render json: [@data, @data_aggregated] }\n\t\tend\n\tend", "def index\n @daily_visitors = DailyVisitor.all\n end", "def index\n if params[:format].nil? or params[:format] == 'html'\n @iteration = params[:iteration][/\\d+/] rescue 1\n @cultivars = Cultivar.sorted_order(\"#{sort_column('cultivars')} #{sort_direction}\").search(params[:search]).paginate(\n :page => params[:page],\n :per_page => params[:DataTables_Table_0_length]\n )\n log_searches(Cultivar)\n else # Allow url queries of data, with scopes, only xml & csv ( & json? )\n @cultivars = Cultivar.api_search(params)\n log_searches(Cultivar.method(:api_search), params)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.js # index.html.erb\n format.xml { render :xml => @cultivars }\n format.csv { render :csv => @cultivars }\n format.json { render :json => @cultivars }\n end\n end", "def flowchart\r\n @project = Project.find(params[:project_id])\r\n @foundpages = Page.find(:all, :conditions => { :project_id => @project.id })\r\n render 'flowchart'\r\n end", "def performance\n @advert = Advert.find(params[:id])\n @start_date = Date.parse(params[:filters][:start_date]) rescue 1.month.ago\n @end_date = Date.parse(params[:filters][:end_date]) rescue Time.now\n report_days = (@end_date-@start_date)/1.day\n @report_data={}\n #generate aggregate data\n\n @report_data['totals'] = {}\n @report_data['totals']['impressions'] = @advert.impressions.between(@start_date,@end_date).count\n @report_data['totals']['clicks'] = @advert.clicks.between(@start_date,@end_date).count\n @report_data['totals']['impressions_day'] = @report_data['totals']['impressions']/report_days\n @report_data['totals']['clicks_day'] = @report_data['totals']['clicks']/report_days\n @report_data['totals']['conversion'] = 100.0*(@report_data['totals']['clicks'].to_f/@report_data['totals']['impressions'].to_f)\n #generate sereies data\n @report_data['series'] = {}\n @report_data['series']['impressions'] = @advert.impressions.between(@start_date,@end_date).by_day\n @report_data['series']['clicks'] = @advert.clicks.between(@start_date,@end_date).by_day\n \n #correlate/merge keys for date series \n @report_data['series']['merge']={}\n @report_data['series']['impressions'].each do |i|\n @report_data['series']['merge'][i.day]||={}\n @report_data['series']['merge'][i.day].update({'impressions'=>i.total})\n end\n @report_data['series']['clicks'].each do |c|\n @report_data['series']['merge'][c.day]||={}\n @report_data['series']['merge'][c.day].update({'clicks'=>c.total})\n end\n @graph_data={}\n \n #raise {'series'=>(@start_date.to_date..@end_date.to_date).collect {|d| d.strftime('%m/%d/%y'@report_data['series']['merge'].keys.inspect\n\n @graph_data['impressions']=(@start_date.to_date..@end_date.to_date).collect do |date|\n @report_data['series']['merge'][date.strftime(\"%Y-%m-%d\")]['impressions'].to_i rescue 0\n end\n @graph_data['clicks']=(@start_date.to_date..@end_date.to_date).collect do |date|\n @report_data['series']['merge'][date.strftime(\"%Y-%m-%d\")]['clicks'].to_i rescue 0\n end\n end", "def get_data\n\t \thydra = Typhoeus::Hydra.hydra\n\n\t \tfirst_url = \"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22#{self.stock_ticker}%22)&format=json%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env\"\n\t \tsecond_url = \"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.keystats%20where%20symbol%20in%20(%22#{self.stock_ticker}%22)&format=json%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env\"\n\t \tthird_url = \"http://www.quandl.com/api/v1/datasets/DMDRN/#{self.stock_ticker}_ALLFINANCIALRATIOS.csv?auth_token=#{ENV['QUANDL_API_TOKEN']}\"\n\t \tfourth_url = \"http://www.quandl.com/api/v1/datasets/PSYCH/#{self.stock_ticker}_I.json?&auth_token=auth_token=#{ENV['QUANDL_API_TOKEN']}&trim_start=#{Chronic.parse(\"last week\").strftime(\"%F\")}&trim_end=#{Chronic.parse(\"today\").strftime(\"%F\")}&sort_order=desc\"\n\n\t \t(((first_url) =~ URI::DEFAULT_PARSER.regexp[:ABS_URI]) == 0) ? first_request = Typhoeus::Request.new(first_url) : (return false)\n\t \tsecond_request = Typhoeus::Request.new(second_url) \n\t \tthird_request = Typhoeus::Request.new(third_url) \n\t \tfourth_request = Typhoeus::Request.new(fourth_url) \n\n\t \thydra.queue first_request\n\t \thydra.queue second_request\n\t \thydra.queue third_request\n\t \thydra.queue fourth_request\n\t \t\n\t \thydra.run\n\n\t\t\tfirst_request.response.options[:response_code] == 200 ? first_response = first_request.response : (return false )\n\t \tsecond_response = second_request.response\n\t \tthird_response = third_request.response \n\t \tfourth_response = fourth_request.response\n\n\t \t@quotes = JSON.parse(first_response.body) if !first_response.body.nil?\n\n\t \t@key_stats = JSON.parse(second_response.body) \n\n\t \tthird_request.response.options[:response_code] == 200 ? @quandl_data = CSV.parse(third_response.body) : @quandl_data = nil\n\n\t \tfourth_request.response.options[:response_code] == 200 ? @psych_data = JSON.parse(fourth_response.body) : @psych_data = nil\n\n\t \t@tradier = $tradier_client.quote(self.stock_ticker)\n\n\t \tmethod(:assign_yahooQuotes).call\n\t \tmethod(:assign_yahooKeyStats).call\n\t \tmethod(:assign_quandlStockData).call\n\t \tmethod(:assign_quandlPsychData).call\n\t \tmethod(:assign_databaseValues).call\n\t \tmethod(:assign_stockProfile).call\n\t \tmethod(:assign_tradierQuote).call\n\n\t end", "def index\n @traffics = Traffic.find(:all, :order => \"created_at\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @traffics }\n end\n end", "def site_overview\n url = site 'overview'\n o = self.class.get(url.to_s)['overview']\n SiteOverview.new(\n current_power: o['currentPower']['power'],\n last_day_energy: o['lastDayData']['energy'],\n last_month_energy: o['lastMonthData']['energy'],\n last_year_energy: o['lastYearData']['energy'],\n lifetime_energy: o['lifeTimeData']['energy'],\n update_time: DateTime.parse(o['lastUpdateTime'])\n )\n end", "def trends\n data = generate_data(data_factory)\n respond_with data\n end", "def test_get_site_list\r\n endpoint = \"/sites\"\r\n uri = URI(\"#{@host}#{endpoint}\")\r\n request = Net::HTTP::Get.new(uri)\r\n request['Accept'] = 'application/json'\r\n \r\n test_start = Time.now\r\n response = Net::HTTP.start(uri.hostname, uri.port) do |http|\r\n http.request(request)\r\n end\r\n test_end = Time.now\r\n\r\n @results << {\r\n :api => 'GET /sites',\r\n :endpoint => endpoint,\r\n :start_time => test_start,\r\n :runtime => (test_end.to_f - test_start.to_f) * 1000.0,\r\n :status => response.code,\r\n :content_type => response['content-type']\r\n }\r\n end", "def get_runtime_by_path(event_uid, content_path)\n # checks if all required parameters are set\n \n raise ArgumentError, 'Missing required parameter \"event_uid\"' if event_uid.nil?\n \n raise ArgumentError, 'Missing required parameter \"content_path\"' if content_path.nil?\n \n\n op = NovacastSDK::Client::Operation.new '/events/{event_uid}/runtimes{/content_path*}', :GET\n\n # path parameters\n path_params = {}\n path_params['event_uid'] = event_uid\n path_params['content_path'] = content_path\n op.params = path_params\n\n # header parameters\n header_params = {}\n op.headers = header_params\n\n # query parameters\n query_params = {}\n op.query = query_params\n\n # http body (model)\n \n\n \n # authentication requirement\n op.auths = [\n { name: 'accessKey', key: 'access_token', in_query: true }\n ]\n \n\n resp = call_api op\n\n \n NovacastSDK::EventV1::Models::PageRuntime.from_json resp.body\n \n end", "def index\n if params[:hour] != nil && params[:hour].to_i > 0\n @tracked_data = TrackedDatum.where(updated_at: params[:hour].to_i.hours.ago..Time.now).all.order(:pageURL)\n else\n @tracked_data = TrackedDatum.all.order(:pageURL)\n end\n end", "def index\n @perf_benchmarks = @app.perf_benchmarks.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @perf_benchmarks }\n end\n end" ]
[ "0.5912807", "0.5645461", "0.55971444", "0.5320732", "0.531637", "0.52234256", "0.52157116", "0.5162989", "0.5144299", "0.5132467", "0.510403", "0.50984967", "0.5074786", "0.5072108", "0.50115335", "0.5004517", "0.500131", "0.49921793", "0.4983865", "0.4972901", "0.49705002", "0.4963791", "0.4963404", "0.49606663", "0.49389663", "0.4938753", "0.49320403", "0.49315503", "0.4929797", "0.49259642", "0.49212998", "0.4917728", "0.4913216", "0.49044073", "0.48997566", "0.48713183", "0.48696077", "0.484622", "0.48456836", "0.48432475", "0.4840465", "0.4838454", "0.48382735", "0.48380116", "0.4835005", "0.4819764", "0.48166904", "0.4813808", "0.4805914", "0.4799755", "0.47990292", "0.4798846", "0.4779371", "0.47787023", "0.47684783", "0.4768416", "0.4765069", "0.476465", "0.4763238", "0.47612733", "0.47574842", "0.47533372", "0.47523478", "0.47418433", "0.47418204", "0.47404513", "0.47325537", "0.47319734", "0.4724131", "0.47213998", "0.47210866", "0.47206265", "0.4708339", "0.47068673", "0.4706654", "0.47050676", "0.4697334", "0.46965265", "0.46959087", "0.46905768", "0.46888372", "0.46817276", "0.46805927", "0.4679266", "0.46781337", "0.46775556", "0.46773052", "0.46756676", "0.4675546", "0.4672911", "0.46581948", "0.46577078", "0.46542138", "0.46494532", "0.46480712", "0.46476224", "0.4646514", "0.46444476", "0.46423098", "0.46363592", "0.46346438" ]
0.0
-1
View your website's uptime. Returns uptime time series website performance data for the given domain.
def get_uptime(opts = {}) data, _status_code, _headers = get_uptime_with_http_info(opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data\n if @url\n @page = fetch_url(@url)\n @parse_time = parse_dailydev_page\n @page = nil\n self.total_time\n end\n end", "def index\n @uptimes = Uptime.all\n end", "def uptime\n Sys::Uptime.uptime\n end", "def uptime\n File.foreach('/proc/uptime').each do |line|\n return line.split[0].to_i\n end\n end", "def uptime\n rpc(:uptime, _access: :seconds, _coerce: Hash)\n end", "def uptime\n Time.now - live_since\n end", "def uptime\n LOG_STAT()\n id = id_gen()\n LOG_CALL(id, true, __method__)\n defer { LOG_CALL(id, false, 'uptime') }\n return fmt_time(Time.now.to_i - STARTUP_TIME)\n end", "def uptime\n return File.read('/proc/uptime').split(/\\s+/)[0].to_f rescue 0.0\n end", "def uptime\n Time.now - @start_time\n end", "def uptime\n return 0 unless status.include? \"running\"\n raw = command \"cat /proc/uptime\"\n Log.debug(\"Container (#{@ctid}) uptime requested: #{raw}\")\n raw.split(/\\W/).first.to_i\n end", "def uptime\n super\n end", "def uptime\n @rufus ? @rufus.uptime : nil\n end", "def uptime\n\t\treturn Time.now - self.start_time\n\tend", "def get_usage(args= {})\n args = {:day=>\"today\", :type=>\"heat\"}.merge(args)\n result = HTTParty.get( @tstat_ip + '/tstat/datalog', :headers => @headers) \n \n day = result[args[:day]]\n runtime = day[args[:type] + '_runtime']\n\n return runtime\n end", "def stats\n @server.make_json_request('show.stats', tvdbid: @tvdbid)['data']\n end", "def uptime\n @uptime ||= down? ? nil : Time.now - started_at\n end", "def uptime_percentage\n return summary_average[:uptime_percentage]\n end", "def response_time_metrics\n result = {}\n @urls.each do |url|\n result[url[:name]] = get_metrics(url[:path])\n end\n print result\n end", "def get_site_status(site_url)\n req_start = Time.now\n get_response = HttpHelper.get(site_url)\n if get_response != '-1'\n req_duration = Time.now - req_start\n Rails.logger.info \"STATUS: #{get_response.code} :: response time - #{req_duration}\"\n if req_duration > 4.0\n payload = { \"text\": \"Thredup.com load time exceeded threshold - #{req_duration} sec\" }\n request_hash = {:url => Tokenz.get_channel_url('testing'), :payload => payload}\n HttpHelper.post(request_hash)\n end\n return get_response.code.to_s\n end\n return '-1'\n end", "def calc_uptime(user, password, api_key, id, lastTime, nowTime)\n urlUptime = \"https://#{CGI::escape user}:#{CGI::escape password}@api.pingdom.com/api/2.0/summary.average/#{id}?from=#{lastTime}&to=#{nowTime}&includeuptime=true\"\n responseUptime = RestClient.get(urlUptime, {\"App-Key\" => api_key})\n responseUptime = JSON.parse(responseUptime.body, :symbolize_names => true)\n\n totalUp = responseUptime[:summary][:status][:totalup]\n totalUnknown = responseUptime[:summary][:status][:totalunknown]\n totalDown = responseUptime[:summary][:status][:totaldown]\n\n uptime = (totalUp.to_f - (totalUnknown.to_f + totalDown.to_f)) * 100 / totalUp.to_f\n uptime.round(2)\nend", "def get_data\n if @url\n @page = fetch_url(@url)\n @parse_time = parse_today_page\n @page = nil\n self.total_time\n end\n end", "def uptime\n @root.attributes[\"c\"].to_i\n end", "def display_webpage_views\n webpage_views\n puts 'Overall webpage views'\n puts \"\\n\"\n @webpage_views_hash.each do |webpage, view_hash|\n puts webpage\n puts \"#{view_hash.values[0]} unique views\"\n puts \"#{view_hash.values[1]} total views\"\n puts \"\\n\"\n end\n end", "def get_uptime_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PublicPerformanceApi.get_uptime ...'\n end\n # resource path\n local_var_path = '/cms/v3/performance/uptime'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'domain'] = opts[:'domain'] if !opts[:'domain'].nil?\n query_params[:'path'] = opts[:'path'] if !opts[:'path'].nil?\n query_params[:'pad'] = opts[:'pad'] if !opts[:'pad'].nil?\n query_params[:'sum'] = opts[:'sum'] if !opts[:'sum'].nil?\n query_params[:'period'] = opts[:'period'] if !opts[:'period'].nil?\n query_params[:'interval'] = opts[:'interval'] if !opts[:'interval'].nil?\n query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil?\n query_params[:'end'] = opts[:'_end'] if !opts[:'_end'].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] || 'PublicPerformanceResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['oauth2']\n\n new_options = opts.merge(\n :operation => :\"PublicPerformanceApi.get_uptime\",\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: PublicPerformanceApi#get_uptime\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def uptime\n fmt_time(Time.now.to_i - STARTUP_TIME)\n end", "def calc_uptime(api_key)\n urlUptime = \"https://api.uptimerobot.com/getMonitors?apiKey=#{api_key}&format=json&noJsonCallback=1&responseTimes=1&logs=1&customUptimeRatio=1-7-30-365\"\n response = RestClient.get(urlUptime)\n if response.code == 200\n responseUptime = JSON.parse(response.body, :symbolize_names => true)\n uptime = responseUptime[:monitors][:monitor][0][:customuptimeratio]\n return uptime.split('-')\n else\n puts 'Error: ' + response.code + ' ' + response.body\n return ['?','?','?','?']\n end\n \nend", "def performance\n authenticated_post(\"auth/r/stats/perf:1D/hist\")\n end", "def lifetime_views\n return self.stats.where(:kind => \"lifetime\").first.pageviews\n end", "def parse_dailydev_page\n start = Time.now\n items = @page.search('.ddinfo')\n if items.any?\n items.each do |item|\n desc = item.search('.foot').empty\n desc = item.inner_text.strip\n link_el = item.search('a').select { |item| /\\/deviation\\// === item.attributes['href'] }.first\n link = link_el.attributes['href']\n title = link_el.inner_text\n @daily_data << { :title => title, :desc => desc, :link => link }\n end\n end\n Time.now - start\n end", "def stats\n _get(\"/system/stats\") { |json| json }\n end", "def get_statistics\n response = get_siteinfo('statistics')\n ret = {}\n response['query']['statistics'].each { |k, v| ret[k] = v }\n ret\n end", "def cpu_time_used\n domain_info[:cpuTime]\n end", "def cpu_time_used\n domain_info[:cpuTime]\n end", "def query_uptime\n send(\"QUERY_UPTIME\")\n response = recv\n\n # We expect to get back 1 element only for this method\n raise CommunicationError, \"Unexpected response from QUERY_UPTIME: #{response.join(\":\")}\" if response.length != 1\n\n response[0].to_i\n end", "def realtime_metrics\n current_user = @controller.current_user\n tp = TimeProfile.profile_for_user_tz(current_user.id, current_user.get_timezone) || TimeProfile.default_time_profile\n Metric::Helper.find_for_interval_name('realtime', tp)\n .where(:resource => @ems.try(:all_container_nodes) || ContainerNode.all)\n .where('timestamp > ?', REALTIME_TIME_RANGE.minutes.ago.utc).order('timestamp')\n end", "def show_site_stats # :nologin: :norobots:\n store_location\n @site_data = SiteData.new.get_site_data\n\n # Add some extra stats.\n @site_data[:observed_taxa] = Name.connection.select_value %(\n SELECT COUNT(DISTINCT name_id) FROM observations\n )\n @site_data[:listed_taxa] = Name.connection.select_value %(\n SELECT COUNT(*) FROM names\n )\n\n # Get the last six observations whose thumbnails are highly rated.\n query = Query.lookup(:Observation, :all,\n by: :updated_at,\n where: \"images.vote_cache >= 3\",\n join: :\"images.thumb_image\")\n @observations = query.results(limit: 6,\n include: { thumb_image: :image_votes })\n end", "def uptime\n return 0 if started_at.nil?\n ((Time.now.to_f - started_at.to_f) * 1000.0).to_i\n end", "def uptime\n begin\n return Time.now.to_i.to_f - booted_at.to_f\n rescue Exception\n return 0.0\n end\n end", "def uptime\n return (Time.now.to_i.to_f - booted_at.to_f) rescue 0.0\n end", "def stat_by_url(url, userdics: nil)\n stat_by_web(url, userdics: userdics)\n end", "def date_time_url\n @slowest_time= 0\n print \"\\nTotal requests grouped by the Date/hour\\n\\n\"\n\t\t\n #taking each date&hour\n @count.each do|val1,val2|\n slowest = 0\n \n #searching on each line to find slowest\n $file.each_line do|line|\n\tif line.include? val1\n\t time = line.match /\\d+$/\n\t if time\n\t #finding slowest time\n\t time = time[0].to_i\n\t if time > slowest\n\t slowest = time\n\t end\n\t end\n\tend\n\tslowest = slowest.to_s\n\t#finding slowest url in corresponding date\n\tif line.include? slowest\n\t @url = line.match /https?:\\/\\/[\\S]+/.to_s\n\tend\n\tslowest = slowest.to_i\n end\n \n #checking plural form of request.\n request = \"request\"\n if val1.to_i > 1\n\trequest += \"s\"\n end \n print \"#{ val1 } : #{ val2 } #{ request } \\tSlowest-Time : #{ slowest } \\tSlowest-URL : #{ @url }\\n\\n\"\n \n #finding slowest URL in the log.\n if slowest > @slowest_time\n @slowest_time = slowest\n @slowest_url = @url\n end\n end \n print \"Slowest URL : #{ @slowest_url }\\n\"\n end", "def generate_site_stats\n H.ul {\n H.li {\"#{$r.get(\"users.count\")} users\"} +\n H.li {\"#{$r.zcard(\"news.cron\")} news posted\"} +\n H.li {\"#{$r.info['used_memory_human']} of used memory\"}\n }\nend", "def stats(url, options={})\n query = {:url => url}\n query.merge!(options)\n response = handle_response(self.class.get(\"/stats.json\", :query => query))\n Topsy::Stats.new(response)\n end", "def print_perf_info\n @perf_end_timestamp = Time.now\n @hosts.map { |h| get_perf_data(h, @perf_timestamp, @perf_end_timestamp) }\n end", "def pageviews(period)\n stat = self.stats.find(:first, :conditions => ['period = ? AND kind = ?', period, \"period\"])\n if stat\n return stat.pageviews\n else\n return 0\n end\n end", "def monitoring_stats(region = current_region)\n redis = Redis.new :host => \"localhost\"\n today = \"2012-02-14\" # TODO(philc): \n request_count = redis.get(\"#{region.name}_request_count\").to_i\n errors = redis.get(\"html5player:error_count:#{today}\").to_i\n error_rate = (request_count == 0) ? 0 : (errors / request_count.to_f * 100)\n latency = (request_count == 0) ? 0 : redis.get(\"#{region.name}_latency\").to_i / request_count\n {\n :request_count => request_count,\n :average_latency => latency,\n :error_count => errors,\n :error_rate => error_rate\n }\n end", "def links_with_domain(domain, options = {})\n options = options.clone\n\n parameters = { :url => domain, :t => options[:time] }\n options.merge! parameters\n options.delete :t\n\n objects_from_response(:get, 'api/info.json', options)\n end", "def webpage_views\n count_unique_views\n count_total_views\n\n @unique_views_hash.each do |webpage, unique|\n @webpage_views_hash.store(webpage, 'Unique views' => unique)\n end\n\n @total_views_hash.each do |webpage, total|\n @webpage_views_hash[webpage].store('Total views', total)\n end\n @webpage_views_hash\n end", "def display_info\n @all_domains.each do |key, domain|\n puts \"Domain : \" + domain.domain_name\n puts domain.email_statistics.inspect\n puts \"*\" * 80\n end\n end", "def list\n websites = @logs.records\n @view.show(websites)\n end", "def publications_by_subdomain(subdomain)\n rvalue = []\n\n (ActiveFedora::SolrService.query(\"+press_sim:#{subdomain} AND +visibility_ssi:open\", rows: 100_000, sort: \"date_modified_dtsi desc\") || []).each do |solr_doc|\n sm = ::Sighrax.from_solr_document(solr_doc)\n op = ::Opds::Publication.new_from_monograph(sm, true, params[:filterByEntityId])\n rvalue.append(op.to_h) if op.valid?\n end\n\n rvalue\n end", "def set_uptime\n @uptime = Uptime.find(params[:id])\n end", "def stats\n @stats = time_data Episode.all\n @cloud = word_cloud Episode.pluck(:title)\n\n respond_to do |format|\n format.html # stats.html.erb\n format.json { render json: time_data(Episode.all, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(Episode.all, :hash) }\n end\n end", "def uptime_in_seconds\n if ! File.readable?(\"/proc/uptime\")\n return File.open(\"/proc/uptime\", mode=\"r\").gets[/^\\d+/].to_i\n else \n info = `uptime`.scan(/^\\s(\\d{2}.\\d{2}.\\d{2})\\sup\\s(\\d+)\\s(\\w+),\\s+(\\d+)(:\\d+|\\w+)/).flatten!\n # => [[\"19:52:49\", \"48\", \"days\", \"1\", \":26\"]]\n\n now = info[0]\n value = info[1].to_i\n unit = info[2].to_s\n precision = info[3].to_s\n surprise = info[4].to_s\n\n seconds = 0\n\n case unit\n when \"days\"\n seconds = value*24*60*60\n when \"hour\"\n seconds = value*60*60\n when \"min\"\n seconds = value*60\n end\n\n if surprise.match(/^:(\\d+)$/)[1]\n hours = precision.to_i\n minutes = $1.to_i\n seconds += hours*60*60 + minutes*60\n elsif surprise.match(/min/)\n minutes = precision.to_i\n seconds += minutes*60\n end\n\n return seconds\n end\nend", "def validator_daily_score(_address)\n get('/validators/summary_hourly').map do |summary|\n Celo::ValidatorSummary.new(summary)\n end\n end", "def stats!\n info \"STATS\"\n task \"generate chart\" do\n c = Chart::StatsPerCollection.new\n @dbi.execute( File.read( sql_query(:chart) ) ).each{ |date,collection|\n c.add_one(collection, Date.parse(date).day)\n }\n Chart.new(c).write File.join( @config['settings']['output'], '/chart.jpg' )\n end\n end", "def user_stats\n @user = User.find(params[:id])\n @stats = time_data @user.episodes\n @cloud = word_cloud @user.episodes.pluck(:title)\n\n respond_to do |format|\n format.html { render 'stats' }\n format.json { render json: time_data(@user.episodes, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(@user.episodes, :hash) }\n end\n end", "def index\n @htscdts = Htscdt.all\n end", "def my_websites\n websites = Website.search_by_user(get_current_user)\n websites.each do |w| \n if w.status == Website::STATUS_VERIFIED\n w.count_tagged_images\n w.count_spots\n w.count_total_income\n end\n end\n return websites\n end", "def page_views_dashboard\n @timeframes = Impression::TIMEFRAMES\n end", "def uptime\n @started ? (Time.now - @started).to_i : 0\n end", "def visits(period)\n stat = self.stats.where(:period => period).first\n return stat.visits\n end", "def index\n @system_stats = SystemStat.all\n end", "def video_get_stats(sig, options = {})\n options = {:type => 'day', :value => 15, :sig => sig, :appToken => app_token}.merge options\n response = get(\"/video/getStats/\", options)\n process_response(response, [:stats])\n end", "def results\n get_domain_data\n end", "def stats\n request :get, \"_stats\"\n end", "def stats\n request :get, \"_stats\"\n end", "def runtime\n details.at(\"div.subtext time[itemprop='duration']\")['datetime'].gsub(/[^\\d+]/, '').to_i rescue nil\n end", "def summary(period=:day, date=Date.today)\n raise UnknownSite, \"Site not existent in Piwik yet, call 'save' first\" if new?\n xml = call('VisitsSummary.get', :idSite => id, :period => period, :date => date)\n result = XmlSimple.xml_in(xml, {'ForceArray' => false})\n {\n :visits => result['nb_visits'].to_i,\n :unique_visitors => result['nb_uniq_visitors'].to_i,\n :actions => result['nb_actions'].to_i,\n :max_actions_per_visit => result['max_actions'].to_i,\n :bounces => result['bounce_count'].to_i,\n :total_time_spent => result['sum_visit_length'].to_i, # in seconds\n }\n end", "def track\n url = Rails.env.development? ? \"http://localhost:8000/stat\" : \"http://stats.universit.as/stat\"\n RestClient.get(url, :params => {\n :ip => request.remote_ip,\n :title => request.referrer\n })\n render :js => ''\n end", "def user_activity_live_data\n [\n {\n key: 'active_in_last_hour',\n name: t('statistics.entries.users.currently_active'),\n data: ExternalUser.joins(:submissions)\n .where(['submissions.created_at >= ?', DateTime.now - 5.minutes])\n .distinct('external_users.id').count,\n },\n {\n key: 'submissions_per_minute',\n name: t('statistics.entries.exercises.submissions_per_minute'),\n data: (Submission.where('created_at >= ?', DateTime.now - 1.hour).count.to_f / 60).round(2),\n unit: '/min',\n axis: 'right',\n },\n ]\n end", "def latest_reports(urls)\n urls.each do |cururl|\n if cururl.nil?\n next\n end\n # read from our last run\n filename = DATA_DIR + \"/#{cururl[:label]}.last_run\"\n begin\n f = File.open(filename, \"r\")\n runtime = f.read\n f.close\n rescue\n runtime = 30\n end\n puts \"loadtime#{cururl[:index]}.value #{runtime}\"\n end\nend", "def view_stats_all\n data = {\n :name => \"Company Views\",\n :pointInterval => 1.day * 1000,\n :pointStart => 1.weeks.ago.at_midnight.to_i * 1000,\n :data => (1.weeks.ago.to_date..Date.today).map{ |date|\n Impression.where(\n \"created_at > ? AND created_at < ? AND action_name = ? AND controller_name = ?\",\n date.at_beginning_of_day,\n date.tomorrow.at_beginning_of_day,\n 'stat_show',\n 'companies'\n ).select{ |impression| impression.action_name == \"stat_show\"}.count\n }\n }\n respond_with data\n end", "def domain_report(domain)\n DomainReport.new(api_key: @api_key, domain: domain).response\n end", "def create_hourly_report(url)\n @total_serv_time = 0\n @time_spent_g = 0\n @time_spent_p = 0\n @user_list = []\n @g_count = 0\n @p_count = 0\n @n = 1\n puts \"24 Hour Report for #{url}\"\n puts \"---------------------------------------------------------------------------------------------\"\n puts \"TH HOUR---# USER---# GET---# POST---TOTAL_TIME_GET(ms)---TOTAL_TIME_POST(ms)---TOTAL_TIME(ms)\"\n puts \"---------------------------------------------------------------------------------------------\"\n for n in 1..24\n $all_user_data.each do |k,v|\n if v[:th_hour] == n && !v[:uri].to_s.string_contains(url).nil? \n @total_serv_time += v[:time].to_i\n if v[:method] == 'G'\n @time_spent_g += v[:time].to_i\n @g_count += 1 \n end\n if v[:method] == 'P'\n @time_spent_p += v[:time].to_i\n @p_count += 1 \n end\n @user_list << v[:user].to_s\n end \n end\n #puts \"#{n}TH HOUR---#{@user_list.uniq.length} users---#{@g_count} GET REQs---#{@p_count} POST REQs---#{@time_spent_g}ms in GET---#{@time_spent_p}ms in POST---#{@total_serv_time}ms in Total\"\n puts \"#{n}TH HOUR---#{@user_list.length} users---#{@g_count} GET REQs---#{@p_count} POST REQs---#{@time_spent_g}ms in GET---#{@time_spent_p}ms in POST---#{@total_serv_time}ms in Total\"\n #pp @@user_list.uniq\n @total_serv_time = 0\n @time_spent_g = 0\n @time_spent_p = 0\n @g_count = 0\n @p_count = 0\n @user_list.clear\n end\n end", "def ping_stats(url, time)\n\n logger.info \"ping_stats:start: url = #{url}, time = #{time.to_i}\"\n\n jsonResponse = rest_call(url)\n response_hash = JSON.parse(jsonResponse)\n nodes = response_hash['nodes']\n\n this_node = nodes.select { |node| node.has_key?('thisNode') && node['thisNode'] == true }.first\n\n if this_node != nil\n nodes.each do |node|\n if node['otpNode'] != this_node['otpNode']\n hostname = URI.parse(\"http://#{node['hostname']}\").host.downcase\n ping_time = time_socket_open_close(hostname, '22')\n write_to_graphite( construct_metric_name(\"#{this_node['otpNode'].gsub('.','-')}.ping.#{hostname.gsub('.','-')}\", CONST_NODE_LEVEL), ping_time, time)\n end\n end\n else\n logger.info 'No nodes found with thisNode == true'\n end\n\n logger.info 'ping_stats:end: Completed'\n end", "def getAppStats(package, startDay, endDay)\n dim = \"overall,country,language,os_version,device,app_version,carrier&met=daily_device_installs,active_device_installs,daily_user_installs,total_user_installs,active_user_installs,daily_device_uninstalls,daily_user_uninstalls,daily_device_upgrades\"\n\n url = \"https://play.google.com/apps/publish/statistics/download\"\n url += \"?package=#{package}\"\n url += \"&sd=#{startDay}&ed=#{endDay}\"\n url += \"&dim=#{dim}\"\n url += \"&dev_acc=#{@dev_acc}\"\n\n puts url\n try_get(url)\n return @agent.page.body\n end", "def index\n @system_overviews = SystemOverview.all\n if @system_overviews.size > 0\n\n data_table = GoogleVisualr::DataTable.new\n data_table.new_column('string', 'Label')\n data_table.new_column('number', 'Value')\n data_table.add_rows(3)\n data_table.set_cell(0, 0, 'Current')\n data_table.set_cell(0, 1, SystemOverview\n .last.currently_running\n .tr('W', '')\n .tr('KW', '')\n .to_i\n )\n opts = { width: 400, height: 120, redFrom: 90, redTo: 100, yellowFrom: 75, yellowTo: 90, minorTicks: 5 }\n @chart = GoogleVisualr::Interactive::Gauge.new(data_table, opts)\n end\n end", "def index\n @gp40s = Gp40.all\n @gp40s = duration(@gp40s, params)\n end", "def index\n @log_load_times = LogLoadTime.all\n end", "def stats\n @page_title = I18n.t(\"statistics\")\n redirect_to root_url unless current_user.is_admin? # don't release this yet...it's not ready for public consumption\n @stats = PageStatsTaxon.latest\n end", "def record_result_to_tsdb()\n log_time_sec=@time_now.to_i-120\n @pv_response_time.each do |uri,response_time|\n send_metric(\"jpaas_app_responsetime\",log_time_sec,response_time,{\"uri\"=>uri,\"router\"=>@hostname})\n end\n @pv_response_code.each do |uri,response_code_hash|\n response_code_hash.each do |response_code,count|\n send_metric(\"jpaas_app_pv\",log_time_sec,count,{\"uri\"=>uri,\"response_code\"=>response_code,\"router\"=>@hostname})\n end\n end\n end", "def get_usage_timeseries(start_hr, opts = {})\n data, _status_code, _headers = get_usage_timeseries_with_http_info(start_hr, opts)\n data\n end", "def pull_data\n @pulling = true\n\n model_updating\n\n # pull the page from the url\n page = Nokogiri::HTML(open(@url))\n \n # get the title for the film\n title = page.css(\"h1.film-title\").text\n define_singleton_method(:title, lambda{title})\n\n # get the runtime for the film\n runtime_cap = page.css(\".text-link\").text.match(/(\\d+) mins/)\n if runtime_cap\n runtime = runtime_cap.captures[0].to_i\n else\n runtime = 0\n end\n define_singleton_method(:runtime, lambda{runtime})\n\n # get the tagline for the film\n tagline = page.css(\".tagline\").text\n define_singleton_method(:tagline, lambda{tagline})\n\n # get the overview for the film\n overview = page.css(\"div.truncate\").text.strip\n define_singleton_method(:overview, lambda{overview})\n \n @pulled = true\n @pulling = false\n\n model_updated\n end", "def raw_stats\n url = URI.parse(stats_url)\n Net::HTTP.start(url.host, url.port) {|http|\n http.request(Net::HTTP::Get.new(url.path))\n }.body\nend", "def since_launch\n t_start = Time.parse(\"November 1, 2008\")\n t_current = t_start\n t_end = Time.today\n stats = []\n while (t_current < t_end) do\n puts \"Getting stats for #{t_current.to_s(:date_only)}\"\n stats << \"#{t_current.strftime('%m/%d/%Y')}, #{User.count(:conditions => ['activated_at >= ? and activated_at < ?', t_current, t_current + 1.day])}\"\n t_current += 1.day\n end\n puts stats\n end", "def daily_usage\n @machine = Machine.find(params[:id])\n \n day = DateTime.new(2012,06,10)\n @machine.gen_daily_user_usage(day)\n respond_to do |format|\n format.html # show.html.erb\n end\n end", "def survival_stats\n return unless public?\n\n if @survival_stats.nil?\n survival_data = @xml_data['stats']['survival']\n\n @survival_stats = {}\n @survival_stats[:gold_medals] = survival_data['goldmedals'].to_i\n @survival_stats[:silver_medals] = survival_data['silvermedals'].to_i\n @survival_stats[:bronze_medals] = survival_data['bronzemedals'].to_i\n @survival_stats[:rounds_played] = survival_data['roundsplayed'].to_i\n @survival_stats[:best_time] = survival_data['besttime'].to_f\n end\n\n @survival_stats\n end", "def weekStats()\r\n # Get the first day\r\n curCal = JCalendar::getInstance()\r\n curCal.add(JCalendar::DATE, -7)\r\n weekStatsCount = @daohelper.getVisitAuditDate(curCal)\r\n \r\n # Extract visit stats for the last 7 days\r\n i = -6\r\n statMap = {}\r\n statMapDates = {}\r\n while i <= 0\r\n curCal = JCalendar::getInstance()\r\n curCal.add(JCalendar::DATE, i)\r\n curStat = @daohelper.getVisitAuditOnDate(curCal) \r\n strId = \"stats#{i + 6}\"\r\n statMap[strId] = curStat\r\n statMapDates[strId] = curCal\r\n i += 1\r\n end\r\n\r\n stats = BotListVisitLogStatsForm.new\r\n stats.weekVisits = weekStatsCount\r\n stats.weekStats = statMap\r\n stats.weekStatsDates = statMapDates\r\n return stats\r\n end", "def get_domain_count\n query_push 'Command' => 'GetDomainCount'\n get_response\n end", "def metrics(data)\n results = Crack::XML.parse(perform('/stats', :data => data))['scores']\n return if results.nil? # we have no stats about our data\n AfterTheDeadline::Metrics.new results['metric']\n end", "def index\n @users = User.where(:admin => false).paginate(:page => params[:page])\n @total_domains = Domain.count\n @system_domains = Domain.where('user_id IS NULL').count\n end", "def index\n @users = User.where(:admin => false).paginate(:page => params[:page])\n @total_domains = Domain.count\n @system_domains = Domain.where('user_id IS NULL').count\n end", "def index\n app = extract_app\n ps = heroku.ps(app)\n\n objects = ps.sort_by do |p|\n t,n = p['process'].split('.')\n [t, n.to_i]\n end.each do |p|\n p['state'] << ' for ' << time_ago(p['elapsed']).gsub(/ ago/, '')\n p['command'] = truncate(p['command'], 36)\n end\n\n display_table(\n objects,\n ['process', 'state', 'command'],\n ['Process', 'State', 'Command']\n )\n end", "def data_presenter factor\n collection = search\n data_collector collection, factor, params[:duration]\n if request.xhr?\n render partial: 'graph' and return\n end\n end", "def get_hypervisor_stats\n response = @connection.req('GET', '/os-hypervisors/statistics')\n OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)\n JSON.parse(response.body)['hypervisor_statistics']\n end", "def stats\n Client.current.get(\"#{resource_url}/stats\")\n end", "def site_usage\n BrickFTP::API::SiteUsage.find\n end", "def site_usage\n BrickFTP::API::SiteUsage.find\n end", "def dns_statistics\n super\n end" ]
[ "0.59840435", "0.59541285", "0.5913996", "0.5909636", "0.5870591", "0.5833133", "0.56943285", "0.5674373", "0.56328094", "0.5619118", "0.5614052", "0.5568906", "0.5560233", "0.5453109", "0.543448", "0.54063976", "0.53922963", "0.5389871", "0.5372886", "0.5336553", "0.53162605", "0.52807", "0.5245572", "0.5214113", "0.5213838", "0.5206209", "0.5189791", "0.51611996", "0.515374", "0.5121293", "0.50858915", "0.50674635", "0.50674635", "0.50664216", "0.5062212", "0.5059262", "0.50430864", "0.50366235", "0.502594", "0.49851984", "0.49712822", "0.49549276", "0.49491602", "0.49469596", "0.49381062", "0.49105752", "0.49099305", "0.48789084", "0.48694903", "0.48621008", "0.48537692", "0.48532793", "0.48528898", "0.4838889", "0.48113334", "0.48099652", "0.4803735", "0.48033836", "0.4802121", "0.47784024", "0.47738087", "0.47675353", "0.47636202", "0.47602564", "0.47591642", "0.47544104", "0.47544104", "0.47514367", "0.47461817", "0.4712048", "0.46964505", "0.46893406", "0.46875635", "0.46863115", "0.46862862", "0.46854383", "0.4668544", "0.46653312", "0.46485955", "0.46434087", "0.46420398", "0.46380433", "0.46369407", "0.46352193", "0.4632463", "0.46314198", "0.4626667", "0.46259096", "0.4622986", "0.4620484", "0.46199894", "0.46133155", "0.46133155", "0.46101525", "0.46092287", "0.4597464", "0.45875305", "0.45868084", "0.45868084", "0.45775962" ]
0.52688736
22
View your website&39;s uptime. Returns uptime time series website performance data for the given domain.
def get_uptime_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PublicPerformanceApi.get_uptime ...' end # resource path local_var_path = '/cms/v3/performance/uptime' # query parameters query_params = opts[:query_params] || {} query_params[:'domain'] = opts[:'domain'] if !opts[:'domain'].nil? query_params[:'path'] = opts[:'path'] if !opts[:'path'].nil? query_params[:'pad'] = opts[:'pad'] if !opts[:'pad'].nil? query_params[:'sum'] = opts[:'sum'] if !opts[:'sum'].nil? query_params[:'period'] = opts[:'period'] if !opts[:'period'].nil? query_params[:'interval'] = opts[:'interval'] if !opts[:'interval'].nil? query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil? query_params[:'end'] = opts[:'_end'] if !opts[:'_end'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'PublicPerformanceResponse' # auth_names auth_names = opts[:debug_auth_names] || ['oauth2'] new_options = opts.merge( :operation => :"PublicPerformanceApi.get_uptime", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: PublicPerformanceApi#get_uptime\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data\n if @url\n @page = fetch_url(@url)\n @parse_time = parse_dailydev_page\n @page = nil\n self.total_time\n end\n end", "def uptime\n Sys::Uptime.uptime\n end", "def index\n @uptimes = Uptime.all\n end", "def uptime\n File.foreach('/proc/uptime').each do |line|\n return line.split[0].to_i\n end\n end", "def uptime\n rpc(:uptime, _access: :seconds, _coerce: Hash)\n end", "def uptime\n Time.now - live_since\n end", "def uptime\n super\n end", "def uptime\n return 0 unless status.include? \"running\"\n raw = command \"cat /proc/uptime\"\n Log.debug(\"Container (#{@ctid}) uptime requested: #{raw}\")\n raw.split(/\\W/).first.to_i\n end", "def uptime\n return File.read('/proc/uptime').split(/\\s+/)[0].to_f rescue 0.0\n end", "def uptime\n LOG_STAT()\n id = id_gen()\n LOG_CALL(id, true, __method__)\n defer { LOG_CALL(id, false, 'uptime') }\n return fmt_time(Time.now.to_i - STARTUP_TIME)\n end", "def uptime\n Time.now - @start_time\n end", "def get_site_status(site_url)\n req_start = Time.now\n get_response = HttpHelper.get(site_url)\n if get_response != '-1'\n req_duration = Time.now - req_start\n Rails.logger.info \"STATUS: #{get_response.code} :: response time - #{req_duration}\"\n if req_duration > 4.0\n payload = { \"text\": \"Thredup.com load time exceeded threshold - #{req_duration} sec\" }\n request_hash = {:url => Tokenz.get_channel_url('testing'), :payload => payload}\n HttpHelper.post(request_hash)\n end\n return get_response.code.to_s\n end\n return '-1'\n end", "def uptime\n @rufus ? @rufus.uptime : nil\n end", "def uptime\n\t\treturn Time.now - self.start_time\n\tend", "def stats\n @server.make_json_request('show.stats', tvdbid: @tvdbid)['data']\n end", "def get_usage(args= {})\n args = {:day=>\"today\", :type=>\"heat\"}.merge(args)\n result = HTTParty.get( @tstat_ip + '/tstat/datalog', :headers => @headers) \n \n day = result[args[:day]]\n runtime = day[args[:type] + '_runtime']\n\n return runtime\n end", "def display_webpage_views\n webpage_views\n puts 'Overall webpage views'\n puts \"\\n\"\n @webpage_views_hash.each do |webpage, view_hash|\n puts webpage\n puts \"#{view_hash.values[0]} unique views\"\n puts \"#{view_hash.values[1]} total views\"\n puts \"\\n\"\n end\n end", "def uptime_percentage\n return summary_average[:uptime_percentage]\n end", "def calc_uptime(user, password, api_key, id, lastTime, nowTime)\n urlUptime = \"https://#{CGI::escape user}:#{CGI::escape password}@api.pingdom.com/api/2.0/summary.average/#{id}?from=#{lastTime}&to=#{nowTime}&includeuptime=true\"\n responseUptime = RestClient.get(urlUptime, {\"App-Key\" => api_key})\n responseUptime = JSON.parse(responseUptime.body, :symbolize_names => true)\n\n totalUp = responseUptime[:summary][:status][:totalup]\n totalUnknown = responseUptime[:summary][:status][:totalunknown]\n totalDown = responseUptime[:summary][:status][:totaldown]\n\n uptime = (totalUp.to_f - (totalUnknown.to_f + totalDown.to_f)) * 100 / totalUp.to_f\n uptime.round(2)\nend", "def uptime\n @uptime ||= down? ? nil : Time.now - started_at\n end", "def response_time_metrics\n result = {}\n @urls.each do |url|\n result[url[:name]] = get_metrics(url[:path])\n end\n print result\n end", "def get_data\n if @url\n @page = fetch_url(@url)\n @parse_time = parse_today_page\n @page = nil\n self.total_time\n end\n end", "def uptime\n @root.attributes[\"c\"].to_i\n end", "def calc_uptime(api_key)\n urlUptime = \"https://api.uptimerobot.com/getMonitors?apiKey=#{api_key}&format=json&noJsonCallback=1&responseTimes=1&logs=1&customUptimeRatio=1-7-30-365\"\n response = RestClient.get(urlUptime)\n if response.code == 200\n responseUptime = JSON.parse(response.body, :symbolize_names => true)\n uptime = responseUptime[:monitors][:monitor][0][:customuptimeratio]\n return uptime.split('-')\n else\n puts 'Error: ' + response.code + ' ' + response.body\n return ['?','?','?','?']\n end\n \nend", "def get_uptime(opts = {})\n data, _status_code, _headers = get_uptime_with_http_info(opts)\n data\n end", "def lifetime_views\n return self.stats.where(:kind => \"lifetime\").first.pageviews\n end", "def parse_dailydev_page\n start = Time.now\n items = @page.search('.ddinfo')\n if items.any?\n items.each do |item|\n desc = item.search('.foot').empty\n desc = item.inner_text.strip\n link_el = item.search('a').select { |item| /\\/deviation\\// === item.attributes['href'] }.first\n link = link_el.attributes['href']\n title = link_el.inner_text\n @daily_data << { :title => title, :desc => desc, :link => link }\n end\n end\n Time.now - start\n end", "def uptime\n fmt_time(Time.now.to_i - STARTUP_TIME)\n end", "def get_statistics\n response = get_siteinfo('statistics')\n ret = {}\n response['query']['statistics'].each { |k, v| ret[k] = v }\n ret\n end", "def show_site_stats # :nologin: :norobots:\n store_location\n @site_data = SiteData.new.get_site_data\n\n # Add some extra stats.\n @site_data[:observed_taxa] = Name.connection.select_value %(\n SELECT COUNT(DISTINCT name_id) FROM observations\n )\n @site_data[:listed_taxa] = Name.connection.select_value %(\n SELECT COUNT(*) FROM names\n )\n\n # Get the last six observations whose thumbnails are highly rated.\n query = Query.lookup(:Observation, :all,\n by: :updated_at,\n where: \"images.vote_cache >= 3\",\n join: :\"images.thumb_image\")\n @observations = query.results(limit: 6,\n include: { thumb_image: :image_votes })\n end", "def stat_by_url(url, userdics: nil)\n stat_by_web(url, userdics: userdics)\n end", "def query_uptime\n send(\"QUERY_UPTIME\")\n response = recv\n\n # We expect to get back 1 element only for this method\n raise CommunicationError, \"Unexpected response from QUERY_UPTIME: #{response.join(\":\")}\" if response.length != 1\n\n response[0].to_i\n end", "def stats\n _get(\"/system/stats\") { |json| json }\n end", "def performance\n authenticated_post(\"auth/r/stats/perf:1D/hist\")\n end", "def links_with_domain(domain, options = {})\n options = options.clone\n\n parameters = { :url => domain, :t => options[:time] }\n options.merge! parameters\n options.delete :t\n\n objects_from_response(:get, 'api/info.json', options)\n end", "def date_time_url\n @slowest_time= 0\n print \"\\nTotal requests grouped by the Date/hour\\n\\n\"\n\t\t\n #taking each date&hour\n @count.each do|val1,val2|\n slowest = 0\n \n #searching on each line to find slowest\n $file.each_line do|line|\n\tif line.include? val1\n\t time = line.match /\\d+$/\n\t if time\n\t #finding slowest time\n\t time = time[0].to_i\n\t if time > slowest\n\t slowest = time\n\t end\n\t end\n\tend\n\tslowest = slowest.to_s\n\t#finding slowest url in corresponding date\n\tif line.include? slowest\n\t @url = line.match /https?:\\/\\/[\\S]+/.to_s\n\tend\n\tslowest = slowest.to_i\n end\n \n #checking plural form of request.\n request = \"request\"\n if val1.to_i > 1\n\trequest += \"s\"\n end \n print \"#{ val1 } : #{ val2 } #{ request } \\tSlowest-Time : #{ slowest } \\tSlowest-URL : #{ @url }\\n\\n\"\n \n #finding slowest URL in the log.\n if slowest > @slowest_time\n @slowest_time = slowest\n @slowest_url = @url\n end\n end \n print \"Slowest URL : #{ @slowest_url }\\n\"\n end", "def uptime\n return 0 if started_at.nil?\n ((Time.now.to_f - started_at.to_f) * 1000.0).to_i\n end", "def cpu_time_used\n domain_info[:cpuTime]\n end", "def cpu_time_used\n domain_info[:cpuTime]\n end", "def stats(url, options={})\n query = {:url => url}\n query.merge!(options)\n response = handle_response(self.class.get(\"/stats.json\", :query => query))\n Topsy::Stats.new(response)\n end", "def generate_site_stats\n H.ul {\n H.li {\"#{$r.get(\"users.count\")} users\"} +\n H.li {\"#{$r.zcard(\"news.cron\")} news posted\"} +\n H.li {\"#{$r.info['used_memory_human']} of used memory\"}\n }\nend", "def uptime\n return (Time.now.to_i.to_f - booted_at.to_f) rescue 0.0\n end", "def uptime\n begin\n return Time.now.to_i.to_f - booted_at.to_f\n rescue Exception\n return 0.0\n end\n end", "def pageviews(period)\n stat = self.stats.find(:first, :conditions => ['period = ? AND kind = ?', period, \"period\"])\n if stat\n return stat.pageviews\n else\n return 0\n end\n end", "def realtime_metrics\n current_user = @controller.current_user\n tp = TimeProfile.profile_for_user_tz(current_user.id, current_user.get_timezone) || TimeProfile.default_time_profile\n Metric::Helper.find_for_interval_name('realtime', tp)\n .where(:resource => @ems.try(:all_container_nodes) || ContainerNode.all)\n .where('timestamp > ?', REALTIME_TIME_RANGE.minutes.ago.utc).order('timestamp')\n end", "def webpage_views\n count_unique_views\n count_total_views\n\n @unique_views_hash.each do |webpage, unique|\n @webpage_views_hash.store(webpage, 'Unique views' => unique)\n end\n\n @total_views_hash.each do |webpage, total|\n @webpage_views_hash[webpage].store('Total views', total)\n end\n @webpage_views_hash\n end", "def display_info\n @all_domains.each do |key, domain|\n puts \"Domain : \" + domain.domain_name\n puts domain.email_statistics.inspect\n puts \"*\" * 80\n end\n end", "def my_websites\n websites = Website.search_by_user(get_current_user)\n websites.each do |w| \n if w.status == Website::STATUS_VERIFIED\n w.count_tagged_images\n w.count_spots\n w.count_total_income\n end\n end\n return websites\n end", "def user_stats\n @user = User.find(params[:id])\n @stats = time_data @user.episodes\n @cloud = word_cloud @user.episodes.pluck(:title)\n\n respond_to do |format|\n format.html { render 'stats' }\n format.json { render json: time_data(@user.episodes, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(@user.episodes, :hash) }\n end\n end", "def stats\n @stats = time_data Episode.all\n @cloud = word_cloud Episode.pluck(:title)\n\n respond_to do |format|\n format.html # stats.html.erb\n format.json { render json: time_data(Episode.all, :hash), callback: params[:callback] }\n format.xml { render xml: time_data(Episode.all, :hash) }\n end\n end", "def monitoring_stats(region = current_region)\n redis = Redis.new :host => \"localhost\"\n today = \"2012-02-14\" # TODO(philc): \n request_count = redis.get(\"#{region.name}_request_count\").to_i\n errors = redis.get(\"html5player:error_count:#{today}\").to_i\n error_rate = (request_count == 0) ? 0 : (errors / request_count.to_f * 100)\n latency = (request_count == 0) ? 0 : redis.get(\"#{region.name}_latency\").to_i / request_count\n {\n :request_count => request_count,\n :average_latency => latency,\n :error_count => errors,\n :error_rate => error_rate\n }\n end", "def list\n websites = @logs.records\n @view.show(websites)\n end", "def publications_by_subdomain(subdomain)\n rvalue = []\n\n (ActiveFedora::SolrService.query(\"+press_sim:#{subdomain} AND +visibility_ssi:open\", rows: 100_000, sort: \"date_modified_dtsi desc\") || []).each do |solr_doc|\n sm = ::Sighrax.from_solr_document(solr_doc)\n op = ::Opds::Publication.new_from_monograph(sm, true, params[:filterByEntityId])\n rvalue.append(op.to_h) if op.valid?\n end\n\n rvalue\n end", "def track\n url = Rails.env.development? ? \"http://localhost:8000/stat\" : \"http://stats.universit.as/stat\"\n RestClient.get(url, :params => {\n :ip => request.remote_ip,\n :title => request.referrer\n })\n render :js => ''\n end", "def uptime_in_seconds\n if ! File.readable?(\"/proc/uptime\")\n return File.open(\"/proc/uptime\", mode=\"r\").gets[/^\\d+/].to_i\n else \n info = `uptime`.scan(/^\\s(\\d{2}.\\d{2}.\\d{2})\\sup\\s(\\d+)\\s(\\w+),\\s+(\\d+)(:\\d+|\\w+)/).flatten!\n # => [[\"19:52:49\", \"48\", \"days\", \"1\", \":26\"]]\n\n now = info[0]\n value = info[1].to_i\n unit = info[2].to_s\n precision = info[3].to_s\n surprise = info[4].to_s\n\n seconds = 0\n\n case unit\n when \"days\"\n seconds = value*24*60*60\n when \"hour\"\n seconds = value*60*60\n when \"min\"\n seconds = value*60\n end\n\n if surprise.match(/^:(\\d+)$/)[1]\n hours = precision.to_i\n minutes = $1.to_i\n seconds += hours*60*60 + minutes*60\n elsif surprise.match(/min/)\n minutes = precision.to_i\n seconds += minutes*60\n end\n\n return seconds\n end\nend", "def index\n @htscdts = Htscdt.all\n end", "def page_views_dashboard\n @timeframes = Impression::TIMEFRAMES\n end", "def set_uptime\n @uptime = Uptime.find(params[:id])\n end", "def print_perf_info\n @perf_end_timestamp = Time.now\n @hosts.map { |h| get_perf_data(h, @perf_timestamp, @perf_end_timestamp) }\n end", "def video_get_stats(sig, options = {})\n options = {:type => 'day', :value => 15, :sig => sig, :appToken => app_token}.merge options\n response = get(\"/video/getStats/\", options)\n process_response(response, [:stats])\n end", "def validator_daily_score(_address)\n get('/validators/summary_hourly').map do |summary|\n Celo::ValidatorSummary.new(summary)\n end\n end", "def runtime\n details.at(\"div.subtext time[itemprop='duration']\")['datetime'].gsub(/[^\\d+]/, '').to_i rescue nil\n end", "def summary(period=:day, date=Date.today)\n raise UnknownSite, \"Site not existent in Piwik yet, call 'save' first\" if new?\n xml = call('VisitsSummary.get', :idSite => id, :period => period, :date => date)\n result = XmlSimple.xml_in(xml, {'ForceArray' => false})\n {\n :visits => result['nb_visits'].to_i,\n :unique_visitors => result['nb_uniq_visitors'].to_i,\n :actions => result['nb_actions'].to_i,\n :max_actions_per_visit => result['max_actions'].to_i,\n :bounces => result['bounce_count'].to_i,\n :total_time_spent => result['sum_visit_length'].to_i, # in seconds\n }\n end", "def results\n get_domain_data\n end", "def view_stats_all\n data = {\n :name => \"Company Views\",\n :pointInterval => 1.day * 1000,\n :pointStart => 1.weeks.ago.at_midnight.to_i * 1000,\n :data => (1.weeks.ago.to_date..Date.today).map{ |date|\n Impression.where(\n \"created_at > ? AND created_at < ? AND action_name = ? AND controller_name = ?\",\n date.at_beginning_of_day,\n date.tomorrow.at_beginning_of_day,\n 'stat_show',\n 'companies'\n ).select{ |impression| impression.action_name == \"stat_show\"}.count\n }\n }\n respond_with data\n end", "def raw_stats\n url = URI.parse(stats_url)\n Net::HTTP.start(url.host, url.port) {|http|\n http.request(Net::HTTP::Get.new(url.path))\n }.body\nend", "def visits(period)\n stat = self.stats.where(:period => period).first\n return stat.visits\n end", "def ping_stats(url, time)\n\n logger.info \"ping_stats:start: url = #{url}, time = #{time.to_i}\"\n\n jsonResponse = rest_call(url)\n response_hash = JSON.parse(jsonResponse)\n nodes = response_hash['nodes']\n\n this_node = nodes.select { |node| node.has_key?('thisNode') && node['thisNode'] == true }.first\n\n if this_node != nil\n nodes.each do |node|\n if node['otpNode'] != this_node['otpNode']\n hostname = URI.parse(\"http://#{node['hostname']}\").host.downcase\n ping_time = time_socket_open_close(hostname, '22')\n write_to_graphite( construct_metric_name(\"#{this_node['otpNode'].gsub('.','-')}.ping.#{hostname.gsub('.','-')}\", CONST_NODE_LEVEL), ping_time, time)\n end\n end\n else\n logger.info 'No nodes found with thisNode == true'\n end\n\n logger.info 'ping_stats:end: Completed'\n end", "def getAppStats(package, startDay, endDay)\n dim = \"overall,country,language,os_version,device,app_version,carrier&met=daily_device_installs,active_device_installs,daily_user_installs,total_user_installs,active_user_installs,daily_device_uninstalls,daily_user_uninstalls,daily_device_upgrades\"\n\n url = \"https://play.google.com/apps/publish/statistics/download\"\n url += \"?package=#{package}\"\n url += \"&sd=#{startDay}&ed=#{endDay}\"\n url += \"&dim=#{dim}\"\n url += \"&dev_acc=#{@dev_acc}\"\n\n puts url\n try_get(url)\n return @agent.page.body\n end", "def get_domain_count\n query_push 'Command' => 'GetDomainCount'\n get_response\n end", "def uptime\n @started ? (Time.now - @started).to_i : 0\n end", "def scrapePage(url, domain, projectid, db, useragent)\n\t\t# set results array\n\t\tputs \"\\nPage Start: #{url} - #{Time.now.getutc}\\n\"\n\t\t@pageresult = {\n\t\t\t:_projectid => projectid,\n\t\t\t:title => \"\",\n\t\t\t:h1 => \"\",\n\t\t\t:page_hash => \"\",\n\t\t\t:http_code => \"\",\n\t\t\t:url => url\n\t\t}\n\n\t\tif URI(url).host == domain\n\t\t\thtml = fetch_html(url, 10, useragent)\n\t\t\t@pageresult[:http_code] = html[:http_code]\n\n\t\t\t#page hash\n\t\t\tpage_hash = Digest::MD5.new\n\t\t\tpage_hash.update html[:body]\n\t\t\t@pageresult[:page_hash] = page_hash.hexdigest\n\n\t\t\t#parse page\n\t\t\tparser = Nokogiri::HTML(html[:body])\n\t\t\t@pageresult[:title] = parser.css(\"title\")[0].text if parser.css(\"title\")[0].nil? == false\n\t\t\t@pageresult[:h1] = parser.css(\"h1\")[0].text if parser.css(\"h1\")[0].nil? == false\n\n\t\t\t@links = {}\n\t\t\tfor link in parser.css(\"a\")\n\t\t\t\thref = link['href']\n\t\t\t\t# puts \"'#{href}'\"\n\t\t\t\t# puts \"#{URI(href).host}\\n\"\n\t\t\t\tif href.nil? == false && href =~ /\\A#{URI::regexp(['http', 'https'])}\\z/\n\t\t\t\t\tsafeurl = URI.encode(href.strip)\n\t\t\t\t\tif URI(safeurl).host.nil? == false\n\t\t\t\t\t\tif domain == URI(safeurl).host\n\t\t\t\t\t\t\t@links[href] = 1 #onsite\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t@links[href] = 0 #offsite\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\tif @links.count > 0\n\t\t\t\tputs \"\\t#{@links.count} links to found- #{Time.now.getutc}\\n\"\n\t\t\t\tinsertQueueLinks(url, @links, projectid, db)\n\t\t\tend\n\t\t\t\n\t\tend\n\n\t\t@pageresult[:created_at] = Time.now.getutc\n\t\tputs \"Page End: #{url} - #{Time.now.getutc}\\n\"\n\t\treturn @pageresult\n\tend", "def stats\n request :get, \"_stats\"\n end", "def stats\n request :get, \"_stats\"\n end", "def pull_data\n @pulling = true\n\n model_updating\n\n # pull the page from the url\n page = Nokogiri::HTML(open(@url))\n \n # get the title for the film\n title = page.css(\"h1.film-title\").text\n define_singleton_method(:title, lambda{title})\n\n # get the runtime for the film\n runtime_cap = page.css(\".text-link\").text.match(/(\\d+) mins/)\n if runtime_cap\n runtime = runtime_cap.captures[0].to_i\n else\n runtime = 0\n end\n define_singleton_method(:runtime, lambda{runtime})\n\n # get the tagline for the film\n tagline = page.css(\".tagline\").text\n define_singleton_method(:tagline, lambda{tagline})\n\n # get the overview for the film\n overview = page.css(\"div.truncate\").text.strip\n define_singleton_method(:overview, lambda{overview})\n \n @pulled = true\n @pulling = false\n\n model_updated\n end", "def site_usage\n BrickFTP::API::SiteUsage.find\n end", "def site_usage\n BrickFTP::API::SiteUsage.find\n end", "def domain_report(domain)\n DomainReport.new(api_key: @api_key, domain: domain).response\n end", "def latest_reports(urls)\n urls.each do |cururl|\n if cururl.nil?\n next\n end\n # read from our last run\n filename = DATA_DIR + \"/#{cururl[:label]}.last_run\"\n begin\n f = File.open(filename, \"r\")\n runtime = f.read\n f.close\n rescue\n runtime = 30\n end\n puts \"loadtime#{cururl[:index]}.value #{runtime}\"\n end\nend", "def survival_stats\n return unless public?\n\n if @survival_stats.nil?\n survival_data = @xml_data['stats']['survival']\n\n @survival_stats = {}\n @survival_stats[:gold_medals] = survival_data['goldmedals'].to_i\n @survival_stats[:silver_medals] = survival_data['silvermedals'].to_i\n @survival_stats[:bronze_medals] = survival_data['bronzemedals'].to_i\n @survival_stats[:rounds_played] = survival_data['roundsplayed'].to_i\n @survival_stats[:best_time] = survival_data['besttime'].to_f\n end\n\n @survival_stats\n end", "def weekStats()\r\n # Get the first day\r\n curCal = JCalendar::getInstance()\r\n curCal.add(JCalendar::DATE, -7)\r\n weekStatsCount = @daohelper.getVisitAuditDate(curCal)\r\n \r\n # Extract visit stats for the last 7 days\r\n i = -6\r\n statMap = {}\r\n statMapDates = {}\r\n while i <= 0\r\n curCal = JCalendar::getInstance()\r\n curCal.add(JCalendar::DATE, i)\r\n curStat = @daohelper.getVisitAuditOnDate(curCal) \r\n strId = \"stats#{i + 6}\"\r\n statMap[strId] = curStat\r\n statMapDates[strId] = curCal\r\n i += 1\r\n end\r\n\r\n stats = BotListVisitLogStatsForm.new\r\n stats.weekVisits = weekStatsCount\r\n stats.weekStats = statMap\r\n stats.weekStatsDates = statMapDates\r\n return stats\r\n end", "def stats\n @page_title = I18n.t(\"statistics\")\n redirect_to root_url unless current_user.is_admin? # don't release this yet...it's not ready for public consumption\n @stats = PageStatsTaxon.latest\n end", "def index\n @gp40s = Gp40.all\n @gp40s = duration(@gp40s, params)\n end", "def stats!\n info \"STATS\"\n task \"generate chart\" do\n c = Chart::StatsPerCollection.new\n @dbi.execute( File.read( sql_query(:chart) ) ).each{ |date,collection|\n c.add_one(collection, Date.parse(date).day)\n }\n Chart.new(c).write File.join( @config['settings']['output'], '/chart.jpg' )\n end\n end", "def index\n @system_stats = SystemStat.all\n end", "def get_hypervisor_stats\n response = @connection.req('GET', '/os-hypervisors/statistics')\n OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)\n JSON.parse(response.body)['hypervisor_statistics']\n end", "def site_overview\n url = site 'overview'\n o = self.class.get(url.to_s)['overview']\n SiteOverview.new(\n current_power: o['currentPower']['power'],\n last_day_energy: o['lastDayData']['energy'],\n last_month_energy: o['lastMonthData']['energy'],\n last_year_energy: o['lastYearData']['energy'],\n lifetime_energy: o['lifeTimeData']['energy'],\n update_time: DateTime.parse(o['lastUpdateTime'])\n )\n end", "def dns_statistics\n super\n end", "def index\n @system_overviews = SystemOverview.all\n if @system_overviews.size > 0\n\n data_table = GoogleVisualr::DataTable.new\n data_table.new_column('string', 'Label')\n data_table.new_column('number', 'Value')\n data_table.add_rows(3)\n data_table.set_cell(0, 0, 'Current')\n data_table.set_cell(0, 1, SystemOverview\n .last.currently_running\n .tr('W', '')\n .tr('KW', '')\n .to_i\n )\n opts = { width: 400, height: 120, redFrom: 90, redTo: 100, yellowFrom: 75, yellowTo: 90, minorTicks: 5 }\n @chart = GoogleVisualr::Interactive::Gauge.new(data_table, opts)\n end\n end", "def data_presenter factor\n collection = search\n data_collector collection, factor, params[:duration]\n if request.xhr?\n render partial: 'graph' and return\n end\n end", "def user_activity_live_data\n [\n {\n key: 'active_in_last_hour',\n name: t('statistics.entries.users.currently_active'),\n data: ExternalUser.joins(:submissions)\n .where(['submissions.created_at >= ?', DateTime.now - 5.minutes])\n .distinct('external_users.id').count,\n },\n {\n key: 'submissions_per_minute',\n name: t('statistics.entries.exercises.submissions_per_minute'),\n data: (Submission.where('created_at >= ?', DateTime.now - 1.hour).count.to_f / 60).round(2),\n unit: '/min',\n axis: 'right',\n },\n ]\n end", "def hourly(query)\n get_json(\"#{api_url}/hourly/q/#{parse_query(query)}.#{@options[:format]}\")\n end", "def index\n @users = User.where(:admin => false).paginate(:page => params[:page])\n @total_domains = Domain.count\n @system_domains = Domain.where('user_id IS NULL').count\n end", "def index\n @users = User.where(:admin => false).paginate(:page => params[:page])\n @total_domains = Domain.count\n @system_domains = Domain.where('user_id IS NULL').count\n end", "def summary_site\n \t\tAPI.get_site_wordcount\n \tend", "def get_usage_timeseries(start_hr, opts = {})\n data, _status_code, _headers = get_usage_timeseries_with_http_info(start_hr, opts)\n data\n end", "def rtsp_statistics\n super\n end", "def parse_uptime(up)\n if up =~ /load averages?: (.*)/\n a,b,c = $1.split(/\\s+|,\\s+/)\n (a.to_f + b.to_f + c.to_f) / 3\n end\n end", "def parse_uptime(up)\n if up =~ /load averages?: (.*)/\n a,b,c = $1.split(/\\s+|,\\s+/)\n (a.to_f + b.to_f + c.to_f) / 3\n end\n end", "def versus_stats\n return unless public?\n\n if @versus_stats.nil?\n versus_data = @xml_data['stats']['versus']\n\n @versus_stats = {}\n @versus_stats[:games_played] = versus_data['gamesplayed'].to_i\n @versus_stats[:games_completed] = versus_data['gamescompleted'].to_i\n @versus_stats[:finales_survived] = versus_data['finales'].to_i\n @versus_stats[:points] = versus_data['points'].to_i\n @versus_stats[:most_points_infected] = versus_data['pointsas']\n @versus_stats[:games_won] = versus_data['gameswon'].to_i\n @versus_stats[:games_lost] = versus_data['gameslost'].to_i\n @versus_stats[:highest_survivor_score] = versus_data['survivorscore'].to_i\n\n @versus_stats[:finales_survived_percentage] = @versus_stats[:finales_survived].to_f / @versus_stats[:games_played]\n\n self.class.const_get(:SPECIAL_INFECTED).each do |infected|\n @versus_stats[infected] = {}\n @versus_stats[infected][:special_attacks] = versus_data[\"#{infected}special\"].to_i\n @versus_stats[infected][:most_damage] = versus_data[\"#{infected}dmg\"].to_i\n @versus_stats[infected]['avg_lifespan'] = versus_data[\"#{infected}lifespan\"].to_i\n end\n end\n\n @versus_stats\n end" ]
[ "0.5890123", "0.5829894", "0.58046395", "0.5786207", "0.5763098", "0.5751149", "0.55887675", "0.55694354", "0.55650866", "0.5526869", "0.55214053", "0.54959536", "0.5471349", "0.5429178", "0.53740954", "0.5347858", "0.53419024", "0.5337803", "0.52921784", "0.52817947", "0.5278791", "0.5257309", "0.52531207", "0.51852125", "0.51514465", "0.5150517", "0.5140353", "0.51376545", "0.5120344", "0.50813663", "0.50747293", "0.5066235", "0.50080025", "0.50033885", "0.49770713", "0.49511233", "0.49317312", "0.49235192", "0.49235192", "0.49188867", "0.49180278", "0.4911504", "0.48998627", "0.48961654", "0.48835534", "0.48822588", "0.48763046", "0.4843668", "0.4832825", "0.48240587", "0.48133546", "0.48057672", "0.47935686", "0.47753096", "0.47671834", "0.47670737", "0.47572994", "0.4756003", "0.47464746", "0.4741542", "0.47403416", "0.47043374", "0.46967328", "0.46887258", "0.4670345", "0.46624866", "0.4657898", "0.46530473", "0.46274585", "0.46257767", "0.4625663", "0.46238548", "0.4622309", "0.4622309", "0.4615532", "0.46121705", "0.46121705", "0.4606122", "0.46026787", "0.46012154", "0.4601029", "0.45935142", "0.4588576", "0.45882034", "0.4587063", "0.4582777", "0.45794362", "0.45759162", "0.4575514", "0.45625493", "0.4558729", "0.4556778", "0.455659", "0.455659", "0.45536673", "0.45515016", "0.45415035", "0.4540965", "0.4540965", "0.45343012" ]
0.51053953
29
Inputs: 1. a list of anything, 2. an item for us to count in the list Returns: The number of times our item is contained in the input list Prints: Nothing For example, count_in_list([1,2,3], 1) == 1 count_in_list([1,2,3], 1) == 0 count_in_list([1,1,1], 1) == 3 NOTE Ruby has a builtin method to do this, but the purpose of this kata is to write it yourself. See:
def count_in_list(list, item_to_count) running_total_of_number = 0 #the running total is 0 list.each do |item| #go through the list. example, the first element of 1 is the placeholder. if item == item_to_count #if this #1 is equal to 1 running_total_of_number += 1 #then the the running total increases by 1 # do it with the second number. the .each acts like a coda. end # You'll need three things: # 1. A running total of the number of times you've seen the item # 2. A way to loop/iterate through the list # 3. A way to add to the running total as you see the item end return running_total_of_number #return the # of times item_to_count has appeared end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count(list)\n list.length\nend", "def count(list, number)\n c = 0\n list.each do |n|\n if n == number\n c += 1\n end\n end\n return c\nend", "def count_occurrences(list)\n occurrences = {}\n\n list.each do |item|\n occurrences.has_key?(item) ? occurrences[item] += 1 : occurrences[item] = 1\n end\n\n occurrences.each { |item, count| puts \"#{item} => #{count}\" }\nend", "def count(list)\n list.each do |hash|\n total += 1\n end\n return total\n end", "def count(arr, item)\n\tarr.count { |x| x == item }\nend", "def count_list(array)\n counter = 0\n array.each do |num|\n counter +=1\n end\ncounter\nend", "def my_count(args = nil)\n count = 0\n my_each do |item|\n if block_given?\n count += 1 if yield(item)\n elsif args\n count += 1 if item == args\n else\n count = length\n end\n end\n count\n end", "def count (list, &block)\n list.count(&block)\nend", "def count(array, item)\n i = 0\n output = []\n count = 0\n while i <= array.length-1\n if array[i] == item\n count += 1\n end\n i += 1\n end\n return count\nend", "def my_count(items = nil)\n count = 0\n if block_given?\n my_each { |i| count += 1 if yield(i) == true }\n elsif items.nil?\n my_each { count += 1 }\n else\n my_each { |i| count += 1 if i == items }\n end\n count\n end", "def count_occurrences(list)\n keys = list.uniq\n count = keys.map{ |key| list.count(key) }\n keys.each_index{ |indx| puts \"#{keys[indx]} => #{count[indx]}\"}\nend", "def grocery_list *items\n for item in items\n if item in list\n item.count += 1\n else\n list << item\n end\n end\nend", "def count list, &block\n list.count(&block)\nend", "def count\n\t\t\t\tlist.count\n\t\t\tend", "def todos_count(list)\n list[:todos].size\n end", "def count_mode(list, check)\n count = 0\n list.each do |number|\n if check == number\n count += 1 \n end\n end\n return count\nend", "def my_count(*args)\n count = 0\n if args[0]\n my_each do |x|\n count += 1 if x == args[0]\n end\n elsif !block_given?\n count = size\n elsif !args[0]\n my_each do |x|\n count += 1 if yield x\n end\n end\n count\n end", "def count(input)\n input.reduce(0) do |sum, el|\n yield(el) ? sum + 1 : sum\n end\nend", "def count(item)\n item.select { |*args| yield(*args) }.size\nend", "def my_count(arg = nil)\n result = []\n if block_given?\n my_each do |elem|\n result << elem if yield(elem) == true\n end\n end\n\n unless block_given?\n if arg.nil? arg.nil?\n result = self\n else\n my_each do |elem|\n result << elem if elem == arg\n end\n end\n end\n result.size\n end", "def my_count(arg = nil)\n count = 0\n if block_given?\n my_each do |val|\n count += 1 if yield(val)\n end\n count\n elsif arg.nil?\n length\n else\n my_each do |val|\n count += 1 if val == arg\n end\n count\n end\n end", "def search(list)\n count = 0\n list.each_line do |string|\n count += 1 if is_a_nice_string?(string)\n end\n count\nend", "def count(element = nil)\n if element.nil?\n return size\n end\n filter { |x| x == element }.size\n end", "def test_outstanding_count_list__list_exists\n count = outstanding_count_list(@lists, \"Personal\")\n\n assert_equal(2, count)\n end", "def numUnique list\n if list.length == 0\n return \"**0**\"\n end\n counter = Hash.new\n counter[list[0]] = 1\n\n list.each do |num|\n number_exists = false\n counter.each do |key, count|\n if num == key\n count += 1\n number_exists = true\n end\n end\n\n if !number_exists\n counter[num] = 1\n end\n\n end\n\n puts \"counter #{counter}\"\n unique_nums = []\n\n counter.each do |key, value|\n unique_nums << key\n end\n\n return \"**#{unique_nums.length}**\"\n\nend", "def count\n @item_list.size\n end", "def count(collection)\n counter = 0\n collection.each { |element| counter += 1 if yield(element) }\n counter\nend", "def count_occ(usages_list)\n count = 0\n usages_list.each do |k,v|\n if k['location']['type'] == 'pipeline'\n count += 1\n end\n end\n return count\nend", "def count(collection)\n block_rtn_true_count = 0\n\n for element in collection\n block_rtn_true_count += 1 if yield element\n end\n\n block_rtn_true_count\nend", "def my_count(var = nil)\n result = 0\n if block_given?\n my_each { |item| result += 1 if yield(item) == true }\n elsif var.nil?\n my_each { result += 1 }\n else\n my_each { |item| result += 1 if item == var }\n end\n result\n end", "def count(*args)\n truethy_count = 0\n args.each { |el| truethy_count += 1 if yield(el) }\n truethy_count\nend", "def count_items(electives)\n electives.length #counts number of items in the array\nend", "def count_frequency(word_list, counts)\r\n ignore_list = %w[it its she her he him his they them their i me my you your we us our any]\r\n ignore_list += %w[is be been are was were has have had will would can could do did]\r\n ignore_list += %w[what when where which who whom there here that this these]\r\n ignore_list += %w[for by from at with on to of in into out up down upon back all also about]\r\n ignore_list += %w[ms mrs mr miss no not most more than one an the before after yet so if and as but or then]\r\n ignore_list += ('a'..'z').to_a\r\n word_list = word_list - ignore_list\r\n for word in word_list\r\n counts[word] += 1\r\n end\r\n counts\r\n\r\nend", "def length(list)\n number(list.to_a.size)\n end", "def count(collection)\n block_rtn_true_count = 0\n\n collection.each { |element| block_rtn_true_count += 1 if yield element }\n block_rtn_true_count\nend", "def count_equal(argument, elements)\n elements.inject(0) { |count, elem| elem == argument ? count+1 : count }\nend", "def my_count(e = nil)\n count = 0\n if !e.nil?\n self.my_each do |x|\n if x == e\n count = count + 1\n end\n end\n elsif block_given?\n self.my_each do |x|\n if yield x\n count = count + 1\n end\n end\n else\n count = self.length\n end\n count\n end", "def make_list(list, string_of_items)\n string_of_items.split(\" \").each do |item|\n list[item].nil? ? list[item] = 1 : list[item] += 1\n end\n list\nend", "def my_count(val)\n counter = 0\n self.each do |ele|\n if ele == val\n counter += 1\n end\n end\n counter\n end", "def char_count2(list)\n list.join().chars.inject(Hash.new(0)){ |h, c| h[c] += 1; h }\nend", "def count(*array)\n total = 0\n array.each { |element| total += 1 if yield(element) }\n total\nend", "def count_elements(arr)\n count = 0\n\n arr.each do |x|\n if arr.include?(x+1)\n count += 1\n end\n end\n \n count\nend", "def match_count(data, list = {})\n return nil if @root == nil\n i=0\n while (i<data.length)\n node = @root.find_forward(data, i, data.length-i)\n if (node!=nil && node.value!=nil)\n if (!list.has_key?(node)) \n list[node] = 1\n else\n list[node] += 1\n end\n i += node.length\n else\n i += 1\n end\n end\n list\n end", "def count(*args)\n arr = [*args]\n counter = 0\n\n arr.each do |el|\n counter += 1 if yield(el)\n end\n\n counter\nend", "def count1(collection)\n true_counter = 0\n collection.each { |element| true_counter += 1 if yield(element) }\n true_counter\nend", "def count_frequency(word_list)\n\tcounts = Hash.new(0)\n\tfor word in word_list\n\t\tcounts[word] += 1\n\tend\n\tcounts\nend", "def solution0(a)\n\n total_count = 0\n elem_counts = Hash.new(0)\n\n a.each do |elem|\n elem_counts[elem] += 1\n total_count += 1 if elem_counts[elem] == 2\n end\n\n return total_count\n\nend", "def count(array)\n sum = 0\n array.each do |item|\n sum += 1 if yield(item)\n end\n sum\nend", "def compute_frequencies(list)\n dict = {}\n list.each do |token|\n unless dict.has_key?(token)\n dict[token] = list.count(token)\n end\n end\n dict\nend", "def find_item(list, itemname)\n\t# input: list, name of item(string)\n\t# output: index of matching element from list (integer) or nil\n\n\tfound = false\n\tcounter = 0\n\t# iterate through items looking for match\n\tfor item, qty in list\n\t\t# remove matching item from list\n\t\tif item.downcase.strip == itemname.downcase.strip\n\t\t\treturn counter\n\t\tend\n\t\tcounter += 1\n\tend\n\treturn nil\nend", "def count_item\n count = 0\n @g_net.each do |followers|\n count += 1 unless !followers or followers.empty?\n end\n count\n end", "def create_list(items)\n\n# Make an empty hash for grocery_list:\np grocery_list = {} \n\n \n# Takes the string of items that user puts in the create_list method, and turns it into an array:\np items = items.split\n\n# Iterate through each item in the array. This step turns the array into a hash buy asking if it has an item from the array as a key. If the item appears more than once in the array, it will count it as one key and give it a value of +1.\n items.each do | item |\n if grocery_list.has_key?(item)\n grocery_list[item] += 1\n else\n grocery_list[item] = 1\n end \n\n end\n grocery_list \nend", "def count(array)\n count = 0\n array.each do |x|\n count += 1\n end\n\n return count\nend", "def my_count(a = nil)\n total = 0\n if block_given?\n self.my_each do |ele|\n total += 1 if yield ele\n end\n elsif a\n self.my_each do |ele|\n if ele == a\n total += 1\n end\n end\n else\n self.my_each do |ele|\n total += 1\n end\n end\n total\n end", "def my_count n = nil\n if block_given?\n truths = 0\n self.my_each {|o| truths += 1 if yield(o)}\n truths\n elsif n.nil?\n self.length\n else\n my_count {|x| x==n}\n end\n end", "def test_0600_count\n @@log.debug \"test_0600_count starts\" if @@log.debug?\n assert_respond_to(@list, :count, \"test_0600_count_respond\")\n # Count of all items in the collection\n assert(@list.count == 4, \"test_0600_count_count\")\n # Count of a single present object\n assert(@list.count(@bsb) == 1, \"test_0600_count_oneobj_1\")\n # Count of a non-present object\n assert(@list.count(42) == 0, \"test_0600_count_oneobj_2\")\n # Count of all objects for which the block returns \n result = @list.count {|obj| obj.ndata > 2}\n assert(result == 2, \"test_0600_count_trueres\")\n @@log.debug \"test_0600_count ends\" if @@log.debug?\n end", "def find_suspect(*numbers)\n suspect_count = Hash.new\n # Count number of times integers occurs in list and tally in hash\n numbers.each { |suspect| suspect_count[suspect] = suspect_count[suspect].to_i + 1 }\n # Integers placed into array of arrays ordered by count \n sorted_count = suspect_count.sort_by {|key, value| value}\n if sorted_count.size == 1\n return sorted_count[0][0]\n elsif sorted_count.size == 0\n return nil\n elsif sorted_count[0][1] < sorted_count[1][1]\n # Returns integer with the fewest instances\n return sorted_count[0][0]\n else\n # If all integers have same count return nil\n return nil\n end\nend", "def count\r\n items.size\r\n end", "def count_frequency(word_list)\n counts = Hash.new(0)\n for word in word_list\n counts[word] += 1\n end\n counts\nend", "def my_count (param=nil, &user_block)\n\t\tif param\n\t\t\tcount = 0\n\t\t\tself.my_each do |x|\n\t\t\t\tx == param ? count += 1 : next\n\t\t\tend\n\t\t\treturn count\n\t\telsif user_block\n\t\t\tblock_count = 0\n\t\t\tself.my_each do |element|\n\t\t\t\tuser_block.call(element) == true ? block_count += 1 : next\n\t\t\tend\n\t\t\treturn block_count\n\t\telse \n\t\t\treturn self.length\n\t\tend\n\tend", "def count(array)\n counter = 0\n return counter unless block_given?\n array.each { |el| counter += 1 if yield(el) }\n counter\nend", "def count_items(elective_array)\n return elective_array.length\nend", "def count_of_hufflepuff(values)\n count = 0\n values.each do |house| \n if house[2] == \"Hufflepuff\"\n count += 1\n end\n end\n puts \"There are #{count} Hufflepuffs!\"\nend", "def my_count\n return self unless block_given?\n count = 0\n for i in self\n if yield(i)\n count += 1\n end\n end\n return count\n end", "def numSmaller(list,item)\r\n\tif(list.count > 0) then\r\n\t\treturn list.count{|val| val.to_i<item.to_i}\r\n\telse\r\n\t\treturn 0\r\n\tend\r\nend", "def solution(a)\n counts = {}\n for i in a\n counts[i] ||= 0\n counts[i] += 1\n end\n for i in (1..a.count)\n return 0 if counts[i] != 1\n end\n return 1\nend", "def my_count(pattern = nil)\n if(block_given?)\n counter = 0\n self.my_each do |x|\n counter += 1 if yield(x)\n end\n return counter\n else\n if(pattern.nil?)\n return self.length \n else\n counter = 0\n self.my_each do |x|\n counter += 1 if x == pattern\n end\n return counter\n end\n end\n \n end", "def count_item(food_item, cart)\n cart.select { |groceries| groceries.has_key?(food_item) }.count\nend", "def count(arr)\n counter = 0\n arr.each { |el| counter += 1 if yield(el) }\n counter\nend", "def counter(list)\n views = Hash.new { |hash, key| hash[key] = 0 }\n list.map { |row| views[row[0]] += 1 }\n views.sort_by { |h| h[1] }.reverse\n end", "def my_count\n if block_given?\n num = 0\n self.my_each{|item| num += 1 if yield(item)}\n num\n else\n # if no block given return size of array\n self.length\n end\n end", "def num_occur(array, target)\n count = 0\n if array.empty?\n 0\n else\n count = 1 if array.first == target\n count += num_occur(array.drop(1), target)\n count\n end\nend", "def get_count(input)\n input.count('aeiou')\nend", "def total(list)\n sum = 0\n for i in list\n sum += i\n end\n sum\nend", "def count_frecuency(word_list)\n\tcounts = Hash.new(0) #es un hash que estará inicializado en 0, si indexamos en un key que no existe este retornará 0\n\tword_list.each do |word|\n\t\tcounts[word] +=1 #counts[word] es un hash con la clave del item actual, sabiendo que en principio no hay ningun item cuando asigne counts[word] +=1, sumará 1+0 ya que en principio el hash esta inicializado en 0\n \tend\n\tcounts\t\nend", "def count_occurences(array)\n\n # interate over array and add unique values as keys to a new hash\n unique_values = {}\n\n array.each do |item|\n if unique_values.keys.include?(item) == false\n unique_values[item] = 0\n end\n end\n # ------------\n\n\n # interate over hash and array, +1 the value of key for every match in array\n unique_values.each_key do |key|\n array.each do |item|\n if key == item\n unique_values[key] += 1\n end\n end\n end\n\n unique_values\nend", "def does_list_include?(array, obj)\n array.count(obj) > 0\nend", "def count\n items.compact.count.to_d\n end", "def value_count(hash, value)\n count = 0\n hash.each { |elem| count += 1 if elem[1]==value }\n count\nend", "def unique(mylist)\r\n\r\n counts = Hash.new(0)\r\n\r\n mylist.each { |item|\r\n # if item is Not in the hash\r\n puts \"looking in hash for #{item}\"\r\n if counts[item] == 0\r\n puts \"#{item} is not in hash. Adding it!\"\r\n counts[item] = 1\r\n end\r\n # counts[item] +=1\r\n # puts counts\r\n # if counts[item] > 1\r\n # end\r\n}\r\n\r\n # if element you are testing is the same\r\n # remove the element you are testing\r\n # else redo the loop\r\n \r\nend", "def item_count\n item_values.values.compact.sum { |v| v.is_a?(Array) ? v.size : 1 }\n end", "def create_list(items)\n hash = Hash.new(0)\n items.split(\" \").each do |item|\n hash[item] += 1\n end\n p hash\nend", "def list_creator(inputed_list)\r\n\r\n grocery_hash = {}\r\n grocery_list = inputed_list.split\r\n\r\n grocery_list.each do |item| \r\n grocery_hash[item] = $grocery_hash[item].to_i + 1\r\n end\r\n\r\n p grocery_hash\r\n return $grocery_hash\r\nend", "def num_times_applies(cart_items)\n num_items_matched = cart_items.map do |cart_item|\n item_matches?(cart_item.item) ? cart_item.quantity : 0\n end.inject(:+)\n\n num_discounts = num_items_matched / quantity\n\n if repeating?\n num_discounts\n else\n if num_discounts > 0 then 1 else 0 end\n end\n end", "def count_items(name)\n @items[name].size\n end", "def count_items\n @items.size\n end", "def add_item_counts(cart:[])\n cart.each do |item|\n item.map { |food_item, info| info[:count] = count_item(food_item, cart) }\n end\nend", "def count(*arr)\n arr.inject(0) { |count, el| yield(el) ? count + 1 : count }\nend", "def count(collection)\n collection.select { |el| yield(el) }.size\nend", "def increment_item_count(cart, item_name)\n index = 0\n while index < cart.length do\n current_item = cart[index]\n if ( current_item[:item] == item_name )\n current_item[:count] += 1\n end\n index += 1\n end\n cart\nend", "def count(array)\n hash = {}\n array.each do |item|\n hash[item] = array.count(item)\n end\n hash\nend", "def count_occurence(array)\n counts = Hash.new(0)\n array.each { |name| counts[name] += 1 }\n puts counts\n\n price_calculator=PriceCalculator.new\n price_calculator.sepitem_quantity(counts)\n\n end", "def count\n check = @eob.check_information\n if Output835.element_duplicates?(check.check_number, @check_nums)\n occurence = Output835.all_occurence(check.check_number, @check_nums)\n index_of_check_id = @check_ids.index(check.id)\n count = occurence[index_of_check_id]\n end\n count\n end", "def custom_count(array)\n counter = 0\n array.each do |elem|\n if elem != nil\n counter += 1\n end\n end\n counter\nend", "def num_occur(array, target)\n return 0 if array.empty?\n count = 0\n count += 1 if array.first == target \n count + num_occur(array.drop(1), target)\nend", "def char_count(list)\n letter_count = {}\n list.each do |word|\n word.split('').each do |letter| \n \n if letter_count[letter]# == nil\n letter_count[letter] += 1 \n else\n letter_count[letter]=1\n end\n end \n end\n # binding.pry\n letter_count\nend", "def count_occurrences(array)\n number_of_occurrences = {}\n array.each do |element|\n if number_of_occurrences.include?(element)\n number_of_occurrences[element] += 1\n else\n number_of_occurrences[element] = 1\n end\n end\n number_of_occurrences\nend", "def count_occurrences(arr)\n unique_elements = arr.uniq\n unique_elements.each { |element| puts \"#{element} => #{arr.count(element)}\"}\nend", "def my_count? (pattern = false)\n count = 0\n if block_given?\n self.my_each{|item| count += 1 if yield item}\n elsif !!pattern == true\n self.my_each{|item| count += 1 if pattern === item}\n else\n self.my_each{|item| count += 1 if !!item}\n end\n count\n end", "def getCounts (coins, sums, array, hash)\n for a in array\n if coins.include? a\n hash[a] == nil ? hash[a] = 1 : hash[a] += 1\n else\n otherCoins = sums[a][0]\n getCounts(coins, sums, otherCoins, hash)\n end\n end\nend" ]
[ "0.7423645", "0.73730606", "0.734652", "0.7207684", "0.70814794", "0.6837607", "0.6833629", "0.67698073", "0.6732527", "0.6675238", "0.66296077", "0.6615636", "0.6614344", "0.64636356", "0.6451111", "0.64439", "0.64232343", "0.6388172", "0.6385334", "0.638335", "0.6320419", "0.62967545", "0.6279069", "0.624801", "0.6210039", "0.6170473", "0.61648357", "0.6159945", "0.61562663", "0.6120645", "0.6077909", "0.60476905", "0.60310394", "0.6022943", "0.601736", "0.6015532", "0.5991938", "0.59911233", "0.5972042", "0.59697837", "0.5960313", "0.5955365", "0.5951761", "0.5945356", "0.5944621", "0.5931534", "0.59107107", "0.5909138", "0.58935344", "0.58773816", "0.5866988", "0.5847363", "0.58429736", "0.5798165", "0.5796336", "0.57917035", "0.578425", "0.5783119", "0.57830304", "0.57695717", "0.57653433", "0.57586116", "0.5757274", "0.5756753", "0.5739285", "0.57362425", "0.572453", "0.572075", "0.57136315", "0.5706349", "0.57057536", "0.5705291", "0.5704246", "0.57022417", "0.5693951", "0.56913215", "0.5689635", "0.56894934", "0.5687802", "0.56761366", "0.56740385", "0.56511784", "0.56503695", "0.56484175", "0.5648078", "0.56475306", "0.5639204", "0.5630044", "0.5625928", "0.5624327", "0.56129307", "0.56057316", "0.5605282", "0.5604448", "0.55979615", "0.5596212", "0.5593062", "0.5588658", "0.55740774", "0.5563396" ]
0.8222036
0
Get a list of all players, sorted by player name Response serialized array of players
def index @players = Player.order 'lower(name)' render json: @players, serializer: V1::ApplicationArraySerializer end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_all_players\n json_output = Player.all.map do |player|\n {\n id: player.id,\n name: player.name,\n image_url: player.image_url,\n }\n end\n\n render :json => json_output\n end", "def index\n collection = if request.query_parameters.present?\n Player.where request.query_parameters\n else\n Player.all\n end\n\n @players = collection.order 'first_name'\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @players.to_json(only: public_attrs) }\n end\n end", "def players\n results = get_parts(\"status\", 2..-1)\n results.map do |player|\n player = player.split(\" \", 3)\n {\n :name => player[2][1..-2],\n :ping => player[1].to_i,\n :score => player[0].to_i\n }\n end\n end", "def get_players\n\n end", "def index\n @players = Player.includes(:team).order('last_name, first_name').paginate(:page=>params[:page], :per_page =>20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @players }\n end\n end", "def players(player_name, *additional_player_names)\n player_names = [player_name].concat(additional_player_names)\n filter_params = { 'filter[playerNames]' => player_names.join(',') }\n\n get_request(shard_endpoint_uri('players', filter_params))\n end", "def list_with_ids\n players = Player.all.order(:id)\n response_json = []\n\n players.each do |p|\n # player = {}\n # player[p.id] = p.name\n # response_json.push(player)\n response_json.push({value: p.name, id: p.id})\n end\n\n # render json: players.to_json(only: [:id, :name])\n render json: response_json.to_json\n end", "def index\n @players = Player.all\n render json: @players\n end", "def index\n @players = Player.page params[:page]\n\t respond_with(@players)\n end", "def players(ordering = :raw)\n\t\t@@logger.info { \"Retrieving players.\" } if have_logger?\n\t\tmyplayers = Player.dataset.filter(:tournament_id => self.id).all\n\t\tcase ordering\n\t\t\twhen :random then\n\t\t\t\t@@logger.info { \"Ordering players: :random.\" } if have_logger?\n\t\t\t\tmyplayers.shuffle\n\t\t\twhen :criteria then\n\t\t\t\t@@logger.info { \"Ordering players: :criteria.\" } if have_logger?\n\t\t\t\tmyplayers.sort do |a, b|\n\t\t\t\t\ta_side = []\n\t\t\t\t\tb_side = []\n\t\t\t\t\tself.criteria.each do |func|\n\t\t\t\t\t\ta_side << a.send(func)\n\t\t\t\t\t\tb_side << b.send(func)\n\t\t\t\t\tend\n\t\t\t\t\tb_side <=> a_side\n\t\t\t\tend\n\t\t\twhen :score, :soft then\n\t\t\t\t@@logger.info { \"Ordering players: :score or :soft.\" } if have_logger?\n\t\t\t\tmyplayers.sort { |a, b| b.score <=> a.score }\n\t\t\twhen :hard then\n\t\t\t\t@@logger.info { \"Ordering players: :hard.\" } if have_logger?\n\t\t\t\tscores = []\n\t\t\t\tmyplayers.each { |player| scores << player.score unless scores.include?(player.score) }\n\t\t\t\tscores.each do |score|\n\t\t\t\t\t# Select those with same score\n\t\t\t\t\tplayers_tmp = myplayers.select { |player| player.score == score }\n\t\t\t\t\tnext if players_tmp.length <= 1 # If not more than one, get next group\n\t\t\t\t\t# Great... we have a group. Remove them from the main array\n\t\t\t\t\tmyplayers.delete_if { |player| player.score == score }\n\t\t\t\t\t# Shuffle the temp array\n\t\t\t\t\tplayers_tmp.shuffle!\n\t\t\t\t\t# Give it back to the main array\n\t\t\t\t\tmyplayers += players_tmp\n\t\t\t\tend\n\t\t\t\t# Sort it again in the end\n\t\t\t\tmyplayers.sort { |a, b| b.score <=> a.score }\n\t\t\telse\n\t\t\t\t# This include the :raw case\n\t\t\t\t@@logger.info { \"Ordering players: :raw or any other thing.\" } if have_logger?\n\t\t\t\tmyplayers\n\t\tend\n\tend", "def index\n @players = Player.order(:gamertag_lower).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @players }\n end\n end", "def index\n player = Player.all\n render json: players, status: 200\n end", "def index\n @players = Player.all\n render json: @players, status: 200\n end", "def players\n @players || []\n end", "def index\n @players = Player.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @players }\n end\n end", "def players(list=\"all\")\n\t\t\t\tdata = send(['listPlayers', list])\n\t\t\t\tif data\n\t\t\t\t\treturn Player.players_from_list(data,0)\n\t\t\t\tend\n\t\t\tend", "def get_players\n load_firebase\n # @player_list = Hash.new\n @player_list = Array.new\n @json_object.each do |key, value|\n @player_list << value\n end\n @player_list\n end", "def players\n @players ||= []\n end", "def players\n @players ||= []\n end", "def index\n @players = Player.order(:id)\n end", "def all_players\n Player.all\nend", "def index\n @players = Player.all\n @players = Player.all.paginate(page: params[:page], per_page: 5)\n end", "def player_names\n self.players.pluck(:username).join(\", \")\n end", "def get_all_players\n ret_val = {}\n pr_file = File.expand_path('../../tmp/wiki_pr.json', __FILE__)\n if File.exists?(pr_file)\n ret_val = JSON.parse(File.read(pr_file))\n else\n grab_ranking_links.each do |link|\n ret_val.merge!(get_players_from_link(link))\n end\n File.open(pr_file, \"w\") do |f|\n f.write(ret_val.to_json)\n end\n end\n ret_val\n end", "def name_all_players\n (0..num_players - 1).each { |i| @players[i].name_player('Player' + i.to_s)}\n end", "def index\n @players = Player.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @players }\n end\n end", "def players\n users\n end", "def players\n return [User.find_by(id: player1_id), User.find_by(id: player2_id),\n User.find_by(id: player3_id), User.find_by(id: player4_id)].compact\n end", "def build_list_of_players\nend", "def index\n @qb_players = Qb.order(:sort).all\n @rb_players = Rb.order(:sort).all\n @wr_players = Wr.order(:sort).all\n @te_players = Te.order(:sort).all\n @k_players = K.order(:sort).all\n @d_players = Def.order(:sort).all\n end", "def index\n players=Player.all\n render json: players, include: [:player_items=>{include:[:item]}, :player_skills=>{include:[:skill]}], except: [:created_at, :updated_at], methods: [:adjusted_stats, :equipped_items, :consumables]\n end", "def players\n # Build two arrays of players\n cur_players = teams.map do |team|\n team.wattball_players\n end\n\n # Combine the arrays\n cur_players.flatten! \n end", "def team_players\n Player.all\n end", "def index\n @players = Player.find(:all, :order => 'lname')\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @players.to_xml }\n end\n end", "def get_all_players\n ## Version 2.0 ##\n\n all_players = []\n\n # Same steps, but since we don't care about team, let's use .values to just\n # iterate over the team_data:\n game_hash.values.each do |team_data|\n team_data[:players].each do |player|\n all_players << player\n end\n end\n\n all_players\nend", "def index\n respond_to do |format|\n format.html\n format.json { render json: PlayersDecorator.new(Player.all).all_data }\n end\n end", "def get_players\n all_players = consume_player_data\n delete_id_column(all_players)\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n end", "def index\n @players = Player.all\n auth!\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @players }\n end\n end", "def sport_players(sport_id, season, **options) = get(\"/sports/#{sport_id}/players\", **options.merge(season:))", "def parse_players(player)\n player.each_with_index.map do |s, i|\n [i+1, s.name, s.power, s.combat]\n end\n end", "def get_players_by_team(team_id)\n response = parse_api_request(\"#{BASE_URL}players/2018/#{team_id}\")[\"players\"]\nend", "def get_players\n players = []\n game_hash.each do |teams, team_data|\n # players.push(team_data[:players])\n players << team_data[:players]\n end\n players.flatten\nend", "def index\n # Use includes in the query for performance (lesser hits on DB)\n players = Player.limit(@limit).offset(@offset).includes(:team)\n\n # I want my client to know how many players the db has\n nr = Player.distinct.count(:id)\n\n # Put it all together in a hash\n #@response = {players: players, nrOfPlayers: nr}\n # serializable_hash in the Player-model will render the object\n respond_with players, status: :ok, location: players_path\n end", "def index\n @players = Player.of_rank(params[:rank_id]).by_instance(params[:instance_id]) \\\n .order(\"players.name\") \\\n .includes(:rank)\n end", "def players; [@hunter, @prey] 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 players_names_array \n player_names = []\n game_hash.each do |place,team|\n team.each do |attribute, data|\n next unless attribute == :players\n data.each do |player| \n player_names.push(player[:player_name])\n end\n end\n end\n player_names\nend", "def build_list_of_players\n [\n \"cliff\",\n \"anne\",\n \"harry\",\n \"sam\",\n \"devin\",\n \"ally\",\n \"bob\",\n \"jane\",\n \"jimmy\",\n \"dave\"\n ]\nend", "def players\n @players.select(&:playing)\n end", "def show_favorite_players(fan) #this method is backend finding the players of a specifc fan\n players_array = favorite_players(fan)\n players_array.each do |player|\n puts player.name \n end\nend", "def index\n\t\t@game = Game.find(params[:game_id])\n\t\t@players = @game.players\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @players }\n\t\tend\n\tend", "def player\n fetch('football.players')\n end", "def get_summoner_names\n # Make an API request for all summoners in a ranked division.\n response_string = RestClient.get(\"https://#{REGION}.api.riotgames.com/lol/league/v4/entries/RANKED_SOLO_5x5/#{TIER}/#{DIVISION}?page=1&api_key=#{API_KEY}\")\n #sleep(1)\n summoner_data = JSON.parse(response_string)\n # For each summoner whose data is in summoner_data, return their name.\n summoner_names = summoner_data.map do |summoner| \n summoner_name = summoner[\"summonerName\"].gsub(\" \", \"%20\").encode(\"ASCII\", invalid: :replace, undef: :replace)\n end.delete_if {|name| name.include?('?')}\nend", "def index\n @players = @game.players\n end", "def index\n @players = @game.players\n end", "def player_points_by_game\n player = Player.find(params[:id])\n stats = Statline.where(player: player).order(date: :asc)\n data = Array.new\n labels = Array.new\n stats.each do |line|\n labels << line.opponent.name\n data << line.points\n end\n json = { data: data, labels: labels }\n\n render json: json\n end", "def index\r\n authorize! :index, Player\r\n @operation_players = Operation::Player.accessible_by(current_ability, :read).includes(:player_group)\r\n @operation_players = @operation_players.search(params[:search]) unless params[:search].blank?\r\n @operation_players = @operation_players.where(player_group_id: params[:player_group_id]) unless params[:player_group_id].blank?\r\n @operation_players = @operation_players.order(\"#{sort_column} #{sort_direction}\") unless sort_column.blank?\r\n @operation_players = @operation_players.paginate(page: params[:page], per_page: params[:per_page] || 100)\r\n end", "def index\n @group_players = GroupPlayer.all\n end", "def sorted\n\n require 'open-uri'\n require 'json'\n\n\tmembers = []\n\ttemp = []\n\n\tobject = JSON.parse(open(\"http://sc2ranks.com/api/clist/11658/us/all/1/0.json?appKey=uiucstarcraft.com\").read)\n [\"grandmaster\", \"master\", \"diamond\", \"platinum\", \"gold\", \"silver\", \"bronze\"].each do |league|\n \tobject.each do |player|\n \t\tif player[\"league\"] == \"#{league}\" && player[\"expansion\"] == 1\n \t\t\ttemp.push([player[\"members\"][0][\"fav_race\"], player[\"members\"][0][\"name\"], player[\"league\"], player[\"points\"], player[\"members\"][0][\"bnet_id\"]])\n \t\tend\n \tend\n \ttemp.sort! { |a, b| b[3]<=>a[3] }\n\t\tmembers += temp\n\t\ttemp.clear\n end\n\n return members\nend", "def index\n @players = Player.all\n # handle search parameter\n if params[:search].present?\n @players = @players.search(params[:search])\n if @players.empty?\n flash.now[:alert] = t('flash.alert.search_players')\n end\n end\n # handle sort parameter\n sort = params[:sort]\n if sort.present?\n case sort\n when 'win_loss_ratio'\n if params[:order] == \"desc\"\n @players = @players.sort_by do |p|\n [p.win_loss_ratio, -p.created_at.to_i]\n end.paginate(page: params[:page], per_page: Player::MAX_PLAYERS_PER_PAGE)\n else\n @players = @players.sort_by do |p|\n [p.win_loss_ratio, -p.created_at.to_i]\n end.reverse.paginate(page: params[:page], per_page: Player::MAX_PLAYERS_PER_PAGE)\n end\n else\n @players = @players.order(\"players.?\".gsub('?', params[:sort])).paginate(page: params[:page], per_page: Player::MAX_PLAYERS_PER_PAGE)\n end\n else\n @players = @players.order(created_at: :desc).paginate(page: params[:page], per_page: Player::MAX_PLAYERS_PER_PAGE)\n end\n # handle the order parameter\n if params[:order] == \"desc\" and [email protected]_a?(Array)\n @players = @players.reverse_order\n end\n end", "def get_all_players\n ## Version 5.0 ##\n\n # We can just chain .flatten onto the end of map.\n # By doing this, we can get rid of all_players.\n game_hash.values.map do |team_data|\n team_data[:players]\n end.flatten\nend", "def show\n # user = User.find_by_token(params[:token])\n # # @user = User.find(params[:id])\n matches = current_user.matches\n matches.each do |match|\n match['players'] = Array.new(match.users)\n end\n\n render json: {user: current_user, decks: current_user.decks, matches: matches}\n end", "def players_of_sport\n klass = params[:sport].titleize.constantize\n render json: klass.all.map { |record| convert_to_json(record) }\n end", "def index\n @players = Player.ranking.where('wins != 0 or losses != 0')\n players_without_matches = Player.where('wins = 0 and losses = 0')\n @players.concat players_without_matches\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @players }\n end\n end", "def index\n @players = @tournament.players\n end", "def top_five\n players = Player.all.order(current_mentions: :desc).limit(5)\n\n response_json = []\n\n players.each do |p|\n response_json.push({name: p.name, scores: p.get_hourly_scores, current_mentions: p.current_mentions})\n end\n\n render json: response_json\n end", "def players\n [@player1, @player2].sort_by { |player| player.first ? 0 : 1 }\n end", "def entries_to_players\n\t\tplayers = []\n\t\[email protected] do |entry|\n\t\t\tif entry.enabled\n\t\t\t\tplayers << entry.player\n\t\t\tend\n\t\tend\n\t\tplayers\n\tend", "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 param! :order, String, in: %w(asc desc), transform: :downcase, default: \"desc\"\n param! :sort, String, in: Player.sort_allowed?, default: Player.sort_default\n param! :limit, Integer, in: (10..100), default: 25\n param! :page, Integer, default: 1\n param! :offset, Integer, default: (params[:page]-1)*params[:limit]\n\n\n puts params\n if request.format.json?\n puts params\n if params[:country_countryId]\n query = Country.find(params[:country_countryId]).players.where(hideranking: 0)\n elsif params[:clan_clanId]\n query = Team.find(params[:clan_clanId]).players.where(hideranking: 0)\n else\n query = Player.where(hideranking: 0)\n end\n if params[:search]\n query = query.name_search(params[:search])\n end\n @total = query.count\n @players = query.with_kpd.uniorder(params[:sort], params[:order]).limit(params[:limit]).offset params[:offset]\n else\n @scope = Player.where(hideranking: 0)\n end\n end", "def players\n (@players ||= []).map{|id| W.find_player id}.freeze\n end", "def index\n\n @game_players = GamePlayer.where(:game_id => params[:game_id]).order(\"player_number asc\")\n\n @game_players.each do |each_game_player|\n each_game_player[:username] = each_game_player.user.username\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.js {\n @game_players\n }\n format.json { render json: @game_players }\n end\n end", "def index\n @players = Player.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @players }\n end\n end", "def index\n @players = Player.all\n # \"Player.all\" sends message to the Player model to retrieve all the Player instances\n # that list of players is assigned to @players\n # @players is available in the view to display all players or specific players\n end", "def set_players\n @players = Player.where(account_id: params[:id]).order_by(match_id: :desc).page(params[:page]).per(20)\n end", "def index\n @players = Player.all\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def player_data\n players = []\n game_hash.each do |home_away, team_details|\n players << team_details[:players]\n end\n return players.flatten\nend", "def print_players()\n\t\tfor i in 0...@num_players\n\t\t\tprint_player(i)\n\t\tend\n\tend", "def index\n @players = Player.all\n # @player = current_user.players\n end", "def std_player_names\n\t\tnames = []\n\t\tfor i in 1..Constants::MAX_PLAYERS\n\t\t\tnames << \"Player\" + i.to_s\n\t\tend\n\t\tnames\n\tend", "def show_players\n puts @cards.length\n @players.each do |player|\n puts \"Nombre: #{player.name}\"\n player.cards.each do |card|\n puts card.id\n end\n end\n end", "def index\n @game_players = GamePlayer.all\n end", "def index\n @drafted_players = DraftedPlayer.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @drafted_players }\n end\n end", "def initialize_players\n initial_players = []\n if params[:player_names]\n player_names = params[:player_names].split(\",\")\n player_names.each do |tag|\n new_player = Player.create(:username => tag, :party_id => @party.id)\n initial_players.append(new_player)\n end\n end\n return initial_players\n end", "def players\n gp = Player.where :instance_id => self.id\n gp.map { |p| p.user_id }\n end", "def index\r\n @gameplayers = Gameplayer.includes(:player, :game).all\r\n end" ]
[ "0.74102443", "0.70372635", "0.69200486", "0.6894624", "0.68930185", "0.68434656", "0.6838308", "0.68346655", "0.68102396", "0.6808408", "0.67811495", "0.677879", "0.6767976", "0.6753625", "0.67436063", "0.6736968", "0.6733307", "0.67102844", "0.67102844", "0.67046654", "0.6671046", "0.6646493", "0.66042006", "0.6597353", "0.6557913", "0.65563446", "0.654647", "0.65346587", "0.65316534", "0.6503226", "0.6487842", "0.6482603", "0.6431546", "0.64309657", "0.64177465", "0.6403049", "0.63870114", "0.6373038", "0.6373038", "0.6373038", "0.6373038", "0.6373038", "0.6373038", "0.6373038", "0.6373038", "0.6373038", "0.6373038", "0.6373038", "0.6373038", "0.6373038", "0.6373038", "0.6345491", "0.6341757", "0.63092065", "0.6306112", "0.6301529", "0.629849", "0.6292561", "0.62923944", "0.628824", "0.6285333", "0.62852585", "0.627536", "0.6268562", "0.6262564", "0.6261815", "0.626149", "0.6256759", "0.6256759", "0.6212194", "0.6208778", "0.6207244", "0.6206467", "0.62026197", "0.6192296", "0.6185764", "0.6182811", "0.6159418", "0.6156487", "0.61512494", "0.61494756", "0.6145548", "0.6138611", "0.6129064", "0.6124422", "0.6117989", "0.61111397", "0.61052084", "0.6094564", "0.6091054", "0.60863155", "0.6081409", "0.60772955", "0.60667855", "0.6063116", "0.60533625", "0.6036553", "0.6022164", "0.6013806", "0.60082954" ]
0.7316249
1
Get a particular player Params +:id+ player id Response serialized Player
def show render json: @player end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def player(player_id)\n get_request(shard_endpoint_uri(\"players/#{player_id}\"))\n end", "def get_player(id)\n\t\treturn @players[id]\n\tend", "def player_by_id id\n @players.select {|p| p.id == id}.first\n end", "def player(player_id)\n path = ['shards', @region, 'players', player_id].join('/')\n get(path)\n end", "def show\n @player = Player.find(params[:id])\n\n render :json => @player\n end", "def player_by_id(id)\n response = Faraday.get(\"#{URL}/#{id}\")\n data = JSON.parse(response.body)\n new(data[KEY][0]) if data[KEY]\n end", "def player_params\n params[:player]\n end", "def show\n @player = Player.where(:uuid => params[:uuid]).first\n if @player\n render :json => { :success => true, :player => @player }\n else\n render :json => { :success => false, :player => {} } , :status => 404\n end\n\n end", "def show\n @player = Player.find(params[:id])\n end", "def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @player }\n end\n end", "def get_player(nickname)\n response = get(RESOURCE_PATH, nickname, headers: { 'API-VERSION': 'v2' })\n response_body = JSON.parse(response.body, symbolize_names: true)\n\n Rails.logger.info(\"GS Get Player Response: #{response_body}\")\n\n if response.success?\n #TODO: deserialize response json into Player object automatically\n nickname = response_body[:nickname]\n ext_id = response_body[:ext_id]\n avatar = response_body[:avatar]\n theme = response_body[:theme]\n player_point_types = []\n point_types_response = response_body[:point_types]\n (point_types_response || []).each do |point_type_response|\n player_point_types << GameServer::Model::PlayerPointType.new(point_name: point_type_response[:name], count: point_type_response[:amount])\n end\n\n player = GameServer::Model::Player.new(nickname, ext_id, avatar, theme)\n player.player_point_types = player_point_types\n\n get_player_response = GameServer::Client::Response::GetPlayerResponse.new(true, nil, player)\n else\n error_message = response_body[:error_message]\n\n get_player_response = GameServer::Client::Response::GetPlayerResponse.new(false, error_message, nil)\n end\n\n return get_player_response\n end", "def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player }\n end\n end", "def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player }\n end\n end", "def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player }\n end\n end", "def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player }\n end\n end", "def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player }\n end\n end", "def get_player_id\n\t\t@player_id\n\tend", "def show\n respond_with Player.find(params[:id])\n end", "def show\n @player_id = params[:player_id].to_i # TODO: With Devise, this would be @current_user.id\n end", "def show\n @team = Team.find(params[:team_id])\n @player = @team.players.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @player }\n end\n end", "def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player.to_json(only: public_attrs) }\n end\n end", "def get_players_by_team(team_id)\n response = parse_api_request(\"#{BASE_URL}players/2018/#{team_id}\")[\"players\"]\nend", "def show\n # find the player by their login\n @player = Player.find_by_login(params[:id])\n # 404 if player isn't found\n raise ActiveRecord::RecordNotFound unless @player\n end", "def show\n @game_player = GamePlayer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_player }\n end\n end", "def show\n @all_player = AllPlayer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @all_player }\n end\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def show\n\t\t@player = Player.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml { render :xml => @player }\n\t\tend\n\tend", "def show\n @client_player = ClientPlayer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_player }\n end\n end", "def show\n @player = Player.includes(:team).find(params[:id])\n end", "def player_name(id)\n name = Player.find(id)\n end", "def player_by_username(username)\n @logger.info \"Looking up player by username [#{username}]\"\n\n request = make_request('player', {\n :name => username\n })\n\n Player.from_json request\n end", "def player\n fetch('football.players')\n end", "def player_params\n params.fetch(:player, {})\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find params[:id]\n end", "def player\n\t\t\tPlayer.find(self.playerID)\n\t\tend", "def set_player\n\t @player = Player.find(params[:id])\n\t end", "def show\n @player = Player.find(params[:id])\n\n if request.xhr?\n render @player\n end\n end", "def show\n @player_record = PlayerRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_record }\n end\n end", "def load_player(id)\n load_entity('.player', id)\n end", "def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n end\n end", "def player_by_uuid(uuid)\n @logger.info \"Looking up player by UUID [#{uuid}]\"\n\n request = make_request('player', {\n :uuid => uuid\n })\n\n Player.from_json request\n end", "def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end", "def show\n if session[:user_id].nil?\n flash[:error] = \"Please log in.\"\n redirect_to '/'\n return\n end\n\n if session[:user_id].to_i != params[:id].to_i\n redirect_to '/nope' unless Player.find(params[:id]).tagged\n return\n end\n @player = Player.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player }\n end\n end", "def show\n respond_to do |format|\n format.json { render json: @player }\n end\n end", "def update\n @player = Player.find(params[:id])\n \n if @player.save\n render :json => @player, :status => :ok\n else\n render :json => @player.errors, :status => :unprocessable_entity\n end\n end", "def show\n render json: @player, status: 200\n end", "def show\n @player = Player.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n end\n end", "def get_hanchan_player(hanchan_player_id)\n return DB[:hanchan_players].first(id: hanchan_player_id)\nend", "def show\n # puts \"PARAMSSSSS CONTROLLER #{params[:id]}\"\n url = \"https://api-2445582011268.apicast.io/games/#{params[:id]}\"\n response = HTTParty.get(url, headers: {\"user-key\" => Figaro.env.igdb_api_key, \"Accept\": \"application/json\"})\n @game_response = response.parsed_response\n end", "def set_api_v1_player\n @api_v1_player = Api::V1::Player.find(params[:id])\n end", "def get_url(url, params)\n response = @conn.get(url, params)\n JSON.parse(response.body, symbolize_names: true)[:body][:players]\n end", "def show\n\n \t\t\trespond_with @player\n\n \t\tend", "def show\n @player = Player.find(params[:id])\n @team\n if params[:team_id]\n @team = Team.find(params[:team_id])\n end \n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @player }\n end\n end", "def show\n @player_game = PlayerGame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @player_game }\n end\n end", "def player(player_name)\n players.find{|player| player.name == player_name}\n end", "def get_player\n\t @name\n\tend", "def get_players\n\n end", "def show\n @playerdiv = Playerdiv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @playerdiv }\n end\n end", "def player_params\n params.required(:player).permit(:id, :team_id)\n end", "def update\n player = Player.find(params[:id])\n if player.update(player_params)\n render json: player, status: 200, location: [:api, player]\n else\n failed_to_update(player, \"player\")\n end\n end", "def show\n @player_client = PlayerClient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_client }\n end\n end", "def teams_player_params\n params[:teams_player, :team_id, :player_id]\n end", "def authorized_player(id)\n player = Player.find(id)\n if logged_in? && player == current_player\n return player\n end\n end", "def getPlayer(db, id)\n\tif db.exists('sgt-player:'+id)\n\t\treturn Player.new(db, id)\n\telse\n\t\t# TODO: Find where to put them\n\t\tsector = $defaultWorld.getSector(0,0)\n\t\tloc = astroLocationFromCoords(sector, 50, 50)\n\t\n\t\tplayer = Player.new(db, id)\n\t\tplayer.location.setSpace(loc)\n\t\treturn player\n\tend\nend", "def single_player\n # answer = {}\n klass = params[:sport].titleize.constantize\n record = klass.find_by_cbs_id(params[:id].to_i)\n # answer[:id] = record.cbs_id\n # %i[name_brief first_name last_name position age average_position_age_diff].each do |field|\n # answer[field] = record[field]\n # end\n render json: convert_to_json(record)\n end" ]
[ "0.76298755", "0.75942206", "0.7440805", "0.7428888", "0.73004556", "0.7293837", "0.72263086", "0.71434593", "0.7091214", "0.7069652", "0.70436805", "0.703818", "0.703818", "0.703818", "0.703818", "0.703818", "0.7032797", "0.7025037", "0.6984716", "0.6973886", "0.6902457", "0.6870792", "0.68661046", "0.6795043", "0.6760052", "0.6737223", "0.6737223", "0.6737223", "0.6737223", "0.6737223", "0.6737223", "0.6737223", "0.6737223", "0.67000806", "0.66784877", "0.6673266", "0.6627724", "0.6621681", "0.6613668", "0.66041", "0.6587746", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.65876335", "0.6584911", "0.6567854", "0.6559451", "0.6537713", "0.6530582", "0.65161735", "0.6506836", "0.65062183", "0.65034074", "0.6497511", "0.647474", "0.64743996", "0.64610004", "0.64555734", "0.6445841", "0.64342636", "0.6433738", "0.6422562", "0.64175916", "0.64076763", "0.6388721", "0.63695383", "0.6368695", "0.6355135", "0.63544565", "0.6353542", "0.63369125", "0.6321657", "0.6318174", "0.6313623", "0.62792987", "0.62774837" ]
0.63388366
94
Create a player Request +:name+ player name Response serialized Player or HTTP error
def create @player = Player.new(player_params) if @player.save render json: @player, status: :created, location: @player else render json: {errors: @player.errors}, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_player(name)\n {\n \"id\" => @player_class.create(:player_name => name).id\n }\n end", "def create\n player = Player.new(player_params)\n if player.save\n render json: player, status: 201, location: [:api, player]\n else\n failed_to_create(player, \"player\")\n end\n end", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to \"/players/new\", notice: (@player.name + ' was successfully created.') }\n format.json { render json: @player, status: :created, location: @player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(params[:player])\n \n if @player.save\n render :json => @player, :status => :created, :location => @player\n else\n render :json => @player.errors, :status => :unprocessable_entity\n end\n end", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n flash[:notice] = 'Api::Player was successfully created.'\n format.html { redirect_to(@player) }\n format.xml { render :xml => @player, :status => :created, :location => @player }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n player = Player.create(player_params)\n render json: player, status: 201\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.json { render json: @player, status: :created }\n else\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n \t\t\t@player = Player.new player_params\n\n \t\t\tif @player.save\n\n \t\t\t\trender json: @player,status: :created\n\n \t\t\telse\n\n \t\t\t\trender json: {error: true,errors: @player.errors},status: :unprocessable_entity\n\n \t\t\tend\n\n \t\tend", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render json: @player, status: :created, location: @player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render json: @player, status: :created, location: @player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render json: @player, status: :created, location: @player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render json: @player, status: :created, location: @player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to root_path, notice: 'Player was successfully created.' }\n format.json { render json: @player, status: :created, location: @player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n format.html {\n redirect_to @player, notice: I18n.t(\"messages.players.create.success\")\n }\n else\n format.html {\n @errors = @player.errors\n render action: \"new\"\n }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n event \"create\", :player, @player.id, description: \"#{current_player.name} created player #{@player.name}\"\n format.html { redirect_to @player, flash: { success: 'Player was successfully created.' } }\n format.json { render json: @player.to_json(only: public_attrs), status: :created, location: @player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: \"Player was successfully created.\" }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render json: @player, status: :created, location: @player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n tournament = Tournament.open.last\n\n if tournament\n @player = tournament.players.new name: params[:name],\n key: SecureRandom.uuid\n if @player.valid?\n @player.save!\n message = { :name => @player.name,\n :key => @player.key,\n :message => @player.key }\n else\n message = { :message => \"You must register with a valid and unique player name.\" }\n end\n\n respond_to do |format|\n format.json { render :json => message }\n format.xml { render :xml => message }\n format.html { redirect_to '/pages/registration', :notice => message[:message] }\n end\n else\n respond_to do |format|\n format.json { render_not_found \"The tournament is currently closed.\" }\n format.xml { render_not_found \"The tournament is currently closed.\" }\n format.html { redirect_to '/pages/registration', :alert => \"The tournament is currently closed.\" }\n end\n end\n end", "def createPlayer(params)\n \n # Create a hash\n doc = {:type => \"Person\"}\n \n # Set the name\n doc[:name] = params[\"name\"]\n \n # Set the email\n doc[:email] = params[\"email\"]\n \n # Set the username\n doc[:username] = params[\"username\"]\n \n # Set the guest flag\n doc[:guest] = params[\"guest\"] ? true : false\n \n # Set the current date\n doc[:date] = Time.now.to_i\n \n # Get a new id from the CouchDB server\n uuid = CouchDB.nextUUID @server\n doc[:_id] = uuid\n \n # Put it to the database\n response = CouchRest.put @server + \"/#{CouchDB::DB}/#{uuid}\", doc\n \n return response != false\n \n end", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to(@player, :notice => 'Player was successfully created.') }\n format.xml { render :xml => @player, :status => :created, :location => @player }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render action: 'show', status: :created, location: @player }\n else\n format.html { render action: 'new' }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render action: 'show', status: :created, location: @player }\n else\n format.html { render action: 'new' }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render action: 'show', status: :created, location: @player }\n else\n format.html { render action: 'new' }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render action: 'show', status: :created, location: @player }\n else\n format.html { render action: 'new' }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(params[:player])\n flash[:notice] = 'Se guardó el nuevo Player.' if @player.save\n respond_with(@player)\n end", "def create\n # The data is only in json-format in this example\n player = Player.new(player_params) # using strong parameters\n\n if player.save\n # ok respond with the created object (team)\n respond_with player, status: :created\n else\n # render or error message\n error = ErrorMessage.new(\"Could not create the resource. Bad parameters?\", \"Could not create the resource!\" )\n render json: error, status: :bad_request # just json in this example\n end\n\n end", "def create\n @player = Player.create!(player_params) # anticipated possible exceptions rescued in BaseController\n render json: @player, status: :created\n end", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n flash[:notice] = 'Player was successfully created.'\n format.html { redirect_to(@player) }\n format.xml { render :xml => @player, :status => :created, :location => @player }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n flash[:notice] = 'Dodano nowego zawodnika.'\n format.html { redirect_to(@player) }\n format.xml { render :xml => @player, :status => :created, :location => @player }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n if @player.save\n flash[:notice] = 'Player was successfully created.'\n respond_with @player\n else\n render action: :new\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n @players = Player.all\n @players.each do |p|\n if p.id != @player.id\n @team = Team.create(name: p.name[0, 3] + @player.name[0, 3] + (p.id + @player.id).to_s, player_ids: [p.id, @player.id])\n else\n end\n end\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n @player.save\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to [:admin, @player], notice: 'Player was successfully created.' }\n format.json { render json: @player, status: :created, location: @player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n flash[:notice] = \"Player was created successfully.\" if @player.save\n respond_with @player\n end", "def create\n @player = Player.new(player_params)\n @player.user = current_user\n # automatically create a new team for the user if there isn't one already\n unless @player.team || @player.name.blank?\n team = Team.find_or_initialize_by(name: \"#{@player.name}'s Team\", code: @player.name.upcase)\n @player.team = team if team.save\n end\n respond_to do |format|\n if @player.save\n format.html { redirect_to(@player, :notice => 'Player was successfully created.') }\n format.xml { render :xml => @player, :status => :created, :location => @player }\n else\n team.destroy if team\n format.html { render :action => \"new\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n json = ActiveSupport::JSON.decode(params[:player])\n @player = Player.new\n @player.gender = json[\"gender\"]\n @player.username = json[\"username\"]\n @player.uuid = json[\"uuid\"]\n @player.last_location = json[\"location\"]\n @player.player_monsters = [ PlayerMonster.new({ :nickname => json[\"starting_monster\"][\"nickname\"],\n :monster_id => json[\"starting_monster\"][\"id\"],\n :caught_location => json[\"location\"]\n }) ]\n if @player.save\n render :json => { :success => true, :player => @player } , :status => 200\n else\n render :json => { :success => false, :message => @player.errors } , :status => 400\n end\n end", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n session[:current_player] = @player\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render json: @player, status: :created, location: @player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n puts params\n game = CreateGame.new(\n max_rounds: params[:max_rounds],\n draw_time: params[:draw_time],\n ).perform\n player = CreatePlayer.new(\n username: params[:username],\n game: game,\n creator: true\n ).perform\n\n if game.persisted? && player.persisted?\n session[:uuid] = player.uuid\n redirect_to player_path\n else\n render json: { ok: 'gra nie zapisana :(' }\n end\n end", "def create\n bingo_session = BingoSession.find(params[:bingo_session_id])\n @player = Player.new(params[:player])\n @player.bingo_session = bingo_session\n @player.caller = current_caller\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to(@player, :notice => 'Player was successfully created.') }\n format.xml { render :xml => @player, :status => :created, :location => @player }\n format.json { render :json => @player}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n format.json { render :json => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n# ToDo 0 => Wenn Spieler erstellt wurde, schließe das Fenster und aktualisiere die Spielerliste bzw. die Spielerübersicht\n format.html { redirect_to home_path, notice: 'Player was successfully created.' }\n format.json { render json: @player, status: :created, location: @player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = Player.create!(player_params)\n session[:user_id] = user.id\n \n if user.valid?\n render json: player, status: :created\n else\n render json: { errors: user.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def create\n @player = Player.new\n @player.playername = params[:playername]\n @player.password = params[:password]\n\n if @player.save\n redirect_to \"/login\"\n else\n render :new\n end\n end", "def create\n @player = Player.new(player_params)\n @player.user = current_user\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n puts(params);\n @player = Player.new(player_params)\n \n respond_to do |format|\n if @player.save\n # Tell the playerMailer to send a welcome email after save\n # @user_player = Userplayer.new(user_id: @user.id, player_id: @player_id)\n # if @user_player.save\n @tournament.players << @player\n # @tournament.update_attribute(num_players: @tournament.num_players + 1)\n format.html { redirect_to(root_path, notice: 'player was successfully added.') }\n format.json { render json: @player, status: :created, location: @player }\n # end\n else\n format.html { render action: 'new' }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n @player.game = @game\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to game_player_path(id: @player.id), notice: 'Player was successfully created.' }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n session[:player_id] = @player.id\n session[:new_player] = true\n if session[:creator]\n @player.game.update(creator: @player.id)\n end\n format.turbo_stream\n format.html { redirect_to @player.game, notice: \"Player was successfully created.\" }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(params[:player])\n @player.user_id = current_user.id\n\n respond_to do |format|\n if @player.save\n flash[:notice] = 'Player was successfully created.'\n format.html { redirect_to @player }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @team = Team.find(params[:team_id])\n @player = @team.players.build(params[:player])\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to([@player.team, @player], :notice => 'Player was successfully created.') }\n format.json { render :json => @player, :status => :created, :location => [@player.team, @player] }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n @player.create_activity :create, owner: current_user\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render json: @player, status: :created, location: @player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fantasy_team_player = FantasyTeamPlayer.create(team_id: @team.id, player_id: params[:player_id])\n unless @fantasy_team_player.new_record?\n render json: @fantasy_team_player, status: :ok, include: [:player]\n else\n render json: error_messages_on_create, status: :unprocessable_entity\n end\n end", "def create\n @player = Player.new(player_params)\n respond_to do |format|\n if @player.save\n EventMailer.new_player(@player).deliver\n format.html { redirect_to page_thank_you_path }\n format.json { render action: 'show', status: :created, location: @player }\n else\n format.html { render action: 'new' }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_player\n name=gets.chomp\n @name=name\n end", "def create\n @game_player = GamePlayer.new(game_player_params)\n\n respond_to do |format|\n if @game_player.save\n format.html { redirect_to @game_player, notice: \"Game player was successfully created.\" }\n format.json { render :show, status: :created, location: @game_player }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @game_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @team_player = TeamPlayer.new(team_player_params)\n\n respond_to do |format|\n if @team_player.save\n format.html { redirect_to @team_player, notice: 'Team player was successfully created.' }\n format.json { render action: 'show', status: :created, location: @team_player }\n else\n format.html { render action: 'new' }\n format.json { render json: @team_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n player_params = {\"name\"=>room_params[:leader], score: 0, lives: 2}\n \n @room = Room.new(room_params)\n @room.round = 0\n\n respond_to do |format|\n if @room.save\n @player = @room.players.create(player_params)\n if @player.save\n session[:player_id] = @player.id\n format.html { redirect_to @room, notice: 'Room and Player were successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n game = Game.find(params[:game_id])\n @player_game = PlayerGame.new(params[:player_game])\n @player_game.game = game\n\n if params['player_other'] != nil and params['player_other'].length > 0 \n p = Player.new\n p.name = params['player_other']\n p.bingo_session = @player_game.game.bingo_session\n p.save!\n @player_game.player = p\n end\n\n respond_to do |format|\n if @player_game.save\n format.html { redirect_to(@player_game, :notice => 'Player game was successfully created.') }\n format.xml { render :xml => @player_game, :status => :created, :location => @player_game }\n format.json { render :json => @player_game}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @player_game.errors, :status => :unprocessable_entity }\n format.json { render :json => @player_game}\n end\n end\n end", "def generate_player\n ret_val = nil\n msg = \"no changes made\"\n if (!ranking_player.nil?) and !has_base_player\n ret_val = PlayersHelper.generate_player_from_url(ranking_player)\n if !ret_val.nil?\n self.player = ret_val\n if base_player_country_id != base_country_id \\\n and !base_player_country.nil?\n self.country = base_player_country\n end\n self.resolved = true\n self.save!\n msg = \"Created new player \" + base_player_name + \"/\" + \\\n base_player_code + \"/id=\" + ret_val.id.to_s\n else\n msg = \"Player creation failed from url: \" + rp_url\n end\n end\n\n SystemLog.log(msg)\n ret_val\n end", "def new_game\n params_check(params[:player_names]) {\n @game = Game.create\n params[:player_names].split(\",\").each do |player_name|\n player = Player.create(name: player_name, game: @game)\n 10.times do |i|\n i == 10 ? Frame.create!(game: @game, player: player, position: i, final_frame: true) : Frame.create!(game: @game, player: player, position: i + 1)\n end\n end\n players = @game.players.map{ |player| { \"#{player.name}\": player.id } }\n process_response(@game.present?, \"Congratulations, you started a new game. Here's your game id: #{@game.id} and player data: #{players}\", @game.id)\n }\n end", "def create\n @client_player = ClientPlayer.new(params[:client_player])\n\n respond_to do |format|\n if @client_player.save\n format.html { redirect_to @client_player, notice: 'Client player was successfully created.' }\n format.json { render json: @client_player, status: :created, location: @client_player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@game = Game.find(params[:game_id])\n\t\t@player = Player.new(params[:player])\n\t\[email protected] = @game # required for @player to pass validation\n\t\t\n\t\tif @player.valid? and @game.joinable?\n\t\t\tobserving_game_events(@game) do\n\t\t\t\[email protected]_player(@player)\n\t\t\tend\n\t\t\tannounce_event(\"%s has joined the game\", @player.name)\n\n\t\t\tbecome_player(@player)\n\t\t\t\n\t\t\tif request.xhr?\n\t\t\t\trender :text => \"becomePlayer(#{@player.id})\"\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { redirect_to(@game) }\n\t\t\t\tformat.xml { render :xml => @player, :status => :created, :location => @player }\n\t\t\tend\n\t\telse\n\t\t\tflash[:errors] = 'This game is not available for joining' if [email protected]?\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\r\n @gameplayer = Gameplayer.new(gameplayer_params)\r\n\r\n respond_to do |format|\r\n if @gameplayer.save\r\n format.html { redirect_to @gameplayer, notice: \"Gameplayer was successfully created.\" }\r\n format.json { render :show, status: :created, location: @gameplayer }\r\n else\r\n format.html { render :new, status: :unprocessable_entity }\r\n format.json { render json: @gameplayer.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def player_params\n params.require(:player).permit(:name)\n end", "def create_player\n name = gets.chomp\n player = Player.new(name: name)\nend", "def create\n @games_player = GamesPlayer.new(params[:games_player])\n\n respond_to do |format|\n if @games_player.save\n format.html { redirect_to(@games_player, :notice => 'Games player was successfully created.') }\n format.xml { render :xml => @games_player, :status => :created, :location => @games_player }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @games_player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @leagueplayer = Leagueplayer.new(params[:leagueplayer])\n \n respond_to do |format|\n if @leagueplayer.save\n format.html { redirect_to(@leagueplayer, :notice => 'Leagueplayer was successfully created.') }\n format.xml { render :xml => @leagueplayer, :status => :created, :location => @leagueplayer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @leagueplayer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @unavailable_player = UnavailablePlayer.new(unavailable_player_params)\n\n respond_to do |format|\n if @unavailable_player.save\n format.html { redirect_to @unavailable_player, notice: 'Unavailable player was successfully created.' }\n format.json { render action: 'show', status: :created, location: @unavailable_player }\n else\n format.html { render action: 'new' }\n format.json { render json: @unavailable_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_player\n return if !player.nil?\n\n player = Player.new\n player.user_id = id\n player.player_name = login\n \n return nil if !player.save\n return nil if !player.create_weapons\n \n player\n end", "def create\n # Find player or create a new one if this one does not exist...\n if params[:player][\"name\"]==\"\" || params[:player][\"email\"]==\"\"\n # Set the player to a generic default, so user can still play\n # without registering\n @player = Player.find_or_create_by_name_and_email(\n {name: \"Dr. Strangelove\",\n email: \"[email protected]\" }) \n else\n # or create/find a player matching the input data\n @player = Player.find_or_create_by_name_and_email(params[:player]) \n end\n\n session[:player_id] = @player.id\n\n respond_to do |format|\n format.js { } # create.js.erb\n end\n end", "def player_params\n params[:player].permit(:name)\n end", "def create\n @player_creator = PlayerCreator.new_in_model(@game, player_params, current_user)\n\n respond_to do |format|\n if @player_creator.save\n format.html { redirect_to @game, notice: 'Player successfully joined the Game.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_player\n\t\tputs \"What is your name?\"\n\t\t@player = gets.strip.to_s\n\t\tputs \"Welcome #{@player}!\"\n\tend", "def create\n @group_player = GroupPlayer.new(group_player_params)\n\n respond_to do |format|\n if @group_player.save\n format.html { redirect_to @group_player, notice: 'Group player was successfully created.' }\n format.json { render action: 'show', status: :created, location: @group_player }\n else\n format.html { render action: 'new' }\n format.json { render json: @group_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @attribute_player = AttributePlayer.new(attribute_player_params)\n\n respond_to do |format|\n if @attribute_player.save\n format.html { redirect_to @attribute_player, notice: 'Attribute player was successfully created.' }\n format.json { render action: 'show', status: :created, location: @attribute_player }\n else\n format.html { render action: 'new' }\n format.json { render json: @attribute_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @teams_player = TeamsPlayer.new(teams_player_params)\n\n respond_to do |format|\n if @teams_player.save\n format.html { redirect_to @teams_player, notice: 'Teams player was successfully created.' }\n format.json { render :show, status: :created, location: @teams_player }\n else\n format.html { render :new }\n format.json { render json: @teams_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_player(id,name)\n @players.push(Player.new(id, name, 0))\n end", "def create\n @player_game = PlayerGame.new(params[:player_game])\n\n respond_to do |format|\n if @player_game.save\n format.html { redirect_to @player_game, :notice => 'Player game was successfully created.' }\n format.json { render :json => @player_game, :status => :created, :location => @player_game }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @player_game.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_player(name, num)\n if name.downcase == \"computer\"\n player = ComputerPlayer.new(num)\n else\n player = HumanPlayer.new(name, num)\n end\n end", "def player_params\n params.require(:player).permit(:name).tap do |player_params|\n player_params.require(:name)\n end\n end", "def create\n @game = Game.new(game_params)\n\n params[:players].each do |player_name|\n p = Player.new\n p.name = player_name\n p.game = @game\n p.save!\n end\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @game }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @all_player = AllPlayer.new(params[:all_player])\n\n respond_to do |format|\n if @all_player.save\n format.html { redirect_to @all_player, notice: 'All player was successfully created.' }\n format.json { render json: @all_player, status: :created, location: @all_player }\n else\n format.html { render action: \"new\" }\n format.json { render json: @all_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def player_params\n params.require(:player).permit(:name, :email)\n end", "def create\n @player_action = PlayerAction.new(player_action_params)\n\n respond_to do |format|\n if @player_action.save\n format.html { redirect_to @player_action, notice: 'Player action was successfully created.' }\n format.json { render :show, status: :created, location: @player_action }\n else\n format.html { render :new }\n format.json { render json: @player_action.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game_session_player = GameSessionPlayer.new(game_session_player_params)\n\n respond_to do |format|\n if @game_session_player.save\n format.html { redirect_to @game_session_player, notice: 'Game session player was successfully created.' }\n format.json { render :show, status: :created, location: @game_session_player }\n else\n format.html { render :new }\n format.json { render json: @game_session_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @team = Team.find_by_name(params[:team][:team_name])\n if @team.nil?\n @team = Team.new(captain_id: params[:team][:captain_id],\n\t\t team_name: params[:team][:team_name])\n\n respond_to do |format|\n if @team.save\n format.json { render json: @team, status: :created, location: @team }\n if params[:players]\n \tTeamPlayers.create(params[:players], team_name: @team.name)\n end\n else\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n else \n Team.update(params[:team])\n end\n end", "def create\n @game = Game.new\n #create the first player\n first_player = Player.new\n first_player.name = params[:first_player_name]\n first_player.game = @game\n\n #create the second player\n second_player = Player.new\n second_player.name = params[:second_player_name]\n second_player.game = @game\n\n # add first and second players to the game object\n @game.first_player = first_player\n @game.second_player = second_player\n\n respond_to do |format|\n if @game.save\n #create a new game round using a redirect to new_game_round_path\n format.html { redirect_to new_game_round_path(@game), notice: t(\"games.successfully_created\") }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n plan_id = params[:player].delete(:plan_id)\n travel_date_year = params[:player].delete(:travel_date_year)\n travel_date_season = params[:player].delete(:travel_date_season)\n @player = Player.new(player_params)\n @player.plan = Plan.find(plan_id)\n @player.travel_date = \"#{travel_date_season}/#{travel_date_year}\"\n @player.password = params[:player][:email]\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to active_players_path, notice: 'Player was successfully created.' }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def createplayers\n\n\t\t@bad_player_entries = Array.new\n\t\t@added_players = Array.new\n\t\t@error_count = 0\n\t\t\n\t\t# Get values from form field parameters\n\t\t\n\t\t@player_name = params[:Player1Name]\n\t\t@player_index = params[:Player1Index]\n\t\t@gid = params[:id]\n\n\t\tif !params[:Player1Name].empty?\n process_player(params[:id], params[:Player1Name], params[:Player1Index])\n\t\tend\n\t\t\n\t\t\n\t\tif @error_count > 0\n @game = Game.find(2)\n\t\t\trender('addplayers')\n else\n\t\t\tredirect_to(:action => 'gamelist')\n\t\tend\n\t\t\t\n\tend", "def player_params\n params.require(:player).permit(:name, :image_url, :elo)\n end", "def create\n @player_record = PlayerRecord.new(params[:player_record])\n\n respond_to do |format|\n if @player_record.save\n format.html { redirect_to @player_record, notice: 'Player record was successfully created.' }\n format.json { render json: @player_record, status: :created, location: @player_record }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n room_code = params[:player][:room_id]\n room = Room.find_by_code(room_code)\n\n potential_existing_players = Player.where(:alias => params[:player][:alias], :room_id => room.id)\n \n if potential_existing_players.count > 0\n @player = potential_existing_players.first\n else\n @player = Player.new(player_params.merge(room_id: room.id))\n end\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to \"/play/#{room.id}/#{@player.id}\", notice: 'Player was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n\t\tavatar = Avatar.new(params[:avatar])\n\t\tavatar_saved = avatar.save\n @player = Player.new(params[:player])\n\t\[email protected] = current_user\n\t\tif avatar_saved\n\t\t\[email protected] = avatar\n\t\tend\n\t\tsaved = @player.save\n\t\tflash[:notice] = 'Zawodnik został dodany' if saved\n\t\tcontinue = !params[:continue].nil?\n\t\trespond_to do |format|\n\t\t\tformat.html do\n\t\t\t\tif saved and continue\n\t\t\t\t\tredirect_to new_player_path\n\t\t\t\telsif saved\n \t redirect_to player_path(@player)\n \telse\n \t render :action => \"new\"\n \tend\n\t\t\tend\n end\n end", "def new_player\n new_player = Player.new 0, 0\n id = SecureRandom.uuid;\n @players[id] = new_player\n {\"id\" => id, \"x\" => new_player.x, \"y\" => new_player.y}.to_json\n end", "def player_params\n params.require(:player).permit(:game_id, :name)\n end", "def create\n @play = Play.new(play_params)\n @play.player = current_player\n respond_to do |format|\n if @play.save\n format.html { redirect_to @play, notice: 'Play was successfully created.' }\n format.json { render :show, status: :created, location: @play }\n else\n format.html { render :new }\n format.json { render json: @play.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.77265984", "0.7640089", "0.7458238", "0.7439472", "0.7416362", "0.73777866", "0.73393756", "0.733539", "0.73177534", "0.73177534", "0.73177534", "0.73177534", "0.72944343", "0.7254512", "0.72503686", "0.72357446", "0.7228008", "0.71955377", "0.7194835", "0.7194835", "0.7194835", "0.7194835", "0.7194835", "0.7194835", "0.71916264", "0.71889156", "0.71872634", "0.71736586", "0.71736586", "0.71736586", "0.71736586", "0.71573824", "0.712611", "0.7120758", "0.71089214", "0.7096111", "0.70865536", "0.7080873", "0.7075955", "0.7053287", "0.7008098", "0.7000729", "0.6991323", "0.69752544", "0.69595045", "0.69210064", "0.68923587", "0.6888251", "0.6876518", "0.6871363", "0.6829777", "0.68206084", "0.6818112", "0.67791957", "0.6760335", "0.674855", "0.67392695", "0.6715791", "0.6687877", "0.6612146", "0.6610768", "0.65915835", "0.65719485", "0.65690327", "0.6561381", "0.65549463", "0.6539346", "0.65388125", "0.6538792", "0.65378", "0.6533582", "0.65307754", "0.65131676", "0.65050757", "0.6504929", "0.6495046", "0.64788604", "0.6463194", "0.6461858", "0.6455117", "0.64532787", "0.6441474", "0.6419257", "0.6411922", "0.6363985", "0.63395333", "0.63223743", "0.6316288", "0.63102", "0.63055354", "0.6298669", "0.6294264", "0.6286345", "0.62857807", "0.6283054", "0.62798387", "0.62457544", "0.6245754", "0.6230325", "0.6217258" ]
0.73067874
12
Update a player Params +:id+ player id Request +:name+ different player name Response serialized Player or HTTP error
def update if @player.update(player_params) render json: @player, status: :ok else render json: {errors: @player.errors}, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n player = Player.find(params[:id])\n if player.update(player_params)\n render json: player, status: 200, location: [:api, player]\n else\n failed_to_update(player, \"player\")\n end\n end", "def update\n @player = Player.find(params[:id])\n \n if @player.save\n render :json => @player, :status => :ok\n else\n render :json => @player.errors, :status => :unprocessable_entity\n end\n end", "def update\n\n if @player.update(player_params)\n\n render json: @player,status: :ok\n\n else\n\n render json: {error: true,errors: @player.errors},status: :unprocessable_entity\n\n end\n\n \t\tend", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(player_params)\n event \"update\", :player, @player.id, description: \"#{current_player.name} updated the information for #{@player.name}\"\n format.html { redirect_to @player, flash: { success: 'Player was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.json { render json: @player, status: :ok }\n else\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to [:admin, @player], notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: \"Player was successfully updated.\" }\n format.json { render :show, status: :ok, location: @player }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: \"Player was successfully updated.\" }\n format.json { render :show, status: :ok, location: @player }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n bingo_session = BingoSession.find(params[:bingo_session_id])\n @player = bingo_session.players.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n format.html { redirect_to(@player, :notice => 'Player was successfully updated.') }\n format.xml { head :ok }\n format.json { render :json => @player}\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n format.json { render :json => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n flash[:notice] = 'Zmieniono dane zawodnika.'\n format.html { redirect_to(@player) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @player.update!(player_params) # anticipated possible exceptions rescued in BaseController\n render json: @player, status: 200\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { render :show, status: :ok, location: @player }\n else\n format.html { render :edit }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { render :show, status: :ok, location: @player }\n else\n format.html { render :edit }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { render :show, status: :ok, location: @player }\n else\n format.html { render :edit }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { render :show, status: :ok, location: @player }\n else\n format.html { render :edit }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { render :show, status: :ok, location: @player }\n else\n format.html { render :edit }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { render :show, status: :ok, location: @player }\n else\n format.html { render :edit }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { render :show, status: :ok, location: @player }\n else\n format.html { render :edit }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { render :show, status: :ok, location: @player }\n else\n format.html { render :edit }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { render :show, status: :ok, location: @player }\n else\n format.html { render :edit }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n params[:player].delete('country')\n params[:player].delete('auth_token')\n if @player.update_attributes(params[:player])\n flash[:notice] = 'Api::Player was successfully updated.'\n format.html { redirect_to(@player) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n respond_to do |format|\n if @player.update_attributes(params[:player])\n flash[:notice] = 'Dane zawodnika zostały uaktualnione.'\n format.html { redirect_to player_path(@player) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update_attributes(player_params)\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { render :show, status: :ok, location: @player }\n else\n format.html { render :edit }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n auth!\n\n respond_to do |format|\n if @player.update_attributes(player_params)\n format.html { redirect_to [hardware, @player], :notice => 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @player.update(player_params)\n render json: @player, status: 200\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to game_player_path(id: @player.id), notice: 'Player was successfully updated.' }\n format.json { render :show, status: :ok, location: @player }\n else\n format.html { render :edit }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n format.html {\n redirect_to @player, notice: I18n.t(\"messages.players.update.success\")\n }\n else\n format.html {\n @errors = @league.errors\n render action: \"edit\"\n }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n flash[:notice] = 'Player was successfully updated.'\n format.html { redirect_to(@player) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n flash[:notice] = 'Player was successfully updated.'\n format.html { redirect_to(@player) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @team = Team.find(params[:team_id])\n @player = @team.players.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n format.html { redirect_to([@player.team, @player], :notice => 'Player was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n# ToDo 0 => Wenn Spieler aktualisiert wurde, schließe das Fenster und aktualisiere die Spielerliste bzw. die Spielerübersicht\n format.html { redirect_to home_path, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @player.update_attributes(player_params)\n flash[:notice] = 'Player was successfully updated.'\n respond_with @player\n else\n render action: 'edit'\n end\n end", "def update\n flash[:notice] = 'Se actualizó el Player.' if @player.update_attributes(params[:player])\n respond_with(@player)\n end", "def update\n @user= User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:player])\n format.html { redirect_to @player, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update_attributes(player_params)\n format.html { redirect_to(@player, :notice => 'Player was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n flash[:notice] = \"Player was created successfully.\" if @player.update(player_params)\n respond_with(@player)\n end", "def update\n\t\t@player = Player.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @player.update_attributes(params[:player])\n\t\t\t\tflash[:notice] = 'Player was successfully updated.'\n\t\t\t\tformat.html { redirect_to(@game) }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n @player.create_activity :update, owner: current_user\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @game_player = GamePlayer.find(params[:id])\n\n respond_to do |format|\n if @game_player.update_attributes(params[:game_player])\n format.html { redirect_to @game_player, notice: 'Game player was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @team_player.update(team_player_params)\n format.html { redirect_to @team_player, notice: 'Team player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @team_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @team = Team.find(params[:id])\n @player = Player.find(params[:player_id])\n if @player.access_key == params[:access_key] && (@team.leader_id == @player.id || @team.game.owner_id == @player.id) then\n @team.name = params[:name]\n @team.leader_id = params[:leader_id]\n\n respond_to do |format|\n if @team.save\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n format.json { render :json => @team.errors, :status => :unprocessable_entity }\n end\n end\n else\n head :unauthorized\n end\n end", "def update\n respond_to do |format|\n if @game_player.update(game_player_params)\n format.html { redirect_to @game_player, notice: \"Game player was successfully updated.\" }\n format.json { render :show, status: :ok, location: @game_player }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @game_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @all_player = AllPlayer.find(params[:id])\n\n respond_to do |format|\n if @all_player.update_attributes(params[:all_player])\n format.html { redirect_to @all_player, notice: 'All player was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @all_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n format.html { redirect_to(@player, :notice => 'Player was successfully updated.') }\n format.js\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @client_player = ClientPlayer.find(params[:id])\n\n respond_to do |format|\n if @client_player.update_attributes(params[:client_player])\n format.html { redirect_to @client_player, notice: 'Client player was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @attribute_player.update(attribute_player_params)\n format.html { redirect_to @attribute_player, notice: 'Attribute player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @attribute_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @unavailable_player.update(unavailable_player_params)\n format.html { redirect_to @unavailable_player, notice: 'Unavailable player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @unavailable_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @gameplayer.update(gameplayer_params)\r\n format.html { redirect_to @gameplayer, notice: \"Gameplayer was successfully updated.\" }\r\n format.json { render :show, status: :ok, location: @gameplayer }\r\n else\r\n format.html { render :edit, status: :unprocessable_entity }\r\n format.json { render json: @gameplayer.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @teams_player.update(teams_player_params)\n format.html { redirect_to @teams_player, notice: 'Teams player was successfully updated.' }\n format.json { render :show, status: :ok, location: @teams_player }\n else\n format.html { render :edit }\n format.json { render json: @teams_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @games_player = GamesPlayer.find(params[:id])\n\n respond_to do |format|\n if @games_player.update_attributes(params[:games_player])\n format.html { redirect_to(@games_player, :notice => 'Games player was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @games_player.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @leagueplayer = Leagueplayer.find(params[:id])\n \n respond_to do |format|\n if @leagueplayer.update_attributes(params[:leagueplayer])\n format.html { redirect_to(@leagueplayer, :notice => 'Leagueplayer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @leagueplayer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @game_player.update(game_player_params)\n format.html { redirect_to case_game_round_path(@game_player.game_round), notice: '玩家信息更新成功.' }\n format.json { render :show, status: :ok, location: @game_player }\n else\n format.html { render :edit }\n format.json { render json: @game_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player_game = PlayerGame.find(params[:id])\n\n respond_to do |format|\n if @player_game.update_attributes(params[:player_game])\n format.html { redirect_to @player_game, :notice => 'Player game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @player_game.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin_player.update(admin_User_params)\n format.html { redirect_to admin_player_path(@admin_player) , notice: 'Player was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_User }\n else\n flash[:error] = @admin_player.errors.full_messages\n format.html { render :edit }\n format.json { render json: @admin_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group_player.update(group_player_params)\n format.html { redirect_to @group_player, notice: 'Group player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player_action.update(player_action_params)\n format.html { redirect_to @player_action, notice: 'Player action was successfully updated.' }\n format.json { render :show, status: :ok, location: @player_action }\n else\n format.html { render :edit }\n format.json { render json: @player_action.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player = Player.find(params[:id])\n @player.password_confirmation = @player.password\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n flash[:notice] = 'Player was successfully updated.'\n format.html { redirect_to player_url(@player) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @player.errors.to_xml }\n end\n end\n end", "def update\n @team = Team.find(params[:team][:team_id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n if params[:players]\n TeamPlayers.update(params[:players], team_name: @team.name)\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player_record = PlayerRecord.find(params[:id])\n respond_to do |format|\n if @player_record.update_attributes(params[:player_record])\n format.html { redirect_to @player_record, notice: 'Player record was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @playerdiv = Playerdiv.find(params[:id])\n\n respond_to do |format|\n if @playerdiv.update_attributes(params[:playerdiv])\n format.html { redirect_to @playerdiv, :notice => 'Playerdiv was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @playerdiv.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player.update(player_params)\n # TODO: email the player if there is a team associated\n\t# This email only goes out if the old_value is nil and new_value\n\t# is truthy\n format.html { redirect_to @player, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n game = Game.find(params[:game_id])\n @player_game = game.player_games.find(params[:id])\n\n respond_to do |format|\n if @player_game.update_attributes(params[:player_game])\n format.html { redirect_to(@player_game, :notice => 'Player game was successfully updated.') }\n format.xml { head :ok }\n format.json { render :json => @player_game}\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @player_game.errors, :status => :unprocessable_entity }\n format.json { render :json => @player_game}\n end\n end\n end", "def update\n respond_to do |format|\n if @player_record.update(player_record_params)\n format.html { redirect_to @player_record, notice: 'Player record was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @player_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @player_status.update(player_status_params)\n format.html { redirect_to @player_status, notice: 'Player status was successfully updated.' }\n format.json { render :show, status: :ok, location: @player_status }\n else\n format.html { render :edit }\n format.json { render json: @player_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n room_code = params[:player][:room_id]\n room = Room.find_by_code(room_code)\n\n respond_to do |format|\n if @player.update(player_params.merge(room_id: room.id))\n format.html { redirect_to \"/play/#{room.id}/#{@player.id}\", notice: 'Player was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n respond_to do |format|\n if @game_session_player.update(game_session_player_params)\n format.html { redirect_to @game_session_player, notice: 'Game session player was successfully updated.' }\n format.json { render :show, status: :ok, location: @game_session_player }\n else\n format.html { render :edit }\n format.json { render json: @game_session_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @drafted_player.update(drafted_player_params)\n format.html { redirect_to @drafted_player, notice: 'Drafted player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @drafted_player.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player_promise = PlayerPromise.find(params[:id])\n\n respond_to do |format|\n if @player_promise.update_attributes(params[:player_promise])\n format.html { redirect_to @player_promise, notice: 'Player promise was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player_promise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_player\n @player.update\n update_player_actions\n end", "def update\n @playerprofile = Playerprofile.find(params[:id])\n\n respond_to do |format|\n if @playerprofile.update_attributes(params[:playerprofile])\n format.html { redirect_to @playerprofile, notice: 'Playerprofile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @playerprofile.errors, status: :unprocessable_entity }\n end\n end\n end", "def pbChangePlayer(id)\n return false if id<0 || id>=8\n meta=pbGetMetadata(0,MetadataPlayerA+id)\n return false if !meta\n $Trainer.trainertype=meta[0] if $Trainer\n $game_player.character_name=meta[1]\n $game_player.character_hue=0\n $PokemonGlobal.playerID=id\n $Trainer.metaID=id if $Trainer\nend", "def update\n @player_game_stat = PlayerGameStat.find(params[:id])\n\n respond_to do |format|\n if @player_game_stat.update_attributes(params[:player_game_stat])\n format.html { redirect_to @player_game_stat, notice: 'Player game stat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player_game_stat.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_player\n @player = Player.find params[:id]\n end", "def update\n @replay = Replay.find(params[:id])\n @replay.level_id = params[:replay][:level_id]\n @replay.score = params[:replay][:score]\n @replay.player = params[:replay][:player]\n @replay.data = params[:replay][:data].read\n\n respond_to do |format|\n\n format.html { redirect_to replays_path, :notice => 'Replay was successfully updated.' }\n format.json { head :no_content }\n\n end\n end", "def update\n respond_to do |format|\n if @pmplayer.update(pmplayer_params)\n format.html { redirect_to @pmplayer, notice: 'Pmplayer was successfully updated.' }\n format.json { render :show, status: :ok, location: @pmplayer }\n else\n format.html { render :edit }\n format.json { render json: @pmplayer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @player_client = PlayerClient.find(params[:id])\n\n respond_to do |format|\n if @player_client.update_attributes(params[:player_client])\n format.html { redirect_to @player_client, notice: 'Player client was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if params[:draft]\n @player.claimed_by = 1\n elsif params[:remove]\n @player.claimed_by = 0\n else\n raise \"Expecting draft or remove\"\n end\n @player.claim_time = Time.now\n\n @player.save!\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n end\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def set_player\n @player = Player.find(params[:id])\n end", "def player_params\n params.require(:player).permit(:game_id, :name)\n end", "def player_params\n params[:player].permit(:name)\n end", "def player_params\n params.require(:player).permit(:player_id, :sport, :first_name, :last_name, :position, :age, :name_brief, :age_diff)\n end" ]
[ "0.81990284", "0.81164795", "0.78854823", "0.7877426", "0.7876997", "0.7876997", "0.7876997", "0.7876997", "0.7876997", "0.7876997", "0.78732723", "0.7862343", "0.78346187", "0.7802089", "0.77845657", "0.77845657", "0.77845657", "0.77845657", "0.77671754", "0.77671754", "0.77234954", "0.7721015", "0.7720764", "0.77140754", "0.77140754", "0.77140754", "0.77140754", "0.77140754", "0.77140754", "0.77140754", "0.77139926", "0.77130944", "0.7707955", "0.76965046", "0.7688825", "0.7684209", "0.7683057", "0.7668875", "0.7641053", "0.76309025", "0.76309025", "0.76076263", "0.7510968", "0.74929863", "0.7492831", "0.74745727", "0.7468234", "0.7447295", "0.7447109", "0.7427689", "0.74142635", "0.73794574", "0.7325516", "0.7321425", "0.7302836", "0.729263", "0.7282098", "0.72735125", "0.723945", "0.7187227", "0.71527797", "0.7144171", "0.7123589", "0.7103293", "0.7073289", "0.7041948", "0.7033464", "0.7032213", "0.7019825", "0.698358", "0.698263", "0.69597685", "0.6946962", "0.69374514", "0.6936939", "0.69329286", "0.69240993", "0.6899777", "0.68991935", "0.68866676", "0.68137604", "0.67813337", "0.67338854", "0.6728569", "0.6716273", "0.66986877", "0.6696311", "0.6694036", "0.6693336", "0.66860944", "0.66860944", "0.66860944", "0.66860944", "0.66860944", "0.66860944", "0.66860944", "0.66860944", "0.6660811", "0.6651478", "0.66308194" ]
0.79548746
2
Delete a player A player in a match or on a team may not be deleted. Params +:id+ player id Response +:no_content+ or HTTP error
def destroy if @player.destroy head :no_content else render json: {errors: @player.errors}, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n player = Player.find(params[:id])\n player.destroy\n head 204\n end", "def destroy\n @team = Team.find(params[:team_id])\n @player = @team.players.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to team_players_url(@team) }\n format.json { head :ok }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n if @player.destroy\n flash[:success] = \"Player was deleted.\"\n else\n flash[:error] = \"Player could not be deleted.\"\n end\n redirect_to players_path\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :ok }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :ok }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to(api_players_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n\n if @player.destroy\n\n render json: {player: {id: params[:id].to_i}},status: :ok\n\n else\n\n render json: {error: true,errors: @player.errors},status: :unprocessable_entity\n\n end\n\n \t\tend", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html {\n redirect_to players_url\n }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n auth!\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to hardware.players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url(team_id: @player.team.id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n render :json => \"Ok\", :status => :ok\n end", "def destroy\n @team = Team.find(params[:id])\n @player = Player.find(params[:player_id])\n if @player.access_key == params[:access_key] && (@team.leader_id == @player.id || @team.game.owner_id == @player.id) then\n @team.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.json { head :ok }\n end\n else\n head :unauthorized\n end\n end", "def remove_player\n @team.remove_player(@player)\n\n redirect_to team_path(@team)\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n event \"delete\", :player, @player.id, description: \"#{current_player.name} deleted player #{@player.name}\"\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to(players_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to(players_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to(players_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to(players_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to(players_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @team_player.destroy\n respond_to do |format|\n format.html { redirect_to team_players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_player = ClientPlayer.find(params[:id])\n @client_player.destroy\n\n respond_to do |format|\n format.html { redirect_to client_players_url }\n format.json { head :ok }\n end\n end", "def destroy\n @game_player = GamePlayer.find(params[:id])\n @game_player.destroy\n\n respond_to do |format|\n format.html { redirect_to game_players_url }\n format.json { head :ok }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.create_activity :destroy, owner: current_user\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n bingo_session = BingoSession.find(params[:bingo_session_id])\n @player = bingo_session.players.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to(players_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end", "def destroy\n team = @player.team\n @player.destroy\n respond_to do |format|\n format.html { redirect_to team }\n format.json { head :no_content }\n end\n end", "def destroy\n @all_player = AllPlayer.find(params[:id])\n @all_player.destroy\n\n respond_to do |format|\n format.html { redirect_to all_players_url }\n format.json { head :ok }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to game_players_path, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def remove_match_day_player\n match_day_team = MatchDayTeam.find(params[:match_day_team_id])\n match_day_player = MatchDayPlayer.find(params[:id])\n match_day_team.match_day_players.delete(match_day_player)\n update_match_day_team(match_day_team)\n end", "def destroy\n if @fantasy_team_player.destroy\n render json: @fantasy_team_player, status: :ok, include: [:player]\n else\n render json: { message: 'could not delete' }, status: :unprocessable_entity\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url, notice: t( '.success' ) }\n end\n end", "def destroy\n @leagueplayer = Leagueplayer.find(params[:id])\n @leagueplayer.destroy\n \n respond_to do |format|\n format.html { redirect_to(leagueplayers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n flash[:notice] = 'Player successfully deleted.'\n respond_with @player\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.html { redirect_to players_url, notice: \"Player was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @teams_player.destroy\n respond_to do |format|\n format.html { redirect_to teams_players_url, notice: 'Teams player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n flash[:notice] = 'Se eliminó el Player.' if @player.destroy\n respond_with(@player)\n end", "def destroy\n @match.destroy\n respond_to do |format|\n format.html { redirect_to current_player, notice: 'Match was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @games_player = GamesPlayer.find(params[:id])\n @games_player.destroy\n\n respond_to do |format|\n format.html { redirect_to(games_players_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @player_record = PlayerRecord.find(params[:id])\n @player_record.destroy\n\n respond_to do |format|\n format.html { redirect_to player_records_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player_challenge = PlayerChallenge.find(params[:id])\n @player_challenge.destroy\n respond_to do |format|\n format.html { redirect_to player_challenges_url }\n format.json { head :ok }\n end\n end", "def destroy\n @stat_of_player_of_team_of_match.destroy\n respond_to do |format|\n format.html { redirect_to stat_of_player_of_team_of_matches_url, notice: 'Stat of player of team of match was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n @teams = @player.teams\n if @teams.exists?\n @teams.each do |t|\n t.destroy\n end\n end\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @playerdiv = Playerdiv.find(params[:id])\n @playerdiv.destroy\n\n respond_to do |format|\n format.html { redirect_to playerdivs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player_game = PlayerGame.find(params[:id])\n @player_game.destroy\n\n respond_to do |format|\n format.html { redirect_to player_games_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_player.destroy\n respond_to do |format|\n format.html { redirect_to admin_players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n respond_with(@player)\n end", "def destroy\n @player.destroy\n\n head :no_content\n end", "def destroy\n \n @drafted_player.destroy\n respond_to do |format|\n format.html { redirect_to drafted_players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @game_player.destroy\n respond_to do |format|\n format.html { redirect_to game_players_url, notice: \"Game player was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @player_client = PlayerClient.find(params[:id])\n @player_client.destroy\n\n respond_to do |format|\n format.html { redirect_to player_clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n match_day_team = MatchDayTeam.find(params[:id])\n match_day_team.destroy\n head 204\n end", "def destroy\n @match = Match.find(params[:id])\n respond_to do |format|\n if @match\n if @match.destroy\n format.json { head :no_content, status: :ok}\n end\n else\n format.json { render json: @match.errors, status: :unprocessable_entity }\n end\n end\n end", "def remove_player(table_id)\n\t\t\t\tplayer_for(table_id).quit\n\t\t\t\[email protected](table_id)\n\t\t\tend", "def destroy\n @player_action.destroy\n respond_to do |format|\n format.html { redirect_to player_actions_url, notice: 'Player action was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n game = Game.find(params[:game_id])\n @player_game = game.player_games.find(params[:id])\n @player_game.destroy\n\n respond_to do |format|\n format.html { redirect_to(player_games_path, :notice => 'Player game was successfully removed.') }\n format.xml { head :ok }\n format.json { render :json => @player_game}\n end\n end", "def destroy\n @match = match.find(params[:id])\n @match.destroy\n\n respond_to do |format|\n format.html { redirect_to matchs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player = Player.find(params[:id])\n @player.password_confirmation = @player.password\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.xml { head :ok }\n end\n end", "def delete_team(id)\n boolean_request :delete, \"/teams/#{id}\"\n end", "def destroy\n @player_promise = PlayerPromise.find(params[:id])\n @player_promise.destroy\n\n respond_to do |format|\n format.html { redirect_to player_promises_url }\n format.json { head :ok }\n end\n end", "def destroy\n @player.user.destroy\n\n respond_to do |format|\n format.html { redirect_to(players_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @match.destroy\n respond_to do |format|\n format.html { redirect_to matches_path(tournament: match_params[:tournament_id]), notice: 'Match was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @match = Match.find(params[:id])\n @match.destroy\n\n respond_to do |format|\n format.html { redirect_to matches_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @match = Match.find(params[:id])\n @match.destroy\n\n respond_to do |format|\n format.html { redirect_to matches_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @match = Match.find(params[:id])\n @match.destroy\n\n respond_to do |format|\n format.html { redirect_to matches_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @gameplayer.destroy\r\n respond_to do |format|\r\n format.html { redirect_to gameplayers_url, notice: \"Gameplayer was successfully destroyed.\" }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @team_for_the_match = TeamForTheMatch.find(params[:id])\n @team_for_the_match.destroy\n\n respond_to do |format|\n format.html { redirect_to(team_for_the_matches_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @unavailable_player.destroy\n respond_to do |format|\n format.html { redirect_to unavailable_players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @match = Match.find(params[:id])\n if cannot? :update, @match\n\tredirect_to \"/hax.html\"\n else\n \[email protected]\n end\n\n respond_to do |format|\n format.html { redirect_to(matches_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @team_match.destroy\n respond_to do |format|\n format.html { redirect_to team_matches_url, notice: 'Team match was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @matchparticipant.destroy\n respond_to do |format|\n format.html { redirect_to matchparticipants_url, notice: 'Matchparticipant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player_record.destroy\n respond_to do |format|\n format.html { redirect_to player_records_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @match = @contest.matches.find(params[:id])\n @match.destroy\n\n respond_to do |format|\n format.html { redirect_to(@contest) }\n format.xml { head :ok }\n end\n end", "def destroy\n @match_team.destroy\n respond_to do |format|\n format.html { redirect_to match_teams_url, notice: 'Match team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #@match = Match.find(params[:id])\n @match.destroy\n\n respond_to do |format|\n format.html { redirect_to matches_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @group_player.destroy\n respond_to do |format|\n format.html { redirect_to group_players_url }\n format.json { head :no_content }\n end\n end", "def destroy\n id = params[:id].to_i\n UserGame.find(id)\n @user_game.destroy\n respond_to do |format|\n format.html { redirect_to user_games_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @player.destroy\n @destroy_message = \"Success deleted!\"\n render :show\n end" ]
[ "0.76531553", "0.7625851", "0.7534544", "0.75273216", "0.75202805", "0.75202805", "0.75153", "0.75153", "0.75153", "0.75153", "0.75153", "0.75153", "0.75153", "0.75153", "0.7481308", "0.74725527", "0.7442496", "0.7440227", "0.74254096", "0.7410926", "0.73559475", "0.7321974", "0.7309829", "0.7295947", "0.7295947", "0.7295947", "0.7295947", "0.7295947", "0.727492", "0.7181305", "0.71783334", "0.71532315", "0.71505386", "0.71237665", "0.7119561", "0.71025985", "0.7100941", "0.70948154", "0.707183", "0.707183", "0.707183", "0.70596445", "0.7050394", "0.7046829", "0.70456934", "0.70456934", "0.70456934", "0.70456934", "0.70456934", "0.70456934", "0.70456934", "0.70456934", "0.70456934", "0.70456934", "0.7043232", "0.7036743", "0.7003079", "0.69905317", "0.69867325", "0.69862425", "0.69829184", "0.6969204", "0.6951968", "0.69183034", "0.6883429", "0.68749684", "0.6857453", "0.6847794", "0.684595", "0.68392277", "0.6822694", "0.68156445", "0.6797759", "0.6790309", "0.6788534", "0.6787232", "0.677109", "0.67547923", "0.67527336", "0.6752716", "0.6751121", "0.6739949", "0.67340547", "0.67239517", "0.66966754", "0.66966754", "0.66966754", "0.66944224", "0.6675349", "0.6654365", "0.6635794", "0.6635687", "0.6634534", "0.6634455", "0.6631503", "0.6615011", "0.66103786", "0.66069156", "0.6602939", "0.6594203" ]
0.69646364
62
returns a CRUD menu returns a Menu
def crud_menu(class_name) class_string = class_name.to_s.underscore.downcase m = Menu.new("What would you like to do with #{class_string.humanize.downcase.pluralize}?") m.add_menu_item(user_message: ["Create a new #{class_string.humanize.downcase}."], method_name: "#{class_string}/create") m.add_menu_item(user_message: ["Show all #{class_string.humanize.downcase.pluralize}."], method_name: "#{class_string}/show") m.add_menu_item(user_message: ["Update a #{class_string.humanize.downcase}."], method_name: "#{class_string}/update") m.add_menu_item(user_message: ["Delete a #{class_string.humanize.downcase}."], method_name: "#{class_string}/delete") m end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource\n @menu ||= params[:id].present? ? Transit::Menu.find(params[:id]) : Transit::Menu.new\n end", "def show\n if(Admin.first.nil?)\n createAdmin\n end\n\n menu=Menu.new(menu_params)\n # if the menu is saved successfully than respond with json data and status code 201\n if menu.save\n render json: Menu.all, status: 200\n else\n render json: \"422\", status: 422\n end\n # if(params[:id].include?(\"menu\"))\n # render json: \"Test\", status: 200\n # end\n #\n # menu = Menu.all.last # grabs the latest menu\n # render json: menu, status: 200\n end", "def getMenu(menu)\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @admin_menus = Menu.all\n end", "def index\n\t\t@menus = Menu.all\n\tend", "def menu\n @menu ||= Menu.new\n end", "def create\n @menu = uhook_create_menu\n\n respond_to do |format|\n if @menu.valid?\n flash[:notice] = t(\"ubiquo.menu.created\")\n return if check_redirects(@menu)\n format.html { redirect_to(ubiquo.edit_menu_path(@menu)) }\n format.xml { render :xml => @menu, :status => :created, :location => @menu }\n else\n flash[:error] = t(\"ubiquo.menu.create_error\")\n format.html { render :action => \"new\" }\n format.xml { render :xml => @menu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @menu_items = @menu.menu_items.all\n @menu_item = @menu.menu_items.build\n end", "def index\n @normal_menus = NormalMenu.all\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def get_permission_menu\n return @client.raw(\"get\", \"/helpers/menu\")\n end", "def index\n if @menu\n @menu_items = @menu.items\n else\n @menu_items = MenuItem.all\n end\n end", "def index\n @admin_menus = Admin::Menu.all\n end", "def create_menu\n Rails.logger.warn params.to_s\n menu = Menu.create\n menu.published = false\n if !params[:odesk_id].blank?\n odesk = Odesk.where(access_token:params[:odesk_id]).first\n menu.odesk = odesk\n else\n restaurant = Restaurant.find(params[:restaurant_id])\n menu.restaurant = restaurant\n end\n menu.save\n render json: {id:menu.id}.as_json\n end", "def build_menu\n comment = table_info['comment']\n # #puts \"build Rails menu for #{model_name} (#{comment}) in\n # app/views/shared\"\n @@menus << { :model_name => model_name, :comment => comment, :route => \"/\"+ plural_table_name}\n \n end", "def create\n\t\t@menu = Menu.new(menu_params)\n\n\t\trespond_to do |format|\n\t\t\tif @menu.save\n\t\t\t\tformat.html { redirect_to @menu, notice: 'Menuen blev oprettet.' }\n\t\t\t\tformat.json { render action: 'show', status: :created, location: @menu }\n\t\t\telse\n\t\t\t\tformat.html { render action: 'new' }\n\t\t\t\tformat.json { render json: @menu.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def index\n @menus = load_establishment.menus.all\n end", "def menu\n @menu_items = MenuItem.where(restaurant_id: params[:restaurant_id])\n @restaurants = Restaurant.find(params[:restaurant_id])\n\n end", "def new\n @menu = Menu.new\n @categories = Category.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end", "def set_menu\n\t\t@menu = Menu.find(params[:id])\n\tend", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_menu\n @menu = Menu.find(params[:id])\n end", "def set_admin_menu\n @admin_menu = Menu.find(params[:id])\n end", "def new\n @table_menu = Table::Menu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @table_menu }\n end\n end", "def menus\n @menus = Menu.where(location_id: params[:id]).all\n end", "def get_permission_menu\n @client.raw('get', '/helpers/menu')\n end", "def new\n @current_admin_user = current_admin_user\n session[:menu_params] ||= {}\n @title = \"New Menu\"\n @menu = Menu.new(session[:menu_params])\n @categories = @menu.categories\n @menu.current_step = session[:menu_step]\n end", "def new\n @menu = uhook_new_menu\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end", "def new\n @stylesheet = \"admin_menus\"\n @menu = Menu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end", "def gen_menu\n @menu = MenuTree.new\n\n return unless @sysuser\n\n @menu << MenuItem.new(_('Laboratories'),\n url_for(:controller => 'laboratories')) <<\n MenuItem.new(_('Profiles'),\n url_for(:controller => 'profiles')) <<\n MenuItem.new(_('Disk devices'),\n url_for(:controller => 'disk_devs')) <<\n MenuItem.new(_('Terminals'),\n url_for(:controller => 'terminals')) <<\n MenuItem.new(_('Terminal classes'),\n url_for(:controller => 'term_classes')) <<\n MenuItem.new(_('Instances'),\n url_for(:controller => 'instances')) \n\n if @sysuser.admin?\n @menu << MenuItem.new(_('User management'),\n url_for(:action => 'list', \n :controller => 'sysusers'))\n end\n end", "def menu\n response[\"menu\"]\n end", "def set_menu\n @menu = Menu.find(params[:menu_id])\n end", "def index\n @menu_items = MenuItem.all\n end", "def index\n @menu_items = MenuItem.all\n end", "def index\n @menu_items = MenuItem.all\n end", "def index\n @menu_items = MenuItem.all\n end", "def new\n @menu = Menu.new()\n return unless request.post?\n @menu = Menu.new(params[:menu])\n if @menu.save\n flash[:success_notice] = 'Menu was successfully created.'\n redirect_to :action => 'index'\n else\n flash[:fail_notice] = 'Menu was successfully created.'\n redirect_to :action => 'new'\n end\n end", "def index\n @menu_items = Menu::Item.all\n end", "def index\n @menu ||= @menus.first\n @menu_table = MenuItemTreeBuilder.new(@menu)\n @menu_table.build\n end", "def new\n @site = Site.find_by_name(params[:site])\n if @site.nil?\n return render_404\n end\n @menu = @site.menus.by_menu_type(params[:menu_type]).first\n if @menu.nil?\n return render_404\n end\n \n @menu_item = MenuItem.new(:menu => @menu)\n @menu_item.parent_id = params[:parent_id]\n generate_selections!(@menu_item)\n respond_to do |format|\n format.html { render :action => :new}\n end\n end", "def new\n @menu = Menu.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def set_api_menu\n @api_menu = Menu.find(params[:id])\n end", "def index\n @main_menus = MainMenu.all\n end", "def create\n @table_menu = Table::Menu.new(params[:table_menu])\n\n respond_to do |format|\n if @table_menu.save\n format.html do\n if params[:continue]\n redirect_to edit_table_menu_path(@table_menu)\n else\n redirect_to table_menus_path(:site_id => @table_menu.site_id)\n end\n end\n format.json { render json: @table_menu, status: :created, location: @table_menu }\n else\n format.html { render action: \"new\" }\n format.json { render json: @table_menu.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @menu = Menu.new(params[:menu])\n\n respond_to do |format|\n if @menu.save\n format.html { redirect_to @menu, notice: 'Menu was successfully created.' }\n format.json { render json: @menu, status: :created, location: @menu }\n else\n format.html { render action: \"new\" }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @menu = Menu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end", "def show\n @menu_item = MenuItem.new\n @menu_group = MenuGroup.find(params[:id])\n @menu_items = MenuItem.where(menu_group_id: @menu_group.id)\n end", "def new\n @original_menu = OriginalMenu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @original_menu }\n end\n end", "def create\n @admin_menu = Admin::Menu.new(admin_menu_params)\n\n respond_to do |format|\n if @admin_menu.save\n format.html { redirect_to admin_menus_url, notice: \"#{ t 'activerecord.successful.messages.menu_created'}\" }\n format.json { render :show, status: :created, location: @admin_menu }\n else\n format.html { render :new }\n format.json { render json: @admin_menu.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_menu\n id = params[:id]\n @menu = Menu.find(id)\n end", "def index\n #@fdn_menus = Fdn::Menu.all\n @fdn_menu = Fdn::Menu.top_level.first\n end", "def show\n @current_admin_user = current_admin_user \n @menu = Menu.find(params[:id])\n @menu_items = @menu.menu_items\n @title = @menu.name\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => {:menu => @menu, :menu_items => @menu_items} }\n end\n end", "def link_menu(resource, options={})\n html= ' '\n if permitted_to? :index, table_symbol_from(resource) then\n if resource.is_a? Symbol then\n model_plural = resource.to_s\n else\n model= singular_table_name_from( resource).pluralize \n end\n a = link_to(tmenu(model_plural), eval(model_plural + \"_path\"), options) \n html = wrap_in_html_container a, 'li', 'menuItem'\n end\n #ebugger\n return html.html_safe\n end", "def system_menu\n reply = []\n\n reply << if current_user == User.anonymous\n MenuItem.new('Sign In', new_session_path)\n else\n MenuItem.new('Profile', current_user)\n end\n\n reply += [\n MenuItem.new('Dashboard', admin_root_path),\n MenuItem.new('Content', admin_nodes_path, [\n MenuItem.new('New', new_admin_node_path, ScratchPad::Addon::NodeExtension.enabled.sort.map { |extension|\n MenuItem.new(extension.title, new_admin_node_path(:node_type => extension.machine_name))\n })\n ]),\n MenuItem.new('Taxonomy', admin_vocabularies_path, [\n MenuItem.new('New', new_admin_vocabulary_path)\n ]),\n MenuItem.new('Filters', admin_filter_groups_path, [\n MenuItem.new('New', new_admin_filter_group_path)\n ]),\n MenuItem.new('Themes', admin_themes_path, [\n MenuItem.new('Frontend', admin_themes_path(:scope => :frontend)),\n MenuItem.new('Backend', admin_themes_path(:scope => :backend))\n ]),\n MenuItem.new('Users', admin_users_path, [\n MenuItem.new('New', new_admin_user_path)\n ]),\n MenuItem.new('Groups'),\n MenuItem.new('Permissions'),\n MenuItem.new('Settings', admin_settings_path),\n MenuItem.new('Addon Configuration', admin_addon_configurations_path, ScratchPad::Addon::Base.addon_types.map { |addon_type|\n MenuItem.new(addon_type.title.pluralize, admin_addon_configurations_path(addon_type.machine_name))\n })\n ] if authorize\n\n reply\n end", "def write_crud_by_type(menu, crud_type)\n column_names = @@selected_table.columns.map(&:name)\n crud_by_options = [:all].concat(column_names)\n crud_column_menu = CliBuilder::Menu.new(title: \"Select Type of CRUD\", menu_options: crud_by_options, menu_type: \"crud\")\n menu.define_singleton_method :\"#{crud_type}\" do\n @@crud_type = crud_type\n crud_by_options.each do |column_name|\n write_crud_by_model(crud_column_menu, column_name)\n end\n crud_column_menu.build_menu\n end\n end", "def show\n @table_menu = Table::Menu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @table_menu }\n end\n end", "def set_menu\n set_system_config\n @menu = @system_config.menus.find(params[:id])\n end", "def index\n @current_admin_user = current_admin_user\n @menus = Menu.all\n @title = \"Menus\"\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @menus }\n end\n end", "def new\n @menuitem = Menuitem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @menuitem }\n end\n end", "def index\n @security_role_menus = Security::RoleMenu.all\n end", "def create\n @menu = Menu.new(menu_params)\n\n respond_to do |format|\n if @menu.save\n format.html { redirect_to @menu, notice: 'Menu was successfully created.' }\n format.json { render :show, status: :created, location: @menu }\n else\n format.html { render :new }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @menu = Menu.new(menu_params)\n\n respond_to do |format|\n if @menu.save\n format.html { redirect_to @menu, notice: 'Menu was successfully created.' }\n format.json { render :show, status: :created, location: @menu }\n else\n format.html { render :new }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @menu = Menu.new(menu_params)\n\n respond_to do |format|\n if @menu.save\n format.html { redirect_to @menu, notice: 'Menu was successfully created.' }\n format.json { render :show, status: :created, location: @menu }\n else\n format.html { render :new }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @menu = @menus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end", "def build_menu\n build_menu_title\n build_menu_body\n build_application\n end", "def create_menu\n h = { f: :create_a_file,\n d: :create_a_dir,\n s: :create_dir_with_selection,\n b: :create_bookmark }\n _, menu_text = menu 'Create Menu', h\nend", "def create\n @admin_menu = Menu.new(admin_menu_params)\n respond_to do |format|\n if @admin_menu.save\n format.html { redirect_to admin_menus_path, notice: 'Запис успішно створено.' }\n format.json { render :show, status: :created, location: @admin_menu }\n else\n format.html { render :new }\n format.json { render json: @admin_menu.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @menu_mensa = ::Menu.new\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def object_menu(class_name, action)\n class_string = class_name.to_s.underscore.downcase\n create_menu = Menu.new(menu_title_hash_by_action(class_string.humanize.downcase)[action])\n all = class_name.all\n all.each_with_index do |object, x|\n create_menu.add_menu_item({user_message: get_object_display_message(object), method_name: \"#{class_string}/#{action}/#{object.id}\"})\n end\n create_menu\n end", "def create\n @menu = Menu.new(params[:menu])\n\n respond_to do |format|\n if @menu.save\n flash[:notice] = 'Menu was successfully created.'\n format.html { redirect_to(@menu) }\n format.xml { render :xml => @menu, :status => :created, :location => @menu }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @menu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @role_menus = RoleMenu.all\n end", "def create\n @menu = Menu.new(menu_params)\n respond_to do |format|\n if @menu.save\n format.html { redirect_to menus_url, notice: 'Menu was successfully created.' }\n format.json { render :show, status: :created, location: @menu }\n else\n format.html { render :new }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end", "def menu(context={})\n \n app = context[:app]\n \n menu_items = [{:path => '/cms',\n :options => {:title => app.t.cms_admin_menu.cms_menu,\n :description => 'Content management', \n :module => 'cms',\n :weight => 10}},\n {:path => '/cms/newcontent',\n :options => {:title => app.t.cms_admin_menu.content_new,\n :link_route => \"/admin/cms/content/new\",\n :description => 'Creates a new content.',\n :module => 'cms',\n :weight => 6}}, \n {:path => '/cms/contenttypes',\n :options => {:title => app.t.cms_admin_menu.contenttype_management,\n :link_route => \"/admin/cms/content-types\",\n :description => 'Manages the content types: creation and update of content types.',\n :module => 'cms',\n :weight => 5}}, \n {:path => '/cms/contents',\n :options => {:title => app.t.cms_admin_menu.content_management,\n :link_route => \"/admin/cms/contents\",\n :description => 'Contents explorer.',\n :module => 'cms',\n :weight => 4}},\n {:path => '/cms/comments',\n :options => {:title => app.t.cms_admin_menu.comment_management,\n :link_route => \"/admin/cms/comments\",\n :description => 'Comments manager.',\n :module => 'cms',\n :weight => 3}}, \n {:path => '/cms/taxonomies', \n :options => {:title => app.t.cms_admin_menu.taxonomy_management,\n :link_route => \"/admin/cms/taxonomy\",\n :description => 'Manages the taxonomies: creation and update of taxonomies.',\n :module => 'cms',\n :weight => 2}},\n {:path => '/cms/templates', \n :options => {:title => app.t.cms_admin_menu.template_management,\n :link_route => \"/admin/cms/templates\",\n :description => 'Manages template: creation and update of template.',\n :module => 'cms',\n :weight => 1}}, \n {:path => '/cms/redirects',\n :options => {:title => app.t.cms_admin_menu.redirects_management,\n :link_route => \"/admin/cms/redirects\",\n :description => 'Redirects a content',\n :module => 'cms',\n :weight => 12}}, \n {:path => '/sbm',\n :options => {:title => app.t.cms_admin_menu.build_site_menu,\n :description => 'Site building',\n :module => 'cms',\n :weight => 9 }},\n {:path => '/sbm/blocks', \n :options => {:title => app.t.cms_admin_menu.block_management,\n :link_route => \"/admin/cms/blocks\",\n :description => 'Manage the blocks. It allows to discover and configure modules blocks.',\n :module => 'cms',\n :weight => 6}},\n {:path => '/sbm/views',\n :options => {:title => app.t.cms_admin_menu.view_management,\n :link_route => \"/admin/cms/views\",\n :description => 'Manage the views: creation and update of views.',\n :module => 'cms',\n :weight => 5}},\n {:path => '/sbm/menus', \n :options => {:title => app.t.site_admin_menu.menu_management,\n :link_route => \"/admin/cms/menu-management\",\n :description => 'Manage the menus. It allows to define custom menus.',\n :module => :cms,\n :weight => 7}}\n ] \n \n end", "def create\n @current_admin_user = current_admin_user\n session[:menu_params].deep_merge!(params[:menu]) if params[:menu]\n @menu = Menu.new(session[:menu_params])\n @categories = @menu.categories\n @menu.current_step = session[:menu_step]\n @selected_type = @menu.menu_type\n puts \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #{@selected_type}\"\n if params[:back_button]\n @menu.previous_step\n elsif @menu.last_step?\n @menu.save\n else\n @menu.next_step\n end\n session[:menu_step] = @menu.current_step\n if @menu.new_record?\n render \"new\"\n else\n session[:menu_steps]=session[:menu_params] = nil\n redirect_to @menu, notice: \"Menu was successfully created.\"\n end\n end", "def index\n @menus = Menu.all\n @menu = Menu.new\n @active = Menu.where(\"active = ?\", true)\n end", "def create\n @api_v1_menu = Menu.new(api_v1_menu_params)\n\n if @api_v1_menu.save\n render json: @api_v1_menu\n else\n render json: @api_v1_menu.errors\n end\n\n end", "def new\n @menu_list = MenuList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @menu_list }\n end\n end", "def create\n @menu_item = uhook_create_menu_item\n\n respond_to do |format|\n if @menu_item.valid?\n flash[:notice] = t('ubiquo.menu_item.created')\n format.html { redirect_to(ubiquo.edit_menu_path(@menu_item.menu)) }\n format.xml { render :xml => @menu_item, :status => :created, :location => @menu_item }\n else\n flash[:error] = t('ubiquo.menu_item.create_error')\n format.html { render :action => \"new\" }\n format.xml { render :xml => @menu_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @menus = @menus.all\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end" ]
[ "0.7293648", "0.7074873", "0.6942919", "0.67682034", "0.67682034", "0.67682034", "0.67682034", "0.67682034", "0.67682034", "0.6735522", "0.6734754", "0.6717449", "0.6693078", "0.66853017", "0.66700715", "0.6652952", "0.6652952", "0.6652952", "0.6627485", "0.660715", "0.65971494", "0.65934545", "0.65870893", "0.65824413", "0.65350163", "0.65336436", "0.6531305", "0.65256834", "0.65212035", "0.65212035", "0.65212035", "0.65212035", "0.65212035", "0.65212035", "0.65212035", "0.65212035", "0.65212035", "0.65212035", "0.65212035", "0.65212035", "0.65212035", "0.65212035", "0.65212035", "0.65037316", "0.65001255", "0.6496611", "0.64828753", "0.6470291", "0.6464688", "0.6460824", "0.6447307", "0.6442959", "0.6442731", "0.6427479", "0.6427479", "0.6427479", "0.6427479", "0.6397246", "0.63915026", "0.6377557", "0.63733107", "0.63579136", "0.6353753", "0.6349262", "0.6347327", "0.6346034", "0.6341601", "0.63409686", "0.63342226", "0.63304263", "0.6325184", "0.631208", "0.6309871", "0.6273775", "0.6254726", "0.62502843", "0.62490845", "0.624618", "0.624541", "0.62453717", "0.62436235", "0.62383425", "0.62383425", "0.62383425", "0.62259614", "0.62256455", "0.62167376", "0.62156373", "0.6214964", "0.6212726", "0.6210377", "0.62080085", "0.6201237", "0.62012345", "0.620057", "0.6199462", "0.6197068", "0.6191943", "0.61726534", "0.6171422" ]
0.74049234
0
returns a Menu of all the class's objects returns a Menu
def object_menu(class_name, action) class_string = class_name.to_s.underscore.downcase create_menu = Menu.new(menu_title_hash_by_action(class_string.humanize.downcase)[action]) all = class_name.all all.each_with_index do |object, x| create_menu.add_menu_item({user_message: get_object_display_message(object), method_name: "#{class_string}/#{action}/#{object.id}"}) end create_menu end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def menu\n @menu ||= Menu.new\n end", "def menu\n @menu ||= Interface::Menu.new(self)\n end", "def crud_menu(class_name)\n class_string = class_name.to_s.underscore.downcase\n m = Menu.new(\"What would you like to do with #{class_string.humanize.downcase.pluralize}?\")\n m.add_menu_item(user_message: [\"Create a new #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/create\")\n m.add_menu_item(user_message: [\"Show all #{class_string.humanize.downcase.pluralize}.\"], method_name: \"#{class_string}/show\")\n m.add_menu_item(user_message: [\"Update a #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/update\")\n m.add_menu_item(user_message: [\"Delete a #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/delete\")\n m\n end", "def menu_items\n\n menu.items(self)\n\n end", "def getMenu(menu)\n end", "def menu_items\n menu.items(self)\n end", "def menu_items\n menu.items(self)\n end", "def menu\n if self.has_parent?\n menu = self.parent.menu\n else\n menu = {:levels=>0,:items=>Array.new}\n end\n\n if !self.menu_items.empty?\n menu[:items][ menu[:levels] ] = self.menu_items\n menu[:levels] = menu[:levels]+1\n end\n\n return menu\n end", "def index\n @admin_menus = Admin::Menu.all\n end", "def createMenu _obj, _args\n \"_obj createMenu _args;\" \n end", "def index\n\t\t@menus = Menu.all\n\tend", "def menus\n Vedeu::Menus.registered\n end", "def gen_menu\n @menu = MenuTree.new\n\n return unless @sysuser\n\n @menu << MenuItem.new(_('Laboratories'),\n url_for(:controller => 'laboratories')) <<\n MenuItem.new(_('Profiles'),\n url_for(:controller => 'profiles')) <<\n MenuItem.new(_('Disk devices'),\n url_for(:controller => 'disk_devs')) <<\n MenuItem.new(_('Terminals'),\n url_for(:controller => 'terminals')) <<\n MenuItem.new(_('Terminal classes'),\n url_for(:controller => 'term_classes')) <<\n MenuItem.new(_('Instances'),\n url_for(:controller => 'instances')) \n\n if @sysuser.admin?\n @menu << MenuItem.new(_('User management'),\n url_for(:action => 'list', \n :controller => 'sysusers'))\n end\n end", "def nMenuItems _obj, _args\n \"_obj nMenuItems _args;\" \n end", "def menu\n @streams.select { |stream| stream.is_a? MenuStream }\n end", "def menus\n @_menus ||= nodes.map(&:root)\n end", "def get_menus()\n\n all_menus = []\n\n @raw.raw_menus.each do |menu| \n all_menus.push(menu.keys)\n end\n\n @menus = all_menus.flatten.uniq.sort_by(&:downcase)\n\n end", "def index\n @menu_items = Menu::Item.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n if @menu\n @menu_items = @menu.items\n else\n @menu_items = MenuItem.all\n end\n end", "def refinery_menu_pages\n Menu.new Page.fast_menu\n end", "def index\n @normal_menus = NormalMenu.all\n end", "def menu_items_html\n @menu_items = MenuItem.where(show: true, type_item: \"Головне меню\").order(order_item: :asc)\n\n @menu = '<ul class=\"nav navbar-nav\">'\n\n @menu_items.each do |m_a|\n if m_a.parent_id == 0\n @menu << \"<li class='dropdown'><a class='dropdown-toggle' aria-expanded='false' aria-haspopup = 'true' data-toggle = 'dropdown' href = '#{m_a.link}' role = 'button' target= 'blank'> #{m_a.title} <span class='caret'></span></a>\" if m_a.type_level == 'Заголовок меню'\n @menu << \"<li > <a href = '#{m_a.link}'> #{m_a.title} </span></a>\" if m_a.type_level == 'Пункт меню'\n\n get_children m_a.id, m_a.type_level\n\n @menu << '</li>'\n end\n end\n @menu << '</ul>'\n # $menu << @menu\n end", "def main_menu\n\n# Step 1, create the entries with (display text, method(:to_be_called), optional_args)\n\n hello = GemMenu::Entry.new('hello', method(:hello_world))\n world = GemMenu::Entry.new('world', method(:counting_world))\n second_menu = GemMenu::Entry.new('2nd level', method(:menu_2))\n food_menu = GemMenu::Entry.new('food menu', method(:menu_favorite_foods))\n long = GemMenu::Entry.new('long menu', method(:long_menu))\n\n# Step 2, once entries are created, create the Menu object and return it with\n# (title text, array_of_Entries, optional_args)\n GemMenu::Menu.new('main menu', [hello, world, second_menu, food_menu, long])\nend", "def choices4_all_as_tree(all=false)\n all ? DcManual.get_menu_all() : DcManual.get_menu(self)\nend", "def menu # can do custom methods within a method/class\n end", "def create_activity_menu\n # Create an array for the menu to display the activity names\n menu = []\n @activities.each { |activity| menu.push(activity.name)}\n return menu\n end", "def menu(name, *args, &block)\n if self[name]\n self[name].extend(&block)\n else\n self[name] = Menu.new(nil, :menu, name, *args, &block)\n end\n end", "def main_menu\n h = {\n a: :ag,\n z: :z_interface,\n # f: :file_actions,\n b: :bookmark_menu,\n c: :create_menu,\n f: :filter_menu,\n o: :order_menu,\n s: :selection_menu,\n t: :toggle_menu,\n v: :view_menu,\n '`' => :goto_parent_dir,\n x: :extras\n }\n menu 'Main Menu', h\nend", "def build_menu\n build_menu_title\n build_menu_body\n build_application\n end", "def index\n @admin_menus = Menu.all\n end", "def create_menus\n @file_menu = menu_bar.add_menu(tr(\"&File\"))\n @currency_menu = menu_bar.add_menu(tr(\"&Currency\"))\n @currency_menu.add_action(@import_file_action)\n @currency_menu.add_action(@import_url_action)\n @token_menu = menu_bar.add_menu(tr(\"&Token\"))\n @token_menu.add_action(@verify_action)\n @token_menu.add_action(@reissue_action)\n menu_bar.add_separator\n @help_menu = menu_bar.add_menu(tr(\"&Help\"))\n @help_menu.add_action(@about_action)\n end", "def menu_for(parent, abstract_model = nil, object = nil) # perf matters here (no action view trickery)\n actions = actions(parent, abstract_model, object).select{ |action| action.http_methods.include?(:get) }\n actions.map do |action|\n %{\n <li class=\"#{action.key}_#{parent}_link #{'active' if current_action?(action)}\">\n <a href=\"#{url_for({ :action => action.action_name, :controller => 'rails_admin/main', :model_name => abstract_model.try(:to_param), :id => object.try(:id) })}\">\n #{wording_for(:menu, action)}\n </a>\n </li>\n }\n end.join.html_safe\n end", "def index\n @menu ||= @menus.first\n @menu_table = MenuItemTreeBuilder.new(@menu)\n @menu_table.build\n end", "def getMenu(menu)\n menu.add_item(\"Done\") {self.done}\n menu.add_item(\"Edit Camera...\") {self.edit}\n menu.add_item(\"Reset Tilt\") {self.reset_tilt}\nend", "def index\n @menus = load_establishment.menus.all\n end", "def build_menu\n comment = table_info['comment']\n # #puts \"build Rails menu for #{model_name} (#{comment}) in\n # app/views/shared\"\n @@menus << { :model_name => model_name, :comment => comment, :route => \"/\"+ plural_table_name}\n \n end", "def index\n @main_menus = MainMenu.all\n end", "def create_menu_from_object_list(array_of_objects, action)\n create_menu = Menu.new(\"\")\n array_of_objects.each_with_index do |object, x|\n create_menu.add_menu_item({user_message: get_object_display_message(object), method_name: \"#{object.class}/#{action}/#{object.id}\"})\n end\n create_menu\n end", "def menu_items\n MenuItem.all.select {|item| item.recipe == self}\n end", "def index\n #@fdn_menus = Fdn::Menu.all\n @fdn_menu = Fdn::Menu.top_level.first\n end", "def show\n @menu_item = MenuItem.new\n @menu_group = MenuGroup.find(params[:id])\n @menu_items = MenuItem.where(menu_group_id: @menu_group.id)\n end", "def menu\n response[\"menu\"]\n end", "def main_menu(include_children=true,&block)\n menu_items = []\n \n if (root_menus=SiteMenu.roots).any?\n # load menu from database\n root_menus.each do |menu|\n menu_items << yield(menu.name, \n render( 'home/menu/with_children', \n :menu => menu, \n :recursive=>include_children,\n :force => true\n )\n ) if menu && (menu.role_needed||0) <= current_role\n end\n else\n # Use default menu\n \n # home\n menu_items = [ ]\n \n # Top pages\n menu_items << top_pages.map { |page|\n yield( page.id.to_s.to_sym, menu_link_to( page.short_title, \"/p/#{page.link_to_title}\" ))\n } if can? :read, Page\n \n # Blogs, Userlist, Comments\n menu_items << yield(:blogs, menu_link_to( t(:blogs), blogs_path )) if can? :read, Blog\n menu_items << yield(:userlist, menu_link_to( t(\"menu.userlist\"), registrations_path)) if can? :read, Page\n menu_items << yield(:comments, menu_link_to( t(\"menu.comments\"), comments_path)) if can? :read, Comment.new\n end\n \n menu_items\n end", "def index\n @menu_items = MenuItem.all\n end", "def index\n @menu_items = MenuItem.all\n end", "def index\n @menu_items = MenuItem.all\n end", "def index\n @menu_items = MenuItem.all\n end", "def show # Show method\n menu # Show menu method above\n end", "def create_menu\n h = { f: :create_a_file,\n d: :create_a_dir,\n s: :create_dir_with_selection,\n b: :create_bookmark }\n _, menu_text = menu 'Create Menu', h\nend", "def generate_menu\n @items = []\n @x = @window.width / 3 + Const::FONT_SMALL_SIZE\n @y = @title_image.height * @img_size_factor + Const::GAME_WIN_GAP\n n_g = proc { @window.state = GameState.new(@window, @window.width / 3, 40) }\n cr_n = proc { @window.state = NetSetupState.new(@window) }\n j_n = proc { @window.state = NetJoinState.new(@window) }\n exit = proc { @window.close }\n @items << MenuItem.new(@window, Const::MENU_NEW, 0, n_g, @font, @x, @y)\n @items << MenuItem.new(@window, Const::MENU_CREATE, 1, cr_n, @font, @x, @y)\n @items << MenuItem.new(@window, Const::MENU_JOIN, 2, j_n, @font, @x, @y)\n @items << MenuItem.new(@window, Const::MENU_QUIT, 3, exit, @font, @x, @y)\n end", "def menu menu_name, options = {}\n\toptions = {\n\t :dir_class => 'dir',\n\t :active_dir_class => 'active',\n\t :active_link_class => 'active',\n\t :root => nil\n\t}.deep_merge(options)\n\n\tul_li_menu(menu_name,options) do |page|\n\t if page[:page].page_type=='directory'\n\t page[:page].menu\n\t else\n\t %[<a href=\"#{root_url+page[:page].url}\" #{%[class=\"#{options[:active_link_class]}\"] if options[:active_link_class] && page[:page]==@page}>#{page[:page].menu}</a>]\n\t end\n\tend\n end", "def main_menu\n main_menu = parent\n return main_menu if main_menu.present?\n\n parent_menu = parent_item\n parent_menu.main_menu if parent_menu.present?\n end", "def createMenuItems(invocation)\r\n \r\n menu = []\r\n\r\n # Which part of the interface the user selects\r\n ctx = invocation.getInvocationContext()\r\n\r\n # Sitemap history, Proxy History will show menu item if selected by the user\r\n @stdout.println('Menu TYPE: %s\\n' % ctx)\r\n if ctx == 5 or ctx == 6 or ctx == 7\r\n\r\n faradayMenu = JMenuItem.new(\"Send to Faraday\", nil)\r\n\r\n faradayMenu.addActionListener do |e|\r\n eventScan(invocation, ctx)\r\n end\r\n\r\n menu.push(faradayMenu)\r\n end\r\n \r\n return menu\r\n end", "def index\n @menu_items = @menu.menu_items.all\n @menu_item = @menu.menu_items.build\n end", "def theatre_menu\n theatre = Menu.new(\"What would you like to do with theatres?\")\n theatre.add_menu_item({key_user_returns: 1, user_message: \"Create a theatre.\", do_if_chosen: [\"create_theatre\"]})\n theatre.add_menu_item({key_user_returns: 2, user_message: \"Update a theatre.\", do_if_chosen: [\"update_object\", Location, \"theatre_menu\"]})\n theatre.add_menu_item({key_user_returns: 3, user_message: \"Show me theatres.\", do_if_chosen: [\"show_object\", Location, \"theatre_menu\"]})\n theatre.add_menu_item({key_user_returns: 4, user_message: \"Delete a theatre.\", do_if_chosen: [\"delete_object\", Location, \"theatre_menu\"]})\n theatre.add_menu_item({key_user_returns: 5, user_message: \"Return to main menu.\", do_if_chosen: \n [\"main_menu\"]})\n run_menu_and_call_next(theatre)\n end", "def index\n #@menus = Menu.find(:all, :include => :dishes)\n\t@menus = Menu.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @menus }\n end\n end", "def createMenuItems(invocation)\n\n menu = []\n\n # Which part of the interface the user selects\n ctx = invocation.getInvocationContext()\n\n # Sitemap history, Proxy History, Request views, and Scanner will show menu item if selected by the user\n #@stdout.println('Menu TYPE: %s\\n' % ctx)\n if ctx == 5 or ctx == 6 or ctx == 2 or ctx == 7\n\n \t faradayMenu = JMenuItem.new(\"Send to Faraday\", nil)\n\n \t faradayMenu.addActionListener do |e|\n \t eventScan(invocation, ctx)\n \t end\n\n \t menu.push(faradayMenu)\n end\n\n return menu\n end", "def movie_menu\n movie = Menu.new(\"What would you like to do with movies?\")\n movie.add_menu_item({key_user_returns: 1, user_message: \"Create a movie.\", do_if_chosen: [\"create_movie\"]})\n movie.add_menu_item({key_user_returns: 2, user_message: \"Update a movie.\", do_if_chosen: [\"update_object\", Movie, \"movie_menu\"]})\n movie.add_menu_item({key_user_returns: 3, user_message: \"Show me movies.\", do_if_chosen: [\"show_object\", Movie, \"movie_menu\"]})\n movie.add_menu_item({key_user_returns: 4, user_message: \"Delete a movie.\", do_if_chosen: [\"delete_object\", Movie, \"movie_menu\"]})\n movie.add_menu_item({key_user_returns: 5, user_message: \"Return to main menu.\", do_if_chosen: \n [\"main_menu\"]})\n run_menu_and_call_next(movie)\n end", "def menu_to_class_name\n {\"user\" => User, \"collaborator\" => Collaborator, \"assignment\" => Assignment, \"link\" => Link}\n end", "def cargar_menu\n\t\tif session[:usuario]\n\t\t\t@opciones = Menu.find(:all, :order => 'padre, orden')\n\t\telse\n\t\t\t@opciones = []\n\t\tend\n\tend", "def create_menu_lists\n menu_lists = [\n {\n type: 'puppet_class',\n title: 'Puppet Classes',\n search_title: 'Puppet Classes'\n },\n {\n type: 'puppet_data_type',\n title: 'Data Types',\n search_title: 'Data Types'\n },\n {\n type: 'puppet_defined_type',\n title: 'Defined Types',\n search_title: 'Defined Types'\n },\n {\n type: 'puppet_type',\n title: 'Resource Types',\n search_title: 'Resource Types'\n },\n {\n type: 'puppet_provider',\n title: 'Providers',\n search_title: 'Providers'\n },\n {\n type: 'puppet_function',\n title: 'Puppet Functions',\n search_title: 'Puppet Functions'\n },\n {\n type: 'puppet_task',\n title: 'Puppet Tasks',\n search_totle: 'Puppet Tasks'\n },\n {\n type: 'puppet_plan',\n title: 'Puppet Plans',\n search_totle: 'Puppet Plans'\n },\n {\n type: 'class',\n title: 'Ruby Classes',\n search_title: 'Class List'\n },\n {\n type: 'method',\n title: 'Ruby Methods',\n search_title: 'Method List'\n }\n ]\n\n menu_lists.delete_if { |e| YARD::Registry.all(e[:type].intern).empty? }\n\n # We must always return at least one group, so always keep the files list\n if menu_lists.empty? || !YARD::Registry.all(:file).empty?\n menu_lists << {\n type: 'file',\n title: 'Files',\n search_title: 'File List'\n }\n end\n\n menu_lists\nend", "def build_menu_by_name(initial_name,limit = 1)\n lang = Mokio::Lang.default\n position = Mokio::Menu.find_by_lang_id_and_name(lang.id,initial_name)\n\n html = \"<nav class='navmenu' id='menuMain'>\"\n html << build_items(position, limit, 1) if position.children.present? && position.active\n html << \"</nav>\"\n html.html_safe\n\n end", "def addMenu _obj, _args\n \"_obj addMenu _args;\" \n end", "def self_and_parent_menus(options={})\n\t\t\tarr = [self]\n\t\t\tfather = self.parent\n\t\t\twhile father.present?\n\t\t\t\tarr << father\n\t\t\t\tfather = father.parent\n\t\t\tend\n\n\t\t\treturn arr.reverse\n\t\tend", "def view_menu\n h = {\n f: :select_from_visited_files,\n d: :select_from_used_dirs,\n b: :view_bookmarks,\n s: :list_selected_files,\n c: :child_dirs,\n r: :recent_files,\n t: :tree,\n e: :dirtree\n }\n menu 'View Menu', h\nend", "def menu_for(parent, abstract_model = nil, object = nil, only_icon = false) # perf matters here (no action view trickery)\n actions = actions(parent, abstract_model, object).select{ |a| a.http_methods.include?(:get) }\n actions.map do |action|\n wording = wording_for(:menu, action)\n %{\n <li title=\"#{wording if only_icon}\" rel=\"#{'tooltip' if only_icon}\" class=\"icon #{action.key}_#{parent}_link #{'active' if current_action?(action)}\">\n <a class=\"pjax\" href=\"#{locale_url_for({ :action => action.action_name, :controller => 'rails_admin/main', :model_name => abstract_model.try(:to_param), :id => (object.try(:persisted?) && object.try(:id) || nil) })}\">\n <i class=\"#{action.link_icon}\"></i>\n <span#{only_icon ? \" style='display:none'\" : \"\"}>#{wording}</span>\n </a>\n </li>\n }\n end.join.html_safe\n end", "def menu(context={})\n \n app = context[:app]\n\n menu_items = [{:path => '/system',\n :options => {\n \t:title => app.t.system_admin_menu.system_menu,\n :description => 'System menu',\n :module => :system,\n :weight => 0\n }\n },\n {:path => '/system/logger', \n :options => {:title => app.t.system_admin_menu.logger,\n :link_route => \"/admin/logger\",\n :description => 'Reads the logs',\n :module => :system,\n :weight => 1}\n },\n {:path => '/system/business-events', \n :options => {:title => app.t.system_admin_menu.business_event,\n :link_route => \"/admin/business-events\",\n :description => 'Manages business events',\n :module => :system,\n :weight => 0}\n }\n ] \n \n end", "def index\n @menus = Menu.all\n @menu = Menu.new\n @active = Menu.where(\"active = ?\", true)\n end", "def main_menu\n h = { \n :a => :ack,\n \"/\" => :ffind,\n :l => :locate,\n :v => :viminfo,\n :z => :z_interface,\n :d => :child_dirs,\n :r => :recent_files,\n :t => :dirtree,\n \"4\" => :tree,\n :s => :sort_menu, \n :F => :filter_menu,\n :c => :command_menu ,\n :B => :bindkey_ext_command,\n :M => :newdir,\n \"%\" => :newfile,\n :x => :extras\n }\n menu \"Main Menu\", h\nend", "def create_menu\n items = Hash.new\n # action shd be a hash\n # menu should have array of hashes (or just a string)\n #db = { :name => \"Databases\", :accelerator => \"M-d\", :enabled = true, :on_right => :get_databases }\n #or = { :name => \"Open Recent\", :accelerator => \"M-o\", :enabled = true, :on_right => :get_recent }\n #find_array = {\"Find ...\" => :find, \"Find Next\" => :find_next, \"Find Previous\" => :find_prev}\n items[\"File >\"] = [\"Open ... C-o\" , \"Open Recent\", \"Databases\" , \"Tables\", \"Exit\"]\n items[\"Window >\"] = { \"Tile\" => nil, \"Find >\" => {\"Find ...\" => :find, \"Find Next\" => :find_next, \"Find Previous\" => :find_prev},\n \"Edit\" => nil, \"Whatever\" => nil}\n items[\"Others >\"] = { \"Shell Output ...\" => :shell_output, \"Suspend ...\" => :suspend , \"View File\" => :choose_file_and_view}\n\n # in the case of generated names how will call back know that it is a db name or a table name\n # We get back an array containing the entire path of selections\n right_actions = {}\n right_actions[\"Databases\"] = Proc.new { Dir.glob(\"**/*.{sqlite,db}\") }\n right_actions[\"Tables\"] = :get_table_names\n\n ret = popupmenu items, :row => 1, :col => 0, :bgcolor => :cyan, :color => :white, :right_actions => right_actions\n # ret can be nil, or have a symbol to execute, or a String for an item with no leaf/symbol\n if ret\n alert \"Got #{ret}\"\n last = ret.last\n if last.is_a? Symbol\n if respond_to?(last, true)\n send(last)\n end\n end\n end\n\n return\n r = 1\n ix = popuplist( top , :title => \" Menu \" , :row => r, :col => 0, :bgcolor => :cyan, :color => :white)\n if ix\n value = top[ix]\n ix = popuplist( items[value] , :row => r + 2 + ix, :col => 10, :bgcolor => :cyan, :color => :white)\n end\nend", "def menu\nend", "def initialize(*args)\n super\n @cur_menu = 0\n @past_menu = nil\n @items = [Item.new('New', :read_new_menu),\n Item.new('Boards', :print_board_menu),\n Item.new('Select', :select_board_menu),\n Item.new('Read', :read_board_menu)]\n @items.concat(\n %w(Post Talk Mail Diary Welcome Xyz Goodbye Help)\n .map { |name| Item.new(name) })\n # @items.concat(%w(Extra Visit InfoBBS).map { |name| Item.new(name) }))\n @items << Item.new('Admin') if term.current_user.admin?\n @items.freeze\n end", "def computeNewMenu\n @NewMenu = Wx::Menu.new\n @Controller.getIntegrationPlugins.each do |iPluginID, iPluginInfo|\n lNewMenuItem = Wx::MenuItem.new(@NewMenu, Wx::ID_ANY, iPluginInfo[:Title])\n lNewMenuItem.bitmap = @Controller.getPluginBitmap(iPluginInfo)\n @NewMenu.append_item(lNewMenuItem)\n # The event\n # Clone variables to make them persistent in the Proc context\n lPluginIDCloned = iPluginID\n evt_menu(lNewMenuItem) do |iEvent|\n @Controller.accessIntegrationPlugin(lPluginIDCloned) do |iPlugin|\n @DisplayedList << [\n lPluginIDCloned,\n [],\n true,\n iPlugin.getDefaultOptions,\n [ nil, nil ]\n ]\n end\n refreshList\n end\n end\n end", "def type\n \"mymenu\"\n end", "def index\n @security_role_menus = Security::RoleMenu.all\n end", "def render_menu ( menu , options={}, style=:tabs , level=1 )\n links = []\n case style\n when :tabs\n Atlantis::MenuManager.items_at_level(menu, level).each do |node|\n links << render_menu_node(node, style, options)\n end\n links.empty? ? '' : content_tag('ul', links.join(\"\\n\").html_safe , :class=>options[:ul_class] ).html_safe\n when :divs\n Atlantis::MenuManager.items_at_level(menu, level-1).each do |node|\n links2 = Array.new\n node.children.each do |n|\n links2 << render_menu_node(n, style, options)\n end\n links << content_tag('div', links2.join(\"\\n\").html_safe).html_safe\n end\n links.empty? ? '' : links.join(\"\\n\").html_safe\n end\n end", "def index\n @root_menus = @system_config.menus.root_menus\n end", "def right_js_classes_menu\n packs = {}\n Unit.all.each do |unit|\n packs[unit.package] ||= []\n packs[unit.package] << unit\n end\n\n packs.keys.sort.collect { |package|\n content_tag(:label, package.capitalize) +\n content_tag(:ul, packs[package].collect { |unit|\n menu_link_to(unit.name, unit, {}, request.request_uri == unit_path(unit))+\n (@unit == unit ? right_js_unit_menu(unit) : '')\n })\n }.join(\"\\n\")\n end", "def menu_root\n @menu_root ||= MenuNode.new do |root|\n root.add 'Home', url: url_for(action: \"index\")\n root.add 'Schedule', url: url_for(action: \"schedule\")\n root.add 'Private lessons', url: url_for(action: \"private_lessons\")\n root.add 'Instructors', url: url_for(action: \"instructors\")\n root.add 'Register', url: url_for(action: \"registration\")\n end\n end", "def resource_menu\n xml = Builder::XmlMarkup.new\n xml.div(:id => \"ResourceMenu\") do\n xml << resource_tab_link(\"players\", \"Players\")\n xml << resource_tab_link(\"games\", \"Games\")\n xml << resource_tab_link(\"matches\", \"Matches\")\n xml << resource_tab_link(\"seasons\", \"Seasons\")\n end\n end", "def menu(context={})\n \n app = context[:app]\n \n menu_items = [{:path => '/cms',\n :options => {:title => app.t.cms_admin_menu.cms_menu,\n :description => 'Content management', \n :module => 'cms',\n :weight => 10}},\n {:path => '/cms/newcontent',\n :options => {:title => app.t.cms_admin_menu.content_new,\n :link_route => \"/admin/cms/content/new\",\n :description => 'Creates a new content.',\n :module => 'cms',\n :weight => 6}}, \n {:path => '/cms/contenttypes',\n :options => {:title => app.t.cms_admin_menu.contenttype_management,\n :link_route => \"/admin/cms/content-types\",\n :description => 'Manages the content types: creation and update of content types.',\n :module => 'cms',\n :weight => 5}}, \n {:path => '/cms/contents',\n :options => {:title => app.t.cms_admin_menu.content_management,\n :link_route => \"/admin/cms/contents\",\n :description => 'Contents explorer.',\n :module => 'cms',\n :weight => 4}},\n {:path => '/cms/comments',\n :options => {:title => app.t.cms_admin_menu.comment_management,\n :link_route => \"/admin/cms/comments\",\n :description => 'Comments manager.',\n :module => 'cms',\n :weight => 3}}, \n {:path => '/cms/taxonomies', \n :options => {:title => app.t.cms_admin_menu.taxonomy_management,\n :link_route => \"/admin/cms/taxonomy\",\n :description => 'Manages the taxonomies: creation and update of taxonomies.',\n :module => 'cms',\n :weight => 2}},\n {:path => '/cms/templates', \n :options => {:title => app.t.cms_admin_menu.template_management,\n :link_route => \"/admin/cms/templates\",\n :description => 'Manages template: creation and update of template.',\n :module => 'cms',\n :weight => 1}}, \n {:path => '/cms/redirects',\n :options => {:title => app.t.cms_admin_menu.redirects_management,\n :link_route => \"/admin/cms/redirects\",\n :description => 'Redirects a content',\n :module => 'cms',\n :weight => 12}}, \n {:path => '/sbm',\n :options => {:title => app.t.cms_admin_menu.build_site_menu,\n :description => 'Site building',\n :module => 'cms',\n :weight => 9 }},\n {:path => '/sbm/blocks', \n :options => {:title => app.t.cms_admin_menu.block_management,\n :link_route => \"/admin/cms/blocks\",\n :description => 'Manage the blocks. It allows to discover and configure modules blocks.',\n :module => 'cms',\n :weight => 6}},\n {:path => '/sbm/views',\n :options => {:title => app.t.cms_admin_menu.view_management,\n :link_route => \"/admin/cms/views\",\n :description => 'Manage the views: creation and update of views.',\n :module => 'cms',\n :weight => 5}},\n {:path => '/sbm/menus', \n :options => {:title => app.t.site_admin_menu.menu_management,\n :link_route => \"/admin/cms/menu-management\",\n :description => 'Manage the menus. It allows to define custom menus.',\n :module => :cms,\n :weight => 7}}\n ] \n \n end", "def return_scene\n $scene = Scene_Menu.new(6)\n end", "def menu(context={})\n \n app = context[:app]\n\n menu_items = [ \n ] \n \n end", "def menu(context={})\n \n app = context[:app]\n\n menu_items = [ \n ] \n \n end", "def admin_menu_items\n menu = []\n menu.push([t(\"menu.home\"), admin_home_path, Proc.new {controller_name == \"home\"}])\n if current_user\n menu.push([t(\"menu.projects\"), admin_projects_path, Proc.new {controller_name == \"projects\" || controller_name == \"project_to_users\"}])\n menu.push([t(\"menu.users\"), admin_users_path, Proc.new {controller_name == \"users\"}])\n menu.push([t(\"menu.profile\"), admin_profile_path, Proc.new {controller_name == \"profile\"}])\n menu.push([t(\"menu.logout\"), logout_path])\n end\n menu\n end", "def generate_menu\n @menu = MenuTree.new\n @menu.add( _('Conference listing'),\n url_for(:controller => '/conferences', :action => 'list') )\n # A link will be generated here and at some other views all over,\n # so we declare a dirty, ugly @link_to_nametags\n @link_to_nametag = CertifFormat.for_personal_nametag\n\n if @user.nil?\n @menu.add(_('Log in'),\n url_for(:controller => '/people', :action => 'login'))\n @menu.add(_('New account'),\n url_for(:controller => '/people', :action => 'new'))\n else\n personal = MenuTree.new\n personal.add(_('Basic information'),\n url_for(:controller => '/people', :action => 'account'))\n personal.add(_('Update your personal information'),\n url_for(:controller => '/people', :action => 'personal'))\n personal.add(_('Change password'),\n url_for(:controller => '/people', :action => 'password'))\n personal.add(_('My public profile'),\n url_for(:controller => '/people', :action => 'profile',\n :id => @user.id))\n @link_to_nametag and personal.add(_('Generate nametag'),\n url_for(:controller => '/people', :action => 'my_nametag'))\n @user.can_submit_proposals_now? and\n personal.add(_('My proposals'),\n url_for(:controller=>'/people', :action => 'proposals'))\n @user.conferences.size > 0 and\n personal.add(_('Invite a friend'),\n url_for(:controller=>'/people', :action => 'invite'))\n\n @menu.add(_('My account'), nil, personal)\n\n @user.admin_tasks.sort_by(&:sys_name).each do |task|\n begin\n control = \"#{task.sys_name.camelcase}Controller\".constantize\n menu = menu_subtree_for((control.constants.include?('Menu') ?\n control::Menu : []), task)\n rescue NameError\n # Probably caused by an unimplemented controller? A\n # controller which does not implement a menu?\n menu = menu_subtree_for([[_'-*- Unimplemented']], task)\n end\n\n @menu.add(Translation.for(task.qualified_name),\n nil, menu)\n end\n end\n end", "def build_menu(name = DEFAULT_MENU)\n @menus.before_build do |menus|\n menus.menu name do |menu|\n yield menu\n end\n end\n end", "def menu(name, path=nil, options={}, &block)\n @menus << Menu.new(name, path, options, &block)\n end", "def createMenu\n\n # File menu\n recordAction = @actions.addNew(i18n('Start Download'), self, \\\n { :icon => 'arrow-down', :triggered => :startDownload })\n reloadStyleAction = @actions.addNew(i18n('&Reload StyleSheet'), self, \\\n { :icon => 'view-refresh', :shortCut => 'Ctrl+R', :triggered => :reloadStyleSheet })\n clearStyleAction = @actions.addNew(i18n('&Clear StyleSheet'), self, \\\n { :icon => 'list-remove', :shortCut => 'Ctrl+L', :triggered => :clearStyleSheet })\n quitAction = @actions.addNew(i18n('&Quit'), self, \\\n { :icon => 'application-exit', :shortCut => 'Ctrl+Q', :triggered => :close })\n\n updateScheduleAction = @actions.addNew(i18n('Update Schedule'), @scheduleWin, \\\n { :shortCut => 'Ctrl+U', :triggered => :updateAllFilters })\n\n fileMenu = KDE::Menu.new('&File', self)\n fileMenu.addAction(recordAction)\n fileMenu.addAction(reloadStyleAction)\n fileMenu.addAction(clearStyleAction)\n fileMenu.addAction(updateScheduleAction)\n fileMenu.addAction(quitAction)\n\n\n # settings menu\n playerDockAction = @playerDock.toggleViewAction\n playerDockAction.text = i18n('Show Player')\n configureAppAction = @actions.addNew(i18n('Configure %s') % APP_NAME, self, \\\n { :icon => 'configure', :shortCut => 'F2', :triggered => :configureApp })\n\n settingsMenu = KDE::Menu.new(i18n('&Settings'), self)\n settingsMenu.addAction(playerDockAction)\n settingsMenu.addSeparator\n settingsMenu.addAction(configureAppAction)\n\n\n # Help menu\n aboutDlg = KDE::AboutApplicationDialog.new(KDE::CmdLineArgs.aboutData)\n openAboutAction = @actions.addNew(i18n('About %s') % APP_NAME, self, \\\n { :icon => 'irecorder', :triggered =>[aboutDlg, :exec] })\n openDocUrlAction = @actions.addNew(i18n('Open Document Wiki'), self, \\\n { :icon => 'help-contents', :triggered =>:openDocUrl})\n openReportIssueUrlAction = @actions.addNew(i18n('Report Bug'), self, \\\n { :icon => 'tools-report-bug', :triggered =>:openReportIssueUrl })\n openRdocAction = @actions.addNew(i18n('Open Rdoc'), self, \\\n { :icon => 'help-contents', :triggered =>:openRdoc })\n openSourceAction = @actions.addNew(i18n('Open Source Folder'), self, \\\n { :icon => 'document-open-folder', :triggered =>:openSource })\n\n\n helpMenu = KDE::Menu.new(i18n('&Help'), self)\n helpMenu.addAction(openDocUrlAction)\n helpMenu.addAction(openReportIssueUrlAction)\n helpMenu.addAction(openRdocAction)\n helpMenu.addAction(openSourceAction)\n helpMenu.addSeparator\n helpMenu.addAction(openAboutAction)\n\n # insert menus in MenuBar\n menu = KDE::MenuBar.new\n menu.addMenu( fileMenu )\n menu.addMenu( settingsMenu )\n menu.addSeparator\n menu.addMenu( helpMenu )\n setMenuBar(menu)\n end", "def user_choice_of_object_in_class(class_object)\n create_menu = Menu.new(\"Which #{class_object.name} do you want to look up?\")\n all = class_object.all\n all.each_with_index do |object, x|\n object_to_s = object.attributes.map{|k,v| \"#{k}: #{v}\"}.join(', ')\n create_menu.add_menu_item({key_user_returns: x + 1, user_message: object_to_s, do_if_chosen: \"#{object.id}\"})\n end\n create_menu\n end", "def main_Menu_Name\n Goldberg.menu.main_Menu_Name\n end", "def main_menu\n ctrlr = request.parameters['controller'].split('/').last\n dashboard_class = (ctrlr == 'dashboard' ? 'current' : '')\n assets_class = (ctrlr == 'assets' ? 'current' : '')\n design_class = ((ctrlr == 'themes' || ctrlr == 'resources') ? 'current' : '')\n contacts_class = (ctrlr == 'contacts' ? 'current' : '')\n settings_class = (ctrlr == 'settings' ? 'current' : '')\n content_class = ((ctrlr == 'home' || ctrlr == 'links' || ctrlr == 'news_items' || ctrlr == 'portfolios' || ctrlr == 'assigned_assets' || ctrlr == 'resume_sections' || ctrlr == 'resume_items' || ctrlr == 'galleries') ? 'current' : '')\n admin_class = ((ctrlr == 'users' || ctrlr == 'sites' || ctrlr == 'memberships') ? 'current' : '')\n \n result = content_tag('li', link_to('Dashboard', admin_dashboard_path, :class => dashboard_class))\n result << content_tag('li', link_to('Content', edit_admin_home_path, :class => content_class))\n result << content_tag('li', link_to(assets_name, admin_assets_path, :class => assets_class))\n result << content_tag('li', link_to('Design', admin_themes_path, :class => design_class))\n result << content_tag('li', link_to('Contacts', admin_contacts_path, :class => contacts_class))\n result << content_tag('li', link_to('Settings', edit_admin_settings_path, :class => settings_class))\n if admin?\n result << content_tag('li', link_to('Admin', admin_users_path, :class => admin_class))\n end\n result\n end", "def menu\n \nend", "def menus\n @menus = Menu.where(location_id: params[:id]).all\n end" ]
[ "0.75239736", "0.7251913", "0.7152285", "0.7067058", "0.6993228", "0.69154716", "0.69154716", "0.68096507", "0.6669297", "0.665324", "0.6645677", "0.66043955", "0.6604207", "0.65116745", "0.6510946", "0.648266", "0.6466476", "0.6440695", "0.6434809", "0.6434809", "0.6434809", "0.6434809", "0.6434809", "0.6434809", "0.64345914", "0.6415263", "0.6395127", "0.6389207", "0.63735354", "0.63708776", "0.6347896", "0.6337831", "0.6303036", "0.62959105", "0.62915283", "0.62845486", "0.6267528", "0.6253762", "0.62383974", "0.6233292", "0.6196817", "0.61531353", "0.6135448", "0.61342824", "0.6129926", "0.6095572", "0.6068128", "0.60566926", "0.6055658", "0.60452133", "0.60452133", "0.60452133", "0.60452133", "0.6035744", "0.6033408", "0.60255665", "0.60208434", "0.6019727", "0.6016955", "0.6012655", "0.6012588", "0.60052747", "0.60039145", "0.60032034", "0.59992284", "0.59856784", "0.59836954", "0.5979973", "0.5978772", "0.59775525", "0.5969379", "0.596623", "0.59589916", "0.5942706", "0.59277785", "0.59194845", "0.59044063", "0.58954805", "0.5887945", "0.58862305", "0.5883073", "0.5883068", "0.5879826", "0.5864011", "0.58589065", "0.58569324", "0.5855073", "0.58544385", "0.5850248", "0.5850248", "0.584776", "0.5842945", "0.58253384", "0.582116", "0.581621", "0.58144283", "0.5797909", "0.5791182", "0.57875776", "0.57861346" ]
0.7957775
0
returns a Menu of all the class's objects returns a Menu
def create_menu_from_object_list(array_of_objects, action) create_menu = Menu.new("") array_of_objects.each_with_index do |object, x| create_menu.add_menu_item({user_message: get_object_display_message(object), method_name: "#{object.class}/#{action}/#{object.id}"}) end create_menu end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def object_menu(class_name, action)\n class_string = class_name.to_s.underscore.downcase\n create_menu = Menu.new(menu_title_hash_by_action(class_string.humanize.downcase)[action])\n all = class_name.all\n all.each_with_index do |object, x|\n create_menu.add_menu_item({user_message: get_object_display_message(object), method_name: \"#{class_string}/#{action}/#{object.id}\"})\n end\n create_menu\n end", "def menu\n @menu ||= Menu.new\n end", "def menu\n @menu ||= Interface::Menu.new(self)\n end", "def crud_menu(class_name)\n class_string = class_name.to_s.underscore.downcase\n m = Menu.new(\"What would you like to do with #{class_string.humanize.downcase.pluralize}?\")\n m.add_menu_item(user_message: [\"Create a new #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/create\")\n m.add_menu_item(user_message: [\"Show all #{class_string.humanize.downcase.pluralize}.\"], method_name: \"#{class_string}/show\")\n m.add_menu_item(user_message: [\"Update a #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/update\")\n m.add_menu_item(user_message: [\"Delete a #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/delete\")\n m\n end", "def menu_items\n\n menu.items(self)\n\n end", "def getMenu(menu)\n end", "def menu_items\n menu.items(self)\n end", "def menu_items\n menu.items(self)\n end", "def menu\n if self.has_parent?\n menu = self.parent.menu\n else\n menu = {:levels=>0,:items=>Array.new}\n end\n\n if !self.menu_items.empty?\n menu[:items][ menu[:levels] ] = self.menu_items\n menu[:levels] = menu[:levels]+1\n end\n\n return menu\n end", "def index\n @admin_menus = Admin::Menu.all\n end", "def createMenu _obj, _args\n \"_obj createMenu _args;\" \n end", "def index\n\t\t@menus = Menu.all\n\tend", "def menus\n Vedeu::Menus.registered\n end", "def gen_menu\n @menu = MenuTree.new\n\n return unless @sysuser\n\n @menu << MenuItem.new(_('Laboratories'),\n url_for(:controller => 'laboratories')) <<\n MenuItem.new(_('Profiles'),\n url_for(:controller => 'profiles')) <<\n MenuItem.new(_('Disk devices'),\n url_for(:controller => 'disk_devs')) <<\n MenuItem.new(_('Terminals'),\n url_for(:controller => 'terminals')) <<\n MenuItem.new(_('Terminal classes'),\n url_for(:controller => 'term_classes')) <<\n MenuItem.new(_('Instances'),\n url_for(:controller => 'instances')) \n\n if @sysuser.admin?\n @menu << MenuItem.new(_('User management'),\n url_for(:action => 'list', \n :controller => 'sysusers'))\n end\n end", "def nMenuItems _obj, _args\n \"_obj nMenuItems _args;\" \n end", "def menu\n @streams.select { |stream| stream.is_a? MenuStream }\n end", "def menus\n @_menus ||= nodes.map(&:root)\n end", "def get_menus()\n\n all_menus = []\n\n @raw.raw_menus.each do |menu| \n all_menus.push(menu.keys)\n end\n\n @menus = all_menus.flatten.uniq.sort_by(&:downcase)\n\n end", "def index\n @menu_items = Menu::Item.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n @menus = Menu.all\n end", "def index\n if @menu\n @menu_items = @menu.items\n else\n @menu_items = MenuItem.all\n end\n end", "def refinery_menu_pages\n Menu.new Page.fast_menu\n end", "def index\n @normal_menus = NormalMenu.all\n end", "def menu_items_html\n @menu_items = MenuItem.where(show: true, type_item: \"Головне меню\").order(order_item: :asc)\n\n @menu = '<ul class=\"nav navbar-nav\">'\n\n @menu_items.each do |m_a|\n if m_a.parent_id == 0\n @menu << \"<li class='dropdown'><a class='dropdown-toggle' aria-expanded='false' aria-haspopup = 'true' data-toggle = 'dropdown' href = '#{m_a.link}' role = 'button' target= 'blank'> #{m_a.title} <span class='caret'></span></a>\" if m_a.type_level == 'Заголовок меню'\n @menu << \"<li > <a href = '#{m_a.link}'> #{m_a.title} </span></a>\" if m_a.type_level == 'Пункт меню'\n\n get_children m_a.id, m_a.type_level\n\n @menu << '</li>'\n end\n end\n @menu << '</ul>'\n # $menu << @menu\n end", "def main_menu\n\n# Step 1, create the entries with (display text, method(:to_be_called), optional_args)\n\n hello = GemMenu::Entry.new('hello', method(:hello_world))\n world = GemMenu::Entry.new('world', method(:counting_world))\n second_menu = GemMenu::Entry.new('2nd level', method(:menu_2))\n food_menu = GemMenu::Entry.new('food menu', method(:menu_favorite_foods))\n long = GemMenu::Entry.new('long menu', method(:long_menu))\n\n# Step 2, once entries are created, create the Menu object and return it with\n# (title text, array_of_Entries, optional_args)\n GemMenu::Menu.new('main menu', [hello, world, second_menu, food_menu, long])\nend", "def choices4_all_as_tree(all=false)\n all ? DcManual.get_menu_all() : DcManual.get_menu(self)\nend", "def menu # can do custom methods within a method/class\n end", "def create_activity_menu\n # Create an array for the menu to display the activity names\n menu = []\n @activities.each { |activity| menu.push(activity.name)}\n return menu\n end", "def menu(name, *args, &block)\n if self[name]\n self[name].extend(&block)\n else\n self[name] = Menu.new(nil, :menu, name, *args, &block)\n end\n end", "def main_menu\n h = {\n a: :ag,\n z: :z_interface,\n # f: :file_actions,\n b: :bookmark_menu,\n c: :create_menu,\n f: :filter_menu,\n o: :order_menu,\n s: :selection_menu,\n t: :toggle_menu,\n v: :view_menu,\n '`' => :goto_parent_dir,\n x: :extras\n }\n menu 'Main Menu', h\nend", "def build_menu\n build_menu_title\n build_menu_body\n build_application\n end", "def index\n @admin_menus = Menu.all\n end", "def create_menus\n @file_menu = menu_bar.add_menu(tr(\"&File\"))\n @currency_menu = menu_bar.add_menu(tr(\"&Currency\"))\n @currency_menu.add_action(@import_file_action)\n @currency_menu.add_action(@import_url_action)\n @token_menu = menu_bar.add_menu(tr(\"&Token\"))\n @token_menu.add_action(@verify_action)\n @token_menu.add_action(@reissue_action)\n menu_bar.add_separator\n @help_menu = menu_bar.add_menu(tr(\"&Help\"))\n @help_menu.add_action(@about_action)\n end", "def menu_for(parent, abstract_model = nil, object = nil) # perf matters here (no action view trickery)\n actions = actions(parent, abstract_model, object).select{ |action| action.http_methods.include?(:get) }\n actions.map do |action|\n %{\n <li class=\"#{action.key}_#{parent}_link #{'active' if current_action?(action)}\">\n <a href=\"#{url_for({ :action => action.action_name, :controller => 'rails_admin/main', :model_name => abstract_model.try(:to_param), :id => object.try(:id) })}\">\n #{wording_for(:menu, action)}\n </a>\n </li>\n }\n end.join.html_safe\n end", "def index\n @menu ||= @menus.first\n @menu_table = MenuItemTreeBuilder.new(@menu)\n @menu_table.build\n end", "def getMenu(menu)\n menu.add_item(\"Done\") {self.done}\n menu.add_item(\"Edit Camera...\") {self.edit}\n menu.add_item(\"Reset Tilt\") {self.reset_tilt}\nend", "def index\n @menus = load_establishment.menus.all\n end", "def build_menu\n comment = table_info['comment']\n # #puts \"build Rails menu for #{model_name} (#{comment}) in\n # app/views/shared\"\n @@menus << { :model_name => model_name, :comment => comment, :route => \"/\"+ plural_table_name}\n \n end", "def index\n @main_menus = MainMenu.all\n end", "def menu_items\n MenuItem.all.select {|item| item.recipe == self}\n end", "def index\n #@fdn_menus = Fdn::Menu.all\n @fdn_menu = Fdn::Menu.top_level.first\n end", "def show\n @menu_item = MenuItem.new\n @menu_group = MenuGroup.find(params[:id])\n @menu_items = MenuItem.where(menu_group_id: @menu_group.id)\n end", "def menu\n response[\"menu\"]\n end", "def main_menu(include_children=true,&block)\n menu_items = []\n \n if (root_menus=SiteMenu.roots).any?\n # load menu from database\n root_menus.each do |menu|\n menu_items << yield(menu.name, \n render( 'home/menu/with_children', \n :menu => menu, \n :recursive=>include_children,\n :force => true\n )\n ) if menu && (menu.role_needed||0) <= current_role\n end\n else\n # Use default menu\n \n # home\n menu_items = [ ]\n \n # Top pages\n menu_items << top_pages.map { |page|\n yield( page.id.to_s.to_sym, menu_link_to( page.short_title, \"/p/#{page.link_to_title}\" ))\n } if can? :read, Page\n \n # Blogs, Userlist, Comments\n menu_items << yield(:blogs, menu_link_to( t(:blogs), blogs_path )) if can? :read, Blog\n menu_items << yield(:userlist, menu_link_to( t(\"menu.userlist\"), registrations_path)) if can? :read, Page\n menu_items << yield(:comments, menu_link_to( t(\"menu.comments\"), comments_path)) if can? :read, Comment.new\n end\n \n menu_items\n end", "def index\n @menu_items = MenuItem.all\n end", "def index\n @menu_items = MenuItem.all\n end", "def index\n @menu_items = MenuItem.all\n end", "def index\n @menu_items = MenuItem.all\n end", "def show # Show method\n menu # Show menu method above\n end", "def create_menu\n h = { f: :create_a_file,\n d: :create_a_dir,\n s: :create_dir_with_selection,\n b: :create_bookmark }\n _, menu_text = menu 'Create Menu', h\nend", "def generate_menu\n @items = []\n @x = @window.width / 3 + Const::FONT_SMALL_SIZE\n @y = @title_image.height * @img_size_factor + Const::GAME_WIN_GAP\n n_g = proc { @window.state = GameState.new(@window, @window.width / 3, 40) }\n cr_n = proc { @window.state = NetSetupState.new(@window) }\n j_n = proc { @window.state = NetJoinState.new(@window) }\n exit = proc { @window.close }\n @items << MenuItem.new(@window, Const::MENU_NEW, 0, n_g, @font, @x, @y)\n @items << MenuItem.new(@window, Const::MENU_CREATE, 1, cr_n, @font, @x, @y)\n @items << MenuItem.new(@window, Const::MENU_JOIN, 2, j_n, @font, @x, @y)\n @items << MenuItem.new(@window, Const::MENU_QUIT, 3, exit, @font, @x, @y)\n end", "def menu menu_name, options = {}\n\toptions = {\n\t :dir_class => 'dir',\n\t :active_dir_class => 'active',\n\t :active_link_class => 'active',\n\t :root => nil\n\t}.deep_merge(options)\n\n\tul_li_menu(menu_name,options) do |page|\n\t if page[:page].page_type=='directory'\n\t page[:page].menu\n\t else\n\t %[<a href=\"#{root_url+page[:page].url}\" #{%[class=\"#{options[:active_link_class]}\"] if options[:active_link_class] && page[:page]==@page}>#{page[:page].menu}</a>]\n\t end\n\tend\n end", "def main_menu\n main_menu = parent\n return main_menu if main_menu.present?\n\n parent_menu = parent_item\n parent_menu.main_menu if parent_menu.present?\n end", "def createMenuItems(invocation)\r\n \r\n menu = []\r\n\r\n # Which part of the interface the user selects\r\n ctx = invocation.getInvocationContext()\r\n\r\n # Sitemap history, Proxy History will show menu item if selected by the user\r\n @stdout.println('Menu TYPE: %s\\n' % ctx)\r\n if ctx == 5 or ctx == 6 or ctx == 7\r\n\r\n faradayMenu = JMenuItem.new(\"Send to Faraday\", nil)\r\n\r\n faradayMenu.addActionListener do |e|\r\n eventScan(invocation, ctx)\r\n end\r\n\r\n menu.push(faradayMenu)\r\n end\r\n \r\n return menu\r\n end", "def index\n @menu_items = @menu.menu_items.all\n @menu_item = @menu.menu_items.build\n end", "def theatre_menu\n theatre = Menu.new(\"What would you like to do with theatres?\")\n theatre.add_menu_item({key_user_returns: 1, user_message: \"Create a theatre.\", do_if_chosen: [\"create_theatre\"]})\n theatre.add_menu_item({key_user_returns: 2, user_message: \"Update a theatre.\", do_if_chosen: [\"update_object\", Location, \"theatre_menu\"]})\n theatre.add_menu_item({key_user_returns: 3, user_message: \"Show me theatres.\", do_if_chosen: [\"show_object\", Location, \"theatre_menu\"]})\n theatre.add_menu_item({key_user_returns: 4, user_message: \"Delete a theatre.\", do_if_chosen: [\"delete_object\", Location, \"theatre_menu\"]})\n theatre.add_menu_item({key_user_returns: 5, user_message: \"Return to main menu.\", do_if_chosen: \n [\"main_menu\"]})\n run_menu_and_call_next(theatre)\n end", "def index\n #@menus = Menu.find(:all, :include => :dishes)\n\t@menus = Menu.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @menus }\n end\n end", "def createMenuItems(invocation)\n\n menu = []\n\n # Which part of the interface the user selects\n ctx = invocation.getInvocationContext()\n\n # Sitemap history, Proxy History, Request views, and Scanner will show menu item if selected by the user\n #@stdout.println('Menu TYPE: %s\\n' % ctx)\n if ctx == 5 or ctx == 6 or ctx == 2 or ctx == 7\n\n \t faradayMenu = JMenuItem.new(\"Send to Faraday\", nil)\n\n \t faradayMenu.addActionListener do |e|\n \t eventScan(invocation, ctx)\n \t end\n\n \t menu.push(faradayMenu)\n end\n\n return menu\n end", "def movie_menu\n movie = Menu.new(\"What would you like to do with movies?\")\n movie.add_menu_item({key_user_returns: 1, user_message: \"Create a movie.\", do_if_chosen: [\"create_movie\"]})\n movie.add_menu_item({key_user_returns: 2, user_message: \"Update a movie.\", do_if_chosen: [\"update_object\", Movie, \"movie_menu\"]})\n movie.add_menu_item({key_user_returns: 3, user_message: \"Show me movies.\", do_if_chosen: [\"show_object\", Movie, \"movie_menu\"]})\n movie.add_menu_item({key_user_returns: 4, user_message: \"Delete a movie.\", do_if_chosen: [\"delete_object\", Movie, \"movie_menu\"]})\n movie.add_menu_item({key_user_returns: 5, user_message: \"Return to main menu.\", do_if_chosen: \n [\"main_menu\"]})\n run_menu_and_call_next(movie)\n end", "def menu_to_class_name\n {\"user\" => User, \"collaborator\" => Collaborator, \"assignment\" => Assignment, \"link\" => Link}\n end", "def cargar_menu\n\t\tif session[:usuario]\n\t\t\t@opciones = Menu.find(:all, :order => 'padre, orden')\n\t\telse\n\t\t\t@opciones = []\n\t\tend\n\tend", "def create_menu_lists\n menu_lists = [\n {\n type: 'puppet_class',\n title: 'Puppet Classes',\n search_title: 'Puppet Classes'\n },\n {\n type: 'puppet_data_type',\n title: 'Data Types',\n search_title: 'Data Types'\n },\n {\n type: 'puppet_defined_type',\n title: 'Defined Types',\n search_title: 'Defined Types'\n },\n {\n type: 'puppet_type',\n title: 'Resource Types',\n search_title: 'Resource Types'\n },\n {\n type: 'puppet_provider',\n title: 'Providers',\n search_title: 'Providers'\n },\n {\n type: 'puppet_function',\n title: 'Puppet Functions',\n search_title: 'Puppet Functions'\n },\n {\n type: 'puppet_task',\n title: 'Puppet Tasks',\n search_totle: 'Puppet Tasks'\n },\n {\n type: 'puppet_plan',\n title: 'Puppet Plans',\n search_totle: 'Puppet Plans'\n },\n {\n type: 'class',\n title: 'Ruby Classes',\n search_title: 'Class List'\n },\n {\n type: 'method',\n title: 'Ruby Methods',\n search_title: 'Method List'\n }\n ]\n\n menu_lists.delete_if { |e| YARD::Registry.all(e[:type].intern).empty? }\n\n # We must always return at least one group, so always keep the files list\n if menu_lists.empty? || !YARD::Registry.all(:file).empty?\n menu_lists << {\n type: 'file',\n title: 'Files',\n search_title: 'File List'\n }\n end\n\n menu_lists\nend", "def build_menu_by_name(initial_name,limit = 1)\n lang = Mokio::Lang.default\n position = Mokio::Menu.find_by_lang_id_and_name(lang.id,initial_name)\n\n html = \"<nav class='navmenu' id='menuMain'>\"\n html << build_items(position, limit, 1) if position.children.present? && position.active\n html << \"</nav>\"\n html.html_safe\n\n end", "def addMenu _obj, _args\n \"_obj addMenu _args;\" \n end", "def self_and_parent_menus(options={})\n\t\t\tarr = [self]\n\t\t\tfather = self.parent\n\t\t\twhile father.present?\n\t\t\t\tarr << father\n\t\t\t\tfather = father.parent\n\t\t\tend\n\n\t\t\treturn arr.reverse\n\t\tend", "def view_menu\n h = {\n f: :select_from_visited_files,\n d: :select_from_used_dirs,\n b: :view_bookmarks,\n s: :list_selected_files,\n c: :child_dirs,\n r: :recent_files,\n t: :tree,\n e: :dirtree\n }\n menu 'View Menu', h\nend", "def menu_for(parent, abstract_model = nil, object = nil, only_icon = false) # perf matters here (no action view trickery)\n actions = actions(parent, abstract_model, object).select{ |a| a.http_methods.include?(:get) }\n actions.map do |action|\n wording = wording_for(:menu, action)\n %{\n <li title=\"#{wording if only_icon}\" rel=\"#{'tooltip' if only_icon}\" class=\"icon #{action.key}_#{parent}_link #{'active' if current_action?(action)}\">\n <a class=\"pjax\" href=\"#{locale_url_for({ :action => action.action_name, :controller => 'rails_admin/main', :model_name => abstract_model.try(:to_param), :id => (object.try(:persisted?) && object.try(:id) || nil) })}\">\n <i class=\"#{action.link_icon}\"></i>\n <span#{only_icon ? \" style='display:none'\" : \"\"}>#{wording}</span>\n </a>\n </li>\n }\n end.join.html_safe\n end", "def menu(context={})\n \n app = context[:app]\n\n menu_items = [{:path => '/system',\n :options => {\n \t:title => app.t.system_admin_menu.system_menu,\n :description => 'System menu',\n :module => :system,\n :weight => 0\n }\n },\n {:path => '/system/logger', \n :options => {:title => app.t.system_admin_menu.logger,\n :link_route => \"/admin/logger\",\n :description => 'Reads the logs',\n :module => :system,\n :weight => 1}\n },\n {:path => '/system/business-events', \n :options => {:title => app.t.system_admin_menu.business_event,\n :link_route => \"/admin/business-events\",\n :description => 'Manages business events',\n :module => :system,\n :weight => 0}\n }\n ] \n \n end", "def index\n @menus = Menu.all\n @menu = Menu.new\n @active = Menu.where(\"active = ?\", true)\n end", "def main_menu\n h = { \n :a => :ack,\n \"/\" => :ffind,\n :l => :locate,\n :v => :viminfo,\n :z => :z_interface,\n :d => :child_dirs,\n :r => :recent_files,\n :t => :dirtree,\n \"4\" => :tree,\n :s => :sort_menu, \n :F => :filter_menu,\n :c => :command_menu ,\n :B => :bindkey_ext_command,\n :M => :newdir,\n \"%\" => :newfile,\n :x => :extras\n }\n menu \"Main Menu\", h\nend", "def create_menu\n items = Hash.new\n # action shd be a hash\n # menu should have array of hashes (or just a string)\n #db = { :name => \"Databases\", :accelerator => \"M-d\", :enabled = true, :on_right => :get_databases }\n #or = { :name => \"Open Recent\", :accelerator => \"M-o\", :enabled = true, :on_right => :get_recent }\n #find_array = {\"Find ...\" => :find, \"Find Next\" => :find_next, \"Find Previous\" => :find_prev}\n items[\"File >\"] = [\"Open ... C-o\" , \"Open Recent\", \"Databases\" , \"Tables\", \"Exit\"]\n items[\"Window >\"] = { \"Tile\" => nil, \"Find >\" => {\"Find ...\" => :find, \"Find Next\" => :find_next, \"Find Previous\" => :find_prev},\n \"Edit\" => nil, \"Whatever\" => nil}\n items[\"Others >\"] = { \"Shell Output ...\" => :shell_output, \"Suspend ...\" => :suspend , \"View File\" => :choose_file_and_view}\n\n # in the case of generated names how will call back know that it is a db name or a table name\n # We get back an array containing the entire path of selections\n right_actions = {}\n right_actions[\"Databases\"] = Proc.new { Dir.glob(\"**/*.{sqlite,db}\") }\n right_actions[\"Tables\"] = :get_table_names\n\n ret = popupmenu items, :row => 1, :col => 0, :bgcolor => :cyan, :color => :white, :right_actions => right_actions\n # ret can be nil, or have a symbol to execute, or a String for an item with no leaf/symbol\n if ret\n alert \"Got #{ret}\"\n last = ret.last\n if last.is_a? Symbol\n if respond_to?(last, true)\n send(last)\n end\n end\n end\n\n return\n r = 1\n ix = popuplist( top , :title => \" Menu \" , :row => r, :col => 0, :bgcolor => :cyan, :color => :white)\n if ix\n value = top[ix]\n ix = popuplist( items[value] , :row => r + 2 + ix, :col => 10, :bgcolor => :cyan, :color => :white)\n end\nend", "def menu\nend", "def initialize(*args)\n super\n @cur_menu = 0\n @past_menu = nil\n @items = [Item.new('New', :read_new_menu),\n Item.new('Boards', :print_board_menu),\n Item.new('Select', :select_board_menu),\n Item.new('Read', :read_board_menu)]\n @items.concat(\n %w(Post Talk Mail Diary Welcome Xyz Goodbye Help)\n .map { |name| Item.new(name) })\n # @items.concat(%w(Extra Visit InfoBBS).map { |name| Item.new(name) }))\n @items << Item.new('Admin') if term.current_user.admin?\n @items.freeze\n end", "def computeNewMenu\n @NewMenu = Wx::Menu.new\n @Controller.getIntegrationPlugins.each do |iPluginID, iPluginInfo|\n lNewMenuItem = Wx::MenuItem.new(@NewMenu, Wx::ID_ANY, iPluginInfo[:Title])\n lNewMenuItem.bitmap = @Controller.getPluginBitmap(iPluginInfo)\n @NewMenu.append_item(lNewMenuItem)\n # The event\n # Clone variables to make them persistent in the Proc context\n lPluginIDCloned = iPluginID\n evt_menu(lNewMenuItem) do |iEvent|\n @Controller.accessIntegrationPlugin(lPluginIDCloned) do |iPlugin|\n @DisplayedList << [\n lPluginIDCloned,\n [],\n true,\n iPlugin.getDefaultOptions,\n [ nil, nil ]\n ]\n end\n refreshList\n end\n end\n end", "def type\n \"mymenu\"\n end", "def render_menu ( menu , options={}, style=:tabs , level=1 )\n links = []\n case style\n when :tabs\n Atlantis::MenuManager.items_at_level(menu, level).each do |node|\n links << render_menu_node(node, style, options)\n end\n links.empty? ? '' : content_tag('ul', links.join(\"\\n\").html_safe , :class=>options[:ul_class] ).html_safe\n when :divs\n Atlantis::MenuManager.items_at_level(menu, level-1).each do |node|\n links2 = Array.new\n node.children.each do |n|\n links2 << render_menu_node(n, style, options)\n end\n links << content_tag('div', links2.join(\"\\n\").html_safe).html_safe\n end\n links.empty? ? '' : links.join(\"\\n\").html_safe\n end\n end", "def index\n @security_role_menus = Security::RoleMenu.all\n end", "def index\n @root_menus = @system_config.menus.root_menus\n end", "def right_js_classes_menu\n packs = {}\n Unit.all.each do |unit|\n packs[unit.package] ||= []\n packs[unit.package] << unit\n end\n\n packs.keys.sort.collect { |package|\n content_tag(:label, package.capitalize) +\n content_tag(:ul, packs[package].collect { |unit|\n menu_link_to(unit.name, unit, {}, request.request_uri == unit_path(unit))+\n (@unit == unit ? right_js_unit_menu(unit) : '')\n })\n }.join(\"\\n\")\n end", "def menu_root\n @menu_root ||= MenuNode.new do |root|\n root.add 'Home', url: url_for(action: \"index\")\n root.add 'Schedule', url: url_for(action: \"schedule\")\n root.add 'Private lessons', url: url_for(action: \"private_lessons\")\n root.add 'Instructors', url: url_for(action: \"instructors\")\n root.add 'Register', url: url_for(action: \"registration\")\n end\n end", "def resource_menu\n xml = Builder::XmlMarkup.new\n xml.div(:id => \"ResourceMenu\") do\n xml << resource_tab_link(\"players\", \"Players\")\n xml << resource_tab_link(\"games\", \"Games\")\n xml << resource_tab_link(\"matches\", \"Matches\")\n xml << resource_tab_link(\"seasons\", \"Seasons\")\n end\n end", "def return_scene\n $scene = Scene_Menu.new(6)\n end", "def menu(context={})\n \n app = context[:app]\n \n menu_items = [{:path => '/cms',\n :options => {:title => app.t.cms_admin_menu.cms_menu,\n :description => 'Content management', \n :module => 'cms',\n :weight => 10}},\n {:path => '/cms/newcontent',\n :options => {:title => app.t.cms_admin_menu.content_new,\n :link_route => \"/admin/cms/content/new\",\n :description => 'Creates a new content.',\n :module => 'cms',\n :weight => 6}}, \n {:path => '/cms/contenttypes',\n :options => {:title => app.t.cms_admin_menu.contenttype_management,\n :link_route => \"/admin/cms/content-types\",\n :description => 'Manages the content types: creation and update of content types.',\n :module => 'cms',\n :weight => 5}}, \n {:path => '/cms/contents',\n :options => {:title => app.t.cms_admin_menu.content_management,\n :link_route => \"/admin/cms/contents\",\n :description => 'Contents explorer.',\n :module => 'cms',\n :weight => 4}},\n {:path => '/cms/comments',\n :options => {:title => app.t.cms_admin_menu.comment_management,\n :link_route => \"/admin/cms/comments\",\n :description => 'Comments manager.',\n :module => 'cms',\n :weight => 3}}, \n {:path => '/cms/taxonomies', \n :options => {:title => app.t.cms_admin_menu.taxonomy_management,\n :link_route => \"/admin/cms/taxonomy\",\n :description => 'Manages the taxonomies: creation and update of taxonomies.',\n :module => 'cms',\n :weight => 2}},\n {:path => '/cms/templates', \n :options => {:title => app.t.cms_admin_menu.template_management,\n :link_route => \"/admin/cms/templates\",\n :description => 'Manages template: creation and update of template.',\n :module => 'cms',\n :weight => 1}}, \n {:path => '/cms/redirects',\n :options => {:title => app.t.cms_admin_menu.redirects_management,\n :link_route => \"/admin/cms/redirects\",\n :description => 'Redirects a content',\n :module => 'cms',\n :weight => 12}}, \n {:path => '/sbm',\n :options => {:title => app.t.cms_admin_menu.build_site_menu,\n :description => 'Site building',\n :module => 'cms',\n :weight => 9 }},\n {:path => '/sbm/blocks', \n :options => {:title => app.t.cms_admin_menu.block_management,\n :link_route => \"/admin/cms/blocks\",\n :description => 'Manage the blocks. It allows to discover and configure modules blocks.',\n :module => 'cms',\n :weight => 6}},\n {:path => '/sbm/views',\n :options => {:title => app.t.cms_admin_menu.view_management,\n :link_route => \"/admin/cms/views\",\n :description => 'Manage the views: creation and update of views.',\n :module => 'cms',\n :weight => 5}},\n {:path => '/sbm/menus', \n :options => {:title => app.t.site_admin_menu.menu_management,\n :link_route => \"/admin/cms/menu-management\",\n :description => 'Manage the menus. It allows to define custom menus.',\n :module => :cms,\n :weight => 7}}\n ] \n \n end", "def menu(context={})\n \n app = context[:app]\n\n menu_items = [ \n ] \n \n end", "def menu(context={})\n \n app = context[:app]\n\n menu_items = [ \n ] \n \n end", "def admin_menu_items\n menu = []\n menu.push([t(\"menu.home\"), admin_home_path, Proc.new {controller_name == \"home\"}])\n if current_user\n menu.push([t(\"menu.projects\"), admin_projects_path, Proc.new {controller_name == \"projects\" || controller_name == \"project_to_users\"}])\n menu.push([t(\"menu.users\"), admin_users_path, Proc.new {controller_name == \"users\"}])\n menu.push([t(\"menu.profile\"), admin_profile_path, Proc.new {controller_name == \"profile\"}])\n menu.push([t(\"menu.logout\"), logout_path])\n end\n menu\n end", "def generate_menu\n @menu = MenuTree.new\n @menu.add( _('Conference listing'),\n url_for(:controller => '/conferences', :action => 'list') )\n # A link will be generated here and at some other views all over,\n # so we declare a dirty, ugly @link_to_nametags\n @link_to_nametag = CertifFormat.for_personal_nametag\n\n if @user.nil?\n @menu.add(_('Log in'),\n url_for(:controller => '/people', :action => 'login'))\n @menu.add(_('New account'),\n url_for(:controller => '/people', :action => 'new'))\n else\n personal = MenuTree.new\n personal.add(_('Basic information'),\n url_for(:controller => '/people', :action => 'account'))\n personal.add(_('Update your personal information'),\n url_for(:controller => '/people', :action => 'personal'))\n personal.add(_('Change password'),\n url_for(:controller => '/people', :action => 'password'))\n personal.add(_('My public profile'),\n url_for(:controller => '/people', :action => 'profile',\n :id => @user.id))\n @link_to_nametag and personal.add(_('Generate nametag'),\n url_for(:controller => '/people', :action => 'my_nametag'))\n @user.can_submit_proposals_now? and\n personal.add(_('My proposals'),\n url_for(:controller=>'/people', :action => 'proposals'))\n @user.conferences.size > 0 and\n personal.add(_('Invite a friend'),\n url_for(:controller=>'/people', :action => 'invite'))\n\n @menu.add(_('My account'), nil, personal)\n\n @user.admin_tasks.sort_by(&:sys_name).each do |task|\n begin\n control = \"#{task.sys_name.camelcase}Controller\".constantize\n menu = menu_subtree_for((control.constants.include?('Menu') ?\n control::Menu : []), task)\n rescue NameError\n # Probably caused by an unimplemented controller? A\n # controller which does not implement a menu?\n menu = menu_subtree_for([[_'-*- Unimplemented']], task)\n end\n\n @menu.add(Translation.for(task.qualified_name),\n nil, menu)\n end\n end\n end", "def build_menu(name = DEFAULT_MENU)\n @menus.before_build do |menus|\n menus.menu name do |menu|\n yield menu\n end\n end\n end", "def menu(name, path=nil, options={}, &block)\n @menus << Menu.new(name, path, options, &block)\n end", "def createMenu\n\n # File menu\n recordAction = @actions.addNew(i18n('Start Download'), self, \\\n { :icon => 'arrow-down', :triggered => :startDownload })\n reloadStyleAction = @actions.addNew(i18n('&Reload StyleSheet'), self, \\\n { :icon => 'view-refresh', :shortCut => 'Ctrl+R', :triggered => :reloadStyleSheet })\n clearStyleAction = @actions.addNew(i18n('&Clear StyleSheet'), self, \\\n { :icon => 'list-remove', :shortCut => 'Ctrl+L', :triggered => :clearStyleSheet })\n quitAction = @actions.addNew(i18n('&Quit'), self, \\\n { :icon => 'application-exit', :shortCut => 'Ctrl+Q', :triggered => :close })\n\n updateScheduleAction = @actions.addNew(i18n('Update Schedule'), @scheduleWin, \\\n { :shortCut => 'Ctrl+U', :triggered => :updateAllFilters })\n\n fileMenu = KDE::Menu.new('&File', self)\n fileMenu.addAction(recordAction)\n fileMenu.addAction(reloadStyleAction)\n fileMenu.addAction(clearStyleAction)\n fileMenu.addAction(updateScheduleAction)\n fileMenu.addAction(quitAction)\n\n\n # settings menu\n playerDockAction = @playerDock.toggleViewAction\n playerDockAction.text = i18n('Show Player')\n configureAppAction = @actions.addNew(i18n('Configure %s') % APP_NAME, self, \\\n { :icon => 'configure', :shortCut => 'F2', :triggered => :configureApp })\n\n settingsMenu = KDE::Menu.new(i18n('&Settings'), self)\n settingsMenu.addAction(playerDockAction)\n settingsMenu.addSeparator\n settingsMenu.addAction(configureAppAction)\n\n\n # Help menu\n aboutDlg = KDE::AboutApplicationDialog.new(KDE::CmdLineArgs.aboutData)\n openAboutAction = @actions.addNew(i18n('About %s') % APP_NAME, self, \\\n { :icon => 'irecorder', :triggered =>[aboutDlg, :exec] })\n openDocUrlAction = @actions.addNew(i18n('Open Document Wiki'), self, \\\n { :icon => 'help-contents', :triggered =>:openDocUrl})\n openReportIssueUrlAction = @actions.addNew(i18n('Report Bug'), self, \\\n { :icon => 'tools-report-bug', :triggered =>:openReportIssueUrl })\n openRdocAction = @actions.addNew(i18n('Open Rdoc'), self, \\\n { :icon => 'help-contents', :triggered =>:openRdoc })\n openSourceAction = @actions.addNew(i18n('Open Source Folder'), self, \\\n { :icon => 'document-open-folder', :triggered =>:openSource })\n\n\n helpMenu = KDE::Menu.new(i18n('&Help'), self)\n helpMenu.addAction(openDocUrlAction)\n helpMenu.addAction(openReportIssueUrlAction)\n helpMenu.addAction(openRdocAction)\n helpMenu.addAction(openSourceAction)\n helpMenu.addSeparator\n helpMenu.addAction(openAboutAction)\n\n # insert menus in MenuBar\n menu = KDE::MenuBar.new\n menu.addMenu( fileMenu )\n menu.addMenu( settingsMenu )\n menu.addSeparator\n menu.addMenu( helpMenu )\n setMenuBar(menu)\n end", "def user_choice_of_object_in_class(class_object)\n create_menu = Menu.new(\"Which #{class_object.name} do you want to look up?\")\n all = class_object.all\n all.each_with_index do |object, x|\n object_to_s = object.attributes.map{|k,v| \"#{k}: #{v}\"}.join(', ')\n create_menu.add_menu_item({key_user_returns: x + 1, user_message: object_to_s, do_if_chosen: \"#{object.id}\"})\n end\n create_menu\n end", "def main_Menu_Name\n Goldberg.menu.main_Menu_Name\n end", "def main_menu\n ctrlr = request.parameters['controller'].split('/').last\n dashboard_class = (ctrlr == 'dashboard' ? 'current' : '')\n assets_class = (ctrlr == 'assets' ? 'current' : '')\n design_class = ((ctrlr == 'themes' || ctrlr == 'resources') ? 'current' : '')\n contacts_class = (ctrlr == 'contacts' ? 'current' : '')\n settings_class = (ctrlr == 'settings' ? 'current' : '')\n content_class = ((ctrlr == 'home' || ctrlr == 'links' || ctrlr == 'news_items' || ctrlr == 'portfolios' || ctrlr == 'assigned_assets' || ctrlr == 'resume_sections' || ctrlr == 'resume_items' || ctrlr == 'galleries') ? 'current' : '')\n admin_class = ((ctrlr == 'users' || ctrlr == 'sites' || ctrlr == 'memberships') ? 'current' : '')\n \n result = content_tag('li', link_to('Dashboard', admin_dashboard_path, :class => dashboard_class))\n result << content_tag('li', link_to('Content', edit_admin_home_path, :class => content_class))\n result << content_tag('li', link_to(assets_name, admin_assets_path, :class => assets_class))\n result << content_tag('li', link_to('Design', admin_themes_path, :class => design_class))\n result << content_tag('li', link_to('Contacts', admin_contacts_path, :class => contacts_class))\n result << content_tag('li', link_to('Settings', edit_admin_settings_path, :class => settings_class))\n if admin?\n result << content_tag('li', link_to('Admin', admin_users_path, :class => admin_class))\n end\n result\n end", "def menu\n \nend", "def menus\n @menus = Menu.where(location_id: params[:id]).all\n end" ]
[ "0.79575884", "0.75230646", "0.72508806", "0.7150978", "0.7065246", "0.69913936", "0.69137925", "0.69137925", "0.6808621", "0.6669307", "0.66523826", "0.66448665", "0.66033614", "0.6601939", "0.6510299", "0.65098864", "0.6481154", "0.64653426", "0.6440507", "0.6434226", "0.6434226", "0.6434226", "0.6434226", "0.6434226", "0.6434226", "0.6434019", "0.6414423", "0.6394396", "0.638774", "0.63729334", "0.6370218", "0.6346107", "0.6336868", "0.6301818", "0.62942624", "0.62903243", "0.6284273", "0.6265933", "0.62527823", "0.6238192", "0.62316537", "0.61964166", "0.6152229", "0.6135114", "0.6129052", "0.60952836", "0.6067547", "0.6055269", "0.60546505", "0.6044678", "0.6044678", "0.6044678", "0.6044678", "0.6034286", "0.60318696", "0.6024374", "0.60189694", "0.60185575", "0.6015216", "0.6012553", "0.6011627", "0.60053086", "0.6002105", "0.600194", "0.59978867", "0.59848154", "0.598383", "0.59794164", "0.5978046", "0.5976165", "0.596752", "0.5965143", "0.59574914", "0.5942232", "0.592604", "0.59182024", "0.59025663", "0.5893844", "0.5887302", "0.58852696", "0.58819276", "0.58818775", "0.58779657", "0.5863062", "0.5857285", "0.5856745", "0.5853905", "0.5853788", "0.5848441", "0.5848441", "0.58458245", "0.5841906", "0.5824765", "0.5819777", "0.58153284", "0.5813729", "0.579646", "0.57898134", "0.57856476", "0.578539" ]
0.6134044
44
returns object's display_fields values returns an Array of values
def get_object_display_message(object) values = [] object.display_fields.each do |field| values << object.send(field) end values end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_fields\n self.class.fields.values.select { |field| field.show }\n end", "def display_all_fields\n @@all_fields\n end", "def display_fields\n database_field_names\n end", "def fields\n displayed_fields = @display_fields.select { |display_field| @document.key?(display_field) }\n pairs = displayed_fields.map do |display_field|\n [display_field, Array.wrap(@document.fetch(display_field))]\n end\n Hash[pairs]\n end", "def fetch_fields\n @fields\n end", "def fields_for_display\n attributes = self.relevant_fields\n attributes.map{|key| [WorkOrder.human_attribute_name(key), self[key]]}\n end", "def fields_for_display\n attributes = self.relevant_fields\n attributes.map{|key| [WorkOrder.human_attribute_name(key), self[key]]}\n end", "def fields_for_display\n attributes = self.relevant_fields\n attributes.map{|key| [WorkOrder.human_attribute_name(key), self[key]]}\n end", "def all_fields\n @fields.values\n end", "def fields\n @fields\n end", "def fields\n @fields\n end", "def display_fields\n @form.fields.each {|f| puts f.name}\n end", "def fields\n FIELDS\n end", "def fields\n @fields\n end", "def fields\n FIELDS\n end", "def all_fields\n fields.values\n end", "def fields\n self.class.fields(true)\n end", "def get_fields\n FIELD_DESCS\n end", "def fields\n FIELDS\n end", "def document_show_fields\n Blacklight.config[:show_fields][:field_names]\n end", "def detail\n output = []\n detail_fields.each do |field_name|\n output << [field_name.to_s, field(field_name).to_s]\n end\n\n output\n end", "def to_a; @fields end", "def fields\n all_fields\n end", "def fields\n @fields.keys\n end", "def fields\n @fields.keys\n end", "def fields\n []\n end", "def display_fields\n [\"user_name\", \"assignment_name\"]\n end", "def fields\n preview_json['fields']\n end", "def fields; h.fields; end", "def custom_fields_to_show\n begin\n custom_field_names = plugin_setting('custom_fields_shown').to_s\n custom_field_names.split(',').map {|custom_field_name|\n UserCustomField.find_by_name(custom_field_name.strip) \n }.flatten.compact\n rescue\n []\n end\n end", "def all_fields\n found_fields = Array.new\n self.fields.each do |field|\n found_fields << field\n found_fields = found_fields + field.all_fields if field.type == 'ObjectField'\n end\n found_fields\n end", "def display_attributes\n self.class.display_attribute_names.map do |name|\n [name.to_s, self.send(name)]\n end.to_h\n end", "def values\n fields.map { |f| f.value }\n end", "def show_fields_for(display_types)\n Array(display_types).inject(show_fields) do |fields, display_type|\n fields.merge(for_display_type(display_type).show_fields)\n end\n end", "def inspect_values\n @values.inspect\n end", "def inspect_values\n @values.inspect\n end", "def fields\n @fields ||= []\n end", "def fields\n self.class.fields\n end", "def fields\n self.class.fields\n end", "def fields\n self.class.fields\n end", "def fields\n self.class.fields\n end", "def field_options\n self.class.fields.values\n end", "def fields\r\n @hash.keys\r\n end", "def fields\n self.class.fields\n end", "def fields\n raw['fields']\n end", "def fields\n @fields ||= []\n end", "def fields\n klass.members.map(&:to_sym)\n end", "def nested_object_fields\n @nested_object_fields\n end", "def fields\n [*lookup]\n end", "def fields\n self.class.fields\n end", "def to_a\n @fields.collect { |field|\n [ field.name, field.value ]\n }\n end", "def fields; end", "def fields; end", "def fields; end", "def descMetadata_display_fields\n [:identifier, :title, :alternative, :creator, :contributor, :description, :abstract,\n :toc, :publisher, :source, :date, :date_created, :date_copyrighted,\n :date_submitted, :date_accepted, :date_issued, :date_available,\n :date_modified, :language, :type, :format, :extent, :medium, :persname,\n :corpname, :geogname, :subject, :genre, :provenance, :rights,\n :access_rights, :rights_holder, :license, :replaces, :isReplacedBy,\n :hasFormat, :isFormatOf, :hasPart, :isPartOf, :accrualPolicy, :audience,\n :references, :spatial, :bibliographic_citation, :temporal, :funder,\n :resolution, :bitdepth, :colorspace, :filesize]\n end", "def fields(klass, show_all = false)\n fields = send(:\"#{klass.to_s.underscore}_fields\") unless show_all\n fields = send(:\"#{klass.to_s.underscore}_all_fields\") if show_all\n fields\n end", "def fields\n return @fields if defined?(@fields)\n\n @fields = array_of_items_for(Fields, :fields)\n end", "def display\n @attributes[:display]\n end", "def field_values\n fieldset.get_values_using_fsa(self)\n end", "def fetch_fields\n @result.fetch_fields\n end", "def print_searchable_fields\n puts\n puts 'Searchable fields'\n puts '-----------------'\n @searchable_fields[@object].each { |field| puts field }\n puts '-----------------'\n end", "def fields\n properties.keys.map(&:to_sym)\n end", "def fields\n properties.keys.map(&:to_sym)\n end", "def fields\n schema.fields\n end", "def fields\n schema.fields\n end", "def fields\n schema.fields\n end", "def show(obj)\n y(obj.send(\"column_names\"))\nend", "def show(obj)\n y(obj.send(\"column_names\"))\nend", "def fields\n schema.fields\n end", "def attributes\n instance_values\n end", "def fields\n search.class.fields\n end", "def visible_fields\n fields.select {|f| f.visible? }\n end", "def values\n @fields.map { |field_name, field| field.values.map(&:to_s) }.transpose\n end", "def display_names\n collect { |a| a.display_name }\n end", "def display\n to_h.fetch(:display)\n end", "def display\n to_h.fetch(:display)\n end", "def values\n record && record.to_hash(fields)\n end", "def info_hash\n @fields\n end", "def inspect\n \"#<#{model.name} @values=#{inspect_values}>\"\n end", "def inspect\n \"#<#{model.name} @values=#{inspect_values}>\"\n end", "def show_fields=(fields)\n @show_fields = ::ActiveSupport::HashWithIndifferentAccess.new fields\n end", "def record_fields\n record_format.values_at(:key, :sys, :row).flatten.sort_by(&:position) if record_format\n end", "def salesforce_attributes ; @salesforce_fields.keys ; end", "def showable_columns\n showable_attributes.keys\n end", "def get_fields\n return (\n _get_specific_action_config(:action_fields, :fields)&.map(&:to_s) ||\n self.get_model&.column_names ||\n []\n )\n end", "def attributes\n instance_values\n end", "def inspect\n \"#<#{model.name} @values=#{@values.inspect}>\"\n end", "def fields()\n @@defined_subclass_field_lists[self.class]\n end", "def lookups\n (instance_type::INTERNAL_ATTRIBUTES + @mapping.salesforce_fields).uniq.join(\", \")\n end", "def ar_show_data \n result= []\n \n controller.ardata.fields.for_show.each do |column, title|\n label= ar_get_index_label(title)\n if label && !label.empty?\n result << content_tag(:dt, label)\n result << content_tag(:dd, ar_get_resource_value(@resource, column))\n end\n end\n \n content_tag :dl, result.join(\"\\n\")\n end", "def field_names\r\n return @field_names\r\n end", "def fields\n class_name.constantize.fields\n end", "def all_list_view_fields\n return @all_list_view_fields if defined? @all_list_view_fields\n\n @all_list_view_fields ||= all_fields.select(&:display_in_list)\n end", "def visible_fields\n CategoriesMovie::VisibleFields\n end", "def admin_display_fields\n admin.class.terminology.terms.keys - [:admin, :published_at, :edited_at, :template_name, :batch_id]\n end", "def result_fields\n @fields ||= result_meta.collect { |m| m.name }\n end", "def from_values\n d_attrs = development.reload.fields\n self.fields.map{ |field|\n name = field.fetch('name').to_s\n edit_from = field.fetch('from').to_s\n devel_from = d_attrs.fetch( name )\n [ devel_from, edit_from ]\n }\n end", "def get_fields()\n return @api.do_request(\"GET\", get_base_api_path() + \"/fields\")\n end", "def field_names\n internal_format.keys\n end", "def staff_request_all_fields\n StaffRequest.fields\n end" ]
[ "0.7486903", "0.7280955", "0.72705674", "0.7188775", "0.710983", "0.7091536", "0.7091536", "0.7091536", "0.7080267", "0.7077025", "0.7077025", "0.7073988", "0.6992585", "0.697879", "0.69406545", "0.69092053", "0.6907166", "0.6900813", "0.68896186", "0.6759189", "0.6722766", "0.6696035", "0.6693944", "0.6668246", "0.6668246", "0.66626287", "0.6636186", "0.6630611", "0.6628693", "0.66074854", "0.6555645", "0.6526019", "0.6524644", "0.6495578", "0.64370966", "0.64370966", "0.6433486", "0.64286214", "0.64286214", "0.64286214", "0.64286214", "0.64260775", "0.6405217", "0.64006954", "0.6373761", "0.63715184", "0.6367098", "0.6367061", "0.63560873", "0.63321304", "0.63300985", "0.63044447", "0.63044447", "0.63044447", "0.6303364", "0.6288922", "0.62835264", "0.628333", "0.62763184", "0.6241204", "0.6237543", "0.6235719", "0.6235719", "0.62286925", "0.62286925", "0.62286925", "0.62228477", "0.62228477", "0.6207517", "0.6201125", "0.6186714", "0.61761326", "0.61747676", "0.6168611", "0.6156776", "0.6156776", "0.61451465", "0.6142102", "0.6118148", "0.6118148", "0.6117586", "0.6113782", "0.61084616", "0.610846", "0.6102038", "0.6097058", "0.6094224", "0.6081664", "0.6077159", "0.60737634", "0.60616416", "0.60584015", "0.6055227", "0.60227317", "0.60147774", "0.6014552", "0.6007493", "0.5998442", "0.5995733", "0.59894407" ]
0.7910833
0
LookUp Hash for the menu item to the class name Hash
def menu_to_class_name {"user" => User, "collaborator" => Collaborator, "assignment" => Assignment, "link" => Link} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def menu_title_hash_by_action(class_string)\n {\"show\" => \"Here are all the #{class_string.pluralize}.\", \"update\" => \"Which #{class_string} do you want to update?\", \"delete\" => \"Which #{class_string} do you want to delete?\", \"create\" => \"Enter the variables to create a new #{class_string}.\"}\n end", "def menu_item_class(menu_item_title)\n @current_archive == Archive.ada && menu_item_title == @title ? \"current\" : \"\"\n end", "def get_item(item_name)\n return @menu[item_name]\n end", "def menu_item(name)\n self.div(:class=>/lhnavigation(_subnav|)_item_content/, :text=>name)\n end", "def active_link_class(item)\n active_class = 'active_menu_link'\n found = false\n case item.class.to_s\n when 'Project'\n found = true if (@project && @project == item) && (@stage.blank?)\n when 'Host'\n found = true if @host && @host == item\n when 'Recipe'\n found = true if @recipe && @recipe == item\n when 'User'\n found = true if @user && @user == item\n when 'Stage'\n found = true if @stage && @stage == item\n end\n \n if found\n active_class\n else\n ''\n end\n end", "def key\n self.class.item_name\n end", "def menu_items\n {\n :dashboard => {\n :content => \"#{link_to \"Dashboard\", url(:root)} [#{active_task_count}]\",\n :position => 1\n },\n :projects => {\n :content => link_to(\"Projects\", url(:projects)),\n :position => 2\n },\n :contexts => {\n :content => link_to(\"Contexts\", url(:contexts)),\n :position => 3\n },\n :new_action => {\n :content => \"+ #{link_to(\"Action\", url(:new_task))}\",\n :position => 4,\n :attrs => { :class => \"right\" }\n }\n }\n end", "def get_menu_index(menu, name)\n menu.find_index{|item| item[:title] == name }\n end", "def user_choice_of_object_in_class(class_object)\n create_menu = Menu.new(\"Which #{class_object.name} do you want to look up?\")\n all = class_object.all\n all.each_with_index do |object, x|\n create_menu.add_menu_item({key_user_returns: x + 1, user_message: object.to_s, do_if_chosen: \n [object]})\n end\n return run_menu(create_menu)[0]\n end", "def user_choice_of_object_in_class(class_object)\n create_menu = Menu.new(\"Which #{class_object.name} do you want to look up?\")\n all = class_object.all\n all.each_with_index do |object, x|\n object_to_s = object.attributes.map{|k,v| \"#{k}: #{v}\"}.join(', ')\n create_menu.add_menu_item({key_user_returns: x + 1, user_message: object_to_s, do_if_chosen: \"#{object.id}\"})\n end\n create_menu\n end", "def name\n object.try(:menu_display_name)\n end", "def activate_menu(menu_class, selected_menu)\r\n class_list = menu_class\r\n class_list += (selected_menu == menu_class) ? \" active\" : \"\"\r\n end", "def main_menu\n h = { \n :a => :ack,\n \"/\" => :ffind,\n :l => :locate,\n :v => :viminfo,\n :z => :z_interface,\n :d => :child_dirs,\n :r => :recent_files,\n :t => :dirtree,\n \"4\" => :tree,\n :s => :sort_menu, \n :F => :filter_menu,\n :c => :command_menu ,\n :B => :bindkey_ext_command,\n :M => :newdir,\n \"%\" => :newfile,\n :x => :extras\n }\n menu \"Main Menu\", h\nend", "def main_menu\n h = {\n a: :ag,\n z: :z_interface,\n # f: :file_actions,\n b: :bookmark_menu,\n c: :create_menu,\n f: :filter_menu,\n o: :order_menu,\n s: :selection_menu,\n t: :toggle_menu,\n v: :view_menu,\n '`' => :goto_parent_dir,\n x: :extras\n }\n menu 'Main Menu', h\nend", "def goto(item)\n\t\t\t@hash[item] ? @hash[item] : @hash.default\n\t\tend", "def main_menu\n h = { \n \"1\" => :view_article,\n \"2\" => :view_comments,\n :f => :display_forum,\n :v => :view_menu,\n :r => :reload,\n :m => :fetch_more,\n :R => :reddit_options,\n :H => :hacker_options,\n :s => :sort_menu, \n :C => :config_menu,\n :a => :view_article,\n :c => :view_comments,\n :x => :extras\n }\n=begin\n :a => :ack,\n \"/\" => :ffind,\n :l => :locate,\n :v => :viminfo,\n :z => :z_interface,\n :d => :child_dirs,\n :r => :recent_files,\n :t => :dirtree,\n \"4\" => :tree,\n :F => :filter_menu,\n :c => :command_menu ,\n :B => :bindkey_ext_command,\n :M => :newdir,\n \"%\" => :newfile,\n=end\n\n menu \"Main Menu\", h\nend", "def get_Menu_Item\n item_name = session[:goldberg][:menu_item]\n end", "def set_menu_class\n @menu_class = MenuClass.find(params[:id])\n end", "def menu_item_name\n menu_options[:label] || plural_resource_name_alias.html_safe\n end", "def getMenu(menu)\n end", "def class_name\n return @options[:class_name] if not @options[:class_name].nil?\n class_main_found = false\n @catalog['resources'].each_with_index do |r,i|\n if r['type'] == 'Class' and r['title'] == 'main'\n class_main_found = true\n next\n end\n if class_main_found and r['type'] == 'Class'\n return r['title'].downcase\n end\n end\n end", "def tabclass(cname)\n #change cname to the correct selected tab name in exceptional cases:\n case controller.controller_name\n when 'inventory_items'\n rcname = 'reports'\n when 'comments',\n 'line_items',\n 'subcontractors',\n 'subcontracts'\n rcname = 'contracts'\n when 'audits',\n 'dropdowns',\n 'import',\n 'roles',\n 'users'\n rcname = 'admin'\n when 'appgen_orders',\n 'io_slots',\n 'ioscans',\n 'servers',\n 'swlist_blacklists',\n 'swlist_whitelists',\n 'swlists',\n 'swproducts',\n 'upfront_orders'\n rcname = 'tools'\n when 'hw_support_prices',\n 'manufacturers',\n 'manufacturer_lines',\n 'sw_support_prices'\n rcname = 'prices'\n else\n rcname = controller.controller_name\n end\n #general case\n if cname == rcname\n return(\"menuSelected\")\n else\n return(\"menuUnselected\")\n end\n\n end", "def object_menu(class_name, action)\n class_string = class_name.to_s.underscore.downcase\n create_menu = Menu.new(menu_title_hash_by_action(class_string.humanize.downcase)[action])\n all = class_name.all\n all.each_with_index do |object, x|\n create_menu.add_menu_item({user_message: get_object_display_message(object), method_name: \"#{class_string}/#{action}/#{object.id}\"})\n end\n create_menu\n end", "def active_menu\n active[:main_menu].try(:to_s)\n end", "def menu_item(path)\r\n current_menu_items = root_menu_items\r\n matching_menu_item = nil\r\n path.each_with_index do |target_menu_item, index|\r\n case current_menu_items\r\n when Array\r\n matching_menu_item = current_menu_items.find {|node| node.name == target_menu_item} #TODO: make this work with regexes as well as strings...\r\n raise Bewildr::ElementDoesntExist if matching_menu_item.nil?\r\n when Bewildr::Element\r\n if current_menu_items.name == target_menu_item #TODO: make this work with regexes as well as strings...\r\n matching_menu_item = current_menu_items\r\n else\r\n raise Bewildr::ElementDoesntExist\r\n end\r\n end\r\n raise Bewildr::ElementDoesntExist if matching_menu_item.nil?\r\n if path.size != index + 1\r\n matching_menu_item.expand\r\n current_menu_items = matching_menu_item.sub_menus\r\n end\r\n end\r\n return matching_menu_item\r\n end", "def currentMenuItem(expected, controller, action) \t\t\n \t\treturn \"class=active\" if expected == (controller + \"#\" + action)\n\tend", "def build_item_class(i, options, active_ids)\n\n item_class = []\n\n item_class << options[:item_class]\n item_class << i.css_class\n\n if i.has_children?\n item_class << options[:item_with_children_class]\n else\n item_class << options[:item_without_children_class]\n end\n\n item_class << options[:active_class] if i.slug == params[:menu_id] || i.slug == request.original_fullpath.match(/(\\D+\\/{1}|\\D+)/)[0].gsub('/', '') || active_ids.include?(i.id)\n item_class.compact.join(\" \")\n end", "def type\n \"mymenu\"\n end", "def method_missing(sym, *args, &block)\n return @klass_hash[sym.to_s]\n end", "def map_objectName_className(ui_file)\n doc = REXML::Document.new File.new ui_file\n mapping = Hash.new\n REXML::XPath.each( doc, \"//widget\")do |ele|\n mapping[ele.attributes[\"name\"]] = ele.attributes[\"class\"]\n end\n mapping\n end", "def right_js_classes_menu\n packs = {}\n Unit.all.each do |unit|\n packs[unit.package] ||= []\n packs[unit.package] << unit\n end\n\n packs.keys.sort.collect { |package|\n content_tag(:label, package.capitalize) +\n content_tag(:ul, packs[package].collect { |unit|\n menu_link_to(unit.name, unit, {}, request.request_uri == unit_path(unit))+\n (@unit == unit ? right_js_unit_menu(unit) : '')\n })\n }.join(\"\\n\")\n end", "def customizeMenu\n menu[:proteins] = [\"Tofurkey\", \"Hummus\"]\n menu[:veggies] = [:ginger_carrots , :potatoes, :yams]\n menu[:desserts] = { :pies => [:pumkin_pie],\n :other => [\"Chocolate Moose\"],\n :molds => [:cranberry, :mango, :cherry] }\n end", "def find_class_named name\n @classes_hash[name]\n end", "def active_item\n return @active_item if @active_item\n # Simple configuration means that name is returned immediately\n @active_item = get_value(controller_active_item_config)\n\n # If the configuration is a Hash then we need to find the first\n # menu item that has a passing condition\n if @active_item.is_a? Hash\n @active_item.each do |condition, key|\n @active_item = key and break if @template.instance_eval(condition)\n end\n end\n @active_item\n end", "def item_class\n item_type&.classify&.constantize\n end", "def menu_item_name(match)\n return match if match.is_a?(String) || @orginal_menu.nil?\n item_by_name = []\n match.each do |mat|\n item = @orginal_menu.select {|m| mat == m.price}.collect(&:item_name)\n item_by_name <<\n if item.size > 1\n ## If there are multipule items in item than that means that there\n ## are replacement items -- aka menu_items with the same value so we\n ## should suggest those as 1 to 1 replacements in the solutions\n create_suggestion_list(item)\n else\n item\n end\n end\n item_by_name.join(\", \")\n end", "def hash_key\n send(self.class.hash_key)\n end", "def hash_key\n send(self.class.hash_key)\n end", "def submenuhash(id, description)\n {:class => 'submenu', :onmouseover => \"commandDescOn('#{id}','#{description}');\", :onmouseout => \"commandDescOff('#{id}');\"}\n end", "def items_menu_label(item, label: nil)\n label ||= item.menu_label\n label ||= \"#{model_item_name(capitalize: true)} #{item.id}\"\n ERB::Util.h(label)\n end", "def admin_active_class(key)\n request.original_url.include?('/' + key) ? 'active' : ''\n end", "def main_Menu_Name\n Goldberg.menu.main_Menu_Name\n end", "def backstage_navigation_item(id, href, controllers = [])\n if controllers.empty? then controllers = [ id.to_s ] end\n\n selected = controllers.any? { |c| c == controller_name } && ' selected'\n\n title = t :\"backstage.navigation.#{id}.title\"\n name = t :\"backstage.navigation.#{id}.name\"\n\n <<-HTML.html_safe\n <li class=\"#{ h id }#{ selected or '' }\">\n <a href=\"#{ href }\" title=\"#{ h title }\">\n <span class=\"icon\">#{ h name }</span>\n </a>\n </li>\n HTML\n end", "def list_optshash(classname, args = {})\n Knj::ArrayExt.hash_sym(args)\n classname = classname.to_sym\n\n if args[:list_args].is_a?(Hash)\n list_args = args[:list_args]\n else\n list_args = {}\n end\n\n if RUBY_VERSION[0..2] == 1.8 and Php4r.class_exists(\"Dictionary\")\n list = Dictionary.new\n else\n list = {}\n end\n\n if args[:addnew] or args[:add]\n list[\"0\"] = _(\"Add new\")\n elsif args[:choose]\n list[\"0\"] = _(\"Choose\") + \":\"\n elsif args[:all]\n list[\"0\"] = _(\"All\")\n elsif args[:none]\n list[\"0\"] = _(\"None\")\n end\n\n self.list(classname, args[:list_args]) do |object|\n if object.respond_to?(:name)\n list[object.id] = object.name\n elsif object.respond_to?(:title)\n list[object.id] = object.title\n else\n raise \"Object of class '#{object.class.name}' doesnt support 'name' or 'title.\"\n end\n end\n\n return list\n end", "def navmenu_id which\n \"#{which}-navmenu\"\n end", "def current_menu_item\n if action_name == \"index\"\n loaded_menu_items[-2]\n else\n loaded_menu_items[-1]\n end\n end", "def classes_hash\n @classes\n end", "def classes_hash\n @classes\n end", "def menu_from_tag(t)\n if t.menu && t.target_tag.present?\n [(t.target_tag.predefined_class.blank? ? feature_path(t.target_tag.slug) : predefined_tags[t.target_tag.predefined_class]), '#', t.target_name].join\n else\n predefined_tags[t.predefined_class] || feature_path(t.slug)\n end\n end", "def item\n item_type.name.classify.constantize.find(item_id)\n end", "def menu title, h\n case h\n when Hash\n ; # okay\n when Array\n # convert array to a hash using letters for key\n x = \"a\"\n hash = Hash.new\n h.each do |e|\n hash[x] = e\n x.succ!\n end\n h = hash\n end\n return unless h\n\n kmax_length = h.keys.max_by(&:length).length\n vmax_length = h.values.max_by(&:length).length\n puts \"#{ON_BLUE}#{title}#{CLEAR}\"\n h.each_pair { |k, v| \n d = get_action_desc(v) || \"\"\n printf \" #{BOLD}%-*s#{CLEAR} %-*s #{BOLD}%s#{CLEAR}\\n\", kmax_length,k, vmax_length,v, d \n }\n ch = get_char\n binding = h[ch]\n binding = h[ch.to_sym] unless binding\n if binding\n if respond_to?(binding, true)\n send(binding)\n end\n end\n return ch, binding\nend", "def lookup (key)\n\n if key.kind_of?(Class)\n @application_context.each do |k, value|\n return value if value.class == key\n end\n return nil\n end\n\n @application_context[key]\n end", "def menu(current)\n Model::MENU.map{ |m|\n li_class =\n [current == m[:section] ? \"active\" : \"\", m[:cls].to_s].join(\" \")\n \"<li class=\\\"#{li_class}\\\"><a href=\\\"#{m[:href]}\\\">#{m[:label]}</a>\"\n }.join(\"\")\n end", "def getMenu(menu)\n menu.add_item(\"Done\") {self.done}\n menu.add_item(\"Edit Camera...\") {self.edit}\n menu.add_item(\"Reset Tilt\") {self.reset_tilt}\nend", "def get_current_menu_item\n return @jsession_store.get_session[:active_transaction].pdt_method.program_name.to_s if(@jsession_store.get_session[:active_transaction]!=nil && self.class.name != @jsession_store.get_session[:active_transaction].class.name)\n if @pdt_method\n return @pdt_method.program_name\n end\n return nil\n end", "def mobile_menu_item(item_name)\n menu_list = @browser.find_elements(:class, 'dialog-list')\n item_found = nil\n menu_list.each do |item|\n item_found = item if item.text == item_name\n end\n item_found\n end", "def classes_hash\n @classes_hash\n end", "def jssh2firewatir(candidate_class)\r\n hash = {\r\n 'Div' => 'Div',\r\n 'Button' => 'Button',\r\n 'Frame' => 'Frame',\r\n 'Span' => 'Span',\r\n 'Paragraph' => 'P',\r\n 'Label' => 'Label',\r\n 'Form' => 'Form',\r\n 'Image' => 'Image',\r\n 'Table' => 'Table',\r\n 'TableCell' => 'TableCell',\r\n 'TableRow' => 'TableRow',\r\n 'Select' => 'SelectList',\r\n 'Link' => 'Link',\r\n 'Anchor' => 'Link' # FIXME is this right?\r\n #'Option' => 'Option' #Option uses a different constructor\r\n }\r\n hash.default = 'Element'\r\n hash[candidate_class]\r\n end", "def get_item(key)\n self[key]\n end", "def get_as_class_name obj\n # Get class name\n if obj.is_a?(String)\n ruby_class_name = obj\n elsif obj.is_a?(RocketAMF::Values::TypedHash)\n ruby_class_name = obj.type\n elsif obj.is_a?(Hash)\n return nil\n elsif obj.is_a?(RubyAMF::IntermediateObject)\n ruby_class_name = obj.object.class.name\n else\n ruby_class_name = obj.class.name\n end\n\n # Get AS class name\n as_class_name = @mappings.get_as_class_name ruby_class_name\n\n # Auto-map if necessary, removing namespacing to create mapped class name\n if RubyAMF.configuration.auto_class_mapping && ruby_class_name && as_class_name.nil?\n as_class_name = ruby_class_name.split('::').pop\n @mappings.map :as => as_class_name, :ruby => ruby_class_name\n end\n\n as_class_name\n end", "def view_menu\n h = {\n f: :select_from_visited_files,\n d: :select_from_used_dirs,\n b: :view_bookmarks,\n s: :list_selected_files,\n c: :child_dirs,\n r: :recent_files,\n t: :tree,\n e: :dirtree\n }\n menu 'View Menu', h\nend", "def get_class(className)\n prefix = options[:class_prefix] || \"simple-navigation\"\n \"#{prefix}#{className}\"\n end", "def create_menu\n items = Hash.new\n # action shd be a hash\n # menu should have array of hashes (or just a string)\n #db = { :name => \"Databases\", :accelerator => \"M-d\", :enabled = true, :on_right => :get_databases }\n #or = { :name => \"Open Recent\", :accelerator => \"M-o\", :enabled = true, :on_right => :get_recent }\n #find_array = {\"Find ...\" => :find, \"Find Next\" => :find_next, \"Find Previous\" => :find_prev}\n items[\"File >\"] = [\"Open ... C-o\" , \"Open Recent\", \"Databases\" , \"Tables\", \"Exit\"]\n items[\"Window >\"] = { \"Tile\" => nil, \"Find >\" => {\"Find ...\" => :find, \"Find Next\" => :find_next, \"Find Previous\" => :find_prev},\n \"Edit\" => nil, \"Whatever\" => nil}\n items[\"Others >\"] = { \"Shell Output ...\" => :shell_output, \"Suspend ...\" => :suspend , \"View File\" => :choose_file_and_view}\n\n # in the case of generated names how will call back know that it is a db name or a table name\n # We get back an array containing the entire path of selections\n right_actions = {}\n right_actions[\"Databases\"] = Proc.new { Dir.glob(\"**/*.{sqlite,db}\") }\n right_actions[\"Tables\"] = :get_table_names\n\n ret = popupmenu items, :row => 1, :col => 0, :bgcolor => :cyan, :color => :white, :right_actions => right_actions\n # ret can be nil, or have a symbol to execute, or a String for an item with no leaf/symbol\n if ret\n alert \"Got #{ret}\"\n last = ret.last\n if last.is_a? Symbol\n if respond_to?(last, true)\n send(last)\n end\n end\n end\n\n return\n r = 1\n ix = popuplist( top , :title => \" Menu \" , :row => r, :col => 0, :bgcolor => :cyan, :color => :white)\n if ix\n value = top[ix]\n ix = popuplist( items[value] , :row => r + 2 + ix, :col => 10, :bgcolor => :cyan, :color => :white)\n end\nend", "def [](key)\r\n self.class[key]\r\n end", "def assigned_menu\n\n end", "def return_to_menu(input)\n if input.downcase == \"menu\"\n menu_items\n end\nend", "def get(node, key)\n return nil unless map.key?(key)\n\n map[key].map do |matcher|\n return matcher[:klass] if node_matches?(node, matcher)\n end\n nil\n end", "def find_item_by_path(*path)\n path.inject(self) do |parent_item, name|\n return if !name\n if names = @names_to_item[parent_item]\n names[name]\n end\n end\n end", "def menu_class_params\n params.require(:menu_class).permit(:name)\n end", "def selection_menu\n h = {\n a: :select_all,\n u: :unselect_all,\n s: :toggle_select,\n '*' => 'toggle_multiple_selection',\n 'x' => 'toggle_visual_mode',\n 'm' => 'toggle_selection_mode',\n v: :view_selected_files\n }\n menu 'Selection Menu', h\nend", "def menuitem(title, options={}, &block)\n options[:id] = \"mitem-#{rand.to_s.split('.').last}\" if options[:id].nil?\n options[:title] = title\n @menuinfo[menu_number][:menuitems] << options\n nil\n end", "def create_menu\n h = { f: :create_a_file,\n d: :create_a_dir,\n s: :create_dir_with_selection,\n b: :create_bookmark }\n _, menu_text = menu 'Create Menu', h\nend", "def link_id\n names = @resources.map do |resource|\n case resource\n when Class\n resource.name.pluralize.downcase\n else\n resource.class.name.downcase\n end\n end\n \"menu_#{names.join('_')}_link\"\n end", "def nav_menu_item(menu_label, &block)\n \n icon = case menu_label\n when 'category' ; \"<i class='icon-tag'></i>\"\n when 'user' ; \"<i class='icon-user'></i>\"\n when 'post' ; \"<i class='icon-font'></i>\"\n when 'comment' ; \"<i class='icon-comment'></i>\"\n when 'archive' ; \"<i class='icon-upload'></i>\"\n end \n\n menu_label = t(\"activerecord.models.#{menu_label}\")\n content_tag(:li, :class => 'dropdown') do \n link_to(\"#{icon} #{menu_label} <b class='caret'></b>\".html_safe, '#', :class => 'dropdown-toggle', :data => { :toggle => 'dropdown' }) +\n content_tag(:ul, :class => 'dropdown-menu') do \n capture(&block)#yield\n end\n end\n end", "def create_hash_class \n\t hash_class = {}\n\t @students_list.select do |student|\n\t\thash_class[student.name] = student.create_score_hash\n\t end\n\t puts \"Class's Hash: #{hash_class}\"\n\tend", "def build_menu\n comment = table_info['comment']\n # #puts \"build Rails menu for #{model_name} (#{comment}) in\n # app/views/shared\"\n @@menus << { :model_name => model_name, :comment => comment, :route => \"/\"+ plural_table_name}\n \n end", "def set_menu_item\n @menu_item = Menu::Item.find(params[:id])\n end", "def navtab_replacement which\n [ \"ul##{navmenu_id(which)}\", method(:\"#{which}_navtab\").call(true) ]\n end", "def menu_items\n menu.items(self)\n end", "def menu_items\n menu.items(self)\n end", "def name()\n return self.manager.dictionary[self]\n end", "def menu_items\n MenuItem.all.select {|item| item.recipe == self}\n end", "def key\n self.class.name.split(/::/).last.underscore\n end", "def hash\n self.class.name.hash\n end", "def title\n item_hash.deep_find(:title)\n end", "def find_index_class(symbol_or_class)\n\n\n\n case symbol_or_class\n\n\n\n when Symbol\n\n\n\n ::ActiveAdmin::Views.const_get(\"IndexAs\" + symbol_or_class.to_s.camelcase)\n\n\n\n when Class\n\n\n\n symbol_or_class\n\n\n\n end\n\n\n\n end", "def current_menu_item\n controller.current_menu_item\n end", "def define_menu_items\n add_menu_item(\"Http request\", 1)\n add_menu_item(\"Http status\", 2)\n add_menu_item(\"Sourceadress\", 3)\n add_menu_item(\"Timestamp\", 4)\n end", "def select_menu(menu_item)\n session[:active_menu] = menu_item\n end", "def menu\n [\n {item: \"hotdog\", display: \"Hot Dog\", price: 7.50},\n {item: \"sushi\", display: \"Sushi\", price: 13.00},\n {item: \"greendrink\", display: \"Green Drink\", price: 5.50},\n {item: \"burrito\", display: \"Burrito\", price: 6.00}\n ]\nend", "def get_current_value(classname)\n current_value = 0\n @id.each do |key, val|\n if classname == key\n current_value = val\n break\n end\n end\n current_value\n end", "def menu_items\n\n menu.items(self)\n\n end", "def camaleon_spree_on_parse_custom_menu_item(args)\n if args[:menu_item].kind == 'Spree::Taxon'\n taxon = Spree::Taxon.find(args[:menu_item].url)\n res = {name: taxon.name, link: spree.nested_taxons_path(taxon.permalink)}\n res[:current] = site_current_path == res[:link] unless args[:is_from_backend]\n args[:parsed_menu] = res\n end\n\n if args[:menu_item].kind == 'Spree::Product'\n product = Spree::Product.find(args[:menu_item].url)\n res = {name: product.name, link: spree.product_path(product)}\n res[:current] = site_current_path == res[:link] unless args[:is_from_backend]\n args[:parsed_menu] = res\n end\n end", "def css_classes_for(classname)\n css_classes_for_map classname, mapping\n end", "def menu\n response[\"menu\"]\n end", "def set_menu_item\n @menu_item = @menu.menu_items.find(params[:id])\n end", "def crud_menu(class_name)\n class_string = class_name.to_s.underscore.downcase\n m = Menu.new(\"What would you like to do with #{class_string.humanize.downcase.pluralize}?\")\n m.add_menu_item(user_message: [\"Create a new #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/create\")\n m.add_menu_item(user_message: [\"Show all #{class_string.humanize.downcase.pluralize}.\"], method_name: \"#{class_string}/show\")\n m.add_menu_item(user_message: [\"Update a #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/update\")\n m.add_menu_item(user_message: [\"Delete a #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/delete\")\n m\n end", "def main_menu_nav(main_menu_item)\n main_menu_items.each do |item|\n if item.text == main_menu_item\n item.click\n break\n end\n end\n end", "def menu_item(name, path, *link_hashes)\n content_tag :li do\n link = link_to(name, path) if permit_path?(path)\n sub = menu_list_if_permitted(*link_hashes) unless link_hashes.empty?\n link.to_s + sub.to_s\n end\n end", "def menu menu_name, options = {}\n\toptions = {\n\t :dir_class => 'dir',\n\t :active_dir_class => 'active',\n\t :active_link_class => 'active',\n\t :root => nil\n\t}.deep_merge(options)\n\n\tul_li_menu(menu_name,options) do |page|\n\t if page[:page].page_type=='directory'\n\t page[:page].menu\n\t else\n\t %[<a href=\"#{root_url+page[:page].url}\" #{%[class=\"#{options[:active_link_class]}\"] if options[:active_link_class] && page[:page]==@page}>#{page[:page].menu}</a>]\n\t end\n\tend\n end" ]
[ "0.66190386", "0.6362807", "0.6255457", "0.600285", "0.5979732", "0.5927564", "0.58665866", "0.57631284", "0.5714907", "0.56765085", "0.5644437", "0.5602703", "0.5592349", "0.55862653", "0.55572945", "0.5556307", "0.5542953", "0.5542759", "0.5541755", "0.5540217", "0.5513372", "0.5509219", "0.5506171", "0.5480022", "0.54616755", "0.5409477", "0.5392209", "0.5375156", "0.5332197", "0.53001636", "0.52997637", "0.5282501", "0.527636", "0.52707845", "0.52692395", "0.52669424", "0.5245262", "0.5245262", "0.52330667", "0.5230962", "0.5230947", "0.5223225", "0.52192754", "0.5205335", "0.5196873", "0.5188238", "0.5175101", "0.5175101", "0.51582694", "0.5146363", "0.5140823", "0.51039714", "0.5099765", "0.5096655", "0.50816697", "0.507038", "0.5067289", "0.5063697", "0.5052783", "0.50501055", "0.5050014", "0.50486654", "0.50335044", "0.50235116", "0.5019237", "0.50188357", "0.50074255", "0.50045776", "0.50031924", "0.4999379", "0.49956456", "0.4992244", "0.49862623", "0.49828395", "0.49780723", "0.49533007", "0.49146378", "0.49128997", "0.4909952", "0.4909952", "0.49021068", "0.48933938", "0.48896867", "0.48892918", "0.48885435", "0.48833814", "0.4883195", "0.4880275", "0.48765093", "0.48709613", "0.48682696", "0.48651582", "0.48643732", "0.48635596", "0.48622054", "0.48563045", "0.4849805", "0.4849681", "0.48465025", "0.4835715" ]
0.70370597
0
LookUp Hash to get the menu title, based on the class and action returns a String
def menu_title_hash_by_action(class_string) {"show" => "Here are all the #{class_string.pluralize}.", "update" => "Which #{class_string} do you want to update?", "delete" => "Which #{class_string} do you want to delete?", "create" => "Enter the variables to create a new #{class_string}."} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def menu_title\n to_s\n end", "def menu title, h\n case h\n when Hash\n ; # okay\n when Array\n # convert array to a hash using letters for key\n x = \"a\"\n hash = Hash.new\n h.each do |e|\n hash[x] = e\n x.succ!\n end\n h = hash\n end\n return unless h\n\n kmax_length = h.keys.max_by(&:length).length\n vmax_length = h.values.max_by(&:length).length\n puts \"#{ON_BLUE}#{title}#{CLEAR}\"\n h.each_pair { |k, v| \n d = get_action_desc(v) || \"\"\n printf \" #{BOLD}%-*s#{CLEAR} %-*s #{BOLD}%s#{CLEAR}\\n\", kmax_length,k, vmax_length,v, d \n }\n ch = get_char\n binding = h[ch]\n binding = h[ch.to_sym] unless binding\n if binding\n if respond_to?(binding, true)\n send(binding)\n end\n end\n return ch, binding\nend", "def menu_to_class_name\n {\"user\" => User, \"collaborator\" => Collaborator, \"assignment\" => Assignment, \"link\" => Link}\n end", "def menu_action(action)\n if menu_action?(action)\n action.to_sym\n else\n \"#{action}#{SELECT_ACTION_SUFFIX}\".to_sym\n end\n end", "def name\n object.try(:menu_display_name)\n end", "def human_title_name(action, options = {})\n defaults = lookup_ancestors.map do |klass|\n :\"#{self.i18n_scope}.titles.#{klass.model_name.i18n_key}.#{action}\"\n end\n \n defaults << :\"titles.#{action}\"\n defaults << options.delete(:default) if options[:default]\n defaults << action.to_s.humanize\n \n options.reverse_merge! :default => defaults\n I18n.translate(defaults.shift, options)\n end", "def menu_item_class(menu_item_title)\n @current_archive == Archive.ada && menu_item_title == @title ? \"current\" : \"\"\n end", "def object_menu(class_name, action)\n class_string = class_name.to_s.underscore.downcase\n create_menu = Menu.new(menu_title_hash_by_action(class_string.humanize.downcase)[action])\n all = class_name.all\n all.each_with_index do |object, x|\n create_menu.add_menu_item({user_message: get_object_display_message(object), method_name: \"#{class_string}/#{action}/#{object.id}\"})\n end\n create_menu\n end", "def mod_to_title\n entities = {\n '⌃' => 'Control',\n '⌥' => 'Option',\n '⇧' => 'Shift',\n '⌘' => 'Command',\n 'Fn' => 'Function'\n }\n entities.key?(self) ? entities[self] : self\n end", "def title\n if detail_page?\n \"#{resource.name} - #{menu.name} - #{website_tag.name}\"\n else\n \"#{menu.name} - #{website_tag.name}\" \n end \n end", "def getMenu(menu)\n end", "def side_menu_title(resource_key)\n return \"\" if resource_key.blank?\n html = <<-HTML\n <h3>#{t(resource_key)}</h3>\n HTML\n html.html_safe\n end", "def create_menu\n h = { f: :create_a_file,\n d: :create_a_dir,\n s: :create_dir_with_selection,\n b: :create_bookmark }\n _, menu_text = menu 'Create Menu', h\nend", "def menu_item_name\n menu_options[:label] || plural_resource_name_alias.html_safe\n end", "def type\n \"mymenu\"\n end", "def main_menu\n h = {\n a: :ag,\n z: :z_interface,\n # f: :file_actions,\n b: :bookmark_menu,\n c: :create_menu,\n f: :filter_menu,\n o: :order_menu,\n s: :selection_menu,\n t: :toggle_menu,\n v: :view_menu,\n '`' => :goto_parent_dir,\n x: :extras\n }\n menu 'Main Menu', h\nend", "def build_title(action, title)\n if !!action &&\n ([:edit, :show, :list, :back, :cancel].include? action.to_sym)\n prev = action.to_s.humanize\n title.blank? ? prev : \"#{prev} #{title}\"\n else\n title.to_s\n end\n end", "def main_Menu_Name\n Goldberg.menu.main_Menu_Name\n end", "def title_page(controller_name)\n raw=controller_name.split(/[_\\/]/)\n if raw[0] == \"order\"\n 3.times do |i|\n raw.shift\n end\n end\n\n if raw[0] == \"setting\"\n raw.shift\n end\n\n case params[:action]\n when 'show'\n raw.insert((raw.count + 1), 'detail')\n when \"new\"\n raw.insert(0, 'new')\n when \"edit\"\n raw.insert(0, 'edit')\n when \"edit_level_limit\"\n raw.insert(0, 'change level limit')\n when \"get_grn_history\"\n raw.insert(0, 'History of')\n when \"get_grpc_history\"\n raw.insert(0, 'History of')\n when \"features\"\n raw.insert(0, 'Set Feature')\n when \"get_report\"\n raw.insert(0, \"#{params[:search][:order_type].gsub('_', ' ')} Report\")\n when \"detail_report_return\"\n raw.insert(0, \"Detail #{params[:title].gsub('_', ' ')} Report\")\n when \"detail_report_orders\"\n raw.insert(0, \"Detail #{params[:title].gsub('_', ' ')} Report\")\n when \"detail_report_debit_note\"\n raw.insert(0, \"Detail #{params[:title].gsub('_', ' ')} Report\")\n when \"service_level_suppliers\"\n raw.insert(0, \"#{params[:action].gsub('_', ' ')}\")\n when \"on_going_disputes\"\n type = params[:type] == \"GRN\" ? GRN : GRPC\n raw.insert(0, \"#{params[:action].gsub('_', ' ')} (#{type})\")\n when \"pending_deliveries\"\n raw.insert(0, \"#{params[:action].gsub('_', ' ')}\")\n when \"returned_histories\"\n raw.insert(0, \"#{params[:action].gsub('_', ' ')}\")\n when \"returned_history_details\"\n raw.insert(0, \"#{params[:action].gsub('_', ' ')}\")\n when \"on_going_dispute_details\"\n type = params[:type] == \"GRN\" ? GRN : GRPC\n raw.insert(0, \"#{params[:action].gsub('_', ' ')} (#{type})\")\n when \"pending_delivery_details\"\n raw.insert(0, \"#{params[:action].gsub('_', ' ')}\")\n end\n\n unless params[:action] == \"index\"\n temp = raw[-1].singularize\n raw[-1] = temp\n end\n\n #khusus hanya untuk reporting dashboard\n if params[:controller].downcase == \"dashboards\" && params[:action] == \"get_report\"\n title=raw[0].titleize\n elsif params[:controller].downcase == \"dashboards\" && params[:action] == \"detail_report_orders\"\n title=raw[0].titleize\n elsif params[:controller].downcase == \"dashboards\" && params[:action] == \"detail_report_debit_note\"\n title=raw[0].titleize\n elsif params[:controller].downcase == \"dashboards\" && params[:action] == \"detail_report_return\"\n title=raw[0].titleize\n else\n title=raw.join(' ').titleize\n end\n\n if title == 'Companies' || title == 'Company'\n case params[:action]\n when 'index'\n title = \"Company Profile\"\n when 'new'\n title = \"Create Company Profile\"\n when 'edit'\n title = \"Edit Company Profile\"\n end\n end\n\n js= \"<script>\n $('.title-page').html('#{get_alias_title_name_controller(title)}');\n </script>\"\n return js.html_safe\n end", "def expert_system_title(action)\n base_title = \"Expert system\"\n if action.empty?\n base_title\n else\n \"#{action} #{base_title}\"\n end\n end", "def title\n\t\tklass == '-' ? TYPE_ABBREVIATIONS[type] || type : klass\n\tend", "def autotitle\n [:controller, :action].map { |e| params[e].to_s.singularize.titleize }.join(\" · \").html_safe\n end", "def title\n @hash[\"Title\"]\n end", "def main_menu\n h = { \n \"1\" => :view_article,\n \"2\" => :view_comments,\n :f => :display_forum,\n :v => :view_menu,\n :r => :reload,\n :m => :fetch_more,\n :R => :reddit_options,\n :H => :hacker_options,\n :s => :sort_menu, \n :C => :config_menu,\n :a => :view_article,\n :c => :view_comments,\n :x => :extras\n }\n=begin\n :a => :ack,\n \"/\" => :ffind,\n :l => :locate,\n :v => :viminfo,\n :z => :z_interface,\n :d => :child_dirs,\n :r => :recent_files,\n :t => :dirtree,\n \"4\" => :tree,\n :F => :filter_menu,\n :c => :command_menu ,\n :B => :bindkey_ext_command,\n :M => :newdir,\n \"%\" => :newfile,\n=end\n\n menu \"Main Menu\", h\nend", "def apphelp_heading( ctrl = controller, action = nil, default = nil )\n action ||= ctrl.action_name\n\n t(\n \"uk.org.pond.canvass.controllers.#{ ctrl.controller_name }.action_title_#{ action }\",\n :default => default\n )\n end", "def title\n @title ||= heirarchy.full_name\n end", "def title_view\n html = \"\"\n html << \"<span class=\\\"icon12 icomoon-icon-home home_page\\\"></span>\" if self[:home_page]\n html << (ActionController::Base.helpers.link_to self[:title], ApplicationController.helpers.edit_url(self.class.base_class, self))\n html.html_safe\n end", "def action\n \treturn self[:action].to_sym\n \n end", "def menu_items\n {\n :dashboard => {\n :content => \"#{link_to \"Dashboard\", url(:root)} [#{active_task_count}]\",\n :position => 1\n },\n :projects => {\n :content => link_to(\"Projects\", url(:projects)),\n :position => 2\n },\n :contexts => {\n :content => link_to(\"Contexts\", url(:contexts)),\n :position => 3\n },\n :new_action => {\n :content => \"+ #{link_to(\"Action\", url(:new_task))}\",\n :position => 4,\n :attrs => { :class => \"right\" }\n }\n }\n end", "def title\n item_hash.deep_find(:title)\n end", "def action_name\n @action.to_s.upcase\n end", "def title\n \"#{event.kind} #{action}\"\n end", "def view_menu\n h = {\n f: :select_from_visited_files,\n d: :select_from_used_dirs,\n b: :view_bookmarks,\n s: :list_selected_files,\n c: :child_dirs,\n r: :recent_files,\n t: :tree,\n e: :dirtree\n }\n menu 'View Menu', h\nend", "def main_menu\n h = { \n :a => :ack,\n \"/\" => :ffind,\n :l => :locate,\n :v => :viminfo,\n :z => :z_interface,\n :d => :child_dirs,\n :r => :recent_files,\n :t => :dirtree,\n \"4\" => :tree,\n :s => :sort_menu, \n :F => :filter_menu,\n :c => :command_menu ,\n :B => :bindkey_ext_command,\n :M => :newdir,\n \"%\" => :newfile,\n :x => :extras\n }\n menu \"Main Menu\", h\nend", "def tool_action_text(tool_action)\n tool_action\n end", "def get_title\n title = []\n # Exceptions\n prefix_title = if controller_name == \"events\" && action_name == \"show\" && @event.present?\n t('titles.events.show', :name => @event.name, :city => @event.city_name)\n elsif controller_name == \"users\" && action_name == \"show\" && @user.present?\n t('titles.users.show', :name => @user.print_name)\n end\n if prefix_title.blank? || prefix_title.match(/translation_missing/)\n # Just translate the controller and action if it exists in the language file\n prefix_title = t(\"titles.#{controller_name}.#{action_name}\")\n prefix_title = (prefix_title.match(/translation_missing/)) ? nil : prefix_title\n end\n # If add the prefix and suffix in title if there isnt a translation missing\n if prefix_title.present? && !prefix_title.match(/translation_missing/)\n title << prefix_title\n title << t('titles.suffix')\n else\n # Use the default title\n title << t('titles.default_title')\n end\n # We put the controller name and action name in the title if we are in development. Just handy.\n if Rails.env == \"development\"\n title << \"#{controller_name}##{action_name}\"\n end\n # Generate the title\n strip_tags(title.join(\" - \"))\n end", "def action\n self.class.name.split(\"::\").last.tap do |class_name|\n class_name[0] = class_name[0].downcase\n end\n end", "def menu_item(name)\n self.div(:class=>/lhnavigation(_subnav|)_item_content/, :text=>name)\n end", "def title\n _title = self[\"title\"]\n _title ? _title[\"$t\"] : nil\n end", "def print_menu\n puts \"Which action [list|add|delete|mark|idea|quit]?\"\nend", "def set_title\n @title = \"#{controller_name}.#{action_name}.title\"\n end", "def active_menu\n active[:main_menu].try(:to_s)\n end", "def action\n Actions[ self[:action] ]\n end", "def titled\n content_for :title do\n if action_name == 'index'\n translate_text(index_i18_text)\n elsif ['new', 'edit', 'create', 'update', 'show'].include?(action_name)\n translate_text(controller_action_i18_text)\n end\n end\n end", "def page_title\n klass = Module.const_get(self.page.split('_').first)\n return klass.find(self.page.split('_').last.to_i).name || klass.find(self.page.split('_').last.to_i).title\n rescue NameError\n return self.page\n end", "def page_title\n if controller_name == 'pages'\n title = t \"#{action_name}_page\"\n \"#{app_name} | #{title}\" # e.g.: 'Ror4 | Home'\n else\n if @page_title.nil?\n \"#{app_name} | #{t controller_name}-#{t action_name}\" # e.g.: 'Ror4 | groups-index'\n else\n \"#{app_name} | #{t @page_title}\" # e.g.: 'Ror4 | Show group Manager'\n end\n end\n end", "def get_item(item_name)\n return @menu[item_name]\n end", "def get_menu_index(menu, name)\n menu.find_index{|item| item[:title] == name }\n end", "def select_from title, array\n h = {}\n array.each_with_index {|e,ix| ix += 1; h[ix.to_s] = e }\n ch, text = menu title, h\n unless text\n if ch == \"ENTER\"\n return array.first\n end\n end\n return text\nend", "def navbar_friends_name_and_title(menu)\n friend_id = menu.to_s.split('_').last\n if friend = Admin::Customer::Friend.find_by_id(friend_id)\n name = friend.name.to_s\n title = \"Click to View #{name}'s collection\"\n end\n return name, title\n end", "def _find_action_name(action_name); end", "def get_Menu_Item\n item_name = session[:goldberg][:menu_item]\n end", "def getMenu(menu)\n menu.add_item(\"Done\") {self.done}\n menu.add_item(\"Edit Camera...\") {self.edit}\n menu.add_item(\"Reset Tilt\") {self.reset_tilt}\nend", "def popup_title(record)\n title = case params[:action]\n when \"new\", \"create\"\n \"<u>Nuevo cargo</u>\"\n when \"edit\", \"update\"\n \"Modificar cargo <u>#{record.to_label}</u>\"\n when \"nested\"\n case params[:associations]\n when \"empleados\"\n \"<b>#{record.to_label}</b> -- <u>Listado de empleados</u>\"\n end\n else\n record.to_label\n end\n return title\n end", "def currentMenuItem(expected, controller, action) \t\t\n \t\treturn \"class=active\" if expected == (controller + \"#\" + action)\n\tend", "def get_action_name\n return @action\n end", "def fzfmenu(title, h)\n return unless h\n\n pbold title.to_s\n # XXX using keys not values since toggle hash being used\n values = h.keys.join(\"\\n\")\n binding = `echo \"#{values}\" | fzf --prompt=\"#{title.to_s} :\"`\n if binding\n binding = binding.chomp\n send(binding) if respond_to?(binding, true)\n end\n binding\nend", "def action_name\n return @action_name\n end", "def guess_page_title\n case main_nav_guess_current\n when 'main_list_errata' ; 'Advisories'\n when 'main_list' ; 'QA Requests'\n when 'main_dashboard' ; 'Dashboard'\n when 'main_bugs' ; 'Advisory Bugs'\n when 'main_docs' ; 'Documentation Queue'\n when 'main_rpmdiff' ; 'RPMDiff'\n when 'main_tps' ; 'TPS'\n when 'main_releng' ; 'Release Engineering'\n when 'main_admin' ; 'Administration'\n when 'main_secalert' ; 'Security'\n when 'main_pkgbrowser' ; 'Packages'\n else ; nil\n end\n end", "def page_title\n \"swinfo for #{item}\"\n end", "def build_menu(application_name, method_names)\n #take array of method names and turn into menu\n puts \"#{application_name.humanize}\"\n method_names.each_with_index {|method_name, index| puts \"#{index + 1}: #{method_name.to_s.humanize}\"}\n puts \"\\nPlease enter your selection:\"\nend", "def menu_for(parent, abstract_model = nil, object = nil, only_icon = false) # perf matters here (no action view trickery)\n actions = actions(parent, abstract_model, object).select{ |a| a.http_methods.include?(:get) }\n actions.map do |action|\n wording = wording_for(:menu, action)\n %{\n <li title=\"#{wording if only_icon}\" rel=\"#{'tooltip' if only_icon}\" class=\"icon #{action.key}_#{parent}_link #{'active' if current_action?(action)}\">\n <a class=\"pjax\" href=\"#{locale_url_for({ :action => action.action_name, :controller => 'rails_admin/main', :model_name => abstract_model.try(:to_param), :id => (object.try(:persisted?) && object.try(:id) || nil) })}\">\n <i class=\"#{action.link_icon}\"></i>\n <span#{only_icon ? \" style='display:none'\" : \"\"}>#{wording}</span>\n </a>\n </li>\n }\n end.join.html_safe\n end", "def name\n method_missing(:title)\n end", "def nav_title(resource)\n resource.data['nav-title'] || resource.data.title\n end", "def generate_titles( action = nil, content = nil )\n\n action = ( action.nil? ? action_name : action.to_s )\n content ||= @content unless @content.nil? || ( action === 'index' )\n\n # if we’re in something that has an additional segment, show that\n unless content.nil? or action == 'new'\n\n @breadcrumb << {\n title: breadcrumb_t( @model_class, :show, { title: content.to_s } ),\n url: ( path_for( content, :show ) rescue nil )\n }\n\n end\n\n # put the current location on the breadcrumb, + generate the title\n @breadcrumb << breadcrumb_t( @model_class, action, { title: content.to_s }) unless ( action == 'index' )\n @page_title = title_t( @model_class, action, { title: content.to_s })\n\n end", "def menu title, h\n return unless h\n\n clear_last_line # 2019-03-30 - required since cursor is not longer at bottom\n pbold title.to_s\n # h.each_pair { |k, v| puts \" #{k}: #{v}\" }\n # 2019-03-09 - trying out using `column` to print in cols\n ary = []\n\n # 2019-04-07 - check @bindings for shortcut and get key, add global\n # binding in brackets\n h.each_pair do |k, v|\n # get global binding\n vs = v.to_s\n scut = @bindings.key(vs)\n scut = \" (#{scut})\" if scut\n\n # ary << \" #{k}: #{v} #{scut}\"\n vs = vs.sub('_menu', '...') if vs.end_with?('_menu')\n vs = vs.tr('_', ' ')\n ary << \" [#{k}] #{vs} #{scut}\"\n end\n x = ary.join(\"\\n\")\n # echo column line bombs when x contains a single quote.\n # If i double quote it then it bombs with double quote or backtick\n # and prints the entire main menu two times.\n x = x.gsub(\"'\", 'single quote')\n # x = x.gsub(\"`\", \"back-tick\")\n puts `echo '#{x}' | column`\n\n key = get_char\n binding = h[key]\n binding ||= h[key.to_sym]\n # TODO: 2019-03-21 - menu's do not have comments, they are symbols\n # binding, _ = binding.split(':')\n if binding\n # 2019-04-18 - true removed, else 'open' binds to ruby open not OS open\n # without true, many methods here don't get triggered\n send(binding) if respond_to?(binding, true)\n # send(binding) if respond_to?(binding)\n end\n redraw_required\n [key, binding]\nend", "def hops_accepted_page_title\n $tracer.trace(__method__)\n return ToolTag.new(img.id(\"/HoldConfirmationHeader$/\"), __method__)\n end", "def breadcrumb_name\n title\n end", "def page_title\n if controller.controller_name == \"dashboards\" && params.key?(\"id\")\n \"Nifty #{Dashboard.get(params[:id]).name}\"\n elsif controller.controller_name == \"widgets\" && params.key?(\"dashboard_id\")\n \"Nifty #{Dashboard.get(params[:dashboard_id]).name} Widgets\"\n else\n \"Nifty Monitoring Dashboard\"\n end\n end", "def site_title\n if content_for?(:title)\n \"#{content_for(:title)} - \"\n elsif ['static'].include?(controller_name)\n if action_name == 'home'\n ''\n else\n \"#{action_name.humanize} - \"\n end\n elsif @breadcrumbs && @breadcrumbs.any?\n \"#{@breadcrumbs.last[:name]} - \"\n elsif controller_name\n \"#{controller_name.humanize} - \"\n else\n ''\n end + \"PaN Training Catalogue\"\n end", "def get_header_and_title_from_i18n\n action = request.parameters[\"action\"]\n\n @title = t(action+\".title\")\n @header = t(action+\".header\")\n end", "def menu_for(parent, abstract_model = nil, object = nil) # perf matters here (no action view trickery)\n actions = actions(parent, abstract_model, object).select{ |action| action.http_methods.include?(:get) }\n actions.map do |action|\n %{\n <li class=\"#{action.key}_#{parent}_link #{'active' if current_action?(action)}\">\n <a href=\"#{url_for({ :action => action.action_name, :controller => 'rails_admin/main', :model_name => abstract_model.try(:to_param), :id => object.try(:id) })}\">\n #{wording_for(:menu, action)}\n </a>\n </li>\n }\n end.join.html_safe\n end", "def human_action_name(action, options = {})\n defaults = lookup_ancestors.map do |klass|\n :\"#{self.i18n_scope}.actions.#{klass.model_name.i18n_key}.#{action}\"\n end\n \n defaults << :\"actions.#{action}\"\n defaults << options.delete(:default) if options[:default]\n defaults << action.to_s.humanize\n \n options.reverse_merge! :default => defaults\n I18n.translate(defaults.shift, options)\n end", "def menu_from_tag(t)\n if t.menu && t.target_tag.present?\n [(t.target_tag.predefined_class.blank? ? feature_path(t.target_tag.slug) : predefined_tags[t.target_tag.predefined_class]), '#', t.target_name].join\n else\n predefined_tags[t.predefined_class] || feature_path(t.slug)\n end\n end", "def title_view\n (ActionController::Base.helpers.link_to self[:title], ApplicationController.helpers.edit_url(self.class.base_class, self)).html_safe\n end", "def menu\n response[\"menu\"]\n end", "def action_controller_title\n return \"#{action_name.camelize} #{controller_name.singularize.camelize}\"\n end", "def page_title\n \"CMVC #{type} #{defect_name}\"\n end", "def create_menu\n items = Hash.new\n # action shd be a hash\n # menu should have array of hashes (or just a string)\n #db = { :name => \"Databases\", :accelerator => \"M-d\", :enabled = true, :on_right => :get_databases }\n #or = { :name => \"Open Recent\", :accelerator => \"M-o\", :enabled = true, :on_right => :get_recent }\n #find_array = {\"Find ...\" => :find, \"Find Next\" => :find_next, \"Find Previous\" => :find_prev}\n items[\"File >\"] = [\"Open ... C-o\" , \"Open Recent\", \"Databases\" , \"Tables\", \"Exit\"]\n items[\"Window >\"] = { \"Tile\" => nil, \"Find >\" => {\"Find ...\" => :find, \"Find Next\" => :find_next, \"Find Previous\" => :find_prev},\n \"Edit\" => nil, \"Whatever\" => nil}\n items[\"Others >\"] = { \"Shell Output ...\" => :shell_output, \"Suspend ...\" => :suspend , \"View File\" => :choose_file_and_view}\n\n # in the case of generated names how will call back know that it is a db name or a table name\n # We get back an array containing the entire path of selections\n right_actions = {}\n right_actions[\"Databases\"] = Proc.new { Dir.glob(\"**/*.{sqlite,db}\") }\n right_actions[\"Tables\"] = :get_table_names\n\n ret = popupmenu items, :row => 1, :col => 0, :bgcolor => :cyan, :color => :white, :right_actions => right_actions\n # ret can be nil, or have a symbol to execute, or a String for an item with no leaf/symbol\n if ret\n alert \"Got #{ret}\"\n last = ret.last\n if last.is_a? Symbol\n if respond_to?(last, true)\n send(last)\n end\n end\n end\n\n return\n r = 1\n ix = popuplist( top , :title => \" Menu \" , :row => r, :col => 0, :bgcolor => :cyan, :color => :white)\n if ix\n value = top[ix]\n ix = popuplist( items[value] , :row => r + 2 + ix, :col => 10, :bgcolor => :cyan, :color => :white)\n end\nend", "def title\n return options.title if options.title\n case type\n when :history\n \"RELEASE HISTORY\"\n else\n \"CHANGELOG\"\n end\n end", "def title\n self.class_name.humanize\n end", "def action_html_class\n \"#{h action_name}-action\"\n end", "def display_menu(menu)\n puts menu.title\n menu.menu_items.each_with_index { |item| puts \"#{item.key_user_returns}.\\t #{item.user_message}\" }\n end", "def title\n @info[:Title]\n end", "def action\n self[:action].to_sym if self[:action]\n end", "def action\n self[:action].to_sym if self[:action]\n end", "def theme_name\n \n if params[:action] == \"home\"\n @theme_name = ThemeOption.where(user_id: current_user.id).first.template.downcase\n else\n \"application\"\n end\n end", "def title\n self.class.title\n end", "def get_subject_name\n navigation_tabs.all_tabs.last[:title]\n end", "def title\n self.class.to_s\n end", "def title\n self.class.to_s\n end", "def membership_admin_label\n $tracer.trace(__method__)\n return ToolTag.new(h1.className(\"/CommonTitleBarTitle/\").innerText(\"/Membership Administration/\"), __method__)\n end", "def crud_menu(class_name)\n class_string = class_name.to_s.underscore.downcase\n m = Menu.new(\"What would you like to do with #{class_string.humanize.downcase.pluralize}?\")\n m.add_menu_item(user_message: [\"Create a new #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/create\")\n m.add_menu_item(user_message: [\"Show all #{class_string.humanize.downcase.pluralize}.\"], method_name: \"#{class_string}/show\")\n m.add_menu_item(user_message: [\"Update a #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/update\")\n m.add_menu_item(user_message: [\"Delete a #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/delete\")\n m\n end", "def title\n return params[:controller].camelize\n end", "def menu title, h\n return unless h\n\n pbold \"#{title}\"\n ctr = 0\n #h.each_pair { |k, v| puts \" #{k}: #{v}\" }\n h.each_pair { |k, v| \n print \" #{k}: %-20s\" % [v]\n if ctr > 1\n print \"\\n\"\n ctr = 0\n else\n ctr += 1\n end\n }\n print \"\\n >\"\n #print \"\\r >\"\n ch = get_char\n puts ch\n #system(\"clear\") # ???\n binding = h[ch]\n binding = h[ch.to_sym] unless binding\n if binding\n if respond_to?(binding, true)\n # 2017-03-19 - we can't send return values from a method ??\n send(binding)\n end\n end\n return ch, binding\nend", "def set_page_title\n\t\t@page_title = \"#{self.action_name.capitalize}: Abstract /\" <<\n\t\t\t\" #{Abstract.sections.find{|a|a[:controller] == self.class.name.demodulize}[:label]}\"\n\tend", "def title\n self.class.title(nil, params)\n end", "def actionNom\n\t\treturn \"Je sais rien faire :C\"\n\tend", "def action_name; end", "def title\n @title ||= self.class.non_namespaced_classname\n end" ]
[ "0.68279886", "0.682061", "0.6679982", "0.65504414", "0.64915067", "0.63043845", "0.6280424", "0.62593436", "0.62585306", "0.624361", "0.6151397", "0.60514504", "0.60326844", "0.6006423", "0.59765506", "0.5954675", "0.5940533", "0.5923494", "0.591497", "0.5913613", "0.5910242", "0.59060866", "0.5903823", "0.5895636", "0.58821565", "0.58634835", "0.585102", "0.58201", "0.5815686", "0.58097804", "0.57966053", "0.5787534", "0.57864857", "0.57851255", "0.5776656", "0.57723314", "0.57528895", "0.57427806", "0.5742348", "0.5740133", "0.5738114", "0.5725277", "0.57168436", "0.5699637", "0.5694929", "0.5682536", "0.567544", "0.56752056", "0.56714135", "0.56696945", "0.5665612", "0.56653184", "0.56605476", "0.56545687", "0.5643053", "0.5623817", "0.5622677", "0.5617728", "0.56124574", "0.5612095", "0.56100583", "0.5606943", "0.5599283", "0.55981", "0.55932075", "0.55886084", "0.5588259", "0.55813754", "0.5581137", "0.5573068", "0.5570882", "0.5568337", "0.5562423", "0.5559752", "0.5553335", "0.55466616", "0.5544879", "0.5534062", "0.5529083", "0.5525013", "0.55234474", "0.5515202", "0.5503734", "0.5492658", "0.5473552", "0.5473552", "0.54693836", "0.5463576", "0.5461969", "0.5454117", "0.5454117", "0.5453197", "0.54521364", "0.54447377", "0.54402584", "0.5438467", "0.542308", "0.5413381", "0.5413354", "0.5407504" ]
0.82719135
0
Grade book Complete the function so that it finds the mean of the three scores passed to it and returns the letter value associated with that grade. Numerical ScoreLetter Grade 90 <= score <= 100'A' 80 <= score < 90'B' 70 <= score < 80'C' 60 <= score < 70'D' 0 <= score < 60'F' Tested values are all between 0 and 100. Theres is no need to check for negative values or values greater than 100.
def get_grade(s1, s2, s3) case avg = (s1.to_f + s2.to_f + s3.to_f)/3.0 when 90..100 "A" when 80..90 "B" when 70..80 "C" when 60..70 "D" else "F" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_grade(scores)\n score_total = 0\n\n scores.each { |x| score_total = x + score_total }\n\n average = score_total / (scores.length)\n\n case\n when average >= 90\n letter = 'A'\n when average >= 80\n letter = 'B'\n when average >= 70\n letter = 'C'\n when average >= 60\n letter = 'D'\n else\n letter = 'F'\n end\n \n return letter\nend", "def calculate_letter_grade(*scores) # the asterisk allows any number of arguments and puts them in an array\n if scores.length == 0\n return nil\n end\n average = scores.sum / scores.length\n letter_threshholds = {90 => \"A\", 80 => \"B\", 70 => \"C\", 60 => \"D\", 0 => \"F\"}\n letter_threshholds.each do |threshhold, grade|\n if average >= threshhold\n return grade\n end\n end\nend", "def get_grade scores\n average = 0\n scores.each do |num|\n if num < 0 || num > 100\n p \"Please input a list of valid scores (0-100).\"\n else\n average += num\n end\n end\n average /= scores.length\n if average >= 90\n \"A\"\n elsif average >= 80\n \"B\"\n elsif average >= 70\n \"C\"\n elsif average >= 60\n \"D\"\n else\n \"F\"\n end\nend", "def get_grade(scores)\n \n sum = scores.reduce(:+)\n \n average = sum.to_f/scores.length\n \n if (average >= 90)\n 'A'\n elsif (average >= 80)\n 'B'\n elsif (average >=70)\n 'C'\n elsif (average >=60)\n 'D'\n else \n 'F'\n end\n \n end", "def get_grade(sc1, sc2, sc3)\n # get average of scores\n avg = (sc1 + sc2 + sc3) / 3\n\n # assign letter grade\n # return letter grade\n case avg\n when 90..100 then 'A'\n when 80..89 then 'B'\n when 70..79 then 'C'\n when 60..69 then 'D'\n else 'F'\n end\nend", "def letterGrade average\n case (average/10)\n when 10 , 9 \n return \"A\" #90-100 is an A\n when 8 \n return \"B\" #80-89 is B \n when 7 \n return \"C\" #70-79 is C \n when 6 \n return \"D\" #60-69 is D \n else \n return \"F\" #0-59 is an F\n end\nend", "def get_grade(score1, score2, score3)\n average = (score1 + score2 + score3) / 3\n\n case average\n when 90..100 then 'A'\n when 80...90 then 'B'\n when 70...80 then 'C'\n when 60...70 then 'D'\n when 0...60 then 'F'\n else 'S'\n end\nend", "def letter_grade(score)\n if score >= 90\n return \"A\"\n elsif score >= 80 && score <= 89\n return \"B\"\n elsif score >= 70 && score <= 79\n return \"C\"\n elsif score >= 60 && score <= 69\n return \"D\"\n else\n return \"F\"\n end\nend", "def get_grade(score1, score2, score3)\n avg = [score1, score2, score3].sum / 3\n case avg\n when (90..100) then 'A'\n when (80...90) then 'B'\n when (70...80) then 'C'\n when (60...70) then 'D'\n when (0...60) then 'F'\n end\nend", "def letter_grade(score)\n if score>90\n \"A\"\n elsif score>=80 && score<=89\n \"B\"\n elsif score>=70 && score<=79\n \"C\"\n elsif score>=60 && score<=69\n \"D\"\n else\n \"F\"\n end\nend", "def letter_grade(score)\n if score >= 90\n \"A\"\n elsif score.between?(80,89)\n \"B\"\n elsif score.between?(70,79)\n \"C\"\n elsif score.between?(60,69)\n \"D\"\n else\n \"F\"\n end\nend", "def get_grade(scores)\n\n\t#Find out the average of the scores\n\n\tscore_sum = scores.reduce(:+)\n\ttotal_scores = scores.length\n\taverage_score = score_sum / total_scores\n\n\t#translate average into a letter grade\n\n\tgrade = case average_score\n\twhen 90...100 then \"A\"\n\twhen 80..90 then \"B\"\n\twhen 70..80 then \"C\"\n\twhen 60..70 then \"D\"\n\twhen 0..60 then \"F\"\n\tend\n\t\n\treturn grade\nend", "def get_grade(score1, score2, score3)\n\t\n\taverage = (score1 + score2 + score3) / 3\n\n\tcase average\n\t\twhen (90...)\n\t\t\t'A'\n\t\twhen (80..89)\n\t\t\t'B'\n\t\twhen (70..79)\n\t\t\t'C'\n\t\twhen (60..69)\n\t\t\t'D'\n\t\twhen (0..59)\n\t\t\t'F'\n\tend\nend", "def letter_grade(score)\n if score >= 90\n \"A\"\n elsif score >= 80 && score <= 89\n \"B\"\n elsif score >= 70 && score <= 79\n \"C\"\n elsif score >= 60 && score <= 69\n \"D\"\n else\n \"F\"\n end\nend", "def letter_grade(score)\n if score >= 90\n \"A\"\n elsif score >= 80 && score <= 89\n \"B\"\n elsif score >= 70 && score <= 79\n \"C\"\n elsif score >= 60 && score <= 69\n \"D\"\n else \n \"F\"\n end\nend", "def letter_grade(score)\n if score >= 90\n \"A\"\n elsif score <= 89 && score >= 80\n \"B\"\n elsif score <= 79 && score >= 70\n \"C\"\n elsif score <= 69 && score >= 60\n \"D\"\n else\n \"F\"\n end\nend", "def get_grade(test_scores)\n sum = 0.00\n test_scores.each {|score| sum += score}\n avg = sum / test_scores.length\n case avg\n when 90..100\n return \"A\"\n when 80...90\n return \"B\" \n when 70...80\n return \"C\"\n when 60...70\n return \"D\"\n else\n return \"F\"\n end\nend", "def letterGrade(average)\r\n case average\r\n \twhen 90..100 then\r\n \t\treturn 'A'\r\n \twhen 80..89 then\r\n \t\treturn 'B'\r\n \twhen 70..79 then\r\n \t\treturn 'C'\r\n \twhen 60..69 then\r\n \t\treturn 'D'\r\n \telse\r\n \t\treturn 'F' \t\r\n end\r\nend", "def letter_grade(average)\n if average >= 90\n 'A'\n elsif average >= 80\n 'B'\n elsif average >= 70\n 'C'\n elsif average >= 60\n 'D'\n else\n 'F'\n end\nend", "def letter_grade(score)\n if score >= 90\n \"A\"\n elsif score >= 80\n \"B\"\n elsif score >= 70\n \"C\"\n elsif score >= 60\n \"D\"\n else\n \"F\"\n end\nend", "def get_grade(num1, num2, num3)\n letter_grade = { 'A' => (90..100), 'B' => (80..89), 'C' => (70..79),\n 'D' => (60..69), 'F' => (0..59) }\n\n mean = (num1 + num2 + num3) / 3\n\n case mean\n when letter_grade[\"A\"] then \"A\"\n when letter_grade[\"B\"] then \"B\"\n when letter_grade[\"C\"] then \"C\"\n when letter_grade[\"D\"] then \"D\"\n else \"F\"\n end\nend", "def get_grade(grades)\n sum = 0 # define sum, so that I can add things to it\n grades.each {|grade| sum += grade} # adding each element of the array together\n mean = sum / grades.length # the average of the grades\n case # the letter grade for each mean\n when mean >= 90\n return \"A\" # good job, student\n when mean >= 80\n return \"B\" # pretty good job, student\n when mean >= 70\n return \"C\" # average job, student\n when mean >= 60\n return \"D\" # I've seen better, student\n else\n return \"F\" # Reconsider your life, student\n end # Don't forget your end statements\nend", "def letter_grade(score)\n if score >= 90 \n return \"A\"\n elsif score >= 80\n \"B\"\n elsif score >= 70\n \"C\"\n elsif score >= 60\n \"D\"\n else \n \"F\"\nend\nend", "def get_grade(grades)\n\tgrades.each do |grade|\n\t\tunless grade.is_a?(Integer) && 0 <= grade && grade <= 100\n\t\t\traise ArgumentError.new(\"Integers between 0 and 100 only please!\")\n\t\tend\n\tend\n\tavg_grade = grades.reduce(:+).to_f / grades.length\n\tcase avg_grade\n\t\twhen 90..100 then \n\t\t\tp \"You averaged #{avg_grade}, which is an A.\"\n\t\t\treturn \"A\"\n\t\twhen 80..89 then \n\t\t\tp \"You averaged #{avg_grade}, which is a B.\"\n\t\t\treturn \"B\"\n\t\twhen 70..79 then \n\t\t\tp \"You averaged #{avg_grade}, which is a C.\"\n\t\t\treturn \"C\"\n\t\twhen 60..69 then \n\t\t\tp \"You averaged #{avg_grade}, which is a D.\"\n\t\t\treturn \"D\"\n\t\twhen 0..59 then \n\t\t\tp \"You averaged #{avg_grade}, which is an F.\"\n\t\treturn \"F\"\n\tend\nend", "def letter_grade(score)\n if score >= 90\n grade = \"A\"\n elsif score >= 80\n grade = \"B\"\n elsif score >= 70\n grade = \"C\"\n elsif score >= 60\n grade = \"D\"\n else\n grade = \"F\"\n end\nend", "def letter_grade(score)\n output = case score\n when 0...60\n 'F'\n when 60..69\n 'D'\n when 70..79\n 'C'\n when 80..89\n 'B'\n when 90..100\n 'A'\n end\n\n return output\nend", "def get_grade(avg_score)\n\tif avg_score >= 90\n\t\t\"A\"\n\telsif avg_score >= 80\n\t\t\"B\"\n\telsif avg_score >= 70\n\t\t\"C\"\n\telsif avg_score >= 60\n\t\t\"D\"\n\telse\n\t\t\"F\"\n\tend\nend", "def letter_grade(score)\n case score\n when 80..89\n \"B\"\n when 70..79\n \"C\"\n when 90..1000\n \"A\"\n when 60..69\n \"D\"\n when 0..59\n \"F\"\n end\n\nend", "def get_grade(score1, score2, score3)\n\n grade_rules = {\n (90..100).to_a => \"A\",\n (80..89).to_a => \"B\",\n (70..79).to_a => \"C\",\n (60..69).to_a => \"D\",\n (0..59).to_a => \"F\"\n }\n\n mean_score = (score1 + score2 + score3) / 3\n\n grade_rules.select { |key, value| key.include?(mean_score) }.values.join\nend", "def final_letter_grades(scores)\n averages(scores).transform_values { |avg_score| letter_grade(avg_score)}\nend", "def get_extra_grade(score1, score2, score3)\n average = ((score1 + score2 + score3) / 3.0).round(2)\n \n GRADES.each do |grade, range|\n return grade if range.cover?(average)\n end\n\n \"A+\"\nend", "def get_grade(score1, score2, score3)\n avg = (score1 + score2 + score3) / 3\n case\n when avg >= 90 then 'A'\n when avg >= 80 then 'B'\n when avg >= 70 then 'C'\n when avg >= 60 then 'D'\n else 'F'\n end\nend", "def get_grade(num1, num2, num3)\n mean = ((num1 + num2 + num3) / 3.0).round\n\n case mean\n when 90..100 then 'A'\n when 80..89 then 'B'\n when 70..79 then 'C'\n when 60..69 then 'D'\n when 0..59 then 'F'\n else 'A'\n end\nend", "def get_grade (average)\r\n\r\n\tif average > 89\r\n\t\tthen letter_grade = 'A'\r\n\telsif average > 79\r\n\t\tthen letter_grade = 'B'\r\n\telsif average > 69\r\n\t\tthen letter_grade = 'C'\r\n\telsif average > 59\r\n\t\tthen letter_grade = 'D'\r\n\telse\r\n\t\tletter_grade = 'F'\r\n\tend\t\t\r\n\r\n\treturn letter_grade\r\n\r\nend", "def get_grade(average)\n case average\n when 90..100\n then \"A\"\n when 80..89\n then \"B\"\n when 70..79\n then \"C\"\n when 60..69\n then \"D\"\n when 0..60\n then \"F\"\n end\n end", "def get_letter\n\n puts \"What percent did oyu score on your test/assignment?\"\n print \"> \"\n score = gets.chomp.to_i\n\n grades = {\n :F+ (0 ... 49),\n D: (50 ... 59),\n C: (60 ... 69),\n B: (70 ... 79),\n A: (80 ... 100)\n }\n\n grades.each do |grade, percent|\n if percent.to_a.include?(score)\n return grade\n end\n end\nend", "def get_grade(grades)\n sum = 0\n grades.each {|grade| sum += grade}\n mean = sum / grades.length\n case\n when mean >= 90\n return \"A\"\n when mean >= 80\n return \"B\"\n when mean >= 70\n return \"C\"\n when mean >= 60\n return \"D\"\n else\n return \"F\"\n end\nend", "def calculate_grade(score)\n case score\n when (90..100) then 'A'\n when (80..90) then 'B'\n when (70..80) then 'C'\n when (60..70) then 'D'\n when (0..60) then 'F'\n end\nend", "def get_grade(scoreArray)\n\t\t\n\tavg = scoreArray.reduce(:+) / scoreArray.length\n\t\t\n\tcase avg\n\t\twhen 90..100 then 'A'\n\t\twhen 80..89 then 'B'\n\t\twhen 70..79 then 'C'\t\n\t\twhen 60..69 then 'D'\n\t\telse 'F'\t\n\tend\nend", "def final_letter_grades(grade_hash)\n letter_grade averages grade_hash\nend", "def get_grade(score1, score2, score3)\n av = (score1 + score2 + score3) / 3\n case\n when av < 60 then 'F'\n when av < 70 then 'D'\n when av < 80 then 'C'\n when av < 90 then 'B'\n when av >= 90 then 'A'\n end\nend", "def get_grade(n)\n #sequence of if else statemnets with >=thresholds like 90, 80, 70 etc.\n #will need to include argumaents as an input for the average\n #return the string value of the letter grade\n if n>= 90\n \"A\"\n elsif n>= 80\n \"B\"\n elsif n >= 70\n \"C\"\n elsif n>= 60\n \"D\"\n else\n \"F\"\n end\nend", "def calculate\n avg_scores = ((@scores.inject(0){|sum,x| sum + x }) / @scores.length)\n if avg_scores >= 90 && avg_scores <= 100\n return 'O'\n elsif avg_scores >= 80 && avg_scores < 90\n return 'E'\n elsif avg_scores >= 70 && avg_scores < 80\n return 'A'\n elsif avg_scores >= 55 && avg_scores < 70\n return 'P'\n elsif avg_scores >= 40 && avg_scores < 55\n return 'D'\n elsif avg_scores < 40\n return 'T'\n end\n end", "def get_grade(input_array)\n\tsum = 0\n\tinput_array.each do |x|\n\t\tsum += x\n\tend\n\tav_score = sum/input_array.length\n\treturn \"A\" if av_score>=90\n\treturn \"B\" if av_score>=80\n\treturn \"C\" if av_score>=70\n\treturn \"D\" if av_score>=60\n\treturn \"F\" if av_score<60\nend", "def get_grade(gr1, gr2, gr3)\n average = (gr1 + gr2 + gr3) / 3\n return \"A\" if average >= 90\n return \"B\" if average >= 80\n return \"C\" if average >= 70\n return \"D\" if average >= 60\n \"F\"\nend", "def get_grade(grade1, grade2, grade3)\n grades_min_score = {\n a: 90,\n b: 80,\n c: 70,\n d: 60,\n f: 0\n }\n grades = [grade1, grade2, grade3]\n\n average = average(grades)\n\n case\n when average >= grades_min_score[:a] && average <= 100\n \"A\"\n when average >= grades_min_score[:b]\n \"B\"\n when average >= grades_min_score[:c]\n \"C\"\n when average >= grades_min_score[:d]\n \"D\"\n when average >= grades_min_score[:f]\n \"F\"\n end\nend", "def get_grade(average)\n return \"A\" if average <= 100 && average >= 90\n \n return \"B\" if average < 90 && average >= 80\n \n return \"C\" if average < 80 && average >= 70\n \n return \"D\" if average < 70 && average >= 60\n \n return \"F\" if average < 60\nend", "def get_grade (average)\n case average\n when (90..100)\n return \"A\"\n when (80..89)\n return \"B\"\n when (70..79)\n return \"C\"\n when (60..69)\n return \"D\"\n when (0..59)\n return \"F\"\n end\nend", "def get_grade(grades)\n\t@grades = grades\n\t@average = (@grades.inject(:+)/@grades.length)\n\tif @average >= 90\n\t\treturn 'A'\n\telsif @average >= 80\n\t\treturn 'B'\n\telsif @average >= 70\n\t\treturn 'C'\n\telsif @average >= 60\n\t\treturn 'D'\n\telse\n\t\treturn 'F'\n\tend\nend", "def get_grade(num1, num2, num3)\n average = [num1, num2, num3].inject(:+) / 3\n\n case average\n when 90..100 then \"A\"\n when 80..89 then \"B\"\n when 70..79 then \"C\"\n when 60..69 then \"D\"\n else \"F\"\n end\nend", "def get_grade(*grades)\r\n\r\n average = grades.sum / grades.size\r\n\r\n case average\r\n when 90..100 then 'A'\r\n when 80..90 then 'B' \r\n when 70..80 then 'C'\r\n when 60..70 then 'D'\r\n when 0..60 then 'F'\r\n else \"Above and beyond! A+\"\r\n end\r\nend", "def what_is_my_grade(score)\n if(score < 0 || score > 100)\n return \"Please enter a number between 0 and 100\"\n end\n if(score > 90)\n return \"A\"\n end\n if(score > 80)\n return \"B\"\n end\n if(score > 70)\n return \"C\"\n end\n if(score > 60)\n return \"D\"\n end\n return \"F\"\nend", "def get_grade(avg)\n if avg.to_i >= 90\n return \"A\"\n elsif avg.to_i >= 80\n return \"B\"\n elsif avg.to_i >= 70\n return \"C\"\n elsif avg.to_i >= 60\n return \"D\"\n elsif avg.to_i < 60\n return \"F\"\n else\n return \"Error. Please enter a number grade from 0-100.\"\n end\nend", "def get_grade(sc1, sc2, sc3)\n average = (sc1 + sc2 + sc3) / 3\n case average\n when 90..100 then \"A\" \n when 80..89 then \"B\"\n when 70..79 then \"C\"\n when 60..69 then \"D\"\n else\n \"F\"\n end\nend", "def get_grade(grade_1, grade_2, grade_3)\n score = (grade_1 + grade_2 + grade_3) / 3.0\n\n case \n when 90 <= score && score <= 100 \n \"A\"\n when 80 <= score && score < 90\t \n 'B'\n when 70 <= score && score < 80\t \n 'C'\n when 60 <= score && score < 70\t \n 'D'\n when 0 <= score && score < 60\t \n 'F'\n end\nend", "def get_grade(avg)\n\tif avg <= 100 and avg > 89\n\t\treturn \"A\"\n\telsif avg < 90 and avg > 79\n\t\treturn \"B\"\n\telsif avg < 80 and avg > 69\n\t\treturn \"C\"\n\telsif avg < 70 and avg > 59\n\t\treturn \"D\"\n\telse avg < 60 and avg > 0\n\t\treturn \"F\"\n\tend\nend", "def get_grade(average)\n if average >= 90\n return \"A\"\n elsif average >= 80 && average <= 89\n return \"B\"\n elsif average >= 70 && average <= 79\n return \"C\"\n elsif average >= 60 && average <= 69\n return \"D\"\n else\n return \"F\"\n end\nend", "def get_grade(average)\n case average\n when (90..100)\n return \"A\"\n when (80..89)\n return \"B\"\n when (70..79)\n return \"C\"\n when (60..69)\n return \"D\"\n when (0..59)\n return \"F\"\n end\n\n\n\n \n\nend", "def get_grade(grade1, grade2, grade3)\n average_grade = (grade1 + grade2 + grade3) / 3\n\n case average_grade\n when 90..100 then 'A'\n when 80...90 then 'B'\n when 70...80 then 'C'\n when 60...70 then 'D'\n when 0...60 then 'F'\n end\nend", "def get_grade(avg)\n if avg >= 90 then\n return \"A\"\n elsif avg > 79 then\n return \"B\"\n elsif avg > 69 then\n return \"C\"\n elsif avg > 59 then\n return \"D\"\n else \n return \"F\"\n end\nend", "def get_grade(grades)\n\tsum = 0\n\ttotal = grades.length\n\tgrades.each { |x| sum = (sum + x) }\n\taverage = (sum / total)\n\tif average >= 90\n\t\treturn \"A\"\n\telsif average >= 80\n\t\treturn \"B\"\n\telsif average >= 70\n\t\treturn \"C\"\n\telsif average >= 60\n\t\treturn \"D\"\n\telse \n\t\treturn \"F\"\n\tend\nend", "def score\n #Here are the letter values. Think about how you might put this data in a usable format for your methods above.\n scores = {a: 1, b: 3, c: 3, d: 2, e: 1,\n f: 4, g: 2, h: 4, i: 1, j: 8,\n k: 5, l: 1, m: 3, n: 1, o: 1,\n p: 3, q: 10, r: 1, s: 1, t: 1,\n u: 1, v: 4, w: 4, x: 8, y: 4,\n z: 10}\n\n# Need to use @word with something to get the value of the letters combined \n\n\n return score\n end", "def grade\n @grades ||= case score\n when 10.0..100.0\n 16\n when 9.0..10.0\n 13\n when 8.5..9.0\n 12\n when 8.0..8.5\n 11\n when 7.5..8.0\n 10\n when 7.0..7.5\n 9\n when 6.5..7.0\n 8\n when 6.0..6.5\n 7\n when 5.5..6.0\n 6\n when 5.0..5.5\n 5\n else\n 4\n end\n end", "def get_grade(arr)\n\tfinal = 0\n\tarr.each{ |score| final += score}\n\tgrade = final / arr.length\n\tcase grade\n\t\twhen 90..100 then 'A'\n\t\twhen 80..90 then 'B'\n\t\twhen 70..80 then 'C'\n\t\twhen 60..70 then 'D'\n\t\twhen 0..60 then 'F'\n\tend\nend", "def get_grade(avg)\n\tif avg >= 90\n\t\treturn \"A\"\n\telsif avg >= 80\n\t\treturn \"B\"\n\telsif avg >= 70\n\t\treturn \"C\"\n\telsif avg >= 60\n\t\treturn \"D\"\n\telsif avg < 60\n\t\treturn \"F\"\n\tend\t\nend", "def get_grade(average)\n if average >= 90\n return \"A\"\n elsif average >= 80\n return \"B\"\n elsif average >= 70\n return \"C\"\n elsif average >=60\n return \"D\"\n else\n return \"F\"\n end\nend", "def get_grade(first, second, third)\n avg = (first + second + third) / 3\n\n if (90..100).include?(avg)\n 'A'\n elsif (80...90).include?(avg)\n 'B'\n elsif (70...80).include?(avg)\n 'C'\n elsif (60...70).include?(avg)\n 'D'\n elsif (0...60).include?(avg)\n 'F'\n end\nend", "def get_grade(average)\n if average >= 90 && average <= 100\n return \"A\"\n elsif average < 90 && average >= 80\n return \"B\"\n elsif average <80 && average >= 70\n return \"C\"\n elsif average < 70 && average >= 60\n return \"D\"\n else average < 60\n return \"F\"\n end\nend", "def grade(average)\n case\n when average > 90 \n return 'A'\n when average > 80\n return 'B'\n when average > 70\n return 'C'\n when average > 60\n return 'D'\n else\n return 'F'\n end\nend", "def get_grade(grade1, grade2, grade3)\n avg_grade = (grade1 + grade2 + grade3) / 3\n case avg_grade\n when 60...70 then 'D'\n when 70...80 then 'C'\n when 80...90 then 'B'\n when 90..100 then 'A'\n when 100.. then 'A+'\n else 'F'\n end\nend", "def get_grade(score)\n if score >= 90\n return \"A\"\n elsif score < 90 && score >= 80\n return \"B\"\nelsif score < 80 && score >= 70\n return \"C\"\nelsif score < 70 && score >= 60\n return \"D\"\n else\n return \"F\"\n end\nend", "def get_grade(average)\n if average <=100 && average >=90\n p \"A\"\n elsif average <=89 && average >=80\n p \"B\"\n elsif average <=79 && average >=70\n p \"C\"\n elsif average <=69 && average >=60\n p \"D\"\n else\n p \"F\"\n end\nend", "def get_grade(arr)\n sum = arr.inject(:+)\n average = sum / arr.length\n\n return \"A\" if average >= 90\n return \"B\" if average >= 80\n return \"C\" if average >= 70\n return \"D\" if average >= 60\n return \"F\"\nend", "def get_grade(arr)\n\tavg = arr.inject(:+)/arr.length\n \n\tcase avg\n when (90..100) then \"A\"\n when (80..89) then \"B\"\n when (70..79) then \"C\"\n when (60..69) then \"D\"\n else \"F\"\n\tend\nend", "def get_grade(int1, int2, int3)\n score = (int1 + int2 + int3) / 3\n if score <= 100 && score >= 90\n 'A'\n elsif score < 90 && score >= 80\n 'B'\n elsif score < 80 && score >= 70\n 'C'\n elsif score < 70 && score >= 60\n 'D'\n else\n 'F'\n end\nend", "def assign_grade (score)\n if (score > 100 || score < 1)\n puts \"Score (#{score}) is out of range (1-100).\"\n elsif score > 90\n puts \"A (#{score})\"\n elsif score > 80\n puts \"B (#{score})\"\n elsif score > 70\n puts \"C (#{score})\"\n elsif score > 60\n puts \"D (#{score})\"\n else\n puts \"F (#{score})\"\n end\nend", "def get_grade(array)\n sum = 0\n array.each do |number|\n sum += number\n end\n avg = sum / array.length\n if (avg >= 90)\n return \"A\"\n elsif (avg >= 80)\n return \"B\"\n elsif (avg >= 70)\n return \"C\"\n elsif (avg >= 60)\n return \"D\"\n else\n return \"F\"\n end\nend", "def get_grade(score)\n\n if score < 60\n return \"F\"\n elsif score < 70\n return \"D\"\n elsif score < 80\n return \"C\"\n elsif score < 90\n return \"B\"\n else\n return \"A\"\n end\nend", "def gradeAVG(scores)\n sum = 0\n scores.each do |grade|\n sum += grade\n end\n average = sum / (scores.length)\n return average\nend", "def get_grade(array)\nsum = 0\narray.each {|i| sum += i}\naverage = sum / array.length\n case average \n when 90..100\n \"A\"\n when 80..89\n \"B\"\n when 70..79\n \"C\"\n when 60..69\n \"D\"\n else\n \"F\"\n end\nend", "def get_grade(grades)\n\tavg_grade = grades.reduce(:+).to_f / grades.length\n\tcase avg_grade\n\t\twhen 90..100 then \"A\"\n\t\twhen 80..89 then \"B\"\n\t\twhen 70..79 then \"C\"\n\t\twhen 60..69 then \"D\"\n\t\twhen 0..59 then \"F\"\n\tend\nend", "def calculate\n average = (@scores.reduce(:+)/@scores.length)\n return \"O\" if average.between?(90, 100)\n return \"E\" if average.between?(80, 89)\n return \"A\" if average.between?(70, 79)\n return \"P\" if average.between?(55, 69)\n return \"D\" if average.between?(40, 54)\n return \"T\" if average < 40\n end", "def final_letter_grades(grade_hash)\n averages = grade_hash.inject({}) { |h, (k,v)| h[k] = letter_grade(v.reduce{|x,n| x += n}/v.length) ; h}\nend", "def get_grade(array)\n total = 0\n array.each {|x| total = total += x }\n average = total/array.length\n \n if average >= 90\n return \"A\"\n elsif average >= 80\n return \"B\"\n elsif average >= 70\n return \"C\"\n elsif average >= 60\n return \"D\"\n else\n return \"F\"\n end\nend", "def get_grade(letter_grade)\n return \"A\" if letter_grade >= 90\n return \"B\" if letter_grade >= 80\n return \"C\" if letter_grade >= 70\n return \"D\" if letter_grade >= 60\n return \"F\" if letter_grade < 60\nend", "def average_score\n grades.average(:score) || 0\n end", "def get_grade(array)\n\tavg = ((array.inject(:+)) / array.length)\n\tcase avg\n\twhen 90..100\n\t\t'A'\n\twhen 80..89\n\t\t'B'\n\twhen 70..79\n\t\t'C'\n\twhen 60..69\n\t\t'D'\n\telse \n\t\t'F'\n\tend\nend", "def get_grade(*args)\n ave = args.reduce(:+) / args.size\n\n case ave\n when 90..100 then 'A'\n when 80..89 then 'B'\n when 70..79 then 'C'\n when 60..69 then 'D'\n else 'F'\n end\nend", "def get_grade(n1, n2, n3)\n avg = (n1 + n2 + n3) / 3\n case\n when avg < 60 then \"F\"\n when avg < 70 then \"D\"\n when avg < 80 then \"C\"\n when avg < 90 then \"B\"\n else \"A\"\n end\nend", "def letter_grade (number_grade, default = '?')\n return default if number_grade.blank? || !number_grade.instance_of?(Fixnum)\n Review.letter_grade(number_grade) || default\n end", "def get_grades(a, b, c)\n average = (a + b + c) / 3\n \n case average\n when 90..100 then 'A'\n when 80..89 then 'B'\n when 70..79 then 'C'\n when 60..69 then 'D'\n else 'F'\n end\nend", "def get_grade(*grades)\n average = grades.sum / grades.size\n \n case \n when average > 90\n \"A\"\n when average >= 80 && average < 90\n \"B\"\n when average >= 70 && average < 80\n \"C\"\n when average >= 60 && average < 70\n \"D\"\n else\n \"F\"\n end\nend", "def letter_scores\n { \"A\"=>1, \"B\"=>3, \"C\"=>3, \"D\"=>2,\n \"E\"=>1, \"F\"=>4, \"G\"=>2, \"H\"=>4,\n \"I\"=>1, \"J\"=>8, \"K\"=>5, \"L\"=>1,\n \"M\"=>3, \"N\"=>1, \"O\"=>1, \"P\"=>3,\n \"Q\"=>10, \"R\"=>1, \"S\"=>1, \"T\"=>1,\n \"U\"=>1, \"V\"=>4, \"W\"=>4, \"X\"=>8,\n \"Y\"=>4, \"Z\"=>10\n }\n end", "def get_grade(array)\n\ttotal = 0\n\tarray.each do |x|\n\t\ttotal += x\n\tend\n\taverage = total / array.length\n\tif average >= 90\n\t\treturn \"A\"\n\telsif average >= 80\n\t\treturn \"B\"\n\telsif average >= 70\n\t\treturn \"C\"\n\telsif average >= 60\n\t\treturn \"D\"\n\telse\n\t\treturn \"F\"\n\tend\nend", "def get_grade(grade)\n if grade >=1 && grade <=59 then\n letter_grade = 'F'\n elsif grade >=60 && grade <=69 then\n letter_grade = 'D'\n elsif grade >=70 && grade <=79 then\n letter_grade = 'C'\n elsif grade >=80 && grade <=89 then\n letter_grade = 'B'\n elsif grade >=90 && grade <=100 then\n letter_grade = 'A'\n end\n return letter_grade\nend", "def get_grade(average)\n # Your code goes here!\n if average <= 100 && average >= 90\n return \"A\"\n elsif average < 90 && average >= 80\n return \"B\"\n elsif average < 80 && average >= 70\n return \"C\"\n elsif average < 70 && average >= 60\n return \"D\"\n else average < 60\n return \"F\"\n end\nend", "def getGradeLetter(grade)\n if grade >= 0.9 && grade <= 1.0 then\n \"A\"\n elsif grade >= 0.8 && grade < 0.9 then\n \"B\"\n elsif grade >= 0.7 && grade < 0.8 then\n \"C\"\n elsif grade >= 0.6 && grade < 0.7 then\n \"D\"\n else\n \"F\"\n end\n end", "def final_letter_grades(grade_hash)\n averages(grade_hash)\n .transform_values{ |scores| letter_grade(scores)}\nend", "def get_grade(average)\n if average < 60\n p \"F\"\n elsif average < 70 && average >= 60\n p \"D\"\n elsif average < 80 && average >= 70\n p \"C\"\n elsif average < 90 && average >= 80\n p \"B\"\n else average < 101 && average >= 90\n p \"A\"\n end\nend", "def get_grade(int1, int2, int3)\n score = (int1 + int2 + int3) / 3\n case score\n when 90..100 then 'A'\n when 80..89 then 'B'\n when 70..79 then 'C'\n when 60..69 then 'D'\n else 'F'\n end\nend", "def get_grade(array)\n\tavg = array.inject(:+) / array.length\n\n\tif avg >= 90\n\t\t\"A\"\n\telsif avg >= 80\n\t\t\"B\"\n\telsif avg >= 70\n\t\t\"C\"\n\telsif avg >=60\n\t\t\"D\"\n\telse\n\t\t\"F\"\n\tend\nend" ]
[ "0.8182248", "0.80405277", "0.79010636", "0.78174675", "0.7817419", "0.7803895", "0.7782828", "0.77770746", "0.7733853", "0.7733799", "0.77295953", "0.7724674", "0.77172685", "0.7707596", "0.7692923", "0.7688372", "0.76881355", "0.76875144", "0.7668115", "0.7638944", "0.7632744", "0.76311994", "0.7579054", "0.7547504", "0.75378674", "0.7534776", "0.75176084", "0.7509632", "0.7502544", "0.7470123", "0.7421889", "0.7420013", "0.74121547", "0.7388863", "0.73853856", "0.733763", "0.7317997", "0.73060346", "0.7292694", "0.72922003", "0.7262905", "0.7254077", "0.7249362", "0.7243049", "0.7232252", "0.7231558", "0.72281116", "0.72196394", "0.72186613", "0.72168773", "0.72138894", "0.7204615", "0.71994996", "0.71890026", "0.71765673", "0.71483845", "0.7143601", "0.71412563", "0.7128313", "0.71222997", "0.71197", "0.71036726", "0.7091704", "0.7091008", "0.70807266", "0.70708483", "0.70646036", "0.7063208", "0.7059513", "0.7052861", "0.70428747", "0.70415413", "0.7028112", "0.7020679", "0.70191574", "0.7008501", "0.7005316", "0.70039636", "0.7002096", "0.6992702", "0.69849455", "0.6968568", "0.6959331", "0.69562584", "0.69475454", "0.6945024", "0.6935219", "0.6919601", "0.69105494", "0.69093555", "0.6895321", "0.68920314", "0.68841666", "0.6882744", "0.68820083", "0.68746954", "0.68712574", "0.6866652", "0.6866569", "0.6840663", "0.683584" ]
0.0
-1
Add more helper methods to be used by all tests here...
def sign_in(test_user = :user_1) visit new_user_session_path fill_in 'Email', with: users(test_user).email fill_in 'Password', with: 'password' click_on 'Log in' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_legacy_helpers\n assert_equal @patron.primary_phone, @patron.primary_address_phone\n assert_equal @patron.secondary_phone, @patron.secondary_address_phone\n assert_nil @patron.primary_address_mobile_phone\n assert_nil @patron.secondary_address_mobile_phone\n end", "def helpers; end", "def helpers; end", "def helpers; end", "def my_tests\n end", "def tests; end", "def tests; end", "def testing\n # ...\n end", "def test_legacy\n # Set up legacy handlers\n setup_legacy_handling\n\n common_tests\n end", "def test_method\n end", "def define_helpers; end", "def test_defaults\n end", "def self_test; end", "def self_test; end", "def test_case; end", "def default_test; end", "def default_test\r\n end", "def default_test\n end", "def __dummy_test__\n end", "def test_added_methods\r\n assert_respond_to @default_user, :roles\r\n assert_respond_to @default_user, :has_role?\r\n \r\n assert_respond_to @default_user, :permissions\r\n assert_respond_to @default_user, :has_static_permission?\r\n end", "def test_nothing\n end", "def default_test\n end", "def test_cases; end", "def test_users_searches\n do_users_all\n do_simple_query\n do_tag_query\n do_profile_query\n end", "def stest_method_1(test); end", "def test_should_eat()\n yay_or_nay = should_eat(\"ice cream\", \"winter\")\n assert_equal(\"False\", should_eat)\n end", "def test_nothing\n end", "def should; super end", "def before_test(test); end", "def before_test(test); end", "def spec; end", "def spec; end", "def test_entry_attrs\n raise \"Implement this method in your test class\"\n end", "def test_get_content_for\n end", "def test\n end", "def test\n end", "def test\n end", "def test_hack\n assert(true)\n end", "def test_pet_shop_name # this uses a function calles pet_shop_name ans passes in the argument @petshop (which contains the list of pets and admin info)\n name = pet_shop_name(@pet_shop) # the function should pull out the the name:\n assert_equal(\"Camelot of Pets\", name) # should return Camelot of pets\n end", "def test \n end", "def test_nothing; end", "def test_entry_attrs\n raise 'Implement the method \"test_entry_attrs\" in your test class'\n end", "def test\n\n end", "def compare_tests(test_a, test_b); end", "def compare_tests(test_a, test_b); end", "def assertions; end", "def assertions; end", "def test_setup\r\n \r\n end", "def test_truth\n end", "def build_test_helper \n \n return if skip_method(__method__)\n \n puts \"build Rails test helper for #{model_name} in test/helpers\"\n filename = \"#{plural_table_name}_helper_test.rb\"\n\n template = File.read(template(\"rails/test/helper_test.rb\"))\n # #text = ERB.new(template, nil, '-').result(binding)\n text = Erubis::Eruby.new(template).evaluate( self )\n\n path = namespaced_path(\"test/helpers\",filename)\n write_artifact(path,text) \n end", "def make_assertions_on_tests( tests, method )\n assert_equal false, tests[:bad].__send__( method )\n assert_equal true, tests[:good].__send__( method )\n assert_equal true, tests[:extra_good].__send__( method )\n end", "def default_test\n end", "def default_test\n end", "def test_entry\n raise \"Implement this method in your test class\"\n end", "def helper_method(*methods); end", "def integration_test()\n return [\"all\"]\n end", "def test_entry\n raise 'Implement the method \"test_entry\" in your test class'\n end", "def test_order; end", "def test_nothing\n return true\n end", "def test_a\n end", "def test_frameworks; end", "def prepare_helpers\n base = File.join(config[:test_base_path], \"helpers\")\n\n helper_files.each do |src|\n dest = File.join(sandbox_suites_dir, src.sub(\"#{base}/\", \"\"))\n FileUtils.mkdir_p(File.dirname(dest))\n FileUtils.cp(src, dest, preserve: true)\n end\n end", "def smoke_test ()\n\n smoke_test = [\"rest_get\"]\n return smoke_test\n end", "def add_testing\n setup_rspec\n setup_rspec_generators\n setup_rails_helper\n setup_factories_file\nend", "def testHelper arr, description, expected\n\tresult = leastOccuringValueInArray(arr)\n\tString resultType = result.class\n\t \n\tString testStatus = \"Failed\"\n\tif (leastOccuringValueInArray(arr).class == expected.class)\n\t\t(leastOccuringValueInArray(arr) == expected)? testStatus = \"Passed\" : testStatus = \"Failed\"\n\tend\n\t\n\t# Print test results\n\tputs \"| \" + testStatus + \" | \" + description + \", expected: \" + expected.to_s + \"(\" + expected.class.to_s + \")\" + \", actual: \" + result.to_s + \"(\" + resultType.to_s + \")\"\nend", "def test_respond_to\n assert_respond_to system_wide, :role\n assert_respond_to system_wide, :role=\n assert_respond_to system_wide, :inspect\n assert_respond_to system_wide, :object_id\n end", "def final_test_methods\n return []\n end", "def tests=(_arg0); end", "def tests=(_arg0); end", "def running_test_case; end", "def test\n return \"\ndef test_#{@test_name}\n assert_nothing_raised(#{self.class.name}) do\n #{@method} :#{@action}, #{@params.inspect}, #{@session.inspect}, #{@flash.inspect}\n end\nend\n\"\n end", "def smoke_test()\n return [\"case_aaaa\"]\n end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def test_guest_name\n assert_equal('Peter', @guest1.return_guest_name)\n end", "def test_truth\n april = riders(:rider_1)\n assert_equal \"April Jones\", april.name\n trigger = horses(:horse_1)\n assert_equal \"Trigger\", trigger.name\n event2 = events(:event_2)\n assert_equal \"5 Horse Scramble\", event2.name\n \n end", "def generate_alltest\n\n end", "def test_camel_case\n raise NotImplementedError, 'Undecided as to whether to check camel case or not'\n end", "def test_find_single_item\n\n result=find_single_item(@warehouse_data, :b7)\n assert_equal(\"bath fizzers\",result)\n \nend", "def test_autocomplete_searches\n do_find_all\n do_autocomplete_query\n end", "def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend" ]
[ "0.7330966", "0.701972", "0.701972", "0.701972", "0.6772961", "0.6679903", "0.6679903", "0.6583205", "0.65507036", "0.6377433", "0.63762784", "0.632961", "0.6280821", "0.6280821", "0.6249786", "0.6142927", "0.6137607", "0.6121912", "0.6108209", "0.60972595", "0.60949636", "0.6085482", "0.6077252", "0.60748607", "0.603319", "0.60055846", "0.60010356", "0.59755695", "0.5975158", "0.5975158", "0.5973282", "0.5973282", "0.59555405", "0.59167516", "0.59057903", "0.59057903", "0.59057903", "0.5894578", "0.5886192", "0.58858806", "0.5885474", "0.58805525", "0.5860731", "0.5860412", "0.5860412", "0.584998", "0.584998", "0.58033717", "0.5794802", "0.5785648", "0.57691133", "0.57356757", "0.57356757", "0.5733712", "0.5718457", "0.569885", "0.5686251", "0.56847906", "0.56680214", "0.5660432", "0.56465375", "0.5645647", "0.5644992", "0.56355596", "0.5591017", "0.55830294", "0.5579137", "0.55729306", "0.55729306", "0.5563504", "0.555469", "0.55488664", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.5540873", "0.55373555", "0.5536957", "0.55365646", "0.5536232", "0.5533716", "0.5533225", "0.5530253", "0.5530253", "0.5530253", "0.5530253" ]
0.0
-1
GET /institutes/1 GET /institutes/1.xml
def show @institute = Institute.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @institute } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @institucion = Institucion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @institucion }\n end\n end", "def index\n @institutos = Instituto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @institutos }\n end\n end", "def show\n @instituicao = Instituicao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @instituicao }\n end\n end", "def show\n @university = University.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @university }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @instituto }\n end\n end", "def show\n @sitio = Sitio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sitio }\n end\n end", "def show\n @situacoes_juridica = SituacoesJuridica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @situacoes_juridica }\n end\n end", "def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end", "def index\n @med_insts = MedInst.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @med_insts }\n end\n end", "def index\n @interests = Interests.for_person(@person)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @interests }\n end\n end", "def new\n @institucion = Institucion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @institucion }\n end\n end", "def show\n @interests = Interests.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @interests }\n end\n end", "def index\n\t\t@people = Person.all\n\t\t# respond_to do |format|\n\t\t# \tformat.xml { send_data @entries.to_xml, :type => 'text/xml; charset=UTF-8;', :disposition => 'attachment; filename=entries.xml'}\n\t\t# end\n\tend", "def index\n @user = User.find(params[:user_id]) \n @invitations = @user.invitations\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @invitations.to_xml }\n end\nend", "def index\n @ministries = Ministry.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ministries }\n end\n end", "def show\n @analisis = Analisis.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @analisis }\n end\n end", "def show\n @interest = Interest.find(params[:id])\n @interests = Interest.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @interest }\n end\n end", "def show\n @research = Research.find(params[:id])\n @page_title = \"Hello Congress research request: \" + @research.name\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end", "def new\n @institution = Institution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @institution }\n end\n end", "def index\n @usrs = Usr.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @usrs }\n end\n end", "def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end", "def index\n @st_ipis = StIpi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @st_ipis }\n end\n end", "def user_data_xml\n run_url = 'http://nikerunning.nike.com/nikeplus/v1/services/widget/get_public_user_data.jsp?userID='\n run_url += @id.to_s\n open(run_url)\n end", "def new\n @institute = Institute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @institute }\n end\n end", "def index\n @universities = University.find(:all,:conditions => [\"data_type = ?\",\"university\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @universities }\n end\n end", "def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @institution }\n format.json {render :json => {\"success\"=>true,\"data\"=>@institution} }\n \n end\n end", "def index\n @institucions = Institucion.search(params[:search], params[:page])\n end", "def show\n @solicitation = Solicitation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @solicitation }\n end\n end", "def index\n @insts = Inst.all\n end", "def show\n @rute = Rute.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rute }\n end\n end", "def show\n @st_ipi = StIpi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @st_ipi }\n end\n end", "def show\n @incident = Incident.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @incident }\n end\n end", "def show\n @incident = Incident.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @incident }\n end\n end", "def index\n @users = User.all\n render :xml => @users\n end", "def show\n @occurrence = Occurrence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @occurrence }\n end\n end", "def show\n @visit_stat = VisitStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @visit_stat }\n end\n end", "def show\n @ministries = Ministries.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ministries }\n end\n end", "def show\n @ministry = Ministry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ministry }\n end\n end", "def show\n @citystatistic = Citystatistic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @citystatistic }\n end\n end", "def index\n @universes = Universe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @universes }\n end\n end", "def show\n @interviews_it = Interviews::It.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @interviews_it }\n end\n end", "def index\n @invitations = Invitation.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @invitations.to_xml }\n end\n end", "def show\n @socioeconomic_ocupation = SocioeconomicOcupation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @socioeconomic_ocupation }\n end\n end", "def index\n @sites = current_user.sites\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end", "def index\n @sites = current_user.sites\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end", "def show\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estagio }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @download_registrations }\n end\n end", "def show\n @sitetype = Sitetype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sitetype }\n end\n end", "def show\n @estados_civil = EstadosCivil.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estados_civil }\n end\n end", "def index\n @admin_informations = Admin::Information.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @admin_informations }\n end\n end", "def show\n @technician = Technician.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @technician }\n end\n end", "def show\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estudiante }\n end\n end", "def show\n @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @invitation.to_xml }\n end\nend", "def show\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estudiante }\n end\n end", "def index\n @estatus = Estatu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @estatus }\n end\n end", "def index\n @invitations = Invitation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @invitations }\n end\n end", "def show\n @instancia_item = InstanciaItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @instancia_item }\n end\n end", "def index\n @visit_stats = VisitStat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @visit_stats }\n end\n end", "def show\n @cst_ipi = CstIpi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @cst_ipi }\n end\n end", "def show\n @user_datum = UserDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_datum }\n end\n end", "def institutions(pageIndex=0, options={})\n options.merge!({:query => {:pageIndex => pageIndex}})\n self.class.get(\"/Institutions.json\", options)\n end", "def show\n @island = Island.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @island }\n end\n end", "def index\n @registrations = Registration.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @registrations }\n end\n end", "def index\n @registrations = Registration.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @registrations }\n end\n end", "def show\n @alumni = Alumni.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @alumni }\n end\n end", "def read(id=nil)\r\n request = Net::HTTP.new(@uri.host, @uri.port)\r\n if id.nil?\r\n response = request.get(\"#{@uri.path}.xml\") \r\n else\r\n response = request.get(\"#{@uri.path}/#{id}.xml\") \r\n end\r\n response.body\r\n end", "def rest_get(uri)\n \n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n return doc\n \n end\n \nend", "def show\n @estatu = Estatu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estatu }\n end\n end", "def show\n @estacion = Estacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estacion }\n end\n end", "def show\n @neural_population = NeuralPopulation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @neural_population }\n end\n end", "def index\n @cst_ipis = CstIpi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cst_ipis }\n end\n end", "def show\n @inventario = Inventario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @inventario }\n end\n end", "def show\n\t@storecunsumption = Storecunsumption.find(params[:id])\n\t\trespond_to do |format|\t\t\n\t\tformat.html \n\t\tformat.xml { render :xml => @storecunsumptions }\t\t#Render to XML File\n\t\tend\n\tend", "def show\n @regiment = Regiment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @regiment }\n end\n end", "def index\n @uitgelichts = Uitgelicht.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uitgelichts }\n end\n end", "def index\n @iwiw_users = IwiwUser.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @iwiw_users }\n end\n end", "def show\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end", "def show\n @identity = Identity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @identity }\n end\n end", "def show\n @insurer = Insurer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @insurer }\n end\n end", "def show\n @utilisateur = Utilisateur.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @utilisateur }\n end\n end", "def show\n @interview = Interview.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @interview }\n end\n end", "def index\n @countdowns = Countdown.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @countdowns }\n end\n end", "def index\n @creations = Creation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @creations }\n end\n end", "def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution }\n end\n end", "def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @infraction_type }\n end\n end", "def index\n @user = self.current_user\n @sites = @user.find_sites(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @sites.to_xml }\n end\n end", "def show\n @occurence = Occurence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @occurence }\n end\n end", "def show\n @representative = Representative.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @representative }\n end\n end", "def show\n @oil = Oil.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @oil }\n end\n end", "def new\n @situacoes_juridica = SituacoesJuridica.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @situacoes_juridica }\n end\n end", "def show\n @oil = Oil.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @oil }\n end\n end", "def show\n @countdown_ipp = CountdownIpp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @countdown_ipp }\n end\n end", "def show\n @user = User.find(params[:id])\n xml_user = { :percent => @user.total_percent_this_week }\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => xml_user }\n end\n end", "def show\n @lunch = Lunch.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lunch }\n end\n end", "def internships\n respond_to do |format|\n format.html # internships.html.erb\n format.xml { render :xml => nil }\n end\n end", "def new\n @instituicao = Instituicao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituicao }\n end\n end", "def index\n @entries = @resource_finder.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @infraction_types }\n end\n end" ]
[ "0.622178", "0.602342", "0.5913585", "0.586259", "0.58473563", "0.58129275", "0.5792022", "0.5777551", "0.5719514", "0.569494", "0.5681596", "0.56767726", "0.56626225", "0.56564885", "0.56233954", "0.5603082", "0.55932164", "0.5583041", "0.5572815", "0.5571242", "0.55709", "0.5566341", "0.5565607", "0.5547538", "0.5544048", "0.5543302", "0.5528179", "0.5516387", "0.55120206", "0.55098385", "0.55068517", "0.55017585", "0.55017585", "0.5496423", "0.549463", "0.5482728", "0.54585207", "0.54558724", "0.54531956", "0.54458165", "0.5445486", "0.5444421", "0.54368466", "0.5427627", "0.5427627", "0.5422307", "0.5416051", "0.5407825", "0.54007715", "0.539593", "0.53919095", "0.53897226", "0.53874487", "0.5386698", "0.538662", "0.53806096", "0.5378542", "0.5369837", "0.5366825", "0.5366136", "0.53611517", "0.5360666", "0.53580934", "0.53562045", "0.53562045", "0.53548294", "0.53523433", "0.5350681", "0.53486943", "0.5346488", "0.53405505", "0.5340127", "0.5340054", "0.5338073", "0.53361475", "0.5330549", "0.53213537", "0.53200877", "0.53197944", "0.5318185", "0.5317643", "0.53153384", "0.5314559", "0.5314357", "0.5313526", "0.5313526", "0.5310461", "0.530283", "0.5302617", "0.5300744", "0.52997226", "0.5298548", "0.52981204", "0.5297699", "0.52975917", "0.5296092", "0.52942574", "0.52904963", "0.52898294", "0.5289816" ]
0.62872934
0
GET /institutes/new GET /institutes/new.xml
def new @institute = Institute.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @institute } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end", "def new\n @institucion = Institucion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @institucion }\n end\n end", "def new\n @institution = Institution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @institution }\n end\n end", "def new\n @situacoes_juridica = SituacoesJuridica.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @situacoes_juridica }\n end\n end", "def new\n @interest = Interest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @interest }\n end\n end", "def new\n @instituicao = Instituicao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituicao }\n end\n end", "def new\n @interests = Interests.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @interests }\n end\n end", "def new\n @ministries = Ministries.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ministries }\n end\n end", "def new\n @research = Research.new\n @page_title = \"Request research from White House 2 members\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end", "def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end", "def new\n @solicitation = @representative.solicitations.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @solicitation }\n end\n end", "def new\n @incident = Incident.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @incident }\n end\n end", "def new\n @incident = Incident.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @incident }\n end\n end", "def new\n @registry = @user.registries.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @registry }\n end\n end", "def new\n @ministry = Ministry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ministry }\n end\n end", "def new\n @st_ipi = StIpi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @st_ipi }\n end\n end", "def new\n @incident = Incident.new\n \n @title = \"New Incident\" \n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @incident }\n end\n end", "def new\n @identity = Identity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @identity }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nomina }\n end\n end", "def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end", "def new\n @sti = Sti.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sti }\n end\n end", "def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end", "def new\n @representative = Representative.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @representative }\n end\n end", "def new\n @nom = Nom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nom }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @infraction_type }\n end\n end", "def new\n @sitetype = Sitetype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sitetype }\n end\n end", "def new\n @interes = Interes.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @interes }\n end\n end", "def new\n @occurence = Occurence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @occurence }\n end\n end", "def new\n @people = People.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @people }\n end\n end", "def new\n @county = County.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @county }\n end\n end", "def new\n @regiment = Regiment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @regiment }\n end\n end", "def new\n @estagio = Estagio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estagio }\n end\n end", "def new\n @personal = Personal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @personal }\n end\n end", "def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end", "def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end", "def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @neighborhood }\n end\n end", "def new\n @estatu = Estatu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estatu }\n end\n end", "def new\n @estacion = Estacion.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estacion }\n end\n end", "def new\n @entry = @resource_finder.new\n initialize_new_resource\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def new\n @universe = Universe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @universe }\n end\n end", "def new\n @visit_stat = VisitStat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @visit_stat }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end", "def new\n @want = Want.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @want }\n end\n end", "def new\n @inventario = Inventario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @inventario }\n end\n end", "def new\n @title = \"New Networks\"\n @network = Network.new\n @computers = Computer.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @network }\n end\n end", "def new\n @estados_civil = EstadosCivil.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estados_civil }\n end\n end", "def new\n @island = Island.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @island }\n end\n end", "def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end", "def new\n @index = Indice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @index }\n end\n end", "def new\n @noticium = Noticium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @noticium }\n end\n end", "def new\n @usr = Usr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usr }\n end\n end", "def new\n @url_migration = UrlMigration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_migration }\n end\n end", "def new\n @geoname = Geoname.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @geoname }\n end\n end", "def new\n @crew = Crew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @crew }\n end\n end", "def new\n @nossos_servico = NossosServico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end", "def new\n @rute = Rute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rute }\n end\n end", "def new\n @pool = Pool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pool }\n end\n end", "def new\n @discovery = Discovery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @discovery }\n end\n end", "def new\n @estudiante = Estudiante.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estudiante }\n end\n end", "def new\n @administration = Administration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administration }\n end\n end", "def new\n @info = Info.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @info }\n end\n end", "def new\n @info = Info.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @info }\n end\n end", "def new\n @reqinfo = Reqinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reqinfo }\n end\n end", "def new\n @town = Town.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @town }\n end\n end", "def new\n @oil = Oil.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @oil }\n end\n end", "def new\n @oil = Oil.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @oil }\n end\n end", "def new\n @latestinfo = Latestinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @latestinfo }\n end\n end", "def new\n @solicitud = Solicitud.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @solicitud }\n end\n end", "def new\n @impressoras = Impressora.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @impressoras }\n end\n end", "def new\n @registration = Registration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @registration }\n end\n end", "def new\n @registration = Registration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @registration }\n end\n end", "def new\n @registration = Registration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @registration }\n end\n end", "def new\n @users = User.find(:all)\n @invoice = Invoice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @invoice }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @uitgelicht = Uitgelicht.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @uitgelicht }\n end\n end", "def new\n @rssnew = Rssnews.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rssnew }\n end\n end", "def new\n @person = Person.new\n @title = \"people\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @st_pi = StPi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @st_pi }\n end\n end", "def new\n @curnit = Curnit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @curnit }\n end\n end", "def new\n @addition = Addition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @addition }\n end\n end", "def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end", "def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end", "def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end", "def new\n @newz = Newz.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newz }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recipe }\n end\n end", "def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end", "def new\n @ipsearch = Ipsearch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ipsearch }\n end\n end", "def new\n @cst_ipi = CstIpi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cst_ipi }\n end\n end", "def new\n @noami = Noami.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @noami }\n end\n end" ]
[ "0.71660495", "0.7034771", "0.700963", "0.6757138", "0.67484707", "0.6699236", "0.6659012", "0.66344064", "0.66130537", "0.66082895", "0.6607794", "0.65890986", "0.6562933", "0.6562933", "0.6549678", "0.65486044", "0.6546098", "0.6542282", "0.65261036", "0.6525611", "0.6520047", "0.65198636", "0.6510381", "0.65062517", "0.6503133", "0.6499453", "0.6499283", "0.64876497", "0.6475325", "0.6474481", "0.6466756", "0.6465016", "0.6464274", "0.6442103", "0.644122", "0.644122", "0.64408785", "0.6436102", "0.6434233", "0.64294416", "0.6427889", "0.64259815", "0.6422125", "0.64198804", "0.64167076", "0.6416298", "0.64151776", "0.6409358", "0.64010584", "0.63989884", "0.63968813", "0.63968754", "0.6384487", "0.6383678", "0.6382917", "0.6382397", "0.63809854", "0.6379161", "0.6376647", "0.6376539", "0.6376242", "0.63666874", "0.63666874", "0.6363029", "0.6360816", "0.63550276", "0.63550276", "0.635222", "0.63503563", "0.6348199", "0.6347543", "0.6347543", "0.6347543", "0.6347114", "0.63470817", "0.63470817", "0.63470817", "0.63470817", "0.63470817", "0.63470817", "0.63470817", "0.63470817", "0.63470817", "0.63470817", "0.63403744", "0.6338724", "0.63350993", "0.6334138", "0.63319975", "0.6331403", "0.6329194", "0.63277084", "0.63277084", "0.63277084", "0.63260794", "0.6323599", "0.63234407", "0.6320625", "0.63202894", "0.6318713" ]
0.690252
3
POST /institutes POST /institutes.xml
def create @institute = Institute.new(params[:institute]) respond_to do |format| if @institute.save format.html { redirect_to(@institute, :notice => 'Institute was successfully created.') } format.xml { render :xml => @institute, :status => :created, :location => @institute } else format.html { render :action => "new" } format.xml { render :xml => @institute.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @institucion = Institucion.new(params[:institucion])\n\n respond_to do |format|\n if @institucion.save\n flash[:notice] = 'Institucion se ha creado con exito.'\n format.html { redirect_to(admin_institucions_url) }\n format.xml { render :xml => @institucion, :status => :created, :location => @institucion }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @institucion.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @instancium = Instancium.new(instancium_params)\n\n respond_to do |format|\n if @instancium.save\n format.html { redirect_to @instancium, notice: 'Instancium was successfully created.' }\n format.json { render :show, status: :created, location: @instancium }\n else\n format.html { render :new }\n format.json { render json: @instancium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n if @instituto.save\n format.html { redirect_to(@instituto, :notice => 'Instituto fue creado exitosamente.') }\n format.xml { render :xml => @instituto, :status => :created, :location => @instituto }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @instituto.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end", "def create\n @instituicao = Instituicao.new(params[:instituicao])\n\n respond_to do |format|\n if @instituicao.save\n format.html { redirect_to(@instituicao, :notice => 'Instituicao was successfully created.') }\n format.xml { render :xml => @instituicao, :status => :created, :location => @instituicao }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @instituicao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @solicitation = @representative.solicitations.new(params[:solicitation])\n\n respond_to do |format|\n if @solicitation.save\n flash[:notice] = 'Solicitation was successfully created.'\n format.html { redirect_to(representative_solicitations_path(@representative)) }\n format.xml { render :xml => @solicitation, :status => :created, :location => @solicitation }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @solicitation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @instituto = Instituto.new(instituto_params)\n\n respond_to do |format|\n if @instituto.save\n format.html { redirect_to @instituto, notice: 'O instituto foi criado com sucesso.' }\n format.json { render :show, status: :created, location: @instituto }\n else\n format.html { render :new }\n format.json { render json: @instituto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @institucion = Institucion.new(institucion_params)\n\n respond_to do |format|\n if @institucion.save\n format.html { redirect_to @institucion, notice: 'Empresa se ha creado correctamente.' }\n format.json { render :show, status: :created, location: @institucion }\n else\n format.html { render :new }\n format.json { render json: @institucion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @institution = Institution.new(institution_params)\n\n respond_to do |format|\n if @institution.save\n format.html { redirect_to @institution, notice: 'Instituição cadastrada com sucesso.' }\n format.json { render :show, status: :created, location: @institution }\n else\n format.html { render :new }\n format.json { render json: @institution.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @interests = Interests.new(params[:interests])\n @interests.person = @person\n\n respond_to do |format|\n if @interests.save\n flash[:notice] = 'Interests saved.'\n format.html { redirect_to(welcome_path(:id => @person)) }\n format.xml { render :xml => @interests, :status => :created, :location => @interests }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @interests.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @situacoes_juridica = SituacoesJuridica.new(params[:situacoes_juridica])\n\n respond_to do |format|\n if @situacoes_juridica.save\n format.html { redirect_to(@situacoes_juridica, :notice => 'Situação jurídica cadastrada com sucesso.') }\n format.xml { render :xml => @situacoes_juridica, :status => :created, :location => @situacoes_juridica }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @situacoes_juridica.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\n @instum = current_user.insta.build(instum_params)\n # @instum.user_id = current_user.id\n\n respond_to do |format|\n if @instum.valid?\n @instum.save\n # binding.pry\n # redirect_to insta_path, notice: \"写真を投稿しました!\"\n # NoticeMailer.sendmail_insta(@instum).deliver\n format.html { redirect_to @instum, notice: '投稿が成功しました!' }\n format.json { render :show, status: :created, location: @instum }\n else\n format.html { render :new }\n format.json { render json: @instum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @institution = current_user.institutions.new(institution_params)\n\n if @institution.save\n render :show, status: :created\n else\n render json: @institution.errors.full_messages, status: :unprocessable_entity\n end\n end", "def create\n @interest = Interest.new(params[:interest])\n\n respond_to do |format|\n if @interest.save\n flash[:notice] = 'Interest was successfully created.'\n format.html { redirect_to(@interest) }\n format.xml { render :xml => @interest, :status => :created, :location => @interest }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end", "def create\n @instagrampic = Instagrampic.new(instagrampic_params)\n\n respond_to do |format|\n if @instagrampic.save\n format.html { redirect_to @instagrampic, notice: 'Instagrampic was successfully created.' }\n format.json { render :show, status: :created, location: @instagrampic }\n else\n format.html { render :new }\n format.json { render json: @instagrampic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @institution = Institution.new(params[:institution])\n @institution.parametres_cabinet_id = current_user.parametres_cabinet.id\n respond_to do |format|\n if @institution.save\n format.html { redirect_to(@institution, :notice => 'Institution was successfully created.') }\n format.xml { render :xml => @institution, :status => :created, :location => @institution }\n format.json {render :json => {\"success\"=>true,\"data\"=>@institutions} }\n \n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @institution.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create(params = {})\n wrapped_params = { insurance: params }\n @client.make_request(:post, 'insurances', MODEL_CLASS, wrapped_params)\n end", "def create\n doc = Nokogiri::XML(request.body.read)\n bNode = doc.xpath('elwak/benutzer')\n\n @benutzer = Benutzer.new(benutzer_params(bNode))\n if @benutzer.save\n if bNode.xpath('objekt_zuordnungs').length > 0\n objekt_ids = bNode.xpath('objekt_zuordnungs/objekt_id').map{|oz| oz.text.to_s.to_i}\n @benutzer.setze_objekt_zuordnungen(objekt_ids)\n end\n success(@benutzer.id)\n else\n error(@benutzer.errors)\n end\n end", "def create\n @institucional = Institucional.new(params[:institucional])\n\n respond_to do |format|\n if @institucional.save\n format.html { redirect_to @institucional, notice: 'Institucional was successfully created.' }\n format.json { render json: @institucional, status: :created, location: @institucional }\n else\n format.html { render action: \"new\" }\n format.json { render json: @institucional.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sitio = Sitio.new(params[:sitio])\n\n respond_to do |format|\n if @sitio.save\n format.html { redirect_to(@sitio, :notice => 'Sitio was successfully created.') }\n format.xml { render :xml => @sitio, :status => :created, :location => @sitio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sitio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @institution = Institution.new(params[:institution])\n\n respond_to do |format|\n if @institution.save\n format.html { redirect_to @institution, notice: 'Institution was successfully created.' }\n format.json { render json: @institution, status: :created, location: @institution }\n else\n format.html { render action: \"new\" }\n format.json { render json: @institution.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @institution = Institution.new(params[:institution])\n\n respond_to do |format|\n if @institution.save\n format.html { redirect_to @institution, notice: 'Institution was successfully created.' }\n format.json { render json: @institution, status: :created, location: @institution }\n else\n format.html { render action: \"new\" }\n format.json { render json: @institution.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #returning connection.post(collection_path, to_xml, self.class.headers) do |response|\n returning connection.post(collection_path, to_ssj, self.class.headers) do |response|\n self.id = id_from_response(response)\n load_attributes_from_response(response)\n end\n end", "def create\n @one_reg_institution.institution_id = @institution\n @one_reg_institution = @institution.one_reg_institutions.build(params[:one_reg_institution])\n\n\n respond_to do |format|\n if @one_reg_institution.save\n format.html { redirect_to @institution, notice: 'Reg-Inst.1/R01 Creado Exitosamente.' }\n format.json { render json: @one_reg_institution, status: :created, location: @one_reg_institution }\n else\n format.html { render action: \"new\" }\n format.json { render json: @one_reg_institution.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @instagramposter = Instagramposter.new(instagramposter_params)\n\n respond_to do |format|\n if @instagramposter.save\n format.html { redirect_to [:admin, @instagramposter], notice: 'Instagramposter was successfully created.' }\n format.json { render :show, status: :created, location: @instagramposter }\n else\n format.html { render :new }\n format.json { render json: @instagramposter.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @institucion = Institucion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @institucion }\n end\n end", "def create_and_invitation_studant(params = {})\n run(:post, \"/invitations\", [201,422], JSON.dump(params))\n end", "def create\n @interes = Interes.new(params[:interes])\n\n respond_to do |format|\n if @interes.save\n format.html { redirect_to(@interes, :notice => 'Interes was successfully created.') }\n format.xml { render :xml => @interes, :status => :created, :location => @interes }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @interes.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @night = Night.new(night_params)\n @night.user = current_user\n\n respond_to do |format|\n if @night.save\n format.html { redirect_to root_path, notice: 'Sua noite foi registrada!' }\n format.json { render :show, status: :created, location: root_path }\n else\n format.html { render :new }\n format.json { render json: @night.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @st_ipi = StIpi.new(params[:st_ipi])\n\n respond_to do |format|\n if @st_ipi.save\n flash[:notice] = 'IPI criado.'\n format.html { redirect_to(@st_ipi) }\n format.xml { render :xml => @st_ipi, :status => :created, :location => @st_ipi }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @st_ipi.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @instituicao = Instituicao.new(params[:instituicao])\n\n respond_to do |format|\n if @instituicao.save\n format.html { redirect_to @instituicao, notice: 'Instituicao was successfully created.' }\n format.json { render json: @instituicao, status: :created, location: @instituicao }\n else\n format.html { render action: \"new\" }\n format.json { render json: @instituicao.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @siren = Siren.new(siren_params)\n\n respond_to do |format|\n if @siren.save\n format.html { redirect_to @siren, notice: 'Siren was successfully created.' }\n format.json { render :show, status: :created, location: @siren }\n else\n format.html { render :new }\n format.json { render json: @siren.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @situacoes_juridica = SituacoesJuridica.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @situacoes_juridica }\n end\n end", "def create\n @universite = Universite.new(params[:universite])\n\n respond_to do |format|\n if @universite.save\n flash[:notice] = \"L'université a été ajouté\"\n format.html { redirect_to :controller => \"pages\", :action => \"partenaires\" }\n format.xml { head :created, :location => universite_url(@universite) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @universite.errors.to_xml }\n end\n end\n end", "def create_rest\n @entry_instrument = EntryInstrument.new(params[:entry_instrument])\n\n respond_to do |format|\n if @entry_instrument.save\n flash[:notice] = 'EntryInstrument was successfully created.'\n format.html { redirect_to(@entry_instrument) }\n format.xml { render :xml => @entry_instrument, :status => :created, :location => @entry_instrument }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entry_instrument.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_should_create_invite_via_API_XML\r\n get \"/logout\"\r\n post \"/invites.xml\", :api_key=>'testapikey',\r\n :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => '[email protected]',\r\n :user_id => 1 }\r\n assert_response :created\r\n end", "def create\n @institution = Institution.new(institution_params)\n\n respond_to do |format|\n if @institution.save\n format.html { redirect_to @admin_institution, notice: 'Institution was successfully created.' }\n format.json { render action: 'show', status: :created, location: @admin_institution }\n else\n format.html { render action: 'new' }\n format.json { render json: @admin_institution.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @institute = Institute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @institute }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end", "def create\n @instarter = Instarter.new(instarter_params)\n\n respond_to do |format|\n if @instarter.save\n format.html { redirect_to @instarter, notice: 'Instarter was successfully created.' }\n format.json { render :show, status: :created, location: @instarter }\n else\n format.html { render :new }\n format.json { render json: @instarter.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x|\n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x|\n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end", "def create\n @interno_unidad = InternoUnidad.new(interno_unidad_params)\n\n respond_to do |format|\n if @interno_unidad.save\n format.html { redirect_to @interno_unidad, notice: 'Interno unidad was successfully created.' }\n format.json { render :show, status: :created, location: @interno_unidad }\n else\n format.html { render :new }\n format.json { render json: @interno_unidad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @institution = Institution.find params[:site][:institution_id]\n return unless authorize_resource(@institution, CREATE_INSTITUTION_SITE)\n\n @site = @institution.sites.new(site_params)\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to sites_path, notice: 'Site was successfully created.' }\n format.json { render action: 'show', status: :created, location: @site }\n else\n format.html { render action: 'new' }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @inews = Inews.new(inews_params)\n\n respond_to do |format|\n if @inews.save\n format.html { redirect_to @inews, notice: 'Inews was successfully created.' }\n format.json { render :show, status: :created, location: @inews }\n else\n format.html { render :new }\n format.json { render json: @inews.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_institution(inst_name, inst_site, inst_number, inst_email)\n Institution.transaction do\n new_institution = Institution.new(name: inst_name,\n website: inst_site,\n phone_number: inst_number,\n email: inst_email)\n new_institution.id = @inst_id\n @inst_id += 1 if new_institution.save!\n @institutions << new_institution\n end\n end", "def create\n @estatu = Estatu.new(params[:estatu])\n\n respond_to do |format|\n if @estatu.save\n format.html { redirect_to(@estatu, :notice => 'Registro creado correctamente.') }\n format.xml { render :xml => @estatu, :status => :created, :location => @estatu }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estatu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @institution = Institution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @institution }\n end\n end", "def create\n @supervisor_estagio = SupervisorEstagio.new(params[:supervisor_estagio])\n\n respond_to do |format|\n if @supervisor_estagio.save\n flash[:notice] = 'Supervisor de Estagio cadastrado com sucesso.'\n format.html { redirect_to(@supervisor_estagio) }\n format.xml { render :xml => @supervisor_estagio, :status => :created, :location => @supervisor_estagio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @supervisor_estagio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @ministries = Ministries.new(params[:ministries])\n\n respond_to do |format|\n if @ministries.save\n flash[:notice] = 'Ministries was successfully created.'\n format.html { redirect_to(@ministries) }\n format.xml { render :xml => @ministries, :status => :created, :location => @ministries }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ministries.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @inst = Institute.new\n @inst.name = params[:institute][:name]\n @inst.url = params[:institute][:url]\n\n # we need the model persisted before we set the manager and logo\n if @inst.save\n set_manager_settings\n\n if params[:institute][:logo].present?\n add_logo(params[:institute][:logo])\n flash[:error] = t('dri.flash.error.unable_to_save_logo') unless @inst.save\n end\n\n flash[:notice] = t('dri.flash.notice.organisation_created')\n\n respond_to do |format|\n format.html { redirect_to organisation_url(@inst) }\n end\n else\n flash[:error] = t('dri.flash.error.unable_to_save_organisation')\n end\n end", "def create\n @user_interest = UserInterest.new(user_interest_params)\n\n respond_to do |format|\n if @user_interest.save\n format.html { redirect_to @user_interest, notice: 'User interest was successfully created.' }\n format.json { render :show, status: :created, location: @user_interest }\n else\n format.html { render :new }\n format.json { render json: @user_interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @universities = University.all\n @university = University.find(:first,:conditions => [\"name = ?\",private_mw])\n @alumini = Alumini.new(params[:alumini])\n\n respond_to do |format|\n if @alumini.save\n flash[:notice] = 'Alumini was successfully created.'\n format.html { redirect_to(aluminis_url) }\n format.xml { render :xml => @alumini, :status => :created, :location => @alumini }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @alumini.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n neo = Neography::Rest.new\n city = neo.create_node(params[:city])\n redirect_to cities_path\n end", "def create\n @institute = Institute.new(institute_params)\n authorize @institute\n respond_to do |format|\n if @institute.save\n format.html { redirect_to @institute, notice: 'Institute was successfully created.' }\n format.json { render :show, status: :created, location: @institute }\n else\n format.html { render :new }\n format.json { render json: @institute.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x| \n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x| \n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end", "def post_network(request)\n # --- Create the new Instance ---\n network = VirtualNetworkOCCI.new(\n VirtualNetwork.build_xml,\n @client,\n request.body,\n @config[:template_location])\n\n # --- Generate the template and Allocate the new Instance ---\n template = network.to_one_template\n return template, 500 if OpenNebula.is_error?(template)\n\n rc = network.allocate(template, @config[:cluster_id]||ClusterPool::NONE_CLUSTER_ID)\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n # --- Prepare XML Response ---\n network.info\n return to_occi_xml(network, :code=>201)\n end", "def create\n \n \n @usuario = Usuario.create(params[:usuario])\n @[email protected]\n\n #@evento = Evento.new(params[:evento])\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to(@usuario, :notice => t('exito') ) }\n format.xml { render :xml => @usuario, :status => :created, :location => @usuario }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @usuario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @interest = Interest.new(params[:interest])\n \n respond_to do |format|\n if @interest.save\n format.json { render :json => @interest,\n :status => :created, :location => @interest }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n end", "def create(name=\"Default name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Post.new(@url)\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n response.body\n end", "def dame_institucion\n i = Metamares::Institucion.new\n i.nombre_institucion = params[:nombre_institucion]\n\n respond_to do |format|\n format.json { render json: i.busca_institucion.map{ |i| { id: i.id, value: i.nombre_institucion } } }\n format.html { @institucion = i }\n end\n end", "def create\n @nineteen = Nineteen.new(nineteen_params)\n\n respond_to do |format|\n if @nineteen.save\n format.html { redirect_to @nineteen, notice: 'Nineteen was successfully created.' }\n format.json { render action: 'show', status: :created, location: @nineteen }\n else\n format.html { render action: 'new' }\n format.json { render json: @nineteen.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @instance_eni = InstanceEni.new(instance_eni_params)\n\n respond_to do |format|\n if @instance_eni.save\n format.html { redirect_to @instance_eni, notice: 'Instance eni was successfully created.' }\n format.json { render :show, status: :created, location: @instance_eni }\n else\n format.html { render :new }\n format.json { render json: @instance_eni.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @insurer = Insurer.new(params[:insurer])\n\n respond_to do |format|\n if @insurer.save\n format.html { redirect_to(@insurer, :notice => 'Insurer was successfully created.') }\n format.xml { render :xml => @insurer, :status => :created, :location => @insurer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @insurer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @estagio = Estagio.new(params[:estagio])\n\n respond_to do |format|\n if @estagio.save\n flash[:notice] = 'Estagio was successfully created.'\n format.html { redirect_to(@estagio) }\n format.xml { render :xml => @estagio, :status => :created, :location => @estagio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estagio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @estudiante = Estudiante.new(params[:estudiante])\n\n respond_to do |format|\n if @estudiante.save\n format.html { redirect_to(@estudiante, :notice => 'Estudiante was successfully created.') }\n format.xml { render :xml => @estudiante, :status => :created, :location => @estudiante }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estudiante.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @insta_post = InstaPost.new(insta_post_params)\n\n respond_to do |format|\n if @insta_post.save\n format.html { redirect_to @insta_post, notice: 'Insta post was successfully created.' }\n format.json { render :show, status: :created, location: @insta_post }\n else\n format.html { render :new }\n format.json { render json: @insta_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params.permit!\n @interviews_it = Interviews::It.new(params[:interviews_it])\n\n respond_to do |format|\n if @interviews_it.save\n format.html { redirect_to(@interviews_it, :notice => 'It was successfully created.') }\n format.xml { render :xml => @interviews_it, :status => :created, :location => @interviews_it }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @interviews_it.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @interest = Interest.new(params[:interest])\n\n respond_to do |format|\n if @interest.save\n format.html { redirect_to @interest, :notice => 'Interest was successfully created.' }\n format.json { render :json => @interest, :status => :created, :location => @interest }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end", "def incident_create(statuspage_id, incident_name, incident_details, infrastructure_affected, current_status, current_state, notifications = 0, all_infrastructure_affected = \"0\", message_subject = \"Status Notification\")\n data = get_notify(notifications)\n data['statuspage_id'] = statuspage_id\n data['incident_name'] = incident_name\n data['incident_details'] = incident_details\n data['infrastructure_affected'] = infrastructure_affected\n data['current_status'] = current_status\n data['current_state'] = current_state\n data['all_infrastructure_affected'] = all_infrastructure_affected\n data['message_subject'] = message_subject\n\n request :method => :post,\n \t :url => @url + 'incident/create',\n \t :payload => data\n end", "def create\n @resist = Resist.new(resist_params)\n\n respond_to do |format|\n if @resist.save\n format.html { redirect_to @resist, notice: 'Resist was successfully created.' }\n format.json { render :show, status: :created, location: @resist }\n else\n format.html { render :new }\n format.json { render json: @resist.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @nurse = Nurse.new(params[:nurse])\n flash[:notice] = 'Created Nurse.' if @nurse.save\n respond_with @nurse\n end", "def create\n @souvenir = Souvenir.new(souvenir_params)\n\n respond_to do |format|\n if @souvenir.save\n format.html { redirect_to @souvenir, notice: 'Souvenir was successfully created.' }\n format.json { render :show, status: :created, location: @souvenir }\n else\n format.html { render :new }\n format.json { render json: @souvenir.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @incident = Incident.new(incident_params)\n @incident.status = \"abierto\"\n @incident.user ||= current_user\n\n respond_to do |format|\n if @incident.save\n format.html { redirect_to @incident, notice: 'Incidencia registrada' }\n format.json { render :show, status: :created, location: @incident }\n else\n format.html { render :new }\n format.json { render json: @incident.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sitetype = Sitetype.new(params[:sitetype])\n\n respond_to do |format|\n if @sitetype.save\n flash[:notice] = 'Sitetype was successfully created.'\n format.html { redirect_to(@sitetype) }\n format.xml { render :xml => @sitetype, :status => :created, :location => @sitetype }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sitetype.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @cst_ipi = CstIpi.new(params[:cst_ipi])\n\n respond_to do |format|\n if @cst_ipi.save\n flash[:notice] = 'S.T. para Ipi criada.'\n format.html { redirect_to(@cst_ipi) }\n format.xml { render :xml => @cst_ipi, :status => :created, :location => @cst_ipi }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cst_ipi.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n if(current_user.super_admin?)\n @institution = Institution.new(institution_params)\n if @institution.save\n redirect_to @institution, notice: \"Institution was successfully created.\"\n else\n render :new, status: :unprocessable_entity\n end\n end\n end", "def create\n @rute = Rute.new(params[:rute])\n\n respond_to do |format|\n if @rute.save\n format.html { redirect_to(@rute, :notice => 'Rute was successfully created.') }\n format.xml { render :xml => @rute, :status => :created, :location => @rute }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @rute.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @solicitation = @representative.solicitations.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @solicitation }\n end\n end", "def create\n @visitation = Visitation.new(visitation_params)\n\n respond_to do |format|\n if @visitation.save\n format.html { redirect_to @visitation, notice: 'Visitation was successfully created.' }\n format.json { render :show, status: :created, location: @visitation }\n else\n format.html { render :new }\n format.json { render json: @visitation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @insta_account = InstaAccount.new(insta_account_params)\n\n respond_to do |format|\n if @insta_account.save\n format.html { redirect_to @insta_account, notice: 'Insta account was successfully created.' }\n format.json { render :show, status: :created, location: @insta_account }\n else\n format.html { render :new }\n format.json { render json: @insta_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @niveis_ensino = NiveisEnsino.new(params[:niveis_ensino])\n\n respond_to do |format|\n if @niveis_ensino.save\n format.html { redirect_to(@niveis_ensino, :notice => 'Niveis ensino cadastrado com sucesso.') }\n format.xml { render :xml => @niveis_ensino, :status => :created, :location => @niveis_ensino }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @niveis_ensino.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create \n @interest = Interest.new(interest_params)\n @interest.save\n end", "def create\n @sale_representative = SaleRepresentative.new(params[:sale_representative])\n respond_to do |format|\n if @sale_representative.save\n format.html { redirect_to(@sale_representative, :notice => 'Sale representative was successfully created.') }\n format.xml { render :xml => @sale_representative, :status => :created, :location => @sale_representative }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sale_representative.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @interest = Interest.new(params[:interest])\n\n respond_to do |format|\n if @interest.save\n format.html { redirect_to @interest, notice: 'Interest was successfully created.' }\n format.json { render json: @interest, status: :created, location: @interest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def register\n wedgetail = params[:wedgetail]\n @interest=Interest.create(:patient => wedgetail, :user =>@user.wedgetail)\n text=<<EOF\n<a href=\"#\" onclick=\"new Ajax.Request('/record/unregister/#{wedgetail}', \n{asynchronous:true, evalScripts:true}); return false;\">\n<img alt=\"Internet-news-reader\" border=\"0\" id=\"internet-news-reader\" src=\"/images/icons/tango/large/internet-news-reader.png\" valign=\"middle\" />\n<script>new Tip(\"internet-news-reader\",\n\"You have been registered to receive HL7 updates on this patient. Click to unregister\",{title:'Thanks for registering'});\n</script></a>\nEOF\n render :update do |page|\n page.replace_html \"register\",text\n end\n end", "def create\n @instathreat_user = InstathreatUser.new(instathreat_user_params)\n\n respond_to do |format|\n if @instathreat_user.save\n format.html { redirect_to @instathreat_user, notice: 'Instathreat user was successfully created.' }\n format.json { render :show, status: :created, location: @instathreat_user }\n else\n format.html { render :new }\n format.json { render json: @instathreat_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @noticium = Noticium.new(params[:noticium])\n\n respond_to do |format|\n if @noticium.save\n format.html { redirect_to(@noticium, :notice => 'Noticium was successfully created.') }\n format.xml { render :xml => @noticium, :status => :created, :location => @noticium }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @noticium.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n # services / get_nutrients.rb\n fetched_params = GetNutrients.new(params[:marmiton_url]).perform\n puts fetched_params\n @recipe = Recipe.new(fetched_params)\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to root_path, notice: 'La recette a été crée.' }\n else\n format.html { redirect_to root_path, notice: \"La recette n'a pas pu être ajoutée.\" }\n end\n end\n end", "def create\n @indivisual = Indivisual.new(indivisual_params)\n\n respond_to do |format|\n if @indivisual.save\n format.html { redirect_to @indivisual, notice: 'Indivisual was successfully created.' }\n format.json { render :show, status: :created, location: @indivisual }\n else\n format.html { render :new }\n format.json { render json: @indivisual.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @impressoras = Impressora.new(params[:impressora])\n\n respond_to do |format|\n if @impressoras.save\n flash[:notice] = 'SALVO COM SUCESSO.'\n format.html { redirect_to(@impressoras) }\n format.xml { render :xml => @impressoras, :status => :created, :location => @impressora }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @impressoras.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @nature_financing = NatureFinancing.new(nature_financing_params)\n @nature_financing.institute = current_institute\n\n respond_to do |format|\n if @nature_financing.save\n format.html { redirect_to @nature_financing, notice: 'Nature financing was successfully created.' }\n format.json { render :show, status: :created, location: @nature_financing }\n else\n format.html { render :new }\n format.json { render json: @nature_financing.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sitio_entrega = SitioEntrega.new(params[:sitio_entrega])\n\n respond_to do |format|\n if @sitio_entrega.save\n format.html { redirect_to @sitio_entrega, notice: 'Sitio entrega was successfully created.' }\n format.json { render json: @sitio_entrega, status: :created, location: @sitio_entrega }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sitio_entrega.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @incrustation = Incrustation.new(incrustation_params)\n\n respond_to do |format|\n if @incrustation.save\n record_activity(@incrustation)\n format.html { redirect_to admin_incrustations_path, notice: 'Вставка была успешно создана.' }\n format.json { render :show, status: :created, location: @incrustation }\n else\n format.html { render :new }\n format.json { render json: @incrustation.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(hash)\n HttpClient::Preconditions.assert_class('hash', hash, Hash)\n @client.request(\"/membership_requests\").with_json(hash.to_json).post { |hash| Apidoc::Models::MembershipRequest.new(hash) }\n end", "def create\n @instancia_item = InstanciaItem.new(params[:instancia_item])\n\n respond_to do |format|\n if @instancia_item.save\n format.html { redirect_to(@instancia_item, :notice => 'Instancia item was successfully created.') }\n format.xml { render :xml => @instancia_item, :status => :created, :location => @instancia_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @instancia_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @sitio = Sitio.new(params[:sitio])\n\n respond_to do |format|\n if @sitio.save\n format.html { redirect_to @sitio, notice: 'Sitio was successfully created.' }\n format.json { render json: @sitio, status: :created, location: @sitio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sitio.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 @eleccion_interna = EleccionInterna.new(eleccion_interna_params)\n\n respond_to do |format|\n if @eleccion_interna.save\n format.html { redirect_to @eleccion_interna, notice: 'Eleccion interna was successfully created.' }\n format.json { render :show, status: :created, location: @eleccion_interna }\n else\n format.html { render :new }\n format.json { render json: @eleccion_interna.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @visitation = Visitation.new(visitation_params)\n\n respond_to do |format|\n if @visitation.save\n format.html { redirect_to @visitation, notice: 'Visitation was successfully created.' }\n format.json { render json: @visitation, status: :created, location: @visitation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @visitation.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.5904447", "0.5739754", "0.5708926", "0.5508922", "0.5499313", "0.54909134", "0.546466", "0.5407724", "0.53888965", "0.5382299", "0.5378612", "0.5374767", "0.53741145", "0.5371149", "0.5353511", "0.5351774", "0.53458303", "0.5327217", "0.5323071", "0.5309987", "0.52673495", "0.5266704", "0.5266704", "0.52601063", "0.5258219", "0.52452946", "0.5240253", "0.52379894", "0.5235541", "0.5210049", "0.5208605", "0.5178109", "0.5176663", "0.5176261", "0.51739603", "0.51681024", "0.51641184", "0.51525915", "0.5140622", "0.51218957", "0.5118124", "0.5101222", "0.50986284", "0.5094821", "0.507951", "0.5068888", "0.5065984", "0.5065979", "0.50656676", "0.50652766", "0.5065016", "0.5064634", "0.50627935", "0.5052479", "0.50507385", "0.50490105", "0.50339174", "0.502683", "0.50208575", "0.50191313", "0.50154364", "0.50065905", "0.49921185", "0.49888077", "0.4983051", "0.4980324", "0.49753153", "0.49668562", "0.49665132", "0.49631926", "0.49553907", "0.49521452", "0.4951513", "0.49475268", "0.49441734", "0.4942374", "0.49422267", "0.49407303", "0.49379534", "0.49317595", "0.49304602", "0.49287587", "0.49268058", "0.49260795", "0.4925225", "0.49216244", "0.49207142", "0.491906", "0.49168286", "0.49164662", "0.49136427", "0.491186", "0.49073413", "0.490666", "0.49039838", "0.49012104", "0.4886964", "0.48860893", "0.48842946", "0.48814282" ]
0.5931114
0
PUT /institutes/1 PUT /institutes/1.xml
def update @institute = Institute.find(params[:id]) respond_to do |format| if @institute.update_attributes(params[:institute]) format.html { redirect_to(@institute, :notice => 'Institute was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @institute.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update\n respond_to do |format|\n if @instituto.update_attributes(params[:instituto])\n format.html { redirect_to(@instituto, :notice => 'Instituto fue modificado exitosamente.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instituto.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end", "def update\n @institucion = Institucion.find(params[:id])\n\n respond_to do |format|\n if @institucion.update_attributes(params[:institucion])\n flash[:notice] = 'Institucion se ha actualizado con exito.'\n format.html { redirect_to(admin_institucions_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @institucion.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @sitio = Sitio.find(params[:id])\n\n respond_to do |format|\n if @sitio.update_attributes(params[:sitio])\n format.html { redirect_to(@sitio, :notice => 'Sitio was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sitio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_should_update_invite_via_API_XML\r\n get \"/logout\"\r\n put \"/invites/1.xml\", :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => '[email protected]',\r\n :user_id => 1 }\r\n assert_response 401\r\n end", "def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end", "def update\n @instituicao = Instituicao.find(params[:id])\n\n respond_to do |format|\n if @instituicao.update_attributes(params[:instituicao])\n format.html { redirect_to(@instituicao, :notice => 'Instituicao was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instituicao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @supervisor_estagio = SupervisorEstagio.find(params[:id])\n\n respond_to do |format|\n if @supervisor_estagio.update_attributes(params[:supervisor_estagio])\n flash[:notice] = 'Supervisor de Estagio atualizado com sucesso.'\n format.html { redirect_to(@supervisor_estagio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @supervisor_estagio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n if @institution.update_attributes(params[:institution])\n format.html { redirect_to(institutions_url, :notice => 'Institution was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @institution.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end", "def update\n @incident = Incident.find(params[:id])\n\n respond_to do |format|\n if @incident.update_attributes(params[:incident])\n format.html { redirect_to(@incident) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @incident.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @inst.update(inst_params)\n format.html { redirect_to @inst, notice: 'Inst was successfully updated.' }\n format.json { render :show, status: :ok, location: @inst }\n else\n format.html { render :edit }\n format.json { render json: @inst.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n if @institution.update_attributes(params[:institution])\n format.html { redirect_to(@institution, :notice => 'Institution was successfully updated.') }\n format.xml { head :ok }\n format.json {render :json => {\"success\"=>true,\"data\"=>@institutions} }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @institution.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize @institute\n respond_to do |format|\n if @institute.update(institute_params)\n format.html { redirect_to @institute, notice: 'Institute was successfully updated.' }\n format.json { render :show, status: :ok, location: @institute }\n else\n format.html { render :edit }\n format.json { render json: @institute.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @entry_instrument = EntryInstrument.find(params[:id])\n\n respond_to do |format|\n if @entry_instrument.update_attributes(params[:entry_instrument])\n flash[:notice] = 'EntryInstrument was successfully updated.'\n format.html { redirect_to(@entry_instrument) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_instrument.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @st_ipi = StIpi.find(params[:id])\n\n respond_to do |format|\n if @st_ipi.update_attributes(params[:st_ipi])\n flash[:notice] = 'IPI atualizado.'\n format.html { redirect_to(@st_ipi) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @st_ipi.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n if @estagio.update_attributes(params[:estagio])\n flash[:notice] = 'Estagio was successfully updated.'\n format.html { redirect_to(@estagio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estagio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @sitetype = Sitetype.find(params[:id])\n\n respond_to do |format|\n if @sitetype.update_attributes(params[:sitetype])\n flash[:notice] = 'Sitetype was successfully updated.'\n format.html { redirect_to(@sitetype) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sitetype.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @instituto.update(instituto_params)\n format.html { redirect_to @instituto, notice: 'O instituto foi atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @instituto }\n else\n format.html { render :edit }\n format.json { render json: @instituto.errors, status: :unprocessable_entity }\n end\n end\n end", "def _update(type, current_name, metadata={})\n type = type.to_s.camelize\n request :update do |soap|\n soap.body = {\n :metadata => {\n :current_name => current_name,\n :metadata => prepare(metadata),\n :attributes! => { :metadata => { 'xsi:type' => \"ins0:#{type}\" } }\n }\n }\n end\n end", "def update\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n flash[:notice] = 'Interest was successfully updated.'\n format.html { redirect_to(@interest) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @interests = Interests.for_person(@person)[0]\n\n respond_to do |format|\n if @interests.update_attributes(params[:interests])\n flash[:notice] = 'Interests updated.'\n format.html { redirect_to(person_path(:id => @person)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @interests.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n resource_path = \"/projects/#{project_id}/people/#{id}\"\n Request.put(resource_path, self.to_xml('person'))\n end", "def update\n @sitio = Sitio.find(params[:id])\n\n respond_to do |format|\n if @sitio.update_attributes(params[:sitio])\n format.html { redirect_to @sitio, notice: 'Sitio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sitio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @institute_admin = InstituteAdmin.find(params[:id])\n respond_to do |format|\n if @institute_admin.update_attributes(params[:institute_admin])\n format.html { redirect_to @institute_admin, notice: 'InstituteAdmin was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @institute_admin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n doc = Nokogiri::XML(request.body.read)\n bNode = doc.xpath('elwak/benutzer')\n\n @benutzer = Benutzer.find(params[:id])\n \n #Sicherstellen, dass Benutzer synchronisiert wird auch wenn nur Objekt-Zuordnungen anders sind!\n @benutzer.updated_at = DateTime.now \n\n if bNode.xpath('objekt_zuordnungs').length > 0\n @benutzer.setze_objekt_zuordnungen(bNode.xpath('objekt_zuordnungs/objekt_id').map{|oz| oz.text.to_s.to_i})\n end\n if @benutzer.update(benutzer_params(bNode))\n success(nil)\n else\n error(@benutzer.errors)\n end\n end", "def update_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n\n respond_to do |format|\n if @instrument_version.update_attributes(params[:instrument_version])\n flash[:notice] = 'InstrumentVersion was successfully updated.'\n format.html { redirect_to(@instrument_version) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instrument_version.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @sti = Sti.find(params[:id])\n\n respond_to do |format|\n if @sti.update_attributes(params[:sti])\n flash[:notice] = 'Sti was successfully updated.'\n format.html { redirect_to(@sti) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sti.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n @identity = Identity.find(params[:id])\n\n respond_to do |format|\n if @identity.update_attributes(params[:identity])\n format.html { redirect_to(@identity, :notice => 'Identity was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @identity.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @solicitation = Solicitation.find(params[:id])\n\n respond_to do |format|\n if @solicitation.update_attributes(params[:solicitation])\n flash[:notice] = 'Solicitation was successfully updated.'\n format.html { redirect_to(representative_solicitations_path(@representative)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @solicitation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!\n @authorize = nil\n update_plan! &&\n resp = put(\"/users/#{username}.xml\", {\n :user_key => apikey,\n \"user[first_name]\" => first_name,\n \"user[last_name]\" => last_name\n })\n end", "def update\n @instituicao = Instituicao.find(params[:id])\n\n respond_to do |format|\n if @instituicao.update_attributes(params[:instituicao])\n format.html { redirect_to @instituicao, notice: 'Instituicao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @instituicao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ministries = Ministries.find(params[:id])\n\n respond_to do |format|\n if @ministries.update_attributes(params[:ministries])\n flash[:notice] = 'Ministries was successfully updated.'\n format.html { redirect_to(@ministries) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ministries.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @ministry = Ministry.find(params[:id])\n\n respond_to do |format|\n if @ministry.update_attributes(params[:ministry])\n flash[:notice] = 'Ministry was successfully updated.'\n format.html { redirect_to(@ministry) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ministry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_should_update_project_via_API_XML\r\n get \"/logout\"\r\n put \"/projects/1.xml\", :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response 401\r\n end", "def update\n @interes = Interes.find(params[:id])\n\n respond_to do |format|\n if @interes.update_attributes(params[:interes])\n format.html { redirect_to(@interes, :notice => 'Interes was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @interes.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @island = Island.find(params[:id])\n\n respond_to do |format|\n if @island.update_attributes(params[:island])\n flash[:notice] = 'Island was successfully updated.'\n format.html { redirect_to(@island) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @island.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n\n update_params = {inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool}\n respond_to do |format|\n if @checklisten_vorlage.update(update_params)\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n else\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><error />'}\n end\n end\n end", "def update\n update_resource @ride, ride_params\n end", "def update\n @estatu = Estatu.find(params[:id])\n\n respond_to do |format|\n if @estatu.update_attributes(params[:estatu])\n format.html { redirect_to(@estatu, :notice => 'Registro actualizado correctamente.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estatu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @usuario = Usuario.find(params[:id])\n #@[email protected]\n respond_to do |format|\n if @usuario.update_attributes(params[:usuario])\n format.html { redirect_to(@usuario, :notice => t('exitom')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @usuario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @st_pi = StPi.find(params[:id])\n\n respond_to do |format|\n if @st_pi.update_attributes(params[:st_pi])\n flash[:notice] = 'PIS atualizado.'\n format.html { redirect_to(@st_pi) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @st_pi.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n if @institution.update_attributes(params[:institution])\n format.html { redirect_to @institution, notice: 'Institution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @institution.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @situacoes_juridica = SituacoesJuridica.find(params[:id])\n\n respond_to do |format|\n if @situacoes_juridica.update_attributes(params[:situacoes_juridica])\n format.html { redirect_to(@situacoes_juridica, :notice => 'Situação jurídica atualizada com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @situacoes_juridica.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @institucional = Institucional.find(params[:id])\n\n respond_to do |format|\n if @institucional.update_attributes(params[:institucional])\n format.html { redirect_to @institucional, notice: 'Institucional was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @institucional.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ministerio = Ministerio.find(params[:id])\n\n respond_to do |format|\n if @ministerio.update_attributes(params[:ministerio])\n format.html { redirect_to(@ministerio, :notice => 'Ministerio was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ministerio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @instancium.update(instancium_params)\n format.html { redirect_to @instancium, notice: 'Instancium was successfully updated.' }\n format.json { render :show, status: :ok, location: @instancium }\n else\n format.html { render :edit }\n format.json { render json: @instancium.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n if @estudiante.update_attributes(params[:estudiante])\n format.html { redirect_to(@estudiante, :notice => 'Estudiante was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estudiante.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @county = County.find(params[:id])\n\n respond_to do |format|\n if @county.update_attributes(params[:county])\n flash[:notice] = 'County was successfully updated.'\n format.html { redirect_to(@county) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @county.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n params.permit!\n @interviews_it = Interviews::It.find(params[:id])\n\n respond_to do |format|\n if @interviews_it.update_attributes(params[:interviews_it])\n format.html { redirect_to(@interviews_it, :notice => 'It was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @interviews_it.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n put :update\n end", "def update\n @one_reg_institution = OneRegInstitution.find(params[:id])\n\n respond_to do |format|\n if @one_reg_institution.update_attributes(params[:one_reg_institution])\n format.html { redirect_to @one_reg_institution, notice: 'One reg institution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @one_reg_institution.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n if @item_usage.update_attributes(params[:item_usage])\n flash[:notice] = 'ItemUsage was successfully updated.'\n format.html { redirect_to(@item_usage) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @incidenttype = Incidenttype.find(params[:id])\n\n respond_to do |format|\n if @incidenttype.update_attributes(params[:incidenttype])\n flash[:notice] = 'Incidenttype was successfully updated.'\n format.html { redirect_to(@incidenttype) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @incidenttype.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @webinar = Webinar.find(params[:id])\n\n respond_to do |format|\n if @webinar.update_attributes(params[:webinar])\n flash[:notice] = 'Webinar was successfully updated.'\n format.html { redirect_to(@webinar) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @webinar.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(*args)\n request :put, *args\n end", "def update\n @ontology = SYMPH::Ontology.find(params[:id])\n\n respond_to do |format|\n if @ontology.update_attributes(params[:ontology])\n flash[:notice] = 'Ontology was successfully updated.'\n format.html { redirect_to(ontologies_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ontology.errors, :status => :unprocessable_entity }\n end\n end\n\t\n end", "def update\n @technician = Technician.find(params[:id])\n\n respond_to do |format|\n if @technician.update_attributes(params[:technician])\n format.html { redirect_to(@technician, :notice => 'Technician was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @technician.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.path)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n end", "def update\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n if @nossos_servico.update_attributes(params[:nossos_servico])\n format.html { redirect_to(@nossos_servico, :notice => 'Nossos servico was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nossos_servico.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n # returning connection.put(element_path(prefix_options), to_xml, self.class.headers) do |response|\n returning connection.put(element_path(prefix_options), to_ssj, self.class.headers) do |response|\n load_attributes_from_response(response)\n end\n end", "def update\n @cst_ipi = CstIpi.find(params[:id])\n\n respond_to do |format|\n if @cst_ipi.update_attributes(params[:cst_ipi])\n flash[:notice] = 'S.T. para Ipi atualizada.'\n format.html { redirect_to(@cst_ipi) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cst_ipi.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n standard_update(Interest, params[:id], interest_params)\n end", "def update\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n if @estudiante.update_attributes(params[:estudiante])\n flash[:notice] = 'Actualizado.'\n format.html { redirect_to(@estudiante) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estudiante.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def put_compute(request, params)\n # --- Get the VM ---\n vm = VirtualMachineOCCI.new(\n VirtualMachine.build_xml(params[:id]),\n @client)\n\n rc = vm.info\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n result, code = vm.update_from_xml(request.body)\n\n if OpenNebula.is_error?(result)\n return result, code\n else\n vm.info\n return to_occi_xml(vm, :code=>code)\n end\n end", "def put_update(options = {})\n options[:id] ||= @website.id\n options[:website] ||= @attributes\n\n put :update,options\n end", "def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end", "def update\n @spouse = Spouse.find(params[:id])\n\n respond_to do |format|\n if @spouse.update_attributes(params[:spouse])\n flash[:notice] = 'Spouse was successfully updated.'\n format.html { redirect_to(@spouse) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @spouse.errors, :status => :unprocessable_entity }\n end\n end\n end", "def save_incident(incident)\n update_object_xml('Incident', incident.id, incident.to_xml)\n end", "def update\n respond_to do |format|\n if @instum.update(instum_params)\n format.html { redirect_to @instum, notice: '投稿が更新されました' }\n format.json { render :show, status: :ok, location: @instum }\n else\n format.html { render :edit }\n format.json { render json: @instum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @niveis_ensino = NiveisEnsino.find(params[:id])\n\n respond_to do |format|\n if @niveis_ensino.update_attributes(params[:niveis_ensino])\n format.html { redirect_to(@niveis_ensino, :notice => 'Niveis ensino atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @niveis_ensino.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n connection.put(element_path, to_xml)\n end", "def update\n @industry = Industry.find(params[:id])\n\n respond_to do |format|\n if @industry.update_attributes(params[:industry])\n flash[:notice] = 'Industry was successfully updated.'\n format.html { redirect_to(@industry) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @industry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @universite = Universite.find(params[:id])\n\n respond_to do |format|\n if @universite.update_attributes(params[:universite])\n flash[:notice] = 'Universite was successfully updated.'\n format.html { redirect_to :controller => \"pages\", :action => \"partenaires\" }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @universite.errors.to_xml }\n end\n end\n end", "def update\n @tournament = @resource_finder.find(params[:id])\n\n respond_to do |format|\n if @tournament.update_attributes(params[:tournament])\n flash[:notice] = 'Tournament was successfully updated.'\n format.html { redirect_to_resource }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tournament.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @eat = Eat.find(params[:id])\n\n respond_to do |format|\n if @eat.update_attributes(params[:eat])\n flash[:notice] = 'Eat was successfully updated.'\n format.html { redirect_to installation_eat_path(@installation, @eat) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @eat.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @universe = Universe.find(params[:id])\n\n respond_to do |format|\n if @universe.update_attributes(params[:universe])\n flash[:notice] = 'Universe was successfully updated.'\n format.html { redirect_to(@universe) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @universe.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @insurer = Insurer.find(params[:id])\n\n respond_to do |format|\n if @insurer.update_attributes(params[:insurer])\n format.html { redirect_to(@insurer, :notice => 'Insurer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @insurer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n return if auth(\"website_administrator\")\n @incident = Incident.find(params[:id])\n\n respond_to do |format|\n if @incident.update_attributes(params[:incident])\n format.html { redirect_to @incident, :notice => 'Incident was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @incident.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tourist_sight = TouristSight.find(params[:id])\n\n\t\t# Caso não tenha sido preenchido seta nil para que o allow_nil deixe\n\t\t# de validar o formato desse email. (Conferir em app/models/tourist_sight.rb)\n\t\tif params[:tourist_sight][:email] and params[:tourist_sight][:email].strip.length == 0\n\t\t\tparams[:tourist_sight][:email] = nil\n\t\tend \n\t\t\n\t\tif not validate_permission(@tourist_sight)\n return\n end\n\n respond_to do |format|\n if @tourist_sight.update_attributes(params[:tourist_sight])\n flash[:notice] = 'Ponto turístico atualizado com sucesso.'\n format.html { redirect_to(@tourist_sight) }\n format.xml { head :ok }\n else\n\n\t\t\t\t# Recarrega os estados e as cidades se possivel\n\t\t\t\tload_states_and_cities(@tourist_sight)\n\t\t\t\t\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tourist_sight.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @actuator = Actuator.find(params[:id])\n\n respond_to do |format|\n if @actuator.update_attributes(params[:actuator].each_value(&:strip!))\n format.html { redirect_to(@actuator, :notice => 'Actuator was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @actuator.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @sitio_entrega = SitioEntrega.find(params[:id])\n\n respond_to do |format|\n if @sitio_entrega.update_attributes(params[:sitio_entrega])\n format.html { redirect_to @sitio_entrega, notice: 'Sitio entrega was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sitio_entrega.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_should_update_membership\n login_as(:john)\n put :update, :id => 1, :membership => { }\n assert_response :redirect\n end", "def test_should_update_membership\n login_as(:john)\n put :update, :id => 1, :membership => { }\n assert_response :redirect\n end", "def update\n @title = \"EDITAR WMI NAMESPACE\"\n @wmi_namespace = WmiNamespace.find(params[:id])\n\n respond_to do |format|\n if @wmi_namespace.update_attributes(params[:wmi_namespace])\n flash[:notice] = 'Wmi Namespace fué actualizado correctamente.'\n format.html { redirect_to(@wmi_namespace) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @wmi_namespace.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_xml\n self.xml= dumpRouteAsXml\n self.save\n end", "def update\n @sale_representative = SaleRepresentative.find(params[:id])\n\n respond_to do |format|\n if @sale_representative.update_attributes(params[:sale_representative])\n format.html { redirect_to(@sale_representative, :notice => 'Sale representative was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sale_representative.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @simnorth = Simnorth.find(params[:id])\n\n respond_to do |format|\n if @simnorth.update_attributes(params[:simnorth])\n flash[:notice] = 'Simnorth was successfully updated.'\n format.html { redirect_to(@simnorth) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @simnorth.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @issuing_institution = IssuingInstitution.find(params[:id])\n\n respond_to do |format|\n if @issuing_institution.update_attributes(params[:issuing_institution])\n format.html { redirect_to @issuing_institution, :notice => 'Orgão Emissor atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @issuing_institution.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @title = \"Update Operations\"\n @operation = Operation.find(params[:id])\n\n respond_to do |format|\n if @operation.update_attributes(params[:operation])\n flash[:notice] = 'Operation was successfully updated.'\n format.html { redirect_to(@operation) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @operation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @instancia_item = InstanciaItem.find(params[:id])\n\n respond_to do |format|\n if @instancia_item.update_attributes(params[:instancia_item])\n format.html { redirect_to(@instancia_item, :notice => 'Instancia item was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instancia_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @infraction_type.update_attributes(infraction_type_params)\n format.html { redirect_to(@infraction_type, :notice => 'Infraction type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @infraction_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @rute = Rute.find(params[:id])\n\n respond_to do |format|\n if @rute.update_attributes(params[:rute])\n format.html { redirect_to(@rute, :notice => 'Rute was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @rute.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.62186044", "0.60334325", "0.5942457", "0.59328145", "0.5881143", "0.58764386", "0.58001167", "0.5798618", "0.57519615", "0.5719442", "0.57074666", "0.56916845", "0.5681528", "0.5664657", "0.56450707", "0.56340957", "0.5612977", "0.5590952", "0.5580108", "0.55780095", "0.55466294", "0.5541084", "0.553399", "0.553167", "0.54986584", "0.54881734", "0.54822224", "0.54773223", "0.54704124", "0.5469972", "0.546404", "0.5455826", "0.545446", "0.5453334", "0.5450948", "0.5446476", "0.54217124", "0.5407451", "0.53970915", "0.537461", "0.5371145", "0.5369499", "0.53635955", "0.5363147", "0.53536326", "0.5350517", "0.5330424", "0.53262746", "0.53160053", "0.5309466", "0.53064036", "0.5290532", "0.52876425", "0.52872086", "0.52840114", "0.52833736", "0.52824366", "0.5279555", "0.52772045", "0.5268201", "0.52644336", "0.52592933", "0.5255503", "0.5249538", "0.52446926", "0.5239771", "0.5237673", "0.5236217", "0.5234985", "0.5217426", "0.5214193", "0.5204187", "0.5199572", "0.519538", "0.51931715", "0.5192144", "0.5189208", "0.51887935", "0.5185618", "0.5180239", "0.51785934", "0.5177849", "0.5173471", "0.5171175", "0.5167933", "0.5166998", "0.5166815", "0.5164", "0.5162462", "0.5162316", "0.5162316", "0.51615566", "0.51580304", "0.51527977", "0.5148838", "0.51475036", "0.5143565", "0.51431996", "0.5138452", "0.51355433" ]
0.6310584
0
DELETE /institutes/1 DELETE /institutes/1.xml
def destroy @institute = Institute.find(params[:id]) @institute.destroy respond_to do |format| format.html { redirect_to(institutes_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\n @institucion = Institucion.find(params[:id])\n @institucion.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_institucions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @instituto.destroy\n\n respond_to do |format|\n format.html { redirect_to(institutos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @instituicao = Instituicao.find(params[:id])\n @instituicao.destroy\n\n respond_to do |format|\n format.html { redirect_to(instituicoes_url) }\n format.xml { head :ok }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @institution = Institution.find(params[:id])\n @institution.destroy\n\n respond_to do |format|\n format.html { redirect_to(institutions_url) }\n format.xml { head :ok }\n end\n end", "def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def destroy\n @estatu = Estatu.find(params[:id])\n @estatu.destroy\n\n respond_to do |format|\n format.html { redirect_to(estatus_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sitio = Sitio.find(params[:id])\n @sitio.destroy\n\n respond_to do |format|\n format.html { redirect_to(sitios_url) }\n format.xml { head :ok }\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def delete_trust(xml) \n if current_user \n trust_root = xml.root.get_elements('TrustRoot').first.text \n unless trust_root.empty? \n @trust = current_user.trusts.find(:first, :conditions => ['trust_root = ?', trust_root]) \n if @trust \n @trust.destroy \n return render(:text => \"<Response>success</Response>\") \n end \n end \n end \n render :text => '<Response>trust root does not exist</Response>' \n end", "def destroy\n @supervisor_estagio = SupervisorEstagio.find(params[:id])\n @supervisor_estagio.destroy\n\n respond_to do |format|\n format.html { redirect_to(supervisor_estagios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @identity = Identity.find(params[:id])\n @identity.destroy\n\n respond_to do |format|\n format.html { redirect_to(identities_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estacion = Estacion.find(params[:id])\n @estacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(estaciones_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @institution = Institution.find(params[:id])\n @institution.destroy\n\n respond_to do |format|\n format.html { redirect_to(institutions_url) }\n format.xml { head :ok }\n format.json {render :json => {\"success\"=>true,\"data\"=>[]} }\n \n end\n end", "def destroy\n @instancia_item = InstanciaItem.find(params[:id])\n @instancia_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(instancia_items_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n chef_server_rest.delete(\"nodes/#{name}\")\n end", "def destroy\n @nom = Nom.find(params[:id])\n @nom.destroy\n\n respond_to do |format|\n format.html { redirect_to(noms_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @direccion = Direccion.find(params[:id])\n @direccion.destroy\n\n respond_to do |format|\n format.html { redirect_to(direccions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @representative = Representative.find(params[:id])\n @representative.destroy\n\n respond_to do |format|\n format.html { redirect_to(representatives_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @rute = Rute.find(params[:id])\n @rute.destroy\n\n respond_to do |format|\n format.html { redirect_to(rutes_url) }\n format.xml { head :ok }\n end\n end", "def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end", "def destroy\n @situacoes_juridica = SituacoesJuridica.find(params[:id])\n @situacoes_juridica.destroy\n\n respond_to do |format|\n format.html { redirect_to(situacoes_juridicas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estagio = Estagio.find(params[:id])\n @estagio.destroy\n\n respond_to do |format|\n format.html { redirect_to(estagios_url) }\n format.xml { head :ok }\n end\n end", "def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end", "def destroy\n @med_inst = MedInst.find(params[:id])\n @med_inst.destroy\n\n respond_to do |format|\n format.html { redirect_to(med_insts_url) }\n format.xml { head :ok }\n end\n end", "def delete!\n Recliner.delete(uri)\n end", "def destroy_rest\n @entry_instrument = EntryInstrument.find(params[:id])\n @entry_instrument.destroy\n\n respond_to do |format|\n format.html { redirect_to(entry_instruments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sire = Sire.find(params[:id])\n @sire.destroy\n\n respond_to do |format|\n format.html { redirect_to(sires_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @installation = Installation.find(params[:installation_id]) \n @eat = Eat.find(params[:id])\n @eat.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end", "def destroy\n @sti = Sti.find(params[:id])\n @sti.destroy\n\n respond_to do |format|\n format.html { redirect_to(stis_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estate = Estate.find(params[:id])\n @estate.destroy\n \n respond_to do |format|\n format.html { redirect_to(estates_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @interests = Interests.find(params[:id])\n @interests.destroy\n flash[:notice] = 'Interests was successfully removed.'\n\n respond_to do |format|\n format.html { redirect_to(interests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @dossier = Dossier.find(params[:id])\n @dossier.destroy\n\n respond_to do |format|\n format.html { redirect_to(\"/\") }\n format.xml { head :ok }\n end\n end", "def destroy\n @inst.destroy\n respond_to do |format|\n format.html { redirect_to insts_url, notice: 'Inst was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sale_representative = SaleRepresentative.find(params[:id])\n @sale_representative.destroy\n\n respond_to do |format|\n format.html { redirect_to(sale_representatives_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @interest = Interest.find(params[:id])\n @interest.destroy\n\n respond_to do |format|\n format.html { redirect_to(interests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @affiliate = Affiliate.find(params[:id])\n @affiliate.destroy\n\n respond_to do |format|\n format.html { redirect_to(affiliates_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @instum.destroy\n respond_to do |format|\n format.html { redirect_to insta_url, notice: '投稿が削除されました' }\n format.json { head :no_content }\n end\n end", "def delete_by_id id, opts = {}\n update opts.merge(:data => xml.delete_by_id(id))\n end", "def destroy\n mytemplate = Mytemplate.get(params[:id])\n close_document(mytemplate)\n \n begin\n if mytemplate != nil\n if File.exist?(mytemplate.path) \n FileUtils.rm_rf mytemplate.path\n end\n \n if File.exist?(mytemplate.file_path+mytemplate.id.to_s) \n FileUtils.rm_rf mytemplate.file_path+mytemplate.id.to_s\n end\n\n end\n rescue\n puts_message \"Error! in progress of mytemplate file deletion.\"\n end\n\n mytemplate.destroy\n \n respond_to do |format|\n format.html { redirect_to(mytemplates_url) }\n format.xml { head :ok }\n end\n end", "def destroy(params = {})\n client.delete(\"#{endpoint(params)}/#{attributes[:id]}\")\n end", "def destroy\n @utilisateur = Utilisateur.find(params[:id])\n @utilisateur.destroy\n\n respond_to do |format|\n format.html { redirect_to(utilisateurs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @inventario = Inventario.find(params[:id])\n @inventario.destroy\n\n respond_to do |format|\n format.html { redirect_to(inventarios_url) }\n format.xml { head :ok }\n end\n end", "def _delete(type, *args)\n type = type.to_s.camelize\n metadata = args.map { |full_name| {:full_name => full_name} }\n request :delete do |soap|\n soap.body = {\n :metadata => metadata\n }.merge(attributes!(type))\n end\n end", "def destroy\n @administrativo = Administrativo.find(params[:id])\n @administrativo.destroy\n\n respond_to do |format|\n format.html { redirect_to(administrativos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @incident = Incident.find(params[:id])\n @incident.destroy\n\n respond_to do |format|\n format.html { redirect_to(incidents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @incident = Incident.find(params[:id])\n @incident.destroy\n\n respond_to do |format|\n format.html { redirect_to(incidents_url) }\n format.xml { head :ok }\n end\n end", "def delete\n @user = User.find(params[:id])\n @user.rvsps.delete_all()\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end", "def delete(id)\n request = Net::HTTP::Delete.new(\"#{@url}/#{id}.xml\")\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end", "def destroy\n @institucion.destroy\n respond_to do |format|\n format.html { redirect_to institucions_url, notice: 'Empresa se ha eliminado correctamente.' }\n format.json { head :no_content }\n end\n end", "def delete\n delete_from_server single_url\n end", "def destroy\n @universite = Universite.find(params[:id])\n @universite.destroy\n\n respond_to do |format|\n format.html { redirect_to :controller => \"pages\", :action => \"partenaires\" }\n format.xml { head :ok }\n end\n end", "def destroy\n @title = \"Destroy Operations\"\n @operation = Operation.find(params[:id])\n @operation.destroy\n\n respond_to do |format|\n format.html { redirect_to(operations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @uitgelicht = Uitgelicht.find(params[:id])\n @uitgelicht.destroy\n\n respond_to do |format|\n format.html { redirect_to(uitgelichts_url) }\n format.xml { head :ok }\n end\n end", "def destroy; delete end", "def destroy\n @lien = Lien.find(params[:id])\n @lien.destroy\n\n respond_to do |format|\n format.html { redirect_to(liens_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lien = Lien.find(params[:id])\n @lien.destroy\n\n respond_to do |format|\n format.html { redirect_to(liens_url) }\n format.xml { head :ok }\n end\n end", "def delete\n \n end", "def deleteResource(doc, msg_from)\n \n \n begin\n\n puts \"Deleting\"\n\n path = \"\"\n params = {}\n headers = {}\n \n context, path = findContext(doc, path) \n \n # Deleting member from group\n if context == :user_group_member\n params = {}\n else\n raise Exception.new(\"No context given!\")\n end\n \n httpAndNotify(path, params, msg_from, :delete)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n \n end", "def destroy\n @suministro = Suministro.find(params[:id])\n @suministro.destroy\n\n respond_to do |format|\n format.html { redirect_to(suministros_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ministerio = Ministerio.find(params[:id])\n @ministerio.destroy\n\n respond_to do |format|\n format.html { redirect_to(ministerios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @niveau = Niveau.find(params[:id])\r\n @niveau.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(niveaus_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def delete\n request(:delete)\n end", "def delete\n stop\n [ @resource['instances_dir'] + \"/\" + @resource[:name],\n @resource['instances_dir'] + \"/\" + \"_\" + @resource[:name]\n ].each do |dir|\n FileUtils.rm_rf(dir) if File.directory?(dir)\n end\n end", "def destroy\n @convenio = Convenio.find(params[:id])\n @convenio.destroy\n\n respond_to do |format|\n format.html { redirect_to(convenios_url) }\n format.xml { head :ok }\n end\n end", "def destroy_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n @instrument_version.destroy\n\n respond_to do |format|\n format.html { redirect_to(instrument_versions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asistencia = Asistencia.find(params[:id])\n @asistencia.destroy\n\n respond_to do |format|\n format.html { redirect_to(asistencias_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estados_civil = EstadosCivil.find(params[:id])\n @estados_civil.destroy\n\n respond_to do |format|\n format.html { redirect_to(estados_civiles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @instancium.destroy\n respond_to do |format|\n format.html { redirect_to instancia_url, notice: 'Instancium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dossier = Dossier.find(params[:id])\n @dossier.destroy\n\n respond_to do |format|\n format.html { redirect_to(dossiers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @st_ipi = StIpi.find(params[:id])\n @st_ipi.destroy\n\n respond_to do |format|\n format.html { redirect_to(st_ipis_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @reqinfo = Reqinfo.find(params[:id])\n @reqinfo.destroy\n\n respond_to do |format|\n format.html { redirect_to(reqinfos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @relatorios = Relatorio.find(params[:id])\n @relatorios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ocupation = Ocupation.find(params[:id])\n @ocupation.destroy\n\n respond_to do |format|\n format.html { redirect_to(ocupations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @solicitation = Solicitation.find(params[:id])\n @solicitation.destroy\n\n respond_to do |format|\n format.html { redirect_to(solicitations_url) }\n format.xml { head :ok }\n end\n end", "def test_delete_institution\n number_of_institution = Institution.count\n post :destroy,:id => institutions(:institution1)\n assert_redirected_to :action => 'list'\n assert_equal number_of_institution-1, Institution.count\n assert_raise(ActiveRecord::RecordNotFound){ Institution.find(1) }\n end", "def destroy\n @visit = Visit.find(params[:id])\n @visit.destroy\n\n respond_to do |format|\n format.html { redirect_to(visits_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @erratum = Erratum.find(params[:id])\n @erratum.destroy\n\n respond_to do |format|\n format.html { redirect_to(errata_url) }\n format.xml { head :ok }\n end\n end", "def delete_course_template(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}\"\n _delete(path)\n puts '[+] Course template data deleted successfully'.green\nend", "def orchio_delete\n response = client.send_request :delete, inst_args\n orchio_status response, 204\n end", "def destroy\n @ministerios = Ministerios.find(params[:id])\n @ministerios.destroy\n\n respond_to do |format|\n format.html { redirect_to(ministerios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @noticium = Noticium.find(params[:id])\n @noticium.destroy\n\n respond_to do |format|\n format.html { redirect_to(noticia_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @one_reg_institution = OneRegInstitution.find(params[:id])\n @one_reg_institution.destroy\n\n respond_to do |format|\n format.html { redirect_to one_reg_institutions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @consultation = Consultation.find(params[:id])\n @consultation.destroy\n\n respond_to do |format|\n format.html { redirect_to(consultations_url) }\n format.xml { head :ok }\n end\n end", "def delete(*uris); end", "def destroy\n @instituicao = Instituicao.find(params[:id])\n @instituicao.destroy\n\n respond_to do |format|\n format.html { redirect_to instituicoes_url }\n format.json { head :no_content }\n end\n end", "def destroy()\n urn_check()\n @sparql.delete([ @urn, :p, :o ])\n @sparql.delete([ :s, :p, @urn ])\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def destroy\n @economic = Economic.find(params[:id])\n @economic.destroy\n\n respond_to do |format|\n format.html { redirect_to(economics_url) }\n format.xml { head :ok }\n end\n end", "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def destroy\n @discovery = Discovery.find(params[:id])\n @discovery.destroy\n\n respond_to do |format|\n format.html { redirect_to(discoveries_url) }\n format.xml { head :ok }\n end\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def delete\n \n end", "def destroy\n @addition = Addition.find(params[:id])\n @addition.destroy\n\n respond_to do |format|\n format.html { redirect_to(additions_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.6857661", "0.6640354", "0.64919686", "0.63881564", "0.6309334", "0.63089013", "0.62841195", "0.6250412", "0.62290096", "0.619762", "0.6173301", "0.6164449", "0.6137363", "0.61278", "0.61073124", "0.60938275", "0.6090669", "0.60899746", "0.6085073", "0.6079349", "0.605632", "0.60533005", "0.60459393", "0.6036857", "0.60319084", "0.60314816", "0.60273594", "0.60041326", "0.6001033", "0.5998032", "0.59917545", "0.5973285", "0.5971961", "0.59621924", "0.5950312", "0.59473544", "0.5944616", "0.59398985", "0.59331954", "0.5932616", "0.5931895", "0.5928321", "0.5919431", "0.59094536", "0.59046954", "0.59044254", "0.59016746", "0.58972883", "0.5888516", "0.58878607", "0.58840287", "0.5883286", "0.5883286", "0.5881074", "0.5877", "0.5876362", "0.58744633", "0.58740276", "0.58734643", "0.5873095", "0.58711064", "0.5867627", "0.5867627", "0.5866471", "0.5864084", "0.5855801", "0.58448106", "0.58424693", "0.5842059", "0.58412904", "0.58402884", "0.5839374", "0.5834972", "0.5832636", "0.58294976", "0.5821762", "0.5821288", "0.5819412", "0.58192664", "0.5818389", "0.5815365", "0.5815343", "0.5815266", "0.5813685", "0.58134615", "0.5813233", "0.5810565", "0.58076465", "0.58070314", "0.58061343", "0.5805725", "0.5803375", "0.58011407", "0.5801069", "0.5800734", "0.5800549", "0.57927537", "0.5792136", "0.57800406", "0.5779842" ]
0.6538294
2
I worked on this challenge by myself. I spent 1 hour on this challenge. error "Screw you guys " + "I'm going home." = cartmans_phrase This error was analyzed in the README file. error
def cartman_hates(thing) while true puts "What's there to hate about #{thing}?" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cartmans_phrase\n puts \"I'm not fat; I'm big-boned!\"\nend", "def cartmans_phrase\n puts \"I'm not fat; I'm big-boned!\"\nend", "def cartmans_phrase\n puts \"I'm not fat; I'm big-boned!\"\nend", "def cartmans_phrase\n puts \"I'm not fat; I'm big-boned!\"\nend", "def cartmans_phrase\n puts \"I'm not fat; I'm big-boned!\"\nend", "def cartmans_phrase\n puts \"I'm not fat; I'm big-boned!\"\nend", "def cartmans_phrase\n puts \"I'm not fat; I'm big-boned!\"\nend", "def cartmans_phrase phrase\n puts phrase\nend", "def cartmans_phrase(words)\n puts \"I'm not fat; I'm big-boned!\"\nend", "def cartmans_phrase (string) #fix\n puts \"I'm not fat; I'm big-boned,\" + (string) #fix\nend", "def cartmans_phrase(argument)\n puts \"I'm not fat; I'm big-boned!\"\nend", "def cartmans_phrase(arg1)\n puts \"I'm not fat; I'm big-boned!\"\nend", "def cartmans_phrase(x)\n puts \"I'm not fat; I'm big-boned!\"\n puts x\nend", "def meme_phrase; end", "def instruction()\n puts \"Welcome to the MasterMind word game\"\n puts \"\\nThe System has been generate a word which includes 5 letters and no duplicate each \\nletter, you are going to guess this word. you have 10 times chance to guess. you \\nwill get a feedback in each turn like below: \\n\\n Exact: The letter is an exact match to the letter in the same position in the code\\n Near: The letter is contained in the code, but is not in the correct position\\n Miss: The letter is not contained in the code\\n\"\n end", "def hermes_catchphrase; end", "def catch_phrase\n [\n [\"ninja\",\"master\",\"student\"].rand, \n [\"\", \"\", \"\", \"\", \"\", \"\", \"weapons\", \"s' 3rd annual\",\"s' 5th annual\",\"s' 10th annual\", \"s' secret\"].rand,\n [\"gathering\",\"celebration\",\"meeting\",\"tournament\",\"competition\",\"party\",\"training camp\",\"sparring event\"].rand,\n [\"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"with Leonardo\", \"with Raphael\", \"with Michaelangelo\", \"with Donatello\"].rand\n ].join(' ').gsub(/ s\\'/,'s\\'').gsub(/\\s\\s/,' ').strip\n end", "def charm_failure\n slowly do\n\"\"\"\nDuncan barks, wags his tail, rolls over, does all his awesome tricks...\n\nBut the troll just looks on in disdain. \n\n'Go home, little dog, before I sqquish you.' \n\"\"\"\n end\n what_next\n end", "def failedMaths\n system(%Q{say -v \"karen\" \"I beleived in you\"})\n system(%Q{say -v \"karen\" \"Oh well, time for an easier test then\"})\n end", "def q3_page\n\"\n\n\n\n\n\n\n\n\n\n What is your Food Mood?\n\n *-------------------* *-------------------* *-------------------*\n | | | | | |\n | | | | | |\n | | | | | |\n | Old Faves | | Surprise Me! | | Craving |\n | | | | | |\n | | | | | |\n | | | | | |\n *-------------------* *-------------------* *-------------------*\n\n 1: 2: Input your Craving:\n\nAnswer: \"\nend", "def translator\n # Greet your user in the language of their people.\n puts [\"SUP KID? \",\n \t \"What didja say? \",\n \t \"How ya doan? \",\n \t \"How ahrya?\",\n \t \"How 'bout them Sox? \",\n \t \"How 'bout them Pats? \"].sample\n\n # Get their response and lop off the carriage return, Massachusetts Left style.\n phrase = gets.chomp.to_s\n\n # Now we're going to award the user points based on density of Boston-specific\n # diction, aka their Beantown Points(tm).\n i = 0\n beantown_points = 0\n wicked_boston_words = [\"bubblah\",\n \"wicked\",\n \"reveah\",\n \"the dot\",\n \"medfid\",\n \"broons\",\n \"barrel\",\n \"digga\",\n \"southie\",\n \"eastie\",\n \"rotary\",\n \"pissah\",\n \"jp\",\n \"fried\",\n \"directional\",\n \"beantown\",\n \"red sox\",\n \"common\",\n \"dunkin donuts\",\n \"patriots\",\n \"celtics\",\n \"green monster\",\n \"dirty watah\",\n \"packie\"\n ]\n\n searchable_phrase = phrase.downcase\n\n wicked_boston_words.each do |i|\n \tif searchable_phrase.include?(i)\n \t\tbeantown_points += 1\n \tend\n end\n\n ########################################################################################################\n # A-Z dictionary of specific gsubs for targeted replacement. This is about to get wicked awesome, bro! #\n ########################################################################################################\n\n # A\n phrase.gsub!(/\\bacross the rivah?\\b/i, 'on the other side of the Charles River') # across the rivah (other side of the charles)\n phrase.gsub!(/\\b(a)dvahtisin'?g?\\b/i, '\\1dvertising') # advahtisin'(g)\n phrase.gsub!(/\\b(a)dvisah?\\b/i, '\\1dviser') # advisah\n phrase.gsub!(/\\b(a)doah\\b/i, '\\1dore') # adoah\n phrase.gsub!(/(a)ftah/i, '\\1fter') # aftah (aftahwahds, raftah, & other containing words)\n phrase.gsub!(/\\bah(h)?(?=\\s[a-z]+in('|g))?\\b/i, 'are') # ah (usually \"are\" if a word ending in \"ing is after\")\n phrase.gsub!(/\\b(the)? Ahbs\\b/i, '\\1 Arboretum') # the ahbs is a fun place to hang out\n phrase.gsub!(/\\b(a)hm\\b/i, '\\1rm') # curt schilling's gotta good ahm\n phrase.gsub!(/(f|w|h|al|ch|fore)ahm(s?)/i, '\\1arm\\2') # ahm at the end of words\n phrase.gsub!(/\\bahr\\b/i, 'are') # ahr\n phrase.gsub!(/\\bahrya\\b/i, 'are you') # how ahrya?!\n phrase.gsub!(/\\b(a)hnt\\b/i, '\\1unt') # ya ahnt is comin' to Christmas\n phrase.gsub!(/\\ball set\\b/i, 'all done') # all set with my dinnah, thank you\n phrase.gsub!(/\\bAllston Christmas\\b/i, 'The last weekend in August when all the students move out and leave their furniture behind in Allston') # Gonna need a biggah cah\n phrase.gsub!(/\\b(a)mbassad(oah|ah)(s)/i, '\\1ambassad\\2\\3') # ambassadoah/dah\n\n # B\n phrase.gsub!(/\\b(b)ah\\b/i, '\\1ar') # bah (let's get a beeah at the bah)\n phrase.gsub!(/\\b(cross|crow|de|dis|draw|handle|iso|sand|side)bah(s)\\b/i, '\\1bar\\2') # \"bah\" (words ending in bah)\n phrase.gsub!(/\\bbahnie\\b/i, 'smart geek') # bahnie\n phrase.gsub!(/\\bbang a left\\b/i, 'take a left') # bang a left...but do it before the oncoming turns green!\n phrase.gsub!(/\\b(b)ankin/i, 'hillside') # watch the game from the bankin\n phrase.gsub!(/\\bbarrel/i, 'trash can') # throw that yankees jersey in the barrel\n phrase.gsub!(/\\bbazo\\b/i, 'drunk') # bazo on the weekendddd\n phrase.gsub!(/\\bbeantown\\b/i, 'Boston') # beantown\n phrase.gsub!(/\\b(b)eeah(s)?\\b/i, '\\1eer') # lemme buy ya a beeah (sam adams please)\n phrase.gsub!(/\\b(b)ettah\\b/i, '\\1etter') # bettah (than you)\n phrase.gsub!(/\\bbig(-|\\s)ball bowling?/i, '10-pin bowling') # big ball bowlin'\n phrase.gsub!(/\\bBig Dig\\b/i, 'the most expensive highway project in U.S. History') # the big dig, depress that central ahtery\n phrase.gsub!(/\\bb(ill-)?ricka/i, 'Billerica') # Billerica\n phrase.gsub!(/\\bboahded\\b/i, 'dibs') # boahded\n phrase.gsub!(/\\bbobos\\b/i, 'boat shoes') # bobos\n phrase.gsub!(/\\bBostonian\\b/i, 'resident of Boston') # Bostonian\n phrase.gsub!(/\\bbook(ed|in)? outta theah\\b/i, 'took off') # bookin' it\n phrase.gsub!(/\\b(b)r(a|u)h\\b/i, '\\1ro') # brah/bruh\n phrase.gsub!(/\\bbrahmin\\b/i, 'WASP-y type') # Brahmin\n phrase.gsub!(/\\bbreakdown lane\\b/i, 'highway shoulder') # breakdown lane at rush hoah, jeez\n phrase.gsub!(/\\bBroons\\b/i, 'Bruins') # Da Broons!\n phrase.gsub!(/\\bbubblah\\b/i, 'water fountain') # bubblah\n\n # C\n phrase.gsub!(/\\b(c)ahds\\b/i, '\\1ards') # cahds\n phrase.gsub!(/\\b(c|ced|chedd|sc|sidec|tramc|supahc|vic)ah(s)?\\b/i, '\\1ar\\2') # cah(s) and 6 containing words that are most common.\n phrase.gsub!(/\\b(c)alendah(s)?\\b/i, '\\1alendar\\2') # calendah (the sawx got theyah openin' day on theah!)\n phrase.gsub!(/\\bcalm ya liva(a|h)?/i, 'relax') # calm ya livah, I didn't eat ya dinnah\n phrase.gsub!(/\\b(c)an't get\\b/i, '\\1an get') # can't get (no satifaction...but plenty of double negatives up for grabs, so)\n phrase.gsub!(/\\bThe Cape\\b/i, 'Cape Code, Massachusetts') # goin' to the Cape this summah\n phrase.gsub!(/\\bcarriage\\b/i, 'grocery cart') # carriage (for ya lobstahs and beeahs)\n phrase.gsub!(/\\b(c)awna\\b/i, '\\1orner') # coolidge cawna\n phrase.gsub!(/\\b(c)ella(h)\\b?/i, 'basement') # go down cella\n phrase.gsub!(/\\b(c)howdah\\b/i, '\\1howder') # chowdah (clam or lobstah, take ya pick at sullivan's!)\n phrase.gsub!(/\\b(coffee|small|medium|lahge) regulah\\b/i, 'coffee with cream and two sugars') # coffee, regulah\n phrase.gsub!(/\\bCochihchewit\\b/i, 'Cochituate') # Co-CHIH-chew-it\n phrase.gsub!(/\\b(c)onsidah\\b/i, '\\1onsider') # considah\n phrase.gsub!(/\\b(c)orridoah(s)\\b/i, '\\1orridor\\2') # corridor\n phrase.gsub!(/\\b(c)umbie(s|'s)/i, 'Cumberland Farms Mini-Mart') # cumbie's\n\n # D\n phrase.gsub!(/\\b(Mon|Tues|Wed|Thurs|Fri|Sun)diz/i, '\\1days') # plural days of the week, less Saturday which can have a couple pronunciations\n phrase.gsub!(/\\b(d)ecoah\\b/i, '\\1ecor') # decoah (in ya apahtment!) -- most frequently used word ending in \"cor\"\n phrase.gsub!(/\\bdecked\\b/i, 'punched') # he got decked at the sox game\n phrase.gsub!(/\\bdecked\\sout\\b/i, 'dressed up') # he's all decked out for his date!\n phrase.gsub!(/\\b(d)idja\\b/i, '\\1id you') # didja\n phrase.gsub!(/\\bdirty watah\\b/i, 'the Charles River') # love that dirty watah\n phrase.gsub!(/\\bdiggah?\\b/i, 'fall') # fell on some ice and took a diggah\n phrase.gsub!(/\\b(d|fl|ind|p|outd)oah\\b/i, '\\1oor') # oah words ending in oor\n phrase.gsub!(/\\b(direc|doc)tah\\b/i, '\\1tor') # doctah/directah\n phrase.gsub!(/\\bdirectional\\b/i, 'turn signal') # put on ya directional before you take turn\n phrase.gsub!(/\\bDot Ave\\b/i, 'Dorchester Avenue') # Dot Ave\n phrase.gsub!(/\\bDot Rat(s)?/i, 'resident\\1 of Dorchester') # Dot Rats\n phrase.gsub!(/\\bthe Dot\\b/i, 'Dorchester') # the dot\n phrase.gsub!(/\\bdunki(n'?s'?|n|es)(\\sdonuts)?\\b/i, 'Dunkin\\' Donuts') # dunkies, dunkins, dunkin, dunkin's, & dunkin's!\n phrase.gsub!(/\\bdrawring\\b/i, 'drawing') # drawring\n\n # E\n phrase.gsub!(/\\bEastie\\b/i, 'East Boston') # Eastie\n phrase.gsub!(/\\belastic(s)?\\b/i, 'rubber band\\1') # elastics\n phrase.gsub!(/(e)ntah\\b/i, '\\1nter') # entah (come in heah!)\n phrase.gsub!(/\\b(e)ntiah\\b/i, 'entire') # entiah (I've lived in Boston my entiah life)\n phrase.gsub!(/(n)?(e)vah\\b/i, '\\1\\2ver') # evah (or forevahevah! or nevah. that too.)\n\n # F\n phrase.gsub!(/\\bfahr\\b/i, 'for') # fahr (ready fahr spring after this wintah!)\n phrase.gsub!(/\\bfactah\\b/i, 'factor') # factah\n phrase.gsub!(/\\b(af|insof|ovahf|f)ah\\b/i, '\\1ar') # fah (neah, fah, wheahevah you ahhhhh)\n phrase.gsub!(/(f)ahkin'?/i, '\\1*!king') # I mean, it's not very polite but you have to admit it is a distinctive part of a true Boston accent!\n phrase.gsub!(/(f)ahk?/i, '\\1*!k') # I mean, it's not very polite but you have to admit it is a distinctive part of a true Boston accent!\n phrase.gsub!(/\\b(airf|cahf|thoughroughf|welf|wahf|f)ayah\\b/i, '\\1are') # fayah (wahfayah, aihfayah)\n phrase.gsub!(/\\bfawr\\b/i, 'for') # fawr\n phrase.gsub!(/(af|bef|f)oah\\b/i, '\\1ore') # foah (fore & variants)\n phrase.gsub!(/\\bfoddy\\b/i, 'fourty') # foddy\n phrase.gsub!(/\\bfrappe\\b/i, 'a milkshake/malted (ice cream, milk, & syrup blended)') # frappe\n phrase.gsub!(/\\b(frickin|friggin)'?(?!\\z|\\s)/i, 'freaking') # the G-rated version of Boston's favorite adjective\n phrase.gsub!(/\\bfried\\b/i, 'weird') # fried\n phrase.gsub!(/\\bFudgicle\\b/i, 'Fudgsicle') # a fudgsicle that lost the \"s\"\n\n # G\n phrase.gsub!(/\\b(g)ahbidge\\b/i, '\\1arbage') # Wednesdiz is gahbidge day\n phrase.gsub!(/\\b(gawrls|gahls|gawhls)/i, 'girls') # gawrls just wanna...learn to code and change the girl to dave ratio, actually.\n phrase.gsub!(/(g)awd\\b/i, '\\1od') # oh my gawd\n phrase.gsub!(/\\b(g)ovahment\\b/i, '\\1overnment') # Govahment Centah! It's wheah Boston Cawllin' always is!\n phrase.gsub!(/\\b(ci|beg|vul|sug|vine)gah(s)?\\b/i, '\\1gar\\2') # gah --> sugah, cigah, etc.\n phrase.gsub!(/\\b(g)oah\\b/i, '\\1ore') # goah (Melissa-Leigh Goah, like Al Goah, he invented the intahnet)\n phrase.gsub!(/\\bg(o|a)tta\\b/i, 'have to') # gotta\n phrase.gsub!(/\\b(g)rammah\\b/i, '\\1rammar') # grammah\n phrase.gsub!(/\\bgrindah?(s)?\\b/i, 'sub\\1') # grindahs\n phrase.gsub!(/\\b(g)uitah\\b/i, '\\1uitar') # guitah (what's that game the kids ah playin? guitah hero?!)\n\n # H\n phrase.gsub!(/\\b(Hahvahd|Havahd|Havid|Hahvid)/i, 'Harvard') # Let's go to Hahvid and sit outside the Widenah Library\n phrase.gsub!(/\\b(hang|hook) a right\\b/i, 'take a right') # hang/hook a right\n phrase.gsub!(/\\bhamburg\\b/i, 'ground beef') # my grammy's go to dinnah was hamburg thingies..aka ground beef patties with mustard cooked on one side of a hamburger bun (this is an actual true story from the writer of this program, haha)\n phrase.gsub!(/\\b(heahd|heid)\\b/i, 'heard') # ya nevah heahd about that?\n phrase.gsub!(/heah/i, 'here') # heah, wheah, theah (wait, who's on first?!) -- this matches on at least 300 english words containing \"here\"\n #hahbah (no taxation without representation, ya dig?) covered under \"lahbah\"\n phrase.gsub!(/\\bHub\\b/i, 'Boston') # the Hub\n\n # I\n phrase.gsub!(/\\b(i)dear\\b/i, '\\1dea') # idear (so THAT'S where all those \"r\"'s went!')\n phrase.gsub!(/\\b(i)ntahfeah\\b/i, '\\1nterfere') # doan wanna intahfeah, ya know?\n\n # J\n phrase.gsub!(/\\b(a)?(j)ah\\b/i, '\\1\\2ar') # jah and ajah, like jams and doahs, but not doahjahms. well, maybe.\n phrase.gsub!(/\\bjimmies\\b/i, 'chocolate sprinkles') # jimmies, just be careful asking for these in NJ\n phrase.gsub!(/\\bJP\\b/, 'Jamaica Plain') # JP, fastest gentrifying neighbahood\n\n # K\n phrase.gsub!(/\\b(k)eggah?(s)\\b/i, '\\1eg party\\2') # kegga, aka something you throw at ya new apahtment in college\n phrase.gsub!(/\\b(k)inda\\b/i, '\\1ind of') #\n\n # L\n phrase.gsub!(/(chancel|council|sail|counsel|tai|pah|bache|co|sett)lah\\b/i, '\\1lor') # lah (words ending in lah are usually \"ler\", so this looks for the most common ones that should actually be \"lor\" first)\n phrase.gsub!(/([a-z])+ahbah\\b/i, '\\1abor') # lahbah (workin' hahd!) also covers hahbah (no taxation without representation, ya dig?!) and other bor words -- targeted rule so general rule doesn't make this \"laber\"\n phrase.gsub!(/\\b(l)abradoah(s)\\b/i, '\\1abrador\\2') # labradoah retrievah\n phrase.gsub!(/\\bLe(ay|i)?stuh\\b/i, 'Leicester') # Leicester\n phrase.gsub!(/\\bLem(o|i)nstah\\b/i, 'Leominster') # Leominster\n phrase.gsub!(/\\bLight Dawns ovah? Mahblehead\\b/i, 'Oh, DUH.') # light dawns ovah mahblehead\n phrase.gsub!(/\\b(l)iquah\\b/i, '\\1iquor') # liquah stoah...aka a packie, tbh\n phrase.gsub!(/\\blotta\\b/i, 'lot of') # lotta\n\n # M\n phrase.gsub!(/(ah|gla|hu|ru|tre|tu)mah\\b/i, 'mor') # words ending in mah, like rumah, humah (targeted gsub bc most are \"mer\")\n phrase.gsub!(/\\b(m)ajah\\b/i, '\\1ajor') # majah league baseball\n phrase.gsub!(/\\bmasshole\\b/i, 'a proud jerk from Massachusetts') # massholes :)\n phrase.gsub!(/\\b(m)ayah\\b/i, '\\1ayor') # Mayah Menino was the best mayah evah. (RIP)\n phrase.gsub!(/\\b(Mehfuh|Meffid|Medfid)\\b/i, 'Medford') # Meffid. Next to Somerville, home to Tufts\n phrase.gsub(/ministah\\b/i, 'minister') # ministah (the religious kind, but also administer, etc)\n\n # N\n phrase.gsub!(/\\b(nawht|naht)\\b/, 'not') # naht/nawt\n phrase.gsub!(/\\bnooyawka\\b/i, 'New Yorker') # Nooyawka, just the kind of person you don't want to meet at Fenway\n phrase.gsub!(/(semi|so|lu)nah\\b/i, '\\1nar') # \"nah\" ending words that aren't \"ner\"...seminah, solah\n phrase.gsub!(/(na-ah|nuh-uh|nuh-ah)/i, 'no way') # nah-ah\n phrase.gsub!(/\\bneighbahood\\b/i, 'neighborhood') # neighbahood\n\n # O\n phrase.gsub!(/\\b(o)ah\\b/, '\\1ur') # oah (this is ah (our) city!)\n phrase.gsub!(/(o)ffah/i, '\\1ffer') # offah\n phrase.gsub!(/onna(-|\\s)?conna/i, 'on account of') # onna-conna I gotta help my ma\n phrase.gsub!(/\\bopen ai(r|h)\\b/i, 'drive in movie') # open air (drive in movie theatre)\n phrase.gsub!(/(o)thah/i, '\\1ther') # othah (and also containing words like anothah or brothah)\n phrase.gsub!(/(o)vah/i, '\\1ver') # ovah (and also containing words like covah (at the bah!) rovah or ovahpass)\n phrase.gsub!(/(o)wah\\b/i, '\\1wer') # owah (all words ending in \"ower\", powah, flowah, etc)\n\n # P\n phrase.gsub!(/\\bpackie\\b/i, 'liquor store') # packie\n phrase.gsub!(/\\bpeab('dee|dee|ody)\\b/i, 'Peabody') # Peabody\n phrase.gsub!(/\\b(p)lenny\\b/i, '\\1lenty') # plenny ah beahs in the fridge\n phrase.gsub!(/\\bpissah?\\b/i, 'cool') # wicked pissah\n phrase.gsub!(/\\b(Ptown|P-Town|P Town)/i, 'Provincetown') # at the endah tha cape\n\n # Q\n phrase.gsub!(/\\bquality\\b/i, 'worthless') # sarcasm at its finest\n phrase.gsub!(/\\bQuinzee\\b/i, 'Quincy') # Quincy\n\n # R\n phrase.gsub!(/\\b(r)adah?\\b/i, '\\1adar') # radah (cops runnin the radah around to cawnah)\n phrase.gsub!(/\\brahya\\b/i, 'rare') # rahya (wicked rahya steak)\n phrase.gsub!(/\\b(r)apshah?\\b/i, '\\1apture') # rapsha (Jesus and/or Red Sox championship parades, either way)\n phrase.gsub!(/\\b(r)awregg\\b/i, '\\1aw egg') # rawregg can give ya salmonella\n phrase.gsub!(/\\b(r)eahview\\b/i, '\\1earview') # reahview (mirror)\n phrase.gsub!(/\\b(r)emembah\\b/i, '\\1emember') # remembah (when govahment centah was open?)\n phrase.gsub!(/\\breveah\\b/i, 'Revere') # Reveah (as in, Paul. or the beach. or from, kid!)\n phrase.gsub!(/\\brotary\\b/i, 'traffic circle') # second left on tha rotary\n\n # S\n phrase.gsub!(/\\bsangwich\\b/i, 'sandwich') # sangwich\n phrase.gsub!(/\\bsa(dda|ti|tih|ta|tah|tuh)d(ay|ee)\\b/i, 'Saturday') # Satahday\n phrase.gsub!(/\\bsat(a|i)hdiz\\b/i, 'Saturdays') # Satahdays\n phrase.gsub!(/\\bskeeve(s|d)/i, 'grossed out') # skeeved out by hair in food, lemme tell ya\n phrase.gsub!(/soah\\b/i, 'sore') # wicked soah from gettin swole at the gym, bro\n phrase.gsub!(/\\b(s)o do(an|n'?t) i\\b/i, '\\1o do I') # So do(a)n't I!\n phrase.gsub!(/\\bsouthie\\b/i, 'South Boston') # Southie\n phrase.gsub!(/\\bspa\\b/i, 'convenience store (family-owned, usually)') # spa (let's go get an italian ice!)\n phrase.gsub!(/\\b(co|lode|mega|supah|)?stah\\b/i, 'star') # stah (ben affleck/matt damon, need I say moah?)\n phrase.gsub!(/\\bsuppah?\\b/i, 'dinner') # suppah\n phrase.gsub!(/\\bsweet caroline\\b/i, 'Sweet Caroline (BUM BUM BUM)') # GOOD TIMES NEVER SEEMED SO GOOOODD\n\n # T\n phrase.gsub!(/\\bthe T\\b/i, 'subway') # after this winter, it's a wonder I didn't replace this one with \"unusable death trap\"\n # \"theah\" is covered under \"h\" in the heah substitution\n phrase.gsub!(/\\btah\\b/i, 'to') # tah (ready tah go!)\n phrase.gsub!(/\\btawnic\\b/i, 'tonic (soda)') # get a tawnic outta the fridge foh ya fahtah\n phrase.gsub!(/\\btempasha(h)?\\b/i, 'temperature') # David Epstein says the tempasha should go back up tomarrah.\n phrase.gsub!(/\\b(t)ha\\b/i, '\\1he') # tha\n phrase.gsub!(/thah?\\b/i, 'ther') # brothah, fathah, mothah, etc. (matches on 92 english words ending in \"ther\")\n phrase.gsub!(/\\bthi(h)?d\\b/i, 'third') # stealin' thihd\n phrase.gsub!(/\\bthree deckah?\\b/i, 'three story house') # usually three units\n phrase.gsub!(/(pic|ven|lec|cap|adven|sculp|frac|scrip|punc|conjec|rap)sha/i, '\\1ture') # sha sound on end of certain \"ture\" ending words\n\n # U\n phrase.gsub!(/(u)ndah/i, '\\1nder') # undah (including all the words it is a prefix of like undahweah, undahcovah, undahahm, plus bonus containing words like thunder)\n phrase.gsub!(/\\b(u)ey\\b/i, '\\1-turn') # U-turn\n\n # V\n phrase.gsub!(/\\b(v)endah(s)\\b/i, '\\1endor') # vendah(s) (fenway franks, anybody?)\n phrase.gsub!(/\\bvin(yihd|yahd)\\b/i, 'Martha\\'s Vineyard') # mahtha's vinyihd\n phrase.gsub!(/\\b(fahv|fehv|flav|sav|surviv)ah\\b/i, '\\1or') # \"vah\" words that are \"vor\"\n\n # W\n phrase.gsub!(/\\b(w)atah\\b/i, '\\1ater') # watah (as in \"love that dirty\")\n phrase.gsub!(/\\bwah\\b/i, 'war') # wah\n phrase.gsub!(/\\bWal(ltham|thumb)\\b/i, 'Waltham') # home of Brandeis\n phrase.gsub!(/\\bwanna go\\?\\b/i, 'let\\'s fight outside') # wanna go?\n phrase.gsub!(/\\b(w)e(eahd|eid|ahd|eihd)\\b/i, '\\1eird') # weeid\n # wheah is covered under \"t\"...theah/wheah (as in, dude wheah's my car...oh, under a snowbank where I left it in January 2015!)\n phrase.gsub!(/\\bwhole nothah?\\b/i, 'a complete replacement') # I gotta whole notha cah\n phrase.gsub!(/\\bweah\\b/i, 'were') # wheah weah ya?\n phrase.gsub!(/\\b(w)eathah\\b/i, '\\1eather') # wetheah (some weah havin!)\n phrase.gsub!(/\\bwicked\\b/i, 'really') # wicked (wicked weeid kid)\n phrase.gsub!(/\\bwuhst(u|a)h\\b/i, 'Worcester') # Worcester\n\n # X\n\n # Y\n phrase.gsub!(/\\b(y)a\\b/i, '\\1ou') # ya goin to the game?\n phrase.gsub!(/\\b(y)ar(?=\\s?i)/i, '\\1eah ') # yarit's awesome -> yeah it's awesome\n phrase.gsub!(/\\b(y)oah\\b/i, '\\1our') # yoah\n\n # Z\n\n # Last, we're gonna do some broad pickoffs for general sounds common to the Boston accent.\n # This will help translate commonly used words and broadly applicable use-cases. They are\n # a little dangerous without the targeted gsubs above, but with them in place as a filter for\n # uncommon/edge cases, you should get good results.\n\n phrase.gsub!(/atah(s)?\\b/i, 'ator\\1') # \"atah\" (words ending in \"ator\"...decoratah, delegatah)\n phrase.gsub!(/(a)wl(l)?/i, '\\1l\\2') # \"awl\" (going to the mawll, fawllin' down, cawll ya mothah etc)\n phrase.gsub!(/bah(s)?\\b/i, 'ber\\1') # \"bah\" (words ending in bah...bahbah). Works b/c only 30ish words in English end in ber, & targeted gsubs are used above for them.\n phrase.gsub!(/cah(s)?\\b/i, 'cer\\1') # \"cah\" (words ending in cer are more common than car or cor, targeted gsubs for the latter two are above)\n phrase.gsub!(/dah(s)?\\b/i, 'der\\1') # \"dah\" (words ending in dah...chowdah?).\n phrase.gsub!(/eah(s)?\\b/i, 'ear\\1') # \"eah\" (words ending in eah...yeah, cleah)\n phrase.gsub!(/fah(s)?\\b/i, 'fer\\1') # \"fah\" (words ending in fer...offah?).\n phrase.gsub!(/gah(s)?\\b/i, 'ger\\1') # \"gah\" (words ending in ger...swaggah?).\n phrase.gsub!(/ha(h)?(s)?\\b/i, 'her\\2') # \"gah\" (words ending in ger...swaggah?).\n phrase.gsub!(/iah(d)?/i, 'ire\\1') # \"iahd\" (words ending in ire...tiahd, wiahd or ired...fiahd)\n phrase.gsub!(/in'(?=\\z|\\s)/i, 'ing') # \"in'\" (words ending in ing...bring back the g!).\n phrase.gsub!(/kah(s)?\\b/i, 'ker\\1') # \"kah\" (words ending in ker...smokah)\n phrase.gsub!(/lah(s)?\\b/i, 'lar\\1') # \"lah\" (words ending in lar...molah, pillah)\n phrase.gsub!(/mah(s)?\\b/i, 'mer\\1') # \"mah\" (words ending in mer...swimmah, homah)\n phrase.gsub!(/nah(s)?\\b/i, 'ner\\1') # \"nah\" (words ending in ner...gonah, runnah)\n phrase.gsub!(/layah(s)?\\b/i, 'lare\\1') # \"layah\" (words ending in lare..flayah, declayah)\n phrase.gsub!(/(o)ah(s)?/i, '\\1re\\2') # \"oah\" (stoah, moah)\n phrase.gsub!(/pah(s)?\\b/i, 'per\\1') # \"pah\" (words ending in \"pah\"...helpah, peppah, whispah, developah...which I am totally going to be after I win this contest and become...a launchah!)\n phrase.gsub!(/sah(s)?\\b/i, 'ser\\1') # \"sah\" (words ending in ser...think about ya usah in the browsah)\n phrase.gsub!(/tah(s)?\\b/i, 'ter\\1') # \"tah\" (words ending in ter...watah)\n phrase.gsub!(/uahd(s)?\\b/i, 'ured\\1') # \"uahd\" (words ending in ured...figuahd, injuahd)\n phrase.gsub!(/vah(s)?\\b/i, 'ver\\1') # \"vah\" (words ending in ver...ovah, rivah)\n phrase.gsub!(/wah(s)?\\b/i, 'wer\\1') # \"wah\" (words ending in wer...lawnmowah, towah)\n phrase.gsub!(/xah(s)?\\b/i, 'xer\\1') # \"xah\" (words ending in xer...boxah, mixah)\n phrase.gsub!(/yah(s)?\\b/i, 'yer\\1') # \"yah\" (words ending in yer...foyah, lawyah)\n phrase.gsub!(/zah(s)?\\b/i, 'zer\\1') # \"zah\" (words ending in zer...organizah, seltzah)\n\n phrase.gsub!(/aw/i, 'o') # this one is super broad...tawnic/gawd/etc\n phrase.gsub!(/ah(?!\\b)+/, 'ar') # this one should always run last because it's so broad, but it will clean and cover a ton more cases than can be thought up individually\n\n\n # Finally, there is some stuff we just will NOT abide by in the Beantown Translation Machine.\n\n phrase.gsub!(/\\b(A-Rod|Eli Manning|Peyton Manning|the Jets|Bill Buckner|snow|disabled train|severe delays in service|parking ban|commuter rail)\\b/i, '[REDACTED]') # Redact it like the FBI releasing an embarrassing document, okay?\n phrase.gsub!(/\\bYankees\\b/i, 'Yankees (suck!)') # Yankees suck okay?\n phrase.gsub!(/\\bJohnny Damon\\b/i, 'He who shall not be named') # Looks like Jesus, talks like Judas, throws like...someone who can't throw because that's just rude to Mary.\n\n puts \"They said: \" + phrase\n\n # Special \"How Boston Are YOU?\" Beantown Points score for experts! Only shows up for users who earn at least two points.\n\n if beantown_points >= 15\n \tputs \"How Boston Are YOU?: WICKED LEGIT! Ah you from Reveah, kid?! You're as Boston as baked beans and clam chowdah without tomatoes. Hit up that packie, it's time for a toast!\"\n elsif beantown_points < 15 && beantown_points >= 10\n \tputs \"How Boston Are YOU?: Solid work! You probably yell \\\"Yankees Suck\\\" at sporting events where the Yankees aren't even playing. You drink your watah from a bubblah. We salute you.\"\n elsif beantown_points < 10 && beantown_points >= 5\n \tputs \"How Boston Are YOU?: Alright, now we're getting somewhere. This is pretty Boston, we'll admit. Just don't try to pahk ya cah in Hahvahd Yahd, or you'll get towed, alright?\"\n elsif beantown_points >=2 && beantown_points < 5\n \tputs \"How Boston are YOU?: Solid effort, but you need to hit the Pike and go back wheah ya came from, kid.\"\n end\n\n play_again\n\nend", "def cartman_says(offensive_message)\n puts offensive_message #fix\nend", "def test_approach\n prefix = \"This pangram tallies \"\n solution = \"This pangram tallies five a's, one b, one c, two d's, twenty-eight e's, eight f's, six g's, eight h's, thirteen i's, one j, one k, three l's, two m's, eighteen n's, fifteen o's, two p's, one q, seven r's, twenty-five s's, twenty-two t's, four u's, four v's, nine w's, two x's, four y's and one z.\"\n pangram = SelfDocumentingPangram.new(prefix)\n assert_equal(solution, pangram.add_count(pangram.count(solution)))\n\n prefix = \"This terribly inefficient pangram contains \"\n solution = \"This terribly inefficient pangram contains five a's, two b's, three c's, two d's, thirty-one e's, six f's, four g's, ten h's, sixteen i's, one j, one k, three l's, two m's, twenty n's, thirteen o's, two p's, one q, twelve r's, twenty-eight s's, twenty-eight t's, three u's, three v's, nine w's, four x's, six y's and one z.\"\n pangram = SelfDocumentingPangram.new(prefix)\n assert_equal(solution, pangram.add_count(pangram.count(solution)))\n end", "def catch_phrase\n [\n [\"Фирма1\", \"Суперфирма\", \"Фирма3\", \"ПанСамСклепав\"].rand,\n [\"24 часа\", \"24/7\", \"круглосуточно\", \"3 года на рынке\"].rand,\n [\"доступно\", \"быстро\", \"надежно\"].rand\n ].join(' ')\n end", "def speak_to_grandma(input_phrase)\n if input_phrase == \"I LOVE YOU GRANDMA!\"\n \"I LOVE YOU TOO PUMPKIN!\"\n elsif input_phrase!=input_phrase.upcase && input_phrase!=\"I LOVE YOU GRANDMA!\"\n \"HUH?! SPEAK UP, SONNY!\"\n else input_phrase!=input_phrase.upcase \n \"NO, NOT SINCE 1938!\"\n end\nend", "def dynamic_phrase_3\r\n one_it = 'one'\r\n\r\n # Verse 0: **Go to the store and buy some more**\r\n if zero_bottles?\r\n 'Go to the store and buy some more'\r\n else\r\n # Verse 1: **it**\r\n if one_bottle?\r\n one_it = 'it'\r\n end\r\n # Verse x: **Take one down and pass it around**\r\n \"Take #{one_it} down and pass it around\"\r\n end\r\n end", "def instructions\n\t\tputs \"\"\"Mastermind is a code-breaking game that helps develop deductive reasoning and logic by requiring players to deduce secret combinations of colors with minimal clues. After each of these chances, the creator of the code (in this case, the computer) must reveal how many pegs are the correct color in the correct location, or the correct color in the incorrect location, or completely incorrect. With this little information, the code breaker must improve upon his previous guess to crack the code. For this game we'll allow you to have 12 guesses before requiring a forfeit.\"\"\"\n\t\tputs \"Please push Enter to continue\"\n\t\tgets.chomp\n\tend", "def speak_to_grandma(phrase)\n if phrase == \"I LOVE YOU GRANDMA!\"\n return \"I LOVE YOU TOO PUMPKIN!\"\n elsif phrase==phrase.upcase\n return \"NO, NOT SINCE 1938!\"\n else\n return \"HUH?! SPEAK UP, SONNY!\"\n end\nend", "def instruction_message\n puts \"\\nMASTERMIND is a color guessing game where the computer generates a \\\nrandom string of four characters representing the base colors #{\"(r)ed\".red}, \\\n#{\"(g)reen\".green}, #{\"(b)lue\".blue}, and/or #{\"(y)ellow\".yellow}. \\\nThe intermediate difficulty level is six characters and adds \\\n#{\"(m)agenta\".magenta} and the advanced difficulty level is eight characters \\\nand adds #{\"(c)yan\".cyan}. \\\nThe string is only guaranteed to contain one color. The player must submit \\\nguesses to try to find the generated combination. Guesses are not case sensitive.\"\n\n puts \"\\nEnter #{\"(p)lay\".green}, #{\"(i)nstructions\".yellow} or #{\"(q)uit\".red}\"\n end", "def feedback\n puts \"Spelling errors\"\n #Default errors is 0\n errors = 0\n #For each word in the word hash\n $words.each do |word|\n #If the word is spelled wrong prints the word and increments errors\n if word[1] == false\n puts \"#{word[0]}\"\n errors += 1\n end\n end\n #If there are no errors states as much\n if errors == 0\n puts \"No errors found\"\n end\nend", "def research (ingredient)\n puts \"You look through your spellbooks to see how adding #{ingredient} might make your #{@name} spell more powerful.\"\n end", "def display_error\n error <<~MSG\n Sorry, please check\n your input to verify it\n is correct.\n MSG\n prompt error\nend", "def dynamic_phrase_2\r\n # Verse 0: **no more bottles**\r\n if zero_bottles?\r\n \"no more #{bottle_s}\"\r\n else\r\n # Verse 1: **1 bottle**\r\n # Verse x: **x bottles**\r\n \"#{bottle_quantity} #{bottle_s}\"\r\n end\r\n end", "def dynamic_phrase_4\r\n\r\n # Verse 1: **no more bottles**\r\n if one_bottle?\r\n \"no more bottles\"\r\n # Verse 0: **99 bottles**\r\n elsif zero_bottles?\r\n \"99 #{bottle_s}\"\r\n else\r\n # Verse 2: **bottle**\r\n # Verse x: **x bottles**\r\n @bottle_quantity -= 1\r\n \"#{bottle_quantity} #{bottle_s}\"\r\n end\r\n end", "def dynamic_phrase_1\r\n\r\n # Verse 1: **1 bottle**\r\n # Verse 0: **No more bottles**\r\n if zero_bottles?\r\n \"No more bottles\"\r\n # Verse 1: **1 bottle**\r\n # Verse x: **x bottles**\r\n else\r\n \"#{bottle_quantity} #{bottle_s}\"\r\n end\r\n end", "def my_solution\n res = \"\"\n choices.each do |k, v|\n res << \" * #{k}\\n\" if v\n end\n return \"(no correct answer)\" if res.blank?\n res\n end", "def throw_fierce_lqqks\n 'Here I am, giving you Soviet-Satellite realness'\n end", "def learn_english\n puts \"Go learn English!\"\n dyse = \"https://doyouspeakenglish.fr/\"\n puts \"If you're French, go there for FREE: #{dyse}\"\n english_kit = \"http://bit.ly/kit-anglais\"\n puts \"And for only 1€ you can get a complete starter kit here: #{english_kit}\"\n grammar = \"https://learnenglish.britishcouncil.org/skills\"\n puts \"Otherwise go there: #{grammar}\"\n superprof_english = \"http://bit.ly/superprof-anglais\"\n puts \"If you want private lessons, checkout my profile here: #{superprof_english}\"\n podia\nend", "def basic_correction(wrong, right)\n \"ia #{wrong} #{right}\"\n end", "def learn_math\n puts \"If you need some basic maths lessons.\"\n prglump = \"https://www.youtube.com/channel/UCLxVJHhqaLMuyTcbUsoCrFg/videos?view=0&sort=p&flow=grid\"\n puts \"Perhaps you can learn something on this YouTube channel #{prglump}\"\n superprof_math = \"https://bit.ly/2wlBbF9\"\n puts \"If you want more advance math private lessons, checkout my profile here: #{superprof_math}\"\n podia\nend", "def problem(reason_for_error)\n\tputs \"\\aOops, we have a problem here.\" #\\a escape character Bell for error warning\n\tputs \"Your entry '#{reason_for_error}' is incorrect.\"\n\tputs\nend", "def speak_to_grandma(question)\n if question != question.upcase\n return \"HUH?! SPEAK UP, SONNY!\"\n elsif question == \"I LOVE YOU GRANDMA!\"\n return \"I LOVE YOU TOO PUMKIN!\"\n else\n return \"NO, NOT SINCE 1938!\"\n end\nend", "def mascot_sign_for(input)\n\tif input == \"RED HOT\"\n\t\tputs \"H-O-T!\"\n\telsif input == \"DO IT AGAIN\"\n\t\tputs \"Go, Fight, Win\"\n\telsif input == \"2 BITS\"\n\t\tputs \"Holler!\"\n\telsif input == \"STOMP YOUR FEET\"\n\t\tputs \"STOMP!\"\n\telse input == \"\"\n\t\tputs \"Go Team!\"\n\tend\t\t\nend", "def failure_message\n parts = []\n parts << %(\n Hi. Your friendly Curry bot here. Just letting you know that there are\n commit authors in this Pull Request who appear to not have signed a Chef\n CLA.\n ).squish\n\n unknown_commit_authors_with_email_count = @pull_request.unknown_commit_authors.with_known_email.count\n\n if unknown_commit_authors_with_email_count > 0\n parts << %{\n There are #{unknown_commit_authors_with_email_count} commit author(s)\n whose commits are authored by a non GitHub-verified email address in\n this Pull Request. Chef will have to verify by hand that they have\n signed a Chef CLA.\n }.squish\n end\n\n unknown_commit_authors_with_login = @pull_request.unknown_commit_authors.with_known_login\n\n if unknown_commit_authors_with_login.count > 0\n parts << 'The following GitHub users do not appear to have signed a CLA:'\n\n list = unknown_commit_authors_with_login.map do |commit_author|\n \"* @#{commit_author.login}\"\n end.join(\"\\n\")\n\n parts << list\n end\n\n parts << [\n '[Please sign the CLA here.]',\n \"(#{ENV['CURRY_CLA_LOCATION']})\"\n ].join\n\n parts.join(\"\\n\\n\")\n end", "def proof_of_stake\n title(\"Proof of Stake\")\n\n eco_scale = \"https://en.wikipedia.org/wiki/Economies_of_scale\"\n pros1 = \"Energy efficient\"\n pros2 = \"More expensive to attack for attackers\"\n pros3 = \"Not susceptible to ecnomies of scale \\n\\t (for more details about this topic click on this link:\\n\\t #{eco_scale}).\"\n\n pros = [pros1, pros2, pros3]\n\n nothing_at_stake = \"https://medium.com/coinmonks/understanding-proof-of-stake-the-nothing-at-stake-theory-1f0d71bc027\"\n cons = \"nothing-at-stake problem \\n(for more details click on this link:\\n#{nothing_at_stake})\"\n\n\n ppc = {name: \"Peercoin\", website: \"https://peercoin.net/\"}\n pivx = {name: \"Pivx\", website: \"https://pivx.org/\"}\n rdd = {name: \"Reddcoin\", website: \"https://reddcoin.com/\"}\n\n used_by = [ppc, pivx, rdd]\n\n consensus_type = \"Competitive consensus\"\n\n\n explanation = \"\"\"\n The proof of stake was created as an alternative to the proof of work (PoW),\n to tackle inherent issues in the latter. Here instead of using mining, you\n have to have some stake(coins) in the system. So, if you own 10% of the\n stake(coins), then your probability of mining next block will be 10%.\n \"\"\"\n\n further_reading = \"https://en.wikipedia.org/wiki/Proof_of_stake\"\n\n p_o_s = {\n \"pros\" => pros,\n \"cons\" => cons,\n \"used_by\" => used_by,\n \"consensus_type\" => consensus_type,\n \"explanation\" => explanation,\n \"further_reading\" => further_reading\n }\n\n choice = \"0\"\n\n while !choice.include?(\"Q\") && !choice.include?(\"q\")\n choice = consensus_features\n if choice.include?(\"1\")\n puts \"Pros:\"\n p_o_s[\"pros\"].each_with_index { |val, index| puts \"\\t#{index+1}) #{val}\" }\n\n cons = p_o_s[\"cons\"]\n puts \"Cons: #{cons}\"\n elsif choice.include?(\"2\")\n puts \"Used by:\"\n p_o_s[\"used_by\"].each_with_index do\n |valeur, index|\n puts \"#{index+1})\"\n valeur.each do\n |key, value| puts \" #{key}: #{value}\"\n end\n end\n puts \"And others.\"\n elsif choice.include?(\"3\")\n consensus_type = p_o_s[\"consensus_type\"]\n puts \"Type: #{consensus_type}\"\n elsif choice.include?(\"4\")\n explanation = p_o_s[\"explanation\"]\n puts \"Explanation: #{explanation}\"\n elsif choice.include?(\"5\")\n further_reading = p_o_s[\"further_reading\"]\n puts \"Further Reading: #{further_reading}\"\n elsif choice.include?(\"Q\") || choice.include?(\"q\")\n break\n else\n puts \"Error\"\n end\n end\n\nend", "def difficulty_intro\n print \"\\nWhat difficulty would you like to play? (e)asy, (m)edium, or (h)ard? \"\n end", "def explain(error)\n Spotify.error_message disambiguate(error)[0]\n end", "def homework(title, topic, date, thesis_statement, pronoun)\n\tparagraph = \"#{title}/n The #{topic} was an interesting topic. It happened in #{date}. \n\tI feel that #{topic} was a very important part of #{date} because \n\t#{pronoun}. #{thesis_statement}. This is what made #{topic} really \n\tinteresting part of #{date} and an important part of history.\"\n\treturn paragraph\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def print_rationale\n puts \"To start playing, just start typing some Rubinius VM instructions.\"\n puts \"You can find a complete list with documentation here:\"\n puts\n puts \"\\thttp://rubini.us/doc/en/virtual-machine/instructions/\"\n puts\n puts \"To introspect the program you are writing, use the following commands,\"\n puts \"or type \" + bold { \"exit\" } + \" to exit:\"\n puts\n puts \" \" + bold { \"list\" } + \" lists the instruction set of the current program.\"\n puts \" \" + bold { \"reset\" } + \" empties the instruction set and starts a new program.\"\n puts \" \" + bold { \"draw\" } + \" prints a visual representation of the stack after each instruction.\"\n puts\n end", "def serving_size_calc(item_to_make, num_of_ingredients)\n ingredients_per_dish = {\"cookie\" => 1, \"cake\" => 5, \"pie\" => 7}\n\n # Checks if item exists in library. If it doesn't, raise an Argument Error\n # Refactor: Change error check to includes?\n raise ArgumentError.new(\"#{item_to_make} is not a valid input\") unless ingredients_per_dish.include?(item_to_make)\n# error_counter = 3\n\n# ingredients_per_dish.each do |dish|\n# if ingredients_per_dish[dish] != ingredients_per_dish[item_to_make]\n\n# error_counter += -1\n# end\n# end\n\n# if error_counter > 0\n# raise ArgumentError.new(\"#{item_to_make} is not a valid input\")\n# end\n # Refactor: change to just calling the value of the key (item_to_make)\n serving_size = ingredients_per_dish[item_to_make]\n # Where have you see [0] before?\n # - Arrays\n\n # my_array[0] => returns first element in the array.\n\n # Can you have duplicate keys in a hash?\n # - no\n # Therefore we will always have a single element array\n\n # [\"apple\"][0] => \"apple\"\n # [5][0] => 5\n\n # So essentially what this is doing, is converting the single element array into an integer.\n\n # Figures out how many times number of ingredients goes into Serving size\n # If there is a remainder include that on leftover ingredients\n #\n leftover_ingredients = num_of_ingredients % serving_size\n # Refactor to IF, move duplicate first sentence outside of if statement.\n # If remainder then add to return string.\n\n# return_string = \"xyz\"\n\n# if something_is_true\n# return_string += \"additional\"\n# end\n\n# return return_string\n\n return_string = \"Calculations complete: Make #{num_of_ingredients / serving_size} of #{item_to_make}.\"\n return_string += \"You have #{leftover_ingredients} leftover ingredients. Suggested baking: #{leftover_ingredients} cookies.\" if leftover_ingredients > 0\n return_string\n\n# case leftover_ingredients\n# when 0\n\n# return \"Calculations complete: Make #{num_of_ingredients / serving_size} of #{item_to_make}\"\n# else\n# return \"Calculations complete: Make #{num_of_ingredients / serving_size} of #{item_to_make}, you have #{leftover_ingredients} leftover ingredients.\" # Suggested baking items: TODO: MAKE THIS FEATURE\"\n# end\nend", "def print_rhyme(verse_total, is_gender_neutral)\n\n # This array 'num_names' contains English names for\n # numbers from zero to twenty.\n #\n # Though numbers 0 & 1 are not used in the current application,\n # they are included for clarity so that array indexes will\n # correspond to their English names.\n #\n # English names are un-capitalized to give this array\n # general application. Any required\n # capitalization must be accomplised in the code\n num_names = ['zero', 'one', 'two', 'three', 'four', 'five',\n 'six', 'seven', 'eight', 'nine', 'ten',\n 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen',\n 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']\n\n #Print verses greater than 1 in descending order\n verse_counter = verse_total\n until verse_counter == 1 do\n if verse_counter <= 20 #Use my own names array for values up to 20\n puts \"#{num_names[verse_counter].capitalize} little monkeys jumping on the bed,\"\n else #Use a ruby gem to get number names for higher values\n puts \"#{NumbersInWords.in_words(verse_counter).capitalize} little monkeys jumping on the bed,\"\n end\n is_gender_neutral ? (puts 'One fell off and bumped zir head') :\n (puts 'One fell off and bumped his head')\n puts 'Mama called the doctor and the doctor said,'\n puts '\"No more monkeys jumping on the bed!\"'\n puts\n verse_counter -= 1\n end\n\n #Print the final verse\n puts 'One little monkey jumping on the bed,'\n is_gender_neutral ? (puts 'Ze fell off and bumped zir head,') :\n (puts 'He fell off and bumped his head,')\n puts 'Mama called the doctor and the doctor said,'\n puts '\"Get those monkeys right to bed!\"'\n puts\nend", "def stylish_chef\n best_hairstyle = \"Guy Fieri\"\n return \"Martha Stewart\"\n \"Guy Fieri\"\nend", "def greet\n hello + \" \" + world # this format allows us to use puts on line 31\nend", "def cooking\n \"Grab the butter, we're about to be cookin.\"\nend", "def mario\n phrase = \"It's-a me, Mario!\"\n puts phrase\nend", "def compose_explanation(tips)\n \"**#{explanation_introduction_phrase}**\\n\\n#{explanation_paragraphs(tips).join(\"\\n\\n\")}\\n\\n#{retry_phrase}\\n\"\n end", "def king_richard_iii_quote; end", "def essay_writer(title, name, major_accomplishment, year_of_accomplishment, thesis, pronoun)\n\tputs \"Final Assignment Essay:\\n #{title}\n\t\\n\n\t#{year_of_accomplishment} was the year of #{name}. #{major_accomplishment},\n\tdoes that ring a bell? That was all thanks to #{name}. #{thesis} \n\t\\n\n\tMuch more could be said of #{name}, but I believe in brevity. #{pronoun.capitalize} is somebody worth remembering. \n\t\"\n\t\nend", "def mathphrase(integer)\n phrase = [NUMBERS.sample]\n integer.times do |num|\n phrase << OPERATORS.sample << NUMBERS.sample\n end\n phrase.map! do |word| \n if word == 'divided'\n 'divided by'\n else\n word\n end\n end\n phrase.join(\" \")\nend", "def prescription_1\n\tputs \"*** Prescription 1 ***\"\n\tputs \"Use the TDD process to create and adjust your code's design in small, incremental steps.\\n\\n\"\nend", "def pirates_say_arrrrrrrrr(string)\n other_word = \"\"\n string.length.times do | index |\n if ((string[index].downcase.include? \"r\") && (string[index + 1] != nil))\n other_word << string[index + 1]\n end\n end\n\n return other_word\nend", "def error\n\tputs \" - Dis donc #{@name}, tu vois pas que c'est pas possible ?!? Allez rejoue ! \"\n\tputs \" \"\n end", "def madlib\n print \"Enter a noun: \"\n noun = gets.chomp\n print \"Enter a verb: \"\n verb = gets.chomp\n print \"Enter an adjective: \"\n adjective = gets.chomp\n print \"Enter an adverb: \"\n adverb = gets.chomp\n\n puts \"The #{noun} wants to #{verb} #{adverb} but runs into the same #{adjective} problem.\"\nend", "def north_korean_cipher(coded_message)\n input = coded_message.downcase.split(\"\") # Turning every letter into a lower case letter and then splitting it into array\n decoded_sentence = []\n cipher = {\"e\" => \"a\", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n \"f\" => \"b\", # the best data structure for this problem? What are the pros and cons of hashes?\n \"g\" => \"c\", # An array would be beeter structure, we can automate the shiffting of the letters\n \"h\" => \"d\",\n \"i\" => \"e\",\n \"j\" => \"f\",\n \"k\" => \"g\",\n \"l\" => \"h\",\n \"m\" => \"i\",\n \"n\" => \"j\",\n \"o\" => \"k\",\n \"p\" => \"l\",\n \"q\" => \"m\",\n \"r\" => \"n\",\n \"s\" => \"o\",\n \"t\" => \"p\",\n \"u\" => \"q\",\n \"v\" => \"r\",\n \"w\" => \"s\",\n \"x\" => \"t\",\n \"y\" => \"u\",\n \"z\" => \"v\",\n \"a\" => \"w\",\n \"b\" => \"x\",\n \"c\" => \"y\",\n \"d\" => \"z\"}\n\n input.each do |x| # iterating over each input character\n found_match = false #when false the same character will be added to the solution\n cipher.each_key do |y| # iterating thruthe keys of cipher hash\n if x == y #if current character is equal to a hash key\n # puts \"I am comparing x and y. X is #{x} and Y is #{y}.\"\n decoded_sentence << cipher[y]\n found_match = true\n break #it will end the loop once it finds its match\n elsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\" #If it matach one of these characters it will add a space\n decoded_sentence << \" \"\n found_match = true\n break\n elsif (0..9).to_a.include?(x) # turns a range into an array and then checks if that array includes the input\n decoded_sentence << x\n found_match = true\n break\n end\n end\n if not found_match #If there is no match then add the character to the solution\n decoded_sentence << x\n end\n end\n decoded_sentence = decoded_sentence.join(\"\")\n\n if decoded_sentence.match(/\\d+/) #Finding all the didgits\n decoded_sentence.gsub!(/\\d+/) { |num| num.to_i / 100 } #Replace and divide by 100\n end\n return decoded_sentence # it sreturning the string\nend", "def explain_game\n\t\tputs \"In the Secret Number Game, you guess a number between 1 and 10 and, if you pick the right number, you win!\"\n\t\tputs \"Good luck #{@player}!\"\n\tend", "def compile_phrase\n @running_phrases.inject do |phrase, phrase_part|\n phrase + \" #{phrase_part.last_word}\"\n end\n end", "def print_codebreaker_intro_easy\n puts 'Welcome to Mastermind! You are playing the role of the codebreaker.'\n puts 'The computer will choose a 4-color code that you will try to guess.'\n puts \"The valid letters/colors are #{'R'.red}, #{'O'.light_red}, #{'Y'.yellow}, #{'G'.green}, #{'B'.blue}, #{'I'.light_blue}, and #{'V'.magenta}.\"\n puts ''\n puts 'You will get feedback from the code master after each round in the locations corresponding to your guess.'\n puts 'A \"√\" means you have the right color in the right place.'\n puts 'An \"X\" means that the color is in the code but not in that place.'\n puts 'Finally, a \".\" means that color is not part of the code.'\n puts 'You have 6 rounds to guess correctly. Good luck!'\n puts ''\n end", "def frase\n option = 0\n loop do\n option = (rand * 5.5).to_i\n break if option > 0\n end\n case option\n when 1\n return \"Amazing! \"\n when 2\n return \"Good roll! \"\n when 3\n return \"Incredible! \"\n when 4\n return \"Good movement! \"\n when 5\n return \"Are you cheating? \"\n end\n end", "def scrabble(word)\n\npoints = {\n \t\"a\" => 1,\n \t\"e\" => 1,\n \t\"i\" => 1,\n \t\"o\" => 1,\n \t\"u\" => 1,\n \t\"l\" => 1,\n \t\"n\" => 1,\n \t\"r\" => 1,\n \t\"s\" => 1,\n \t\"t\" => 1,\n \t\"d\" => 2,\n \t\"g\" => 2,\n \t\"b\" => 3,\n \t\"c\" => 3,\n \t\"m\" => 3,\n \t\"p\" => 3,\n \t\"f\" => 4,\n \t\"h\" => 4,\n \t\"v\" => 4,\n \t\"w\" => 4,\n \t\"y\" => 4,\n \t\"k\" => 5,\n \t\"j\" => 8,\n \t\"x\" => 8,\n \t\"q\" => 10,\n \t\"z\" => 10,\n }\n puts word\n\n #create a varialbe to store a Score\n score =0\n #go to letter by letter througth word\n word.each_char do |letter|\n #check in proint for a key that matches letter from word\n #take it's value add it to word\n score += points[letter] #try with puts = points[letter] !access to points\n #output message with the full score result\n\nend\n puts \"#{word} is worth #{score} points\" # TRY TO PUT THIS BEFORE END!!\nend", "def mathphrase(num)\n ops = %w[ plus minus times divide ]\n numbers = %w[ zero one two three four five six seven eight nine ]\n phrase = []\n \n num.times do\n phrase << numbers.sample\n phrase << ops.sample\n end\n \n phrase << numbers.sample\n puts phrase.join(' ')\nend", "def about_jude\n message = \"Jude was created one dark fall morning by a bright young student in Mandark's Lab in Pittsburgh. \\nWhile he realised that his assignments were going out of hand he decided to build something that would solve his problem and others. \\nJude has been built to make it easier to add structure to google calendar events for assignments, as well as show upcoming events.\" \n return message\n end", "def hamstrings_stretch\n \"Remaining seated, extend one leg outward. Reach toward your toes. Hold for 10 to 30 seconds. Repeat on the other side. Be sure to do this one leg at a time, as doing this exercise with both legs out can cause back issues.\"\nend", "def test_line_missing_cmd\n alpha = 'RIT'\n assert_equal \"Missing command word (A2P or P2A): #{alpha}\", Phonetic.translate(alpha)\n end", "def sentence(book, opinion)\n p \"I want you to know that #{book} is an amazing book series. #{opinion}\"\nend", "def generate_checkincode\n sai_words = %w(sisters chapter formal music business sigma alpha iota)\n sai_words[rand(sai_words.length)]+(rand(89)+10).to_s()\n end", "def cypher(phrase = nil, offset = nil)\n if phrase == nil\n puts \"What phrase would you like to code?\"\n phrase = gets.chomp\n end\n if offset == nil \n puts \"How much would you like to offset it?\"\n offset = gets.chomp.to_i\n end\n #Sets up a container for the new phrase and splits the previous one\n new_phrase = []\n phrase = phrase.split(\"\")\n phrase.each do |letter|\n #checks if the current character is a letter. if not, it adds it to new_phrase without acting on it.\n if letter =~ /[A-Za-z]/\n #gets the ascii value of the letter then sets a new ascii value in offset_ascii for the cyphered letter.\n ascii = letter.ord\n offset_ascii = ascii + offset\n #This if statement takes the offset and checks to see if its outside the bounds of the upper or lowercase alphabet\n #it then corrects for the wraparound if necessary\n if letter.is_upper?\n if offset_ascii < 65\n offset_ascii += 26\n elsif offset_ascii > 90\n offset_ascii -= 26\n end\n elsif letter.is_lower?\n if offset_ascii < 97\n offset_ascii += 26\n elsif offset_ascii > 122\n offset_ascii -= 26\n end\n end\n #takes the ascii value and turns that into a letter, then pushes it to the new_phrase array\n new_letter = offset_ascii.chr\n new_phrase.push(new_letter) \n else\n new_phrase.push(letter)\n end\n end\n #joins new_phrase into a string and both prints it to the terminal and returns it so it can retain functionality if used in another program\n puts new_phrase.join(\"\")\n return new_phrase.join(\"\")\nend", "def generate_results\n !(@incomplete_word.include? \"_\") ?\n puts(\"Congratulations, you won.\") :\n puts(\"\\nYou failed to guess the words.\")\n end", "def essay_writer(title, name, major_accomplishment, year_of_accomplishment, thesis, pronoun)\n\tputs \"Final Assignment Essay:\\n #{title}\n\t\\n\n\t#{date_of_accomplishment} was the year of #{name}. #{major_accomplishment.capitalize},\n\tdoes that ring a bell? That was all thanks to #{name}. \\n \n\t#{thesis} \\n\n\tMuch more could be said of #{name}. #{pronoun.capitalize} is somebody worth remembering. \n\t\"\n\t\nend", "def oh_crap_i_forgot(title, person, location, date, thesis, major_accomplishment, pronoun)\n pronoun = 'male' ? p_use = 'he' : p_use = 'she'\n date < 1000 ? e_or_l = 'early era' : e_or_l = 'late era'\n\n puts \"#{title} : The Story of #{person}\"\n puts \" \"\n puts \"In #{e_or_l} #{location}, #{person} was a pretty big deal. #{thesis}. #{pronoun.capitalize} changed the very fabric of #{location} when #{pronoun} #{major_accomplishment}.\"\n puts \" \"\n puts \"All in all, #{e_or_l} #{location} would not have been so successful without #{person}, nor would #{location} be the way it is today without those contributions.\"\n puts \"By Mikee.\"\nend", "def test_to_s\n pangram1 = \"This pangram tallies five a's, one b, one c, two d's, twenty-eight e's, eight f's, six g's, eight h's, thirteen i's, one j, one k, three l's, two m's, eighteen n's, fifteen o's, two p's, one q, seven r's, twenty-five s's, twenty-two t's, four u's, four v's, nine w's, two x's, four y's and one z.\"\n assert_equal(pangram1, SelfDocumentingPangram.new(\"This pangram tallies \").to_s)\n\n #pangram2 = \"This computer-generated pangram contains six a's, one b, three c's, three d's, thirty-seven e's, six f's, three g's, nine h's, twelve i's, one j, one k, two l's, three m's, twenty-two n's, thirteen o's, three p's, one q, fourteen r's, twenty-nine s's, twenty-four t's, five u's, six v's, seven w's, four x's, five y's and one z.\"\n #assert_equal(pantram2, SelfDocumentingPangram.new(\"This computer-generated pangram contains \").to_s)\n end", "def intelligenceTest()\r\n puts \"Your intelligence is about to tested, let's see how you can do!\"\r\n if(@charPlaying.smarts == 5)\r\n puts\"Evaluate the expression: \"\r\n puts \"1^2 + 1^2 = \"\r\n @answer = gets()\r\n if (@answer.chomp == '2')\r\n @points += 1\r\n puts \"Good job smarty pants!\"\r\n else\r\n puts \"Really you don't know what 1 + 1 is!\"\r\n end\r\n elsif @charPlaying.smarts == 4\r\n puts\"Evaluate the expression: \"\r\n puts \"pi/0 = \"\r\n @answer = gets()\r\n if(@answer.chomp == '0')\r\n @points += 1\r\n puts \"Wow! You are smart!\"\r\n else\r\n puts \"You probably are not smarter than a 5th grader.\"\r\n end\r\n elsif @charPlaying.smarts == 3\r\n puts \"What is the square root of 4 * 16 = \"\r\n @answer = gets()\r\n if(@answer.chomp == '8')\r\n @points += 1\r\n puts \"Thats correct! One point for you!\"\r\n else\r\n puts \"Better luck next time!\"\r\n end\r\n elsif @charPlaying.smarts == 2\r\n puts \"How many minutes are in one year?\"\r\n @answer = gets()\r\n if(@answer.chomp == '525600')\r\n @points += 1\r\n puts \"That is a lot of minutes! 1 point for you #{@charPlaying.name}\"\r\n else\r\n puts \"I guess there's too many for you to count.\"\r\n end\r\n else\r\n puts \"What is the 50th digit of pi?\"\r\n @answer = gets()\r\n if(@answer.chomp == '1')\r\n @points += 1\r\n puts \"Thats correct and a point for you!\"\r\n else\r\n puts \"Well you only had a 1/10 chance to guess the right answer!\"\r\n end\r\n end\r\n end", "def introduce\n puts \"Hi my name is #{@name}. I am a #{@species}. I had #{@foods_eaten.join (\" and \")} for brunch\"\n end", "def north_korean_cipher(coded_message) # \n input = coded_message.downcase.split(\"\") #Takes input, downcases it, and splits each individual element into an element of an array\n decoded_sentence = [] # creates an empty array called decoded_sentence \n cipher = {\"e\" => \"a\", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n \"f\" => \"b\", # the best data structure for this problem? What are the pros and cons of hashes?\n \"g\" => \"c\", # Pros: This allows a direct translation for each key\n \"h\" => \"d\", # Cons: It's really long and inefficient \n \"i\" => \"e\", \n \"j\" => \"f\",\n \"k\" => \"g\",\n \"l\" => \"h\", \n \"m\" => \"i\",\n \"n\" => \"j\", \n \"o\" => \"k\",\n \"p\" => \"l\",\n \"q\" => \"m\",\n \"r\" => \"n\",\n \"s\" => \"o\",\n \"t\" => \"p\",\n \"u\" => \"q\",\n \"v\" => \"r\",\n \"w\" => \"s\",\n \"x\" => \"t\",\n \"y\" => \"u\",\n \"z\" => \"v\",\n \"a\" => \"w\",\n \"b\" => \"x\",\n \"c\" => \"y\",\n \"d\" => \"z\"}\n \n input.each do |x| # Each is examining each element of the input array as x \n found_match = false # if found false it leaves that element of the input as the same and pushes it decoded_sentence\n cipher.each_key do |y| # Examining each key of the hash cipher \n if x == y # If statement comparing the input element (x) with the key of cipher hash (y) for match \n puts \"I am comparing x and y. X is #{x} and Y is #{y}.\" # puts string \n decoded_sentence << cipher[y] # Pushes cipher[y] into the array decoded_sentence\n found_match = true #marks match as true \n break # the value is found so it doesn't have to search through all the symbols\n elsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\" #Replaces these symbols with a space\n decoded_sentence << \" \" #push space into decoded array \n found_match = true #marks match as true \n break # ends the loop for the symbols \n elsif (0..9).to_a.include?(x) # puts the values in the range in an array \n decoded_sentence << x #pushes number as is into decoded array\n found_match = true #mark match as true\n break # ends the loop for the range class\n end \n end\n if not found_match # if not true \n decoded_sentence << x #pushes the x into the decoded_sentence \n end\n end\n decoded_sentence = decoded_sentence.join(\"\") #takes elements from array and combines them into a string\n \n if decoded_sentence.match(/\\d+/) #finds matches for any numbers in the input \n decoded_sentence.gsub!(/\\d+/) { |num| num.to_i / 100 } # takes that number and inserts it with an integer and divides it by 100 \n end \n return decoded_sentence # Returning string of decoded sentence \nend", "def introduce_myself\n #method body\n puts \"'I am handsome'\"\n puts \"i am talented\"\n puts \"i am briliant\"\n puts \"i am amazing\"\n puts 'is talented'\n puts \"is charming\"\n\n #method body\n end", "def challenge; end" ]
[ "0.65459126", "0.65459126", "0.65459126", "0.65459126", "0.65459126", "0.65459126", "0.65459126", "0.6540971", "0.6426929", "0.6386028", "0.6254576", "0.62112474", "0.61543894", "0.60208774", "0.5929343", "0.57584554", "0.5740522", "0.5724816", "0.568445", "0.5679173", "0.5653715", "0.5638734", "0.5622897", "0.56170696", "0.56012887", "0.5574432", "0.55496097", "0.55377764", "0.5484436", "0.5481037", "0.5460596", "0.54582834", "0.5453492", "0.54397005", "0.5417934", "0.539198", "0.5376795", "0.5362009", "0.5358928", "0.53558606", "0.53554136", "0.53492373", "0.5345465", "0.5336232", "0.5334777", "0.53343797", "0.53234434", "0.53138703", "0.5286791", "0.5286791", "0.5286791", "0.5286791", "0.5286791", "0.5286791", "0.5286791", "0.5286791", "0.5286791", "0.5286791", "0.5286791", "0.5286791", "0.5286791", "0.5286791", "0.5286791", "0.5286791", "0.5277462", "0.5269681", "0.52593756", "0.5258651", "0.5249245", "0.5235864", "0.5232197", "0.52279", "0.52192605", "0.52190864", "0.5211689", "0.5209533", "0.520711", "0.5201063", "0.5199431", "0.51981884", "0.5196371", "0.51955974", "0.51898277", "0.5179034", "0.5171962", "0.5171793", "0.5169999", "0.5163723", "0.5163089", "0.51607656", "0.5153513", "0.5150171", "0.51448894", "0.51429325", "0.51366687", "0.5119295", "0.511509", "0.5111782", "0.51109815", "0.5110043", "0.51069254" ]
0.0
-1
FileSets can include any metadata listed in BasicMetadata file
def file_record(work_attributes) file_set = FileSet.new file_attributes = Hash.new # Singularize non-enumerable attributes work_attributes.each do |k,v| if file_set.attributes.keys.member?(k.to_s) if !file_set.attributes[k.to_s].respond_to?(:each) && work_attributes[k].respond_to?(:each) file_attributes[k] = v.first else file_attributes[k] = v end end end file_attributes[:visibility] = work_attributes['visibility'] unless work_attributes['embargo_release_date'].blank? file_attributes[:embargo_release_date] = work_attributes['embargo_release_date'] file_attributes[:visibility_during_embargo] = work_attributes['visibility_during_embargo'] file_attributes[:visibility_after_embargo] = work_attributes['visibility_after_embargo'] end file_attributes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metadata_file; end", "def metadata_file; end", "def load_workset( filename )\n\n md_filename = ''\n asset_files = []\n File.open( filename, 'r').each do |line|\n if /^metadata : /.match( line )\n md_filename = /^metadata : (.*)$/.match( line ).captures[ 0 ]\n end\n\n if /^asset : /.match( line )\n asset_files << /^asset : (.*)$/.match( line ).captures[ 0 ]\n end\n end\n\n return md_filename, asset_files\n end", "def metadata_file\n study_files.any_of(\n { file_type: 'Metadata' },\n { file_type: 'AnnData', 'ann_data_file_info.has_metadata' => true }\n ).first\n end", "def file_sets_missing_metadata\n FileSet.all.select do |fs|\n fs.original_file && fs.original_file.file_size == []\n end\n end", "def metadata_files\n return @metadata_files unless @metadata_files.nil?\n @metadata_files = MetadataFile.all\n @existing_files, @new_files = [], []\n @metadata_files.each do |f|\n if f.cached?\n @existing_files << f\n else\n @new_files << f\n end\n end\n end", "def file_set_append\n # Append the array of file metadata values to any FileSets with new FileNodes being appended\n parent.file_metadata += file_nodes\n file_nodes\n end", "def metadata_file\n [site.regenerator.metadata_file]\n end", "def file_set?(resource)\n resource.respond_to?(:file_metadata) && !resource.respond_to?(:member_ids)\n end", "def read_metadata; end", "def update_fileset_metadata(work, attrs)\n work.ordered_members.to_a.each_with_index do |member, i|\n builder = FileSetBuilder.new(member, user, attrs[i])\n builder.run\n end\n end", "def find_files(file_set:)\n if file_set.respond_to?(:file_ids)\n return [] unless file_set.file_ids.present?\n query_service.custom_queries.find_many_file_metadata_by_ids(ids: file_set.file_ids)\n else\n raise ::Valkyrie::Persistence::ObjectNotFoundError,\n \"#{file_set.internal_resource} is not a `Hydra::FileSet` implementer\"\n end\n end", "def find_files(file_set:)\n if file_set.respond_to?(:file_ids)\n return [] if file_set.file_ids.blank?\n query_service.custom_queries.find_many_file_metadata_by_ids(ids: file_set.file_ids)\n else\n raise ::Valkyrie::Persistence::ObjectNotFoundError,\n \"#{file_set.internal_resource} is not a `Hydra::FileSet` implementer\"\n end\n end", "def metadata_group(upload_group)\n upload_group.each_with_object({}) do |upload, obj|\n obj[upload.filename] = metadata.for(upload.filename)\n end\n end", "def file_sets\n @iss_file.file_sets.select {|fs| fs.components.include? name }\n end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def external_file_attributes; end", "def metadata(*args)\n opts = args.extract_options!\n args.each do |name|\n self.add_metadata(name, opts)\n end\n end", "def object_filesets_for_export(object_files, include_files = true)\n %w[metadata text].inject([]) do |ret, fileset_type|\n next ret if object_files[fileset_type.to_sym].blank?\n object_fileset = {\n created_at: create_date,\n updated_at: modified_date,\n file_set_of: { ark_id: pid },\n file_set_type: fileset_type,\n file_name_base: \"#{pid}_#{fileset_type}\",\n metastreams: {\n administrative: { access_edit_group: rightsMetadata.access(2).machine.group },\n workflow: {\n ingest_origin: ingest_origin_for_workflow,\n processing_state: workflowMetadata.item_status.state[0] == 'published' ? 'complete' : 'derivatives'\n }.compact\n }\n }\n exemplary_ids = []\n relationships.each_statement do |statement|\n if statement.predicate =~ /isExemplaryImageOf/\n exemplary_ids << statement.object.to_s.gsub(/info:fedora\\//,'')\n end\n end\n unless exemplary_ids.blank?\n object_fileset[:exemplary_image_of] = []\n exemplary_ids.uniq.each do |pid|\n object_fileset[:exemplary_image_of] << { ark_id: pid }\n end\n end\n object_fileset[:files] = object_files[fileset_type.to_sym] if include_files\n ret << { file_set: object_fileset }\n end\n end", "def apply_file_metadata(params)\n uploaded_file_ids = params[\"uploaded_files\"]\n return if uploaded_file_ids.nil?\n uploaded_file_ids.each do |uploaded_file_id|\n uploaded_file = find_or_create_uploaded_file(uploaded_file_id)\n next if uploaded_file.pcdm_use == \"primary\"\n apply_metadata_to_uploaded_file(uploaded_file, params)\n end\n params[\"etd\"].delete(\"supplemental_file_metadata\")\n params # return the params after processing, for ease of testing\n end", "def existing_files\n metadata_files if @existing_files.nil?\n @existing_files\n end", "def load_file_metadata(file, *fallback_keys)\n path = File.expand_path(file)\n\n keys = if Gem::Requirement.create(\">= #{BASELINE_VERSION}\").satisfied_by?(Gem::Version.new(@version))\n # gather available metadata keys from file if '-m' option is supported\n @sh.run_command(@bin.to_path, '-m', path).split($/)\n elsif fallback_keys.count > 0\n # else use fallback keys (if any)\n fallback_keys.map!(&:to_s)\n warn \"MultiMarkdown version #{@version} does not support the '-m' option.\"\n warn \"Only the following metadata will be queried:#{list_join(*fallback_keys)}\"\n fallback_keys\n end\n keys.each.with_object({}) do |key, data| data[key] = @sh.run_command(@bin.to_path, '-e', key, path) end\n end", "def extract_metadata; end", "def external_metadata_file?\n false\n end", "def metadata(filepath)\n metadata = {}\n metadata.merge!(author(filepath))\n metadata.merge!(title(filepath))\n metadata.merge!(serie(filepath))\n metadata\n end", "def metadata=(_); end", "def attributes_for_file_sets(env)\n visibility_attributes =\n FileSetVisibilityAttributeBuilder\n .new(work: env.curation_concern)\n .build\n\n env.attributes.merge!(visibility_attributes)\n\n env.attributes.except!(:embargo_release_date) unless\n env.curation_concern.files_embargoed\n\n true\n end", "def find_metadata(*args)\n results = []\n @filesets.each do |volid, fileset|\n results += fileset.find_metadata(*args)\n end\n return results\n end", "def internal_file_attributes; end", "def file_sets\n @file_sets ||= begin\n geo_concern.geo_file_set_presenters\n end\n end", "def file_set\n @file_set ||= begin\n members = resource_decorator.geo_members\n members.first.decorate unless members.empty?\n end\n end", "def load_metadata\n begin\n load RAILS_ROOT + '/app/metadata/' + self.name.to_s.underscore + '.rb'\n rescue MissingSourceFile\n end\n end", "def metadata_file_set_field?(key)\n field = metadata_field(key)\n return field[:object] != :monograph if field.present?\n false\n end", "def metadata\n metadata = {}\n @file.data.each { |key, value| metadata[key.to_sym] = value }\n\n metadata[:type] = @file.class.name.split('::')[1].downcase\n metadata[:url] = @file.url\n\n metadata[:slug] = slug\n\n metadata[:posted_at] = @file.date.to_time.to_i if @file.respond_to? :date\n metadata[:tags] = tags\n\n metadata\n end", "def representative_file\n file_key = metadata.keys.find { |k| k.to_s =~ /(representative_)?files?/i }\n return [] if file_key.nil?\n\n metadata.fetch(file_key, [])\n end", "def masterfile_keys\n ['gtin', 'tranno']\n end", "def create_metadata(work, file_set_params = {})\n file_set.apply_depositor_metadata(user)\n now = CurationConcerns::TimeService.time_in_utc\n file_set.date_uploaded = now\n file_set.date_modified = now\n file_set.creator = [user.user_key]\n\n interpret_visibility file_set_params if assign_visibility?(file_set_params)\n attach_file_to_work(work, file_set, file_set_params) if work\n yield(file_set) if block_given?\n end", "def applicable_files; end", "def metadata\n return @metadata if @metadata\n return nil unless value\n value.each do |source|\n begin\n if data = Puppet::FileServing::Metadata.indirection.find(source)\n @metadata = data\n @metadata.source = source\n break\n end\n rescue => detail\n fail detail, \"Could not retrieve file metadata for #{source}: #{detail}\"\n end\n end\n fail \"Could not retrieve information from environment #{Puppet[:environment]} source(s) #{value.join(\", \")}\" unless @metadata\n @metadata\n end", "def compile_metadata\n each do |cookbook_name, cookbook|\n compiled_metadata = cookbook.compile_metadata\n if compiled_metadata\n cookbook.all_files << compiled_metadata\n cookbook.cookbook_manifest.send(:generate_manifest)\n end\n end\n end", "def set_metadata( file_list, tag_hash)\n file_list = [*file_list] # make sure file_list is an array\n file_list.each do |file_name|\n if File.exist?(file_name) \n ok = TagLib::FileRef.open(file_name) do |f|\n tag = f.tag\n tag_hash.each do |tag_name, value|\n\n # make sure that the tag_nam (hash key) is a string and then add = to it\n if tag_name.class != String\n tag_name = tag_name.to_s\n end\n tag_name += \"=\"\n\n if tag.respond_to?(tag_name)\n tag.send(tag_name, value)\n else\n puts \"can't modify tag #{tag_name}\"\n end\n end\n f.save\n end\n if ok == false then\n puts \"uh-oh. There was a problem saving/opening #{f}, it's tags were not modified.\"\n end\n else\n puts \"file #{file_name} does not exist, so its tags were not updated.\"\n end\n end\n end", "def file_sets_for(work)\n Hyrax.custom_queries.find_child_file_sets(resource: work)\n end", "def metadata_file\n @metadata_file ||= site.in_source_dir(\".jekyll-metadata\")\n end", "def metadata\n return @metadata if @metadata\n return nil unless value\n #debug 'fragment get metadata from source'\n value.each do |source|\n begin\n if data = Puppet::FileServing::Metadata.indirection.find(source, :environment => resource.catalog.environment)\n @metadata = data\n @metadata.source = source\n break\n end\n rescue => detail\n fail detail, \"Could not retrieve file metadata for #{source}: #{detail}\"\n end\n end\n fail \"Could not retrieve information from environment #{resource.catalog.environment} source(s) #{value.join(\", \")}\" unless @metadata\n @metadata\n end", "def special_files\n @special_files ||= Set.new\n end", "def file_set\n @file_set ||= resource_decorator.geo_members&.first\n end", "def linkMetadataToResults(metas)\n\n # Go through metadata\n # m - has all metadata combined\n m = {} \n metas.each do |t|\n # Skip metadata from old blobs\n if t.metadata_blob_id != nil && t.devfile_blob_id != t.metadata_blob_id\n next\n end\n \n # n - has metadata of one file \n n = {}\n \n store = m[t.devfile_id]\n \n # Is there already data for this devfile_id\n if store == nil\n # No data for this devfile yet, create it\n n.merge!({t.metadatatype => t.metadata_value})\n \n # Add metadata of this file to combined metadata\n m.merge!({t.devfile_id => n })\n\n else\n block = store[t.metadatatype]\n\n # Is there already this metadatatype\n if block == nil\n # Create the new metadatatype for this file\n store.merge!({t.metadatatype => t.metadata_value})\n elsif t.metadatatype == \"tag\" or t.metadatatype == \"context_hash\"\n # Add new metadatatype for this file\n store.merge!({t.metadatatype => block + \", \" + t.metadata_value})\n end\n \n # Add metadata of this file to combined metadata\n m.merge!({t.devfile_id => store }) \n end\n end \n \n \n \n \n # link metadata to right result, with hash\n @results.each do |r|\n mdata = m[r.devfile_id.to_i]\n if mdata != nil\n #puts \"r: #{r.devfile_file_id.to_s}\"\n @metadatas.merge!({r.devfile_id.to_i => mdata})\n end\n end\n \n \n\n \n \n end", "def addMetadata(filename, metadatatype, metadatavalue)\n begin\n \n if @fileMetadata.has_key?(filename)\n @fileMetadata[filename] = @fileMetadata[filename].to_s + \"&&&\" + metadatatype.downcase + \":\" + metadatavalue.downcase\n else\n @fileMetadata[filename] = metadatatype.downcase + \":\" + metadatavalue.downcase\n end\n \n rescue Exception => e\n puts \"Error: #{e.to_s}\"\n puts \" -- line: #{e.backtrace[0].to_s}\"\n raise Exception.new(\"Could not add metadata to a new file!\")\n end\n end", "def new_files\n metadata_files if @existing_files.nil?\n @new_files\n end", "def metadata\n @metadata ||= lambda { read_metadata }.call\n end", "def metadata\n @metadata ||= lambda { read_metadata }.call\n end", "def metadata?\n true\n end", "def test_each_file_returns_data\n files = NutrientDataSet::META_DATA.keys\n files.each do |name|\n parser = data[\"nutr_def\"]\n row = parser.take(1)\n \n assert !row.empty?, \"Expected data for #{name} to exist.\"\n end\n end", "def run\n admin_set\n return unless errors.empty?\n metadata_files.each { |file| parse_metadata(file) }\n end", "def file_set\n @file_set ||= begin\n member_id = resource_decorator.thumbnail_id.try(:first)\n return nil unless member_id\n members = resource_decorator.geo_members.select { |m| m.id == member_id }\n members.first.decorate unless members.empty?\n end\n end", "def load_metadata\n ret = tar.seek('metadata.yml') do |entry|\n YAML.load(entry.read)\n end\n fail 'metadata.yml not found' unless ret\n @metadata = ret\n ret\n end", "def initialize metadata = nil, files = nil\n @metadata = metadata || Metadata.new\n @files = files || []\n end", "def add_fileset\n\n # grab the parameters\n work_id = params[:work]\n file_id = params[:file]\n label = params[:label]\n\n # validate them\n if work_id.blank? == false && file_id.blank? == false && label.blank? == false\n work = get_the_work( work_id )\n if work.nil? == false\n filename = APIV1FilesetsController.cache_contents( file_id )\n if filename.blank? == false\n fileset = ::FileSet.new\n fileset.title << label\n file_actor = ::CurationConcerns::Actors::FileSetActor.new( fileset, @api_user )\n file_actor.create_metadata( work )\n file_actor.create_content( File.open( filename ) )\n fileset.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC\n fileset.save!\n\n # audit the information\n #audit_log( \"File #{label} for work id #{work_id} (#{work.identifier}) added by #{User.cid_from_email( @api_user.email)}\" )\n WorkAudit.audit( work_id, User.cid_from_email( @api_user.email), \"File #{File.basename( filename )}/#{label} added\" )\n\n render_standard_response( :ok )\n else\n render_standard_response( :not_found, 'File not found' )\n end\n else\n render_standard_response( :not_found, 'Work not found' )\n end\n else\n render_standard_response( :unauthorized, 'Missing work identifier or file identifier or file label' )\n end\n\n end", "def initialize(name, metadata = {})\n super\n @files = {}\n end", "def load_metadata(groups)\n nameset = groups.values.flatten.uniq\n basenames = nameset.map { |n| File.basename(n) }\n names = basenames.join(' ')\n raw = JSON.parse(%x(brew info --json=v1 #{names}))\n\n raw.inject({}) do |named, entry|\n named[entry['full_name']] = entry\n named\n end\nend", "def get_metadata_file album\n Albatross::ThrowIf.is_nil? album, \"album\"\n \"storage/dropbox/#{album}.yml\"\nend", "def update_metadata(file)\n metadata = MetadataEngine.new(file)\n\n # Special renaming case for misc files that do not need the tracklist\n if metadata.filepath.get_type == \"misc\"\n metadata.tags.artist = metadata.filepath.artist\n metadata.tags.year = metadata.filepath.year\n metadata.tags.album = metadata.filepath.album\n metadata.tags.cd = metadata.filepath.cd\n metadata.tags.index = metadata.filepath.index\n metadata.tags.title = metadata.filepath.title\n metadata.tags.save\n return\n end\n\n unless metadata.tracklist.has_tracklist?\n puts \"No .tracklist found for #{file}, generating it now.\"\n %x[generate-tracklist #{file.shellescape}]\n metadata = MetadataEngine.new(file)\n end\n\n # Update tags to reflect what's in the tracklist\n metadata.tags.artist = metadata.tracklist.artist\n metadata.tags.year = metadata.tracklist.year\n metadata.tags.album = metadata.tracklist.album\n metadata.tags.cd = metadata.tracklist.cd\n metadata.tags.index = metadata.tracklist.index\n metadata.tags.title = metadata.tracklist.title\n metadata.tags.type = metadata.tracklist.type\n metadata.tags.save\n\n # Update filepath to rename files based on new metadata\n metadata.filepath.artist = metadata.tracklist.artist\n metadata.filepath.year = metadata.tracklist.year\n metadata.filepath.album = metadata.tracklist.album\n metadata.filepath.cd = metadata.tracklist.cd\n metadata.filepath.index = metadata.tracklist.index\n metadata.filepath.title = metadata.tracklist.title\n metadata.filepath.save\n end", "def metadata_info\n @metadata = Chef::Cookbook::Metadata.new\n @metadata.from_file(File.join(@opts[:path], 'metadata.rb'))\n end", "def add_metadata(meta={})\n @local_metadata.deep_merge!(meta.dup)\n end", "def export_metadata_only\n File.foreach(File.join(@export_dir, @pidlist)) do |line|\n begin\n short_pid = strip_pid(line.strip)\n item = GenericAsset.find(line.strip)\n rem_graph = remediate(@remediation, item.descMetadata.graph)\n bag = BagIt::Bag.new(File.join(@bags_dir, short_pid))\n export_profile(item, rem_graph, short_pid)\n export_metadata(item, rem_graph, short_pid)\n export_workflow_metadata_profile(item, short_pid)\n bag_finisher(bag)\n rescue StandardError => e\n message = \"Error #{e.message}:#{e.backtrace.join(\"\\n\")}\"\n puts message if @verbose\n @logger.error(message)\n end\n end\n end", "def files; end", "def files; end", "def files; end", "def files; end", "def files; end", "def files; end", "def metadata\n if config.metadata.include?(:all)\n [:pid, :date, :time, :file]\n else\n config.metadata\n end\n end", "def metadata\n if config.metadata.include?(:all)\n [:pid, :date, :time, :file]\n else\n config.metadata\n end\n end", "def metadata\n result = store.metadata_for_path(path).dup\n\n file_meta = store.metadata_for_file(source_file).dup\n result.deep_merge!(file_meta)\n\n local_meta = @local_metadata.dup\n result.deep_merge!(local_meta)\n\n result\n end", "def metadata(options: DEFAULT_OPTIONS)\n output = %x(exiftool #{options} -json #{file.path.shellescape})\n json = JSON.parse(output).first\n json = json.except(\"SourceFile\")\n ExifTool::Metadata.new(json.with_indifferent_access)\n end", "def special_files=(files)\n @special_files = Set.new(files)\n end", "def files\n file_sets.map{|fs| fs.files }.flatten\n end", "def metadata\n return @metadata unless @metadata.nil?\n\n @metadata = Chef::Cookbook::Metadata.new\n\n metadata_filenames.each do |metadata_file|\n case metadata_file\n when /\\.rb$/\n apply_ruby_metadata(metadata_file)\n when uploaded_cookbook_version_file\n apply_json_cookbook_version_metadata(metadata_file)\n when /\\.json$/\n apply_json_metadata(metadata_file)\n else\n raise \"Invalid metadata file: #{metadata_file} for cookbook: #{cookbook_version}\"\n end\n end\n\n @metadata\n\n # Rescue errors so that users can upload cookbooks via `knife cookbook\n # upload` even if some cookbooks in their chef-repo have errors in\n # their metadata. We only rescue StandardError because you have to be\n # doing something *really* terrible to raise an exception that inherits\n # directly from Exception in your metadata.rb file.\n rescue StandardError => e\n @metadata_error = e\n @metadata\n end", "def metadata_path\n File.join(Rake.original_dir, 'metadata.rb')\nend", "def files_set\n if settings.fs_created + 12 < Time.now\n settings.fs = FuzzySet.new(repo.files)\n settings.fs_created = Time.now\n end\n settings.fs\n end", "def write_metadata; end", "def write_metadata(variable_set: nil)\n @data_file << variable_set.keys if @data_lib.csv_opt[:headers]\n end", "def create_file_set(import_url: nil, label: nil)\n file_set = FileSet.new(import_url: import_url, label: label)\n\n file_set.apply_depositor_metadata(user)\n now = CurationConcerns::TimeService.time_in_utc\n file_set.date_uploaded = now\n file_set.date_modified = now\n file_set.creator = [user.user_key]\n\n visibility_params = {\n visbility: work.visibility,\n embargo_release_date: work.embargo_release_date,\n lease_expiration_date: work.lease_expiration_date\n }.compact\n if visibility_params.present?\n CurationConcerns::Actors::ActorStack.new(file_set, user, [CurationConcerns::Actors::InterpretVisibilityActor]).create(visibility_params)\n end\n\n # We have a weird hard to reproduce bug involving\n # NoMethodError: undefined method 'update' for nil:NilClass at\n # hydra-access-controls-10.4.0/app/models/hydra/access_control.rb:31 :in 'block in permissions_attributes=``\n #\n # Can't reproduce on demand, not sure what's going on, but hoping that maybe\n # saving the file_set _before_ trying to set permissions will be helpful.\n file_set.save!\n\n work_permissions = work.permissions.map(&:to_hash)\n if work_permissions.present?\n file_set.permissions_attributes = work_permissions\n # no additional save seems necessary after doing permissions_attributes=, seems to do it's own save of what's\n # needed...\n end\n\n return file_set\n end", "def write_metadata(variable_set: nil)\n end", "def update_metadata\n file_attributes = ::FileSetEditForm.model_attributes(attributes)\n actor.update_metadata(file_attributes)\n end", "def metadata?\n true\n end", "def file_metadata_present?\n @file_metadata_present = !!file_metadata_before_type_cast.present? if @file_metadata_present.nil?\n end", "def read_metadata\n raise NotImplementedError.new 'This is only a function body for documentation'\n end", "def metadata_monograph_field?(key)\n field = metadata_field(key)\n return field[:object] != :file_set if field.present?\n false\n end", "def metadata_ingest_files\n return if params[:metadata_ingest_files].blank?\n params[:metadata_ingest_files].map do |metadata|\n metadata = JSON.parse(metadata, symbolize_names: true)\n file = Valkyrie::StorageAdapter.find_by(id: metadata[:id])\n PendingUpload.new(\n id: SecureRandom.uuid,\n storage_adapter_id: file.id,\n created_at: Time.current,\n file_name: metadata[:filename],\n type: metadata[:type]\n )\n rescue\n nil\n end.compact\n end", "def ensure_metadata_as_expected!\n expected_metadata_rb = <<~E\n name 'local-cookbook'\n maintainer ''\n maintainer_email ''\n license ''\n description 'Installs/Configures local-cookbook'\n long_description 'Installs/Configures local-cookbook'\n version '2.3.4'\n\n E\n expect(IO.read(metadata_path)).to eq(expected_metadata_rb)\n end", "def existing_files; end", "def file_set(file_expression='lib/**/*.rb', label=:default)\n log \"file sets before: #{@file_sets}\"\n log \"file set label #{label}\"\n new_style = Style.new\n\n yield new_style if block_given?\n\n @file_sets[label] = FileSet.new(file_expression, new_style)\n log \"file sets after: #{@file_sets}\"\n end", "def files\n @files=get_endpoint('extra').keys\n end", "def filesets_for_export(include_files = true)\n filesets = []\n has_ereader_files = false\n # get file-level filesets (image, document, video, etc); remove ereader (do 'em separately)\n all_files = Bplmodels::Finder.getFiles(pid)\n\n ereader_files = all_files.delete(:ereader) || []\n\n ## all_files.delete(:images) # uncomment for easier testing of IA objects\n # Make all non ereader files part of a \"lazy\" eumerator see Enumerator::Lazy at https://ruby-doc.org/core-2.6.8/Enumerator/Lazy.html\n # Note all_files.values.reduce(:+) will flatten the values in the all_files hash into a single array\n filesets = filesets_for_files_lazy(all_files.values.reduce(:+), include_files)\n # get EReader filesets and combine, make EPub the 'primary'\n if ereader_files.present?\n has_ereader_files = true\n ereader_fileset_for_export = nil\n if include_files\n ereader_filesets = filesets_for_files(ereader_files, include_files)\n ereader_filesets.each_with_index do |er_fileset, index|\n if er_fileset[:file_set][:files][0][:content_type] == 'application/epub+zip'\n ereader_fileset_for_export = er_fileset\n ereader_filesets.delete_at(index)\n end\n end\n ereader_filesets.each do |er_fileset|\n er_fileset[:file_set][:files].each do |er_file|\n next unless er_file[:file_type].match?(/ebook_access/)\n\n ereader_fileset_for_export[:file_set][:files] << er_file\n end\n end\n else\n ereader_files = ereader_files.select { |erf| erf[\"mime_type_tesim\"].include?(\"application/epub+zip\") }\n if ereader_files.present?\n ereader_fileset_obj = Bplmodels::File.find(ereader_files.first['id'])\n ereader_fileset_for_export = ereader_fileset_obj.export_data_for_curator_api(include_files)\n end\n end\n\n # have to modify keys of ebook_access_mobi and ebook_access_daisy files to use epub pid\n # NOTE on moving this up from below\n # Instead of reiterating through all of the fileset objects to check for the ereader object we just added...\n # modify the one we are adding before putting it into the filesets enum\n if ereader_fileset_for_export.present?\n pid_for_key = ereader_fileset_for_export.dig(:file_set, :ark_id)\n ereader_fileset_for_export[:file_set][:files].each do |file|\n if file[:file_type] == 'ebook_access_daisy' || file[:file_type] == 'ebook_access_mobi'\n key_parts = file[:key].split('/')\n key_parts[1] = pid_for_key if key_parts[1].match?(/[\\w-]*:[0-9a-z]*/)\n file[:key] = key_parts.join('/')\n end\n end\n end\n # NOTE since filesets is a Enumerator::Lazy object the << operator does not work anymore\n # Instead you have to wrap the object into a Enumerator subtype(Array in this case) and add(+) it\n # This will create an Enumerator::Chain object\n filesets = filesets + Array.wrap(ereader_fileset_for_export)\n end\n\n # if has_ereader_files\n # filesets.each do |fs|\n # fileset = fs[:file_set]\n # next unless fileset[:file_set_type] == 'ereader'\n #\n # pid_for_key = fileset[:ark_id]\n # fileset[:files].each do |file|\n # if file[:file_type] == 'ebook_access_daisy' || file[:file_type] == 'ebook_access_mobi'\n # key_parts = file[:key].split('/')\n # key_parts[1] = pid_for_key if key_parts[1].match?(/[\\w-]*:[0-9a-z]*/)\n # file[:key] = key_parts.join('/')\n # end\n # end\n # end\n # end\n # get the object-level filesets (metadata, plainText, etc)\n object_filesets = object_filesets_for_export(object_filestreams_for_export)\n filesets + object_filesets\n end" ]
[ "0.71350425", "0.71350425", "0.67456824", "0.66652495", "0.6634314", "0.649845", "0.6472493", "0.62322074", "0.62176937", "0.6192708", "0.6182669", "0.6163496", "0.6144549", "0.6090247", "0.60851675", "0.6083046", "0.6083046", "0.6083046", "0.6083046", "0.6083046", "0.6083046", "0.6083046", "0.6071023", "0.60140723", "0.6006411", "0.599947", "0.59600824", "0.5954154", "0.5953415", "0.5937562", "0.5932158", "0.59176236", "0.59162927", "0.5914711", "0.58915997", "0.5871825", "0.586477", "0.5860877", "0.5849104", "0.5837806", "0.58231676", "0.58096594", "0.5792381", "0.57894415", "0.5781824", "0.57665545", "0.57412076", "0.57248145", "0.57126725", "0.57065004", "0.5701312", "0.5696292", "0.5695249", "0.56874007", "0.56725645", "0.56613755", "0.56613755", "0.566136", "0.56607294", "0.56473935", "0.56186336", "0.5615509", "0.56155086", "0.5611639", "0.561056", "0.56039935", "0.5587295", "0.5585275", "0.5584972", "0.5579302", "0.55783683", "0.5570036", "0.5570036", "0.5570036", "0.5570036", "0.5570036", "0.5570036", "0.5569479", "0.5569479", "0.5569045", "0.5552574", "0.5541806", "0.55379987", "0.55354303", "0.55334145", "0.5528379", "0.5527467", "0.5525384", "0.5518238", "0.5516493", "0.55097836", "0.5488653", "0.54861605", "0.5481441", "0.5478919", "0.5475043", "0.54736406", "0.5473088", "0.547154", "0.5464301", "0.54606414" ]
0.0
-1
Below Generates the slug based on title
def slug_candidates [ :title, [:title, self.admin.last_name], [:title, self.admin.last_name, :id] ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_slug_from_title\n self.slug = self.title.downcase.gsub(' ','-')\n end", "def generate_slug\n self.slug = title.parameterize if title\n end", "def generate_slug\n self.slug = self.title[0..47].parameterize\n end", "def generate_slug\n self.slug = self.title[0..47].parameterize\n end", "def generate_slug\n \tself.slug = title.parameterize\n end", "def slug_by_title\n \"#{title.gsub(/[^a-zA-Z0-9]/, '-')}-#{id}\"\n end", "def slug_by_title\n \"#{title.gsub(/[^a-zA-Z0-9]/, '-')}-#{id}\"\n end", "def slug\n title.downcase.gsub(\" \", \"_\")\n title.gsub(\".\",\"\")\n end", "def slug\n Inflector.parameterize(@title, \"_\")\n end", "def get_slug_for(title)\n title.downcase.gsub(/[^a-z0-9_\\s-]/, '').gsub(/\\s+/, '-')\n end", "def create_slug\n return if self.title.blank?\n tail, int = \"\", 1\n initial = convert_to_slug(self.title)\n while Post.find_by_slug(initial + tail) do \n int += 1\n tail = \"-#{int}\"\n end\n self.slug = initial + tail\n end", "def build_slug\n if slug.blank? or title_changed?\n self.slug = self.title.blank? ? Time.now.strftime('%s') + id.to_s : ActiveSupport::Inflector.transliterate(title).downcase.gsub(/[^\\w]+/, '-')\n\n\n i = 0\n # Slug must be unique, so we try guess a good one\n loop do\n if Post.where(:slug => slug).count == 0\n break\n end\n i += 1\n if slug == 1\n slug = [slug, sprintf('%03d', i)].join('-')\n else\n orig_slug = slug.scan(/^(.+)-(\\d+)$/).flatten.first\n slug = [orig_slug, sprintf('%03d', i)].join('-')\n end\n end\n end\n end", "def create_slug\n var_slug = [title.parameterize].join(\"-\")\n self.slug = BlogPost.generate_slug(var_slug)\n end", "def titleize_slug(slug); end", "def generate_slug(title)\n title = clean_title title\n # Strip the string\n ret = title.downcase.strip\n\n # Blow away apostrophes\n ret.gsub! /['`]/,\"\"\n\n # @ --> at, and & --> and\n ret.gsub! /\\s*@\\s*/, \" at \"\n ret.gsub! /\\s*&\\s*/, \" and \"\n\n # Replace all non alphanumeric, underscore or periods with underscore\n ret.gsub! /\\s*[^A-Za-z0-9\\.\\-]\\s*/, '_' \n\n # Convert double underscores to single\n ret.gsub! /_+/,\"_\"\n\n # Strip off leading/trailing underscore\n ret.gsub! /\\A[_\\.]+|[_\\.]+\\z/,\"\"\n\n ret\nend", "def to_slug\n self.title.parameterize\n end", "def generate_slug\n self.slug = self.name.parameterize\n end", "def slug\n self.title.downcase.gsub(\" \", \"-\") unless self.title.nil?\n end", "def slug\n self.title.downcase.gsub(/\\s+/, '-').gsub(/[^a-z0-9_-]/, '').squeeze('-')\n end", "def slug\n self.title.downcase.gsub(/\\s+/, '-').gsub(/[^a-z0-9_-]/, '').squeeze('-')\n end", "def generate_article_slug\n slug = \"#{title.to_s.downcase.gsub(/\\W/, '-')}-#{Time.now.to_i}\"\n self.slug = slug\n end", "def generate_slug\n self.slug = name.parameterize if name.present?\n end", "def set_slug\n self.slug = title.parameterize\n end", "def slugfy\n# self.slug = title.gsub(/\\W/, '-').downcase\n self.slug = title.parameterize.to_s\n end", "def set_slug\n self.slug = title.downcase.tr(\" \", \"_\") if slug.blank?\n slug\n end", "def set_slug\n self.slug = title.downcase.gsub(\" \", \"_\") if slug.blank?\n slug\n end", "def parameterize_slug\n self.slug = self.title if self.slug.empty?\n self.slug = self.slug.downcase.parameterize\n end", "def slug\n parts = Array.new\n parts << event.short_code\n parts << title.parameterize.to_s\n parts.join(\"-\")\n end", "def transform_to_slug(title, extension)\n characters = /(\"|'|!|\\?|:|\\s\\z)/\n whitespace = /\\s/\n \"#{title.gsub(characters,\"\").gsub(whitespace,\"-\").downcase}.#{extension}\"\nend", "def transform_to_slug(title, extension)\r\n characters = /(\"|'|!|\\?|:|\\s\\z)/\r\n whitespace = /\\s/\r\n \"#{title.gsub(characters,\"\").gsub(whitespace,\"-\").downcase}.#{extension}\"\r\nend", "def generate_slug\n [\n :title,\n [:title, :year]\n ]\n end", "def make_slug\n self.permalink = (self.permalink.downcase.gsub(/[^a-zA-Z 0-9]/, \"\")).gsub(/\\s/,'-') if self.permalink\n end", "def generate_path_slug\n slug = \"/#{sluggerize(self.title)}.#{format_class.responds_to.to_s}\"\n end", "def slugando\n\t\tself.slug = summary.parameterize.to_s\n\tend", "def generate_path_slug\n slug = \"/#{archive.slug}/news/#{ymd}/#{sluggerize(news.title)}\"\n end", "def set_slug\n self.slug = self.title.parameterize\n end", "def slug\n @attributes[:slug] = @attributes[:name] && PublicEarth::Db::Collection.create_slug(@attributes[:name]) unless @attributes[:slug] \n @attributes[:slug]\n end", "def slugify(title)\n title.gsub(' ', '-').downcase\n end", "def slug\n name.split(' ').join('-')\n end", "def slug\n #it strips out special characters, and replaces all spaces with -\n name.split.join(\"-\").downcase\n end", "def make_slugged_title\n return true unless self.published?\n return true unless self.slug.to_s.blank?\n self.slug = self.title.to_slug\n end", "def compute_slug\n \"#{normalize_slug_base_string}-#{self.id || sluggify}\"\n end", "def generate_slug\n if self.slug.blank? || self.slug.nil?\n unless self.name.blank?\n if Department.in_clinic(self).where(slug: name.parameterize).count != 0\n n = 1\n while Department.where(slug: \"#{name.parameterize}-#{n}\").count != 0\n n+= 1\n end\n self.slug = \"#{name.parameterize}-#{n}\"\n else\n self.slug = name.parameterize\n end\n else\n self.slug = 'no-name-entered'.parameterize\n end\n end\n end", "def generate_slug\n slug = name.to_s.gsub(/:id/, '').gsub(/[^a-zA-Z0-9]+/, '-').gsub(/^-|-$/, '')\n slug = 'home' if slug.blank?\n \n # If there is a duplicate slug then loop over existing slugs to \n # find the next highest numbered slug.\n if project.resources.where(:slug => slug).count > 0\n index = 0\n project.resources.where(\"slug LIKE ?\", \"#{slug}%\").each do |r|\n m, i = *r.slug.match(/#{Regexp.escape(slug)}-(\\d+)$/)\n index = [index, i.to_i].max if m\n end\n slug += \"-#{index+1}\"\n end\n\n self.slug = slug\n end", "def slug; end", "def slug; end", "def slug\n (self[:headline] || '').parameterize\n end", "def slug\n self.name.downcase.gsub(/[^a-z0-9]/, '-').squeeze('-')\n end", "def slugify\n self.slug = self.name.downcase.strip.gsub(' ', '-').gsub(/[^\\w-]/, '')\n end", "def slug\n name.downcase.gsub(\" \", \"-\")\n end", "def slug\n @slug ||= text.match(/([\\w-]*)$/)[0]\n end", "def slug\n name.gsub(\" \", \"-\").downcase\n end", "def slug\n self.name.gsub(\" \", \"-\").downcase\n end", "def slug\n self.name.downcase.gsub(' ', '-')\n end", "def slug\n self.name.downcase.gsub(' ', '-')\n end", "def slug_for(title)\n dasherized_title = title.downcase.gsub(/\\s+/, '-')\n characters_to_remove = /(\"|'|!|\\?|:)/\n dasherized_title.gsub(characters_to_remove, '')\nend", "def slug\n name.downcase.gsub(\" \",\"-\")\n end", "def slug\n urlname.to_s.split('/').last\n end", "def slug\n self.name.split(/\\W/).map {|word| word.downcase unless word.empty?}.compact.join('-')\n end", "def slug\n name.downcase.gsub(' ', '-')\n end", "def manage_slug\n \tself.slug = self.title.parameterize if self.slug.blank?\n end", "def parameterize_slug slug\n slug = slug.parameterize.split('_').join('-')\n return slug\n end", "def generateSlug(text)\n text=text.to_s\n text=text.gsub(\"-\",\" \")\n text=text.split.join(\" \")\n return text.downcase.gsub(\" \", \"-\").to_s\nend", "def slug\n self.name.downcase.gsub(\" \", \"-\") unless self.name.nil?\n end", "def slug\n self.name.downcase.gsub(\" \", \"-\") unless self.name.nil?\n end", "def generate_custom_slug\n\t\t# \"#{convert_to_lowercase_to} #{convert_to_lowercase_from}\"\n\t\t\"#{self.id}\"\n\tend", "def slug\n self.name.strip.gsub(\" \", \"-\").downcase\n end", "def slug\n self.name.strip.gsub(\" \", \"-\").downcase\n end", "def slugify\n self.slug = name.parameterize \n end", "def slugify\n self.slug = name.parameterize\n end", "def slug_string\n self.name\n end", "def to_param\n FeedEntry.slugize(title, 10)\n end", "def as_slug\n Swift::Transliteration.slugize self\n end", "def slug\n urlname.to_s.split(\"/\").last\n end", "def post_slug(other); end", "def slug\n self.name.downcase.gsub(/[!@%&\"]/,'').tr(\" \", \"-\")\n end", "def slug\n #s = self.name\n #s.downcase.gsub(\" \",\"-\")\n self.name.gsub(\" \", \"-\").downcase\n end", "def generate_path_slug\n slug = \"/#{archive.slug}/\"\n slug += sluggerize(study.ddi_id)\n end", "def generate_slug(name)\n PublicEarth::Db::Collection.one.generate_slug(name)['generate_slug']\n end", "def slug\n\t\tunless name.nil?\n\t\t\tname.downcase.gsub(\" \", \"-\")\t\t\t\n\t\tend\n\tend", "def fix_slug\n # If title is present and slug not set\n if title.present? && !slug.present?\n fixed_slug = Article.stripper(self.title)\n end\n if slug.present?\n # Make sure slug matches format\n fixed_slug = Article.stripper(self.slug)\n end\n self.slug = fixed_slug\n end", "def slug=(_arg0); end", "def slug\n name.downcase.tr(' ', '-').delete('.')\n end", "def slug\n name.downcase.tr(' ', '-').delete('.')\n end", "def to_title(file_slug)\n if file_slug == 'index' && !@pointer['id'].index('/').nil?\n file_slug = @pointer['id'].split('/')[-2]\n end\n\n file_slug.gsub(/[^\\p{Word}+]/u, ' ').gsub(/\\b\\w/){$&.upcase}\n end", "def slug\n attributes['name'].gsub(/\\s/, '-').gsub(/[^\\w\\-]/, '').downcase\n end", "def slugify(item)\n slug = File.basename(item[:filename], File.extname(item[:filename]))\n slug.gsub(/\\s+/, '-')\n end", "def set_slug\n self.slug = full_name.parameterize\n end", "def generate_slug\n self.slug = username.to_slug\n end", "def title=(new_title)\n super(new_title)\n self[:slug] = new_title.parameterize if new_title\n end", "def slug\n name.chomp.downcase.split('').reject{|l| l.match(/[^\\p{L}\\d\\s]/u)}.join.gsub(\" \", \"-\")\n end", "def slug_base_string\n self.id || sluggify\n end", "def sluggify\n name = self.name.downcase.gsub(/[\\W]/,'-').gsub(/[--]+/,'-').dasherize\n slug = Location.find_all_by_slug(name)\n if slug.size > 1\n return \"#{name}-#{slug.size-1}\"\n else\n return name\n end\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def slug\n path\n end", "def slug\n slugAttr = @doc.css('map').attr('slug')\n return slugAttr.nil? ? name.gsub(/[\\s]/, '-').mb_chars.normalize(:c).gsub(/[^\\w-]/n, '').to_s.downcase : slugAttr.value\n end", "def slug_candidates\n [:title]\n end", "def build_slug\n return unless new_slug_needed?\n self.slug = slugs.build :name => slug_text.to_s, :scope => friendly_id_config.scope_for(self)\n end" ]
[ "0.8957013", "0.89245903", "0.8814883", "0.8814883", "0.85977376", "0.8552337", "0.8552337", "0.8481273", "0.83908814", "0.8326465", "0.8307926", "0.8290855", "0.82050955", "0.81547534", "0.81383514", "0.81037927", "0.80989844", "0.80925226", "0.79604113", "0.79604113", "0.7932708", "0.79233426", "0.78546494", "0.78289086", "0.7825328", "0.78078145", "0.7806578", "0.78031814", "0.77979827", "0.7790938", "0.7775319", "0.77752346", "0.775709", "0.7742642", "0.7712235", "0.77069247", "0.7699406", "0.76965404", "0.76954526", "0.76903176", "0.7689207", "0.7643683", "0.7623372", "0.76195675", "0.75840044", "0.75840044", "0.7560517", "0.7560063", "0.7548744", "0.7540532", "0.7526357", "0.7524087", "0.7513877", "0.7513495", "0.7513495", "0.75083923", "0.7505821", "0.7492244", "0.7489295", "0.74881285", "0.7485653", "0.74791795", "0.74758196", "0.7473677", "0.7473677", "0.74639094", "0.7443282", "0.7443282", "0.7442585", "0.7427949", "0.74150795", "0.74140716", "0.7409434", "0.7395631", "0.7384169", "0.73821044", "0.7372609", "0.7363281", "0.7349936", "0.7314484", "0.7300504", "0.7283869", "0.728121", "0.728121", "0.7273164", "0.72719806", "0.72409004", "0.72097784", "0.7173094", "0.71666867", "0.7163496", "0.71606684", "0.7148551", "0.7145796", "0.7145796", "0.7145796", "0.7145796", "0.71435845", "0.713954", "0.71335447", "0.71302456" ]
0.0
-1
Below Determines if there's a blank or new Record to assign a slug to.
def should_generate_new_friendly_id? new_record? || slug.blank? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def should_generate_new_friendly_id?\n new_record? || self[:slug].blank?\n end", "def should_generate_new_friendly_id?\n slug.blank?\n end", "def should_generate_new_friendly_id?\n\t new_record? || slug.blank?\n\tend", "def should_generate_new_friendly_id?\n\t new_record? || slug.blank?\n\tend", "def should_generate_new_friendly_id?\n new_record? || slug.blank?\n end", "def should_generate_new_friendly_id?\n new_record? || slug.blank?\n end", "def should_generate_new_friendly_id?\n new_record? || slug.blank?\n end", "def should_generate_new_friendly_id?\n new_record? || slug.blank?\n end", "def should_generate_new_friendly_id?\n\t new_record? || slug.blank?\n\t \n\tend", "def should_generate_new_friendly_id?\n\t\tslug.blank?\n\tend", "def should_generate_new_friendly_id?\n slug.blank?\n end", "def should_generate_new_friendly_id?\n slug.blank?\n end", "def should_generate_new_friendly_id?\n slug.blank?\n end", "def should_generate_new_friendly_id?\n new_record? || self.slug.nil?\n end", "def new_slug_needed?\n !slug || slug_text != slug.name\n end", "def should_generate_new_friendly_id?\n slug.blank? || permalink_changed?\n end", "def should_generate_new_friendly_id?\n slug.blank? || name_changed?\n end", "def should_generate_new_friendly_id?\n\t name_changed?||self.slug.nil?\n\tend", "def check_and_set_slug\n self.slug ||= self.host&.parameterize\n end", "def create_slug\n return if self.errors.size > 0\n return if self[source_column].blank?\n\n if self[slug_column].to_s.empty?\n proposed_slug = self[source_column].to_slug\n\n suffix = \"\"\n existing = true\n acts_as_slugable_class.transaction do\n while existing != nil\n # look for records with the same url slug and increment a counter until we find a unique slug\n existing = acts_as_slugable_class.\n where(slug_column => proposed_slug + suffix).\n where(slug_scope_condition).first\n if existing\n suffix = suffix.empty? ? \"-0\" : suffix.succ\n end\n end\n end # end of transaction \n self[slug_column] = proposed_slug + suffix\n end\n end", "def manage_slug\n \tself.slug = self.title.parameterize if self.slug.blank?\n end", "def make_slugged_title\n return true unless self.published?\n return true unless self.slug.to_s.blank?\n self.slug = self.title.to_slug\n end", "def set_slug\n \t \tself.slug = name.to_slug unless name.blank?\n\tend", "def slug\n @attributes[:slug] = @attributes[:name] && PublicEarth::Db::Collection.create_slug(@attributes[:name]) unless @attributes[:slug] \n @attributes[:slug]\n end", "def before_save\n if !new? && (title = fields[title_field_name])\n set_slug_from_title(title)\n end\n fix_generated_slug_conflicts if changed_columns.include?(:slug)\n super\n end", "def set_slug\n if self.slug.blank?\n self.slug = self.name.parameterize.downcase unless self.name.nil?\n end\n end", "def set_slug\n self.slug = title.downcase.gsub(\" \", \"_\") if slug.blank?\n slug\n end", "def should_generate_new_friendly_id?\n title_changed? || custom_slug_changed?\n end", "def bad_slug?(object)\n params[:id] != object.to_param\n end", "def bad_slug?(object)\n params[:id] != object.to_param\n end", "def bad_slug?(object)\n params[:id] != object.to_param\nend", "def set_slug\n self.slug = title.downcase.tr(\" \", \"_\") if slug.blank?\n slug\n end", "def fix_slug\n # If title is present and slug not set\n if title.present? && !slug.present?\n fixed_slug = Article.stripper(self.title)\n end\n if slug.present?\n # Make sure slug matches format\n fixed_slug = Article.stripper(self.slug)\n end\n self.slug = fixed_slug\n end", "def stale_slug?\n !((permanent_slug? && slug && !slug.empty?) || (slug_source_value.nil? || slug_source_value.empty?))\n end", "def auto_generate_slug\n return true unless self.slug.nil?\n return true if self.respond_to?(:published?) && !self.published?\n self.slug = self.interpolate_slug\n end", "def slug_set\n unless self.title.nil? || self.slug =~ /\\?preview=true$/\n if self.site_id.nil?\n self.slug = \"\"\n elsif self.root?\n set_root_page_slug\n else\n set_child_page_slug\n end\n end\n end", "def custom_slug_or_title\n title.presence\n end", "def slug_uniqueness\n if name? and slug? and Quotum.where(slug: slug).where.not(id: id).exists?\n errors.add(:name, \"is unavailable\")\n end\n end", "def slug\n self.title.downcase.gsub(\" \", \"-\") unless self.title.nil?\n end", "def create_slug\n return if self.title.blank?\n tail, int = \"\", 1\n initial = convert_to_slug(self.title)\n while Post.find_by_slug(initial + tail) do \n int += 1\n tail = \"-#{int}\"\n end\n self.slug = initial + tail\n end", "def normalize_friendly_id(string)\n if slug.blank?\n super\n else\n super(slug)\n end\n end", "def slug; (page.slug rescue ''); end", "def slug; (page.slug rescue ''); end", "def update_slug\n get_resource.slug = nil\n get_resource.save!\n end", "def set_slug\n self.slug = KeyGenerator.generate(8) if self.slug.blank?\n end", "def slug\n published.nil? ? nil : published.slug\n end", "def need_slug?\n child?\n end", "def slug\n self.name.downcase.gsub(\" \", \"-\") unless self.name.nil?\n end", "def slug\n self.name.downcase.gsub(\" \", \"-\") unless self.name.nil?\n end", "def new_with_slugs?\n if localized?\n # We need to check if slugs are present for the locale without falling back\n # to a default\n new_record? && _slugs_translations.fetch(I18n.locale.to_s, []).any?\n else\n new_record? && _slugs.present?\n end\n end", "def create_slug\n if new? \n \tlength = 16\n \t# Loop while slug is not unique\n \tbegin\n \t\tself.slug = (0..(length-1)).map{ rand(36).to_s(36) }.join \n \t\tobject = self.class.first(:slug => self.slug) \n \tend while(object != nil)\n end\nend", "def is_valid_slug?(slug)\n BSON::ObjectId.legal?(slug) || !(%r(^[a-z0-9-]+$) =~ slug).nil?\n end", "def slug=(value)\n write_attribute(:slug, value) if value.present?\n end", "def slug=(value)\n write_attribute(:slug, value) if value.present?\n end", "def slug=(value)\n write_attribute(:slug, value) if value.present?\n end", "def skip_slug_validation?\n true\n end", "def should_generate_new_friendly_id?\n attribute_changed?(title)\n end", "def new_record?\n self.id.nil? || self.id == ''\n end", "def slug_unique_in_clinic?\n Department.in_clinic(self).where(slug: slug).count == 0\n end", "def should_generate_new_friendly_id?\n company_name_changed? || title_changed? || status_changed? || super\n end", "def generate_slug\n if self.slug.blank? || self.slug.nil?\n unless self.name.blank?\n if Department.in_clinic(self).where(slug: name.parameterize).count != 0\n n = 1\n while Department.where(slug: \"#{name.parameterize}-#{n}\").count != 0\n n+= 1\n end\n self.slug = \"#{name.parameterize}-#{n}\"\n else\n self.slug = name.parameterize\n end\n else\n self.slug = 'no-name-entered'.parameterize\n end\n end\n end", "def should_generate_new_friendly_id?\n title_changed?\n end", "def slug=(s)\n if (new_slug = fit_slug_to_length(s, 64)) != slug\n super(new_slug)\n update_path\n end\n end", "def set_slug(normalized_slug = T.unsafe(nil)); end", "def should_generate_new_friendly_id?\n title_changed?\n end", "def build_slug\n if slug.blank? or title_changed?\n self.slug = self.title.blank? ? Time.now.strftime('%s') + id.to_s : ActiveSupport::Inflector.transliterate(title).downcase.gsub(/[^\\w]+/, '-')\n\n\n i = 0\n # Slug must be unique, so we try guess a good one\n loop do\n if Post.where(:slug => slug).count == 0\n break\n end\n i += 1\n if slug == 1\n slug = [slug, sprintf('%03d', i)].join('-')\n else\n orig_slug = slug.scan(/^(.+)-(\\d+)$/).flatten.first\n slug = [orig_slug, sprintf('%03d', i)].join('-')\n end\n end\n end\n end", "def should_generate_new_friendly_id?\n title_changed?\n end", "def slug_unique_in_clinic\n errors.add(:slug, \"Slug: #{slug} already in use\") unless\n slug_unique_in_clinic?\n end", "def post_slug(other); end", "def set_slug\n if self.class.friendly_id_options[:use_slug] && new_slug_needed?\n @most_recent_slug = nil\n slug_attributes = {:name => slug_text}\n if friendly_id_options[:scope]\n scope = send(friendly_id_options[:scope])\n slug_attributes[:scope] = scope.respond_to?(:to_param) ? scope.to_param : scope.to_s\n end\n # If we're renaming back to a previously used friendly_id, delete the\n # slug so that we can recycle the name without having to use a sequence.\n slugs.find(:all, :conditions => {:name => slug_text, :scope => scope}).each { |s| s.destroy }\n slug = slugs.build slug_attributes\n slug\n end\n end", "def set_slug\n self.slug = self.title.parameterize\n end", "def should_generate_new_friendly_id?\n new_record? || true\n end", "def remember_if_slug_has_changed\n @slug_was_changed = slug_changed?\n end", "def should_generate_new_friendly_id?\n title_changed?\n end", "def should_generate_new_friendly_id?\n title_changed?\n end", "def should_generate_new_friendly_id?\n title_changed?\n end", "def should_generate_new_friendly_id?\n title_changed?\n end", "def has_better_id?\n slug and found_using_numeric_id? || found_using_outdated_friendly_id?\n end", "def set_slug\n self.slug = full_name.parameterize\n end", "def normalize_slug\n self.slug = normalize_friendly_id(slug)\n end", "def set_slug\n self.slug = title.parameterize\n end", "def slug?(arg)\n false if Integer(arg)\n rescue ArgumentError, TypeError\n true\n end", "def slugged?\n !self.include?(\" \")\n end", "def pages_slug_validation\n return unless catalog\n\n return unless catalog.pages.exists?(slug: slug)\n\n errors.add :slug, I18n.t(\"validations.item_type.pages_slug\")\n end", "def slug\n @slug ||= begin\n raw = self['identifier'].find { |id| id.start_with?('slug:') }\n Spot::Identifier.from_string(raw).value unless raw.nil?\n end\n end", "def normalize_slug\n self.slug = normalize_friendly_id(slug)\n end", "def create\n @slug = Slug.new(slug_params)\n\n if @slug.save\n redirect_to slug_stats_url(@slug.short_url)\n else\n render new_slug_path\n end\n end", "def slug\n self.fields[:slug]\n end", "def deprecated?\n self[:slug].nil?\n end", "def add_slug\n loop do\n initials = user.first_name[0, 2].downcase <<\n user.last_name[0, 2].downcase\n year = Time.current.strftime(\"%y\")\n self.slug = \"#{initials}#{year}-#{rand(100..9999)}\"\n break unless self.class.exists?(slug: slug)\n end\n end", "def slug\n fetch[:slug]\n rescue NoMethodError\n nil\n end", "def build_slug\n return unless new_slug_needed?\n @slug = slugs.new(:name => slug_text, :scope => friendly_id_config.scope_for(self))\n raise FriendlyId::BlankError unless @slug.valid?\n @new_friendly_id = @slug.to_friendly_id\n @slug\n end", "def new_record?(object)\n object[\"UID\"].nil? || object[\"UID\"] == \"\"\n end", "def set_slug(normalized_slug = nil)\n if should_generate_new_friendly_id?\n candidates = FriendlyId::Candidates.new(self, normalized_slug || send(friendly_id_config.base))\n slug = slug_generator.generate(candidates) || resolve_friendly_id_conflict(candidates)\n send \"#{friendly_id_config.slug_column}=\", slug\n end\n end" ]
[ "0.75662917", "0.7549237", "0.74837685", "0.74837685", "0.74618816", "0.74618816", "0.74618816", "0.74618816", "0.74598545", "0.7449375", "0.7445815", "0.73239946", "0.73239946", "0.72741103", "0.7230869", "0.7101277", "0.708868", "0.69013137", "0.6858813", "0.67569935", "0.6724413", "0.6707682", "0.66377866", "0.6601364", "0.6587785", "0.65071005", "0.6491309", "0.6489162", "0.64767957", "0.64767957", "0.64649594", "0.64586437", "0.6400528", "0.63805366", "0.63549596", "0.63391083", "0.63251996", "0.63185006", "0.62967825", "0.6291337", "0.6265774", "0.6170414", "0.6170414", "0.6140617", "0.60947233", "0.60861534", "0.6064272", "0.6057457", "0.6057457", "0.6042009", "0.6038491", "0.60372007", "0.6023111", "0.6023111", "0.6023111", "0.60228306", "0.60162777", "0.6000735", "0.5973574", "0.59601825", "0.5959226", "0.5953015", "0.59516877", "0.5938007", "0.59307235", "0.59210634", "0.59150076", "0.59063065", "0.5901627", "0.5898791", "0.5894424", "0.58942866", "0.588729", "0.5872938", "0.5872938", "0.5872938", "0.5872938", "0.5852973", "0.5849351", "0.58457386", "0.5836848", "0.58345497", "0.5823943", "0.58218837", "0.5815502", "0.5814315", "0.5810551", "0.5807652", "0.5802963", "0.5798984", "0.57940483", "0.57924306", "0.5792106", "0.57908714" ]
0.7426962
17
End ASSOCIATIONS: Many/Belongs To/One Relations. Begin METHODS: Custom Methods and model calls. End METHODS: Custom Methods and model calls. Begin CUSTOM CALLBACKS: Before_save, after_commit, & Callbacks. Below Allows Mentions inside Library Uploads to send a notification to shared admins.
def mentions @mentions ||= begin regex = /@([\w]+\s[\w]+)/ tags.scan(regex).flatten end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def notify_and_share_admins\n mentioned_admins.each do |mentioned|\n # Here put email \n entry = self.library_entries.create(sender_id: self.admin.id, receiver_id: mentioned.id, admin_library_id: mentioned.library.id, shared: true)\n if entry.valid?\n Notification.create(recipient: mentioned, actor: self.admin, action: \"shared\", notifiable: self)\n end\n end\n end", "def attach_to_publishers user\n #self.publisher_id\n return nil unless self.user\n\n if user.personal_publishing_status == \"I have an exclusive publisher\" || \n user.personal_publishing_status == \"I own and control my own publishing\"\n self.publisher_id = user.personal_publisher_id\n self.save(validate: false)\n attach_to_publishing_agreement\n else\n ap 'something fancy here'\n end \n end", "def before_save(sender); end", "def associations_after_save\n # # WARNING: the associations here are not using active_record, so they are not auto saved with user intake\n # # we are saving the associations manually here\n # collapse_associations # make obsolete ones = nil\n #\n # TODO: conflicting with 1.6.0 pre-quality. removed to check compatiblity or related errors\n # for remaining, fill login, password details only when login is empty\n # This is a 3 step process\n # \n # Thu Nov 11 00:14:24 IST 2010, ramonrails\n # Link per user, once only. compact.uniq ensures that\n [\"senior\", \"subscriber\", \"caregiver1\", \"caregiver2\", \"caregiver3\"].each do |_what|\n # \n # Sat Nov 20 02:03:52 IST 2010, ramonrails\n # * this logic is required when uset simply toggles the flag and saves\n _user = self.send( _what) # fetch the associated user\n unless _user.blank? || _user.nothing_assigned?\n # * default properties\n _user.autofill_login # create login and password if not already\n _user.lazy_associations[:user_intake] = self\n _user.skip_validation = true # TODO: patch for 1.6.0 release. fix later with business logic, if required\n\n case _what\n when 'senior'\n # _user.save\n # _user.is_halouser_of( group) unless _user.blank? || group.blank? # role\n _user.lazy_roles[:halouser] = group unless _user.blank? || group.blank? # role\n _user.save\n \n when 'subscriber'\n if subscribed_for_self? # senior is same as subscriber\n if was_subscribed_for_self?\n # * user and subscriber are same. not changed\n else\n # * subscriber was different. now same as senior\n self.subscriber_is_user = false # create old condition\n subscriber.is_not_subscriber_of( senior) unless subscriber.blank? || senior.blank? # remove old role first\n # subscriber.delete # remove this extra user\n self.subscriber_is_user = true # back to current situation\n end\n # _user.save\n # _user.is_subscriber_of( senior) unless _user.blank? || senior.blank? # role\n _user.lazy_roles[:subscriber] = senior unless _user.blank? || senior.blank? # role\n _user.save\n\n else # senior different from subscriber\n if was_subscribed_for_self?\n _user = senior.clone_with_profile if senior.equal?( subscriber) # same IDs, clone first\n senior.is_not_subscriber_of( senior) unless senior.blank? # senior was subscriber, not now\n else\n # all good. nothing changed\n end\n # _user.save\n # _user.is_subscriber_of( senior) unless _user.blank? || senior.blank? # role\n _user.lazy_roles[:subscriber] = senior unless _user.blank? || senior.blank? # role\n _user.save\n end\n \n when 'caregiver1'\n if caregiving_subscriber? # subscriber is caregiver\n if was_caregiving_subscriber?\n # all good. nothing changed\n else\n # was separate\n self.subscriber_is_caregiver = false # make old condition\n caregiver1.is_not_caregiver_of( senior) unless caregiver1.blank? || senior.blank?\n # caregiver1.delete # remove extra\n self.subscriber_is_caregiver = true # current condition again\n end\n \n else # subscriber different from caregiver1\n if was_caregiving_subscriber?\n _user = subscriber.clone_with_profile if subscriber.equal?( caregiver1) # same ID? clone first\n subscriber.is_not_caregiver_of( senior) unless subscriber.blank? || senior.blank? # remove caregiving role for subscriber\n else\n # all good. nothing changed\n end\n end\n if caregiving_subscriber? || (caregiver1_required? && _user.something_assigned? && !senior.blank? && !_user.equal?( senior))\n # _user.save\n # _user.is_caregiver_of( senior) unless _user.blank? || senior.blank? || _user.equal?( senior)\n # _user.options_for_senior( senior, mem_caregiver1_options)\n _user.lazy_roles[:caregiver] = senior\n _user.lazy_options[ senior] = mem_caregiver1_options\n _user.save\n # else\n # self.no_caregiver_1 = true\n # self.send(:update_without_callbacks)\n end\n \n when 'caregiver2'\n if caregiver2_required? && _user.something_assigned? && !senior.blank? && !_user.equal?( senior)\n # _user.save\n # _user.is_caregiver_of( senior) unless _user.blank? || senior.blank? || _user.equal?( senior)\n # _user.options_for_senior( senior, mem_caregiver2_options)\n _user.lazy_roles[:caregiver] = senior\n _user.lazy_options[ senior] = mem_caregiver2_options\n _user.save\n else\n self.no_caregiver_2 = true\n self.send(:update_without_callbacks)\n end\n\n when 'caregiver3'\n if caregiver3_required? && _user.something_assigned? && !senior.blank? && !_user.equal?( senior)\n # _user.save\n # _user.is_caregiver_of( senior) unless _user.blank? || senior.blank? || _user.equal?( senior)\n # _user.options_for_senior( senior, mem_caregiver3_options)\n _user.lazy_roles[:caregiver] = senior\n _user.lazy_options[ senior] = mem_caregiver3_options\n _user.save\n else\n self.no_caregiver_3 = true\n self.send(:update_without_callbacks)\n end\n end # case\n end # blank?\n end # _what\n \n # \n # Thu Jan 13 02:38:38 IST 2011, ramonrails\n # * Not required anymore\n # * lazy_associations attaches each user to this user intake\n # #\n # # * replace earlier associations. keep fresh ones\n # # * do not create duplicate associations\n # # QUESTION: what happens to orphaned users here?\n # # * reject new_record? anything not saved does not get assigned\n # # * only associate one copy of each\n # self.users = [senior, subscriber, caregiver1, caregiver2, caregiver3].reject(&:new_record?).compact.uniq\n # # # \n # # # Thu Jan 13 02:34:27 IST 2011, ramonrails\n # # # * pre_quality.feature had error dispatching emails\n # # # * This might dispatch the email more than once\n # # self.users.each(&:dispatch_emails)\n\n\n # [\"senior\", \"subscriber\", \"caregiver1\", \"caregiver2\", \"caregiver3\"].each do |_what|\n # \n # # \n # # Fri Nov 19 03:17:32 IST 2010, ramonrails\n # # * skip saving the object if already saved\n # # * happens when object is shared. subscriber == user, or, subscriber == caregiver\n # # * saving also dispatches emails. A few more triggers/callbacks. Please check model code\n # _skip = ((_what == 'subscriber') && subscribed_for_self?)\n # _skip = (_skip || (_what == 'caregiver1' && caregiving_subscriber?))\n # # \n # # Thu Nov 11 00:32:18 IST 2010, ramonrails\n # # Do not save any non-assigned data, or blank ones\n # unless _user.blank? || _user.nothing_assigned? || _skip\n # _user.skip_validation = true # TODO: patch for 1.6.0 release. fix later with business logic, if required\n # \n # # _user.autofill_login # Step 1: make them valid\n # if _user.save # Step 2: save them to database\n # # \n # # Thu Nov 11 00:13:31 IST 2010, ramonrails\n # # https://redmine.corp.halomonitor.com/issues/3696\n # # caused a bug that created multiple links to the same user\n # self.users << _user unless users.include?( _user) # Step 3: link them to user intake\n # end\n # end\n # end\n # #\n # # * add roles and options\n # # * roles are already handled by user model\n # # * this will not double write the roles\n # # senior\n # senior.is_halouser_of( group) unless senior.blank?\n # # subscriber\n # unless senior.blank? || subscriber.blank?\n # subscriber.is_subscriber_of( senior)\n # subscriber.is_caregiver_of( senior) if caregiving_subscriber?\n # end\n # # Wed Oct 27 23:55:22 IST 2010\n # # * no need to check subscriber_is_caregiver here. that is done in caregiver1 method\n # # * just call for each caregiver and assign position and other options\n # (1..3).each do |index|\n # _caregiver = self.send(\"caregiver#{index}\".to_sym)\n # _required = self.send(\"caregiver#{index}_required?\")\n # unless (_caregiver.blank? || !_required || _caregiver.nothing_assigned?)\n # _caregiver.is_caregiver_of( senior) unless _caregiver.is_caregiver_of?( senior)\n # # \n # # Thu Nov 4 05:57:16 IST 2010, ramonrails\n # # user values were stored with apply_attributes_from_hash\n # # now we persist them into database\n # _options = self.send(\"mem_caregiver#{index}_options\")\n # # \n # # Thu Nov 18 20:58:29 IST 2010, ramonrails\n # # * Do not use any other method here, cyclic dependency can occur\n # _caregiver.options_for_senior( senior, _options)\n # end\n # end\n\n end", "def wall_post_members\n Member.related_to_notification(self)\n end", "def before_saving\n self.save_to_gallery(self.file, self.filename, self.photo_gallery_id, self.user_id)\n# self.save\n# end\n end", "def save_related\n if self.links.present?\n self.links.each do | link |\n link.parent_type = :action_item\n link.parent_key = self.key\n link.save!\n end\n end\n end", "def attachment(*)\n super\n after :save, :save_attachments\n before :destroy, :destroy_attachments\n end", "def define_save_callbacks(klass, attributes)\n b = self\n callback_methods = Module.new do\n define_method :before_save do\n super()\n send(b.association_name).select { |t| attributes.include?(t.__send__(b.key_column)) && Util.blank?(t.__send__(b.value_column)) }.each(&:destroy)\n end\n define_method :after_save do\n super()\n attributes.each { |attribute| mobility_backends[attribute].save_translations }\n end\n end\n klass.include callback_methods\n end", "def manage_items\n end", "def create_notification\n Notification.create(\n notifiable_id: self.post.id, notifiable_type: 'Post', \n notification_type: 'Comment', source_user_id: self.user_id, target_user_hash: {},\n target_user_ids: [self.owner.id] , seen: false, custom_text: self.content)\n Notification.create(\n notifiable_id: self.post.id, notifiable_type: 'Post', \n notification_type: 'FollowedComment', source_user_id: self.user_id, target_user_hash: {},\n target_user_ids: self.notifiable_followers , seen: false, custom_text: self.content)\n end", "def before_save(*); end", "def after_attachment_saved(&block)\n write_inheritable_array(:after_attachment_saved, [block])\n end", "def validate_associated_records_for_notifications; end", "def notify_concierge(record)\n if record.user.concierge && record.user.concierge_id != record.author_id\n create_notification(record, record.user.concierge)\n end\n end", "def notify_parties\n buyer.add_transaction self\n seller.add_transaction self if seller\n end", "def create_post_owner_notification_of_like(like)\n return if like.user.id == self.user.id # don't notify user of his own likes..\n case like.likeable.wallable.class.name\n when 'Recipe'\n url = \"recipes/#{self.wallable_id}\"\n when 'Tip'\n url = \"tips/#{self.wallable_id}\"\n else\n base_url = self.user.poster? ? \"wall_expert\" : \"wall\"\n url = !self.parent_post_id.nil? ? \"#{base_url}/#{self.parent_post_id}?reply=#{self.id}\" : \"#{base_url}/#{self.id}\"\n end\n notify(self.user, \"Your post was liked!\", \"#{like.user.profile.full_name} liked your post!\", :from => like.user, :key => post_like_notification_key(like), :link => url)\n end", "def on_send(node)\n association_statement =\n node.command?(:has_many) ||\n node.command?(:has_one) ||\n node.command?(:belongs_to)\n\n return unless association_statement\n\n class_pair = class_name_node(node)\n\n if class_pair && !string_class_name?(class_pair)\n add_offense(class_pair)\n end\n end", "def send_mail_to_associates\n unless self.matter_people.blank?\n user = self.matter_people.assignee\n if(@is_changed && user && User.current_user!=user)\n send_notification_to_responsible(user,self,User.current_user)\n @is_changed = false\n\n true\n end\n end\n end", "def _invoke_persistent_callbacks\n method(self.class.before_save_callback).call\n method(self.class.after_commit_callback).call\n end", "def embeds_many(models, options = { })\n has_many models, options.merge(:dependent => :destroy, :autosave => true)\n embed_attribute(models)\n attr_accessible \"#{models}_attributes\".to_sym\n\n # What is marked for destruction does not evist anymore from\n # our point of view. FIXME: Really evil hack.\n alias_method \"_super_#{models}\".to_sym, models\n define_method models do\n # This is an evil hack. Because activerecord uses the items method itself to\n # find out which items are deleted, we need to act differently if called by\n # ActiveRecord. So we look at the paths in the Backtrace. If there is\n # activerecord-3 anywhere there, this is called by AR. This will work until\n # AR 4.0...\n if caller(0).select{|x| x =~ /activerecord-3/}.any?\n return send(\"_super_#{models}\".to_sym) \n end\n\n # Otherwise, when we are called by someone else, we will not return the items\n # marked for destruction.\n send(\"_super_#{models}\".to_sym).reject(&:marked_for_destruction?)\n end\n end", "def after_commit(idea)\n\t\t# only process if a create just occurred\n\t\t# - see after_create method above\n\t\tif idea.is_create\n\t\t\tcategory_ids = idea.idea_categories.map{|x| x.category_id}\n\t\t\tif category_ids && !category_ids.empty?\n\t\t\t\tmessage = Message.new\n\t\t\t\tmessage.bcc = Notification.new_idea_users(category_ids)\n\t\t\t\tif message.bcc && !message.bcc.empty?\n\t\t\t\t\t# if the owner is a subscriber, remove from list\n\t\t\t\t\tindex = message.bcc.index(idea.user.email)\n\t\t\t\t\tmessage.bcc.delete_at(index) if index\n\t\t\t\t\t# only continue if owner was not only subscriber\n\t\t\t\t\tif message.bcc.length > 0\n\t\t\t\t\t\tmessage.subject = I18n.t(\"mailer.subscriber.new_idea.subject\")\n\t\t\t\t\t\tmessage.message = I18n.t(\"mailer.subscriber.new_idea.message\")\n\t\t\t\t\t\tmessage.org_message = idea.explaination\n\t\t\t\t\t\tmessage.url_id = idea.id\n\t\t\t\t\t\tNotificationSubscriberMailer.new_idea(message).deliver\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def notify\n notify_unmentioned_reviewers\n notify_mentioned_event_staff if mention_names.any?\n end", "def send_notifications\n end", "def notifications\n end", "def send_mail_to_associates\n user = self.matter_people.assignee\n if(@is_changed && user && User.current_user!=user)\n send_notification_to_responsible(user,self,User.current_user)\n @is_changed = false\n\n true\n end\n end", "def after_commit(idea_progress)\n\t\t# only process if a create just occurred\n\t\t# - see after_create method above\n\t\tif idea_progress.send_notification\n\t\t\t# determine if idea is realized\n\t\t\tif idea_progress.is_completed && idea_progress.url\n\t\t\t\t# idea realized\n\n\t\t\t\t# notify owner if wants notification\n\t\t\t\tif idea_progress.idea.user.wants_notifications\n\t\t\t\t\tmessage = Message.new\n message.locale = idea_progress.idea.user.notification_language \n\t\t\t\t\tmessage.email = idea_progress.idea.user.email\n\t\t\t\t\tmessage.subject = I18n.t(\"mailer.notification.idea_realized_owner.subject\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:organization => idea_progress.organization.name, :locale => locale)\n\t\t\t\t\tmessage.message = I18n.t(\"mailer.notification.idea_realized_owner.message\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:organization => idea_progress.organization.name, :locale => locale)\n\t\t\t\t\tmessage.org_message = idea_progress.explaination\n\t\t\t\t\tmessage.url = idea_progress.url\n\t\t\t\t\tNotificationMailer.idea_realized_owner(message).deliver\n\t\t\t\tend\n\n\t\t\t\t# notify subscribers\n\t\t\t\tI18n.available_locales.each do |locale|\n\t\t\t\t message = Message.new\n\t\t\t\t message.bcc = Notification.follow_idea_users(idea_progress.idea_id, locale)\n\t\t\t\t if !message.bcc.blank?\n\t\t\t\t\t # if the owner is a subscriber, remove from list\n\t\t\t\t\t index = message.bcc.index(idea_progress.idea.user.email)\n\t\t\t\t\t message.bcc.delete_at(index) if index\n\t\t\t\t\t # only continue if owner was not only subscriber\n\t\t\t\t\t if message.bcc.length > 0\n message.locale = locale\n\t\t\t\t\t\t message.subject = I18n.t(\"mailer.notification.idea_realized_subscriber.subject\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t :organization => idea_progress.organization.name, :locale => locale)\n\t\t\t\t\t\t message.message = I18n.t(\"mailer.notification.idea_realized_subscriber.message\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t :organization => idea_progress.organization.name, :locale => locale)\n\t\t\t\t\t\t message.org_message = idea_progress.explaination\n\t\t\t\t\t\t message.url = idea_progress.url\n\t\t\t\t\t\t NotificationMailer.idea_realized_subscriber(message).deliver\n\t\t\t\t\t end\n \t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t# see if this idea is already claimed by this org\n\t\t\t\tideas = IdeaProgress.where(\"idea_id = ? and organization_id = ? and id != ?\",\n\t\t\t\t\tidea_progress.idea_id, idea_progress.organization_id, idea_progress.id)\n\n\t\t\t\tif ideas && !ideas.empty?\n\t\t\t\t\t# org already claimed, just an update\n\t\t\t\t\t# notify owner if wants notification\n\t\t\t\t\tif idea_progress.idea.user.wants_notifications\n\t\t\t\t\t\tmessage = Message.new\n message.locale = idea_progress.idea.user.notification_language \n\t\t\t\t\t\tmessage.email = idea_progress.idea.user.email\n\t\t\t\t\t\tmessage.subject = I18n.t(\"mailer.notification.idea_progress_update_owner.subject\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:organization => idea_progress.organization.name, :locale => locale)\n\t\t\t\t\t\tmessage.message = I18n.t(\"mailer.notification.idea_progress_update_owner.message\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:organization => idea_progress.organization.name, :locale => locale)\n\t\t\t\t\t\tmessage.org_message = idea_progress.explaination\n\t\t\t\t\t\tmessage.url_id = idea_progress.idea_id\n\t\t\t\t\t\tNotificationMailer.idea_progress_update_owner(message).deliver\n\t\t\t\t\tend\n\n\t\t\t\t\t# notify subscribers\n \t\t\t\tI18n.available_locales.each do |locale|\n\t\t\t\t\t message = Message.new\n\t\t\t\t\t message.bcc = Notification.follow_idea_users(idea_progress.idea_id, locale)\n\t\t\t\t\t if !message.bcc.blank?\n\t\t\t\t\t\t # if the owner is a subscriber, remove from list\n\t\t\t\t\t\t index = message.bcc.index(idea_progress.idea.user.email)\n\t\t\t\t\t\t message.bcc.delete_at(index) if index\n\t\t\t\t\t\t # only continue if owner was not only subscriber\n\t\t\t\t\t\t if message.bcc.length > 0\n message.locale = locale\n\t\t\t\t\t\t\t message.subject = I18n.t(\"mailer.notification.idea_progress_update_subscriber.subject\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t :organization => idea_progress.organization.name, :locale => locale)\n\t\t\t\t\t\t\t message.message = I18n.t(\"mailer.notification.idea_progress_update_subscriber.message\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t :organization => idea_progress.organization.name, :locale => locale)\n\t\t\t\t\t\t\t message.org_message = idea_progress.explaination\n\t\t\t\t\t\t\t message.url_id = idea_progress.idea_id\n\t\t\t\t\t\t\t NotificationMailer.idea_progress_update_subscriber(message).deliver\n\t\t\t\t\t\t end\n \t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t# org is claiming idea\n\t\t\t\t\t# notify owner if wants notification\n\t\t\t\t\tif idea_progress.idea.user.wants_notifications\n\t\t\t\t\t\tmessage = Message.new\n message.locale = idea_progress.idea.user.notification_language \n\t\t\t\t\t\tmessage.email = idea_progress.idea.user.email\n\t\t\t\t\t\tmessage.subject = I18n.t(\"mailer.notification.idea_claimed_owner.subject\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:organization => idea_progress.organization.name, :locale => locale)\n\t\t\t\t\t\tmessage.message = I18n.t(\"mailer.notification.idea_claimed_owner.message\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:organization => idea_progress.organization.name, :locale => locale)\n\t\t\t\t\t\tmessage.org_message = idea_progress.explaination\n\t\t\t\t\t\tmessage.url_id = idea_progress.idea_id\n\t\t\t\t\t\tNotificationMailer.idea_claimed_owner(message).deliver\n\t\t\t\t\tend\n\n\t\t\t\t\t# notify subscribers\n \t\t\t\tI18n.available_locales.each do |locale|\n\t\t\t\t\t message = Message.new\n\t\t\t\t\t message.bcc = Notification.follow_idea_users(idea_progress.idea_id, locale)\n\t\t\t\t\t if !message.bcc.blank?\n\t\t\t\t\t\t # if the owner is a subscriber, remove from list\n\t\t\t\t\t\t index = message.bcc.index(idea_progress.idea.user.email)\n\t\t\t\t\t\t message.bcc.delete_at(index) if index\n\t\t\t\t\t\t # only continue if owner was not only subscriber\n\t\t\t\t\t\t if message.bcc.length > 0\n message.locale = locale\n\t\t\t\t\t\t\t message.subject = I18n.t(\"mailer.notification.idea_claimed_subscriber.subject\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t :organization => idea_progress.organization.name, :locale => locale)\n\t\t\t\t\t\t\t message.message = I18n.t(\"mailer.notification.idea_claimed_subscriber.message\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t :organization => idea_progress.organization.name, :locale => locale)\n\t\t\t\t\t\t\t message.org_message = idea_progress.explaination\n\t\t\t\t\t\t\t message.url_id = idea_progress.idea_id\n\t\t\t\t\t\t\t NotificationMailer.idea_claimed_subscriber(message).deliver\n\t\t\t\t\t\t end\n\t\t\t\t\t end\n \t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\tend", "def send_notifications\n send_new_post_to(:person) if self.person.notify_on_response_posted\n send_new_post_to(:receiver) if self.receiver && self.receiver.notify_on_response_received\n end", "def after_save(&block)\n after_saves << block\n end", "def after_store\n if group_owner?\n self.stored_group_notification_count = group_notification_count\n self.stored_group_member_notifier_count = group_member_notifier_count\n self.stored_group_members = group_members.as_json\n self.stored_group_members.each do |group_member|\n # Cast Time and DateTime field to String to handle Dynamoid unsupported type error\n group_member.each do |k, v|\n group_member[k] = v.to_s if v.is_a?(Time) || v.is_a?(DateTime)\n end\n end\n save\n else\n group_owner.after_store\n end\n end", "def after_save_actions\n Logger.d(\"Inside after_save_actions in User\")\n ContactsSync.new(@context, get(:auth_token)).sync if is_user_contacts_syncable? == true # non-blocking\n end", "def has_many_attachments(relationship, options = {})\n has_many relationship, :as => :attachable, :class_name => \"Attachment\", :conditions => \"relationship = '#{relationship}'\", :dependent => :destroy, :order => \"attachments.position, attachments.id\", :extend => Reorderable\n\n if marks = options.delete(:marks)\n marks.each do |mark|\n belongs_to :\"#{mark}_#{relationship.to_s.singularize}\", :class_name => \"Attachment\"\n end\n end\n\n define_method(\"add_#{relationship}_attachment\") do |file_field, position|\n if file_field.size > 0\n attach_info = {:uploaded_data => file_field, :relationship => relationship.to_s}\n unless position.nil?\n attach_info[:position] = position\n end\n new_relationship_obj = self.send(relationship).create!(attach_info)\n end\n end\n define_method(\"create_#{relationship}_attachment\") do |atts|\n if atts[:uploaded_data] && atts[:uploaded_data].size > 0\n return self.send(relationship).create!(atts.merge({:relationship => relationship.to_s}))\n end\n end\n define_method(\"update_#{relationship}_attachment\") do |id, atts|\n unless atts[:uploaded_data] && atts[:uploaded_data].size > 0\n atts.delete(:uploaded_data)\n end\n self.send(relationship).find(id).update_attributes!(atts)\n end\n define_method(\"replace_#{relationship}_attachment\") do |file_field, position|\n if position.nil?\n raise ArgumentError.new(\"Argument missing: position\")\n end\n position = position.to_i\n\n if file_field.size > 0\n old_attachment = self.send(relationship)[position]\n unless old_attachment.nil?\n position = old_attachment.position\n old_attachment.destroy\n end\n attach_info = {:uploaded_data => file_field, :relationship => relationship.to_s, :position => position}\n new_relationship_obj = self.send(relationship).create!(attach_info)\n end\n\n end\n end", "def after_update\n super\n touch_associations\n end", "def trigger_after_like\n likeable.fire_after_like(self) if likeable.respond_to?(:fire_after_like)\n user.fire_after_like(self) if user.respond_to?(:fire_after_like)\n end", "def set_conditional_save_callback(callback)\n # Combines :list and :lists parameters into one array\n @icontact_conditional_save_callback = callback\n end", "def update_many\n if @admin_notifications.update_all(admin_notification_params)\n render json: @admin_notifications, status: :ok, location: admin_notifications_url\n else\n render json: @admin_notifications.errors, status: :unprocessable_entity\n end\n end", "def approve_with_notify(swimming_buddy, shares_passages = false, shares_trainings = false, shares_calendars = false)\n if @user.approve(swimming_buddy, shares_passages, shares_trainings, shares_calendars)\n NewsFeed.create_social_approve_feed(@user, swimming_buddy)\n # TODO: Create also achievement row accordingly?\n end\n end", "def notify_item_ownership\n [[buyer, buyer_items], [seller, seller_items]].each do |set|\n shareholder, items = set\n items.each do |item|\n item.owner = shareholder\n end\n end\n end", "def update_others!\n if status_changed?\n\n if waiting_for_sell? || declined?\n ::Users::Notification.where(related_model_type:'Trading::BuyRequest', related_model_id: self.id).update_all(status: ::Users::Notification::Status::DELETED)\n end\n\n if waiting_for_sell?\n self.items.each{|item| item.status = ::Item::Status::BUYING; item.save; }\n\n elsif declined? || canceled?\n\n self.items.each{|item| item.activate! }\n\n elsif sold?\n\n self.items.each{|item| item.deactivate! }\n ::NotificationMail.create_from_mail(buyer.parent_id, seller.parent_id, UserMailer.new_buy_request_to_seller_parent(self) )\n\n end\n end\n end", "def set_callbacks\n validate :merge_media_errors\n before_save :remove_old_media\n end", "def after_update_save(record); end", "def _process_on_create(entity)\n end", "def manage_books\n\n end", "def after_create_save(record); end", "def send_booking_confirmation_notifications\n\n notify_manager_confirmation\n notify_customer\n \n end", "def join\n @event = Event.find(params[:event_id])\n @e = @event.user_to_events.build(:user_id => current_user.id,\n :event_id => \"#{@event.id}\",\n :owner_id => \"#{@event.user_id}\" )\n\n respond_to do |format|\n if @e.save\n @total_attendence = UserToEvent.find(\"#{@e.id}\").event.update_attributes(:no_of_guests_attending => (@event.no_of_guests_attending)+1)\n format.html { redirect_to(@event, :notice => 'Request has been sent to the meal owner.') }\n format.xml { head :ok }\n else\n format.html { redirect_to(event_path(@event), :notice => 'Something has gone wrong , please try again.') }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def send_deletion_notification\n @notifiable = self\n @tutor = User.find(self.user_id)\n @student = User.find(self.pupil_id)\n Notification.create(:user => @tutor, :receiver_id => @student.id, :message => @tutor.title + ' has removed you from their student list')\n end", "def relate\n resource_class = params[:related][:model].typus_constantize\n association_name = params[:related][:association_name].tableize\n\n if @item.send(association_name) << resource_class.find(params[:related][:id])\n notice = Typus::I18n.t(\"%{model} successfully updated.\", :model => @resource.model_name.human)\n end\n\n redirect_to :back, :notice => notice\n end", "def model_relationships; end", "def after_create\n oscopes = OscopeMsg.find_all_by_timestamp_and_user_id(timestamp, user_id)\n # instantiation of oscopes already caused oscope_start_msg to link to them\n # :update_without_callbacks is a provate method. direct call will not work. need to 'send' it\n oscopes.each {|p| p.send(:update_without_callbacks) } # this will save all instantiated oscopes\n end", "def apply_save_data_to_curation_concern(attributes)\n if attributes.fetch('on_behalf_of', nil).present?\n current_depositor = curation_concern.depositor\n new_depositor = ::User.find_by_user_key(attributes.fetch('on_behalf_of'))\n curation_concern.apply_depositor_metadata(new_depositor)\n curation_concern.edit_users = update_edit_users_for_curation_concern(current_depositor, new_depositor)\n end\n super\n end", "def after_save(&block)\n @hooks ||= {}\n @hooks[\"after_save\".to_sym] = block\n end", "def notify_authors_of_new_item(solr_doc)\n doc = SolrDocument.new(solr_doc)\n ldap = Cul::LDAP.new\n\n unis = solr_doc.fetch('author_uni_ssim', [])\n preferred_emails = EmailPreference.preferred_emails(unis)\n\n preferred_emails.each do |uni, email|\n # Skip if notification was already sent.\n next if Notification.sent_new_item_notification?(solr_doc['cul_doi_ssi'], uni)\n\n begin\n name = (author = ldap.find_by_uni(uni)) ? author.name : nil\n success = true\n UserMailer.new_item_available(doc, uni, email, name).deliver_now\n rescue StandardError => e\n logger.error \"Error Sending Email: #{e.message}\"\n logger.error e.backtrace.join(\"\\n \")\n success = false\n end\n Notification.record_new_item_notification(doc[:cul_doi_ssi], email, uni, success)\n end\n end", "def after_save(record)\n \n end", "def send_notification\n\n\n end", "def after_create; end", "def notify_owner_of_change(notebook, owner, user, type, emails, message, url)\n @notebook = notebook\n @url = url.chomp('/')\n @owner = owner\n @type = type\n if @type == \"shared notebook\"\n @sharer = user\n subject = \"NBGallery notebook shared with others\"\n elsif @type == \"ownership change\"\n @changer = user\n subject = \"NBGallery notebook ownership change\"\n end\n @message = message\n @email_needs_to_be_simplified = need_to_simplify_email?(@notebook, @message)\n mail(\n bcc: emails,\n subject: subject\n )\n end", "def send_notification\n self.target_followers.each do |target_follower|\n @user = User.find(target_follower.follower_id)\n Notification.create_notification(@user.profilable_id, @user.profilable_type, text = \"#{self.name} updated his/her profile\", \"Enterprise\") && reload unless target_follower == self || target_follower.nil?\n end\n end", "def party_horn_callbacks(horn)\n\t\t{:blow_party_horn => horn.public_method(:blow)}\n\tend", "def merge\n document.update_attributes :access => access\n email_on_complete\n super\n end", "def merge_hook(duplicate)\n # Example code:\n # duplicate.custom_association.each do |ca|\n # ca.contact = self; ca.save!\n # end\n end", "def manage_save\n\t\t\trequest = ContactRequest.find params[:request][:id]\n\n\t\t\tcase request.object_type\n\t\t\twhen 'real_estate'\n\t\t\t\t# Author\n\t\t\t\tauthorize! :manage, RealEstate\n\t\t\twhen 'project'\n\t\t\t\t# Author\n\t\t\t\tauthorize! :manage, Project\n\t\t\tend\n\n\t\t\tresult = request.manage_save_with_params(params[:request])\n\n\t\t\trender json: {\n\t\t\t\tstatus: 0\n\t\t\t}\n\t\tend", "def around_save_collection_association\n previously_new_record_before_save = (@new_record_before_save ||= false)\n @new_record_before_save = !previously_new_record_before_save && new_record?\n\n yield\n ensure\n @new_record_before_save = previously_new_record_before_save\n end", "def setup_associations; end", "def notify_on_mention?; true; end", "def add_autosave_association_callbacks(reflection)\n save_method = :\"autosave_associated_records_for_#{reflection.name}\"\n\n if reflection.collection?\n around_save :around_save_collection_association\n\n define_non_cyclic_method(save_method) { save_collection_association(reflection) }\n # Doesn't use after_save as that would save associations added in after_create/after_update twice\n after_create save_method\n after_update save_method\n elsif reflection.has_one?\n define_non_cyclic_method(save_method) { save_has_one_association(reflection) }\n # Configures two callbacks instead of a single after_save so that\n # the model may rely on their execution order relative to its\n # own callbacks.\n #\n # For example, given that after_creates run before after_saves, if\n # we configured instead an after_save there would be no way to fire\n # a custom after_create callback after the child association gets\n # created.\n after_create save_method\n after_update save_method\n else\n define_non_cyclic_method(save_method) { throw(:abort) if save_belongs_to_association(reflection) == false }\n before_save save_method\n end\n\n define_autosave_validation_callbacks(reflection)\n end", "def notify_new_finding\n # TODO: make the method avoid the creation of a Notification record\n end", "def attach(klass)\n # don't attach to non-AR backed models\n # it is the user's responsibility to trigger `Model#netsuite_push` when ActiveRecord isn't used\n return if !defined?(::ActiveRecord) || !klass.ancestors.include?(::ActiveRecord::Base)\n\n if klass.include?(SubListSync)\n klass.after_save { SyncTrigger.sublist_trigger(self) }\n klass.after_destroy { SyncTrigger.sublist_trigger(self) }\n elsif klass.include?(RecordSync)\n\n # during the initial pull we don't want to push changes up\n klass.before_save do\n @netsuite_sync_record_import = self.new_record? && self.netsuite_id.present?\n\n if @netsuite_sync_record_import\n # pull the record down if it has't been pulled yet\n # this is useful when this is triggered by a save on a parent record which has this\n # record as a related record\n\n if !self.netsuite_pulled? && !self.netsuite_async_jobs?\n SyncTrigger.record_pull_trigger(self)\n end\n end\n\n # if false record will not save\n true\n end\n\n klass.after_save do\n # this conditional is implemented as a save hook\n # because the coordination class doesn't know about model persistence state\n\n if @netsuite_sync_record_import\n if !self.netsuite_pulled? && self.netsuite_async_jobs?\n SyncTrigger.record_pull_trigger(self)\n end\n else\n SyncTrigger.record_push_trigger(self)\n end\n\n @netsuite_sync_record_import = false\n end\n end\n\n # TODO think on NetSuiteRails::ListSync\n end", "def before_update_save(record); end", "def notify_user(ad)\n #create notification for the user\n notification = self.notifications.unviewed.event(:new_relevant_ad).new\n notification.user = self.user\n notification.ad = ad\n notification.save!\n end", "def edit_multiple_confirmation_events\n set_confirmation_events\n end", "def create_notification; end", "def associated_callbacks_log(obj, callback)\n\t\tif obj.associated_object\n\t\t\tmodel_obj = obj.associated_object\n\t\t\tcalling_obj = obj\n\t\tend\n\t\tlog_this(model_obj, callback, calling_obj, true)\n\tend", "def create\n @photo = Photo.new(photo_params) \n respond_to do |format|\n if @photo.save\n @photo.pet.users.each do |user|\n Notification.create(recipient: user, user: @photo.user, action: \"uploaded\", notifiable: @photo)\n end \n format.html { redirect_to @photo, notice: 'Photo was successfully created.' }\n format.json { render :show, status: :created, location: @photo }\n else\n @albums=[] if @photo.album_id==nil \n format.html { render \"new\"}\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def notify_friends\n # Create notifications to the users friends\n self.user.friends.each do |friend|\n friend.notifications.create!(:body => I18n.translate('notification.types.event_created'))\n end\n # Create notifications to the users who have this user as a friend\n self.user.inverse_friends.each do |friend|\n friend.notifications.create!(:body => I18n.translate('notification.types.event_created'))\n end\n end", "def notify_friends\n # Create notifications to the users friends\n self.user.friends.each do |friend|\n friend.notifications.create!(:body => I18n.translate('notification.types.event_created'))\n end\n # Create notifications to the users who have this user as a friend\n self.user.inverse_friends.each do |friend|\n friend.notifications.create!(:body => I18n.translate('notification.types.event_created'))\n end\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 owners_included; end", "def run_association_callbacks(reflection, callback_type, object)\n # The reason we automatically set raise_error for singular associations is that\n # assignment in ruby always returns the argument instead of the result of the\n # method, so we can't return nil to signal that the association callback prevented\n # the modification\n raise_error = raise_on_save_failure || !reflection.returns_array?\n stop_on_false = [:before_add, :before_remove, :before_set].include?(callback_type)\n reflection[callback_type].each do |cb|\n res = case cb\n when Symbol\n send(cb, object)\n when Proc\n cb.call(self, object)\n else\n raise Error, \"callbacks should either be Procs or Symbols\"\n end\n\n if res == false and stop_on_false\n Sequel::Deprecation.deprecate(\"Having #{callback_type} association callback return false to cancel modification\", \"Instead, call Model#cancel_action inside the association callback\")\n raise(HookFailed, \"Unable to modify association for #{inspect}: one of the #{callback_type} hooks returned false\")\n end\n end\n rescue HookFailed\n return false unless raise_error\n raise\n end", "def old_notify_user (listing, sender, receiver)\n send_as :notification\n from sender.facebook_session.user \n recipients receiver.facebook_session.user\n #fbml \"<a href='#{FB_APP_HOME_URL}/listings/#{listing.id}'><b>#{listing.title}</b></a> has been approved.\"\n fbml \"Your listing: <a href='#{listings_path(listing.id)}}'><b>#{listing.title}</b></a> has been approved.\"\n end", "def connect_attachments(params)\n json_attachments = params['data'].try(:[], 'relationships').try(:[], 'attachments')\n return if json_attachments.blank?\n\n attachment_list = resource_list('attachment', json_attachments)\n\n attachment_list.each do |attachment|\n attachment.attachable = self\n attachment.save\n end\n end", "def def_many_to_many(opts)\n super\n def_bulk_setter(opts) do |list|\n cur = send(opts[:name])\n if cur\n cur.reject{ |v| v == \"\" }\n end\n instance_variable_set(\"@_#{opts[:name]}_add\", list.reject{ |v| cur.detect{ |v1| v.to_i == v1.pk } }) if cur and list\n instance_variable_set(\"@_#{opts[:name]}_remove\", cur.reject{ |v| list.detect{ |v1| v.pk == v1.to_i } }) if cur and list\n cur.replace(list)\n\n name = \"#{opts[:name]}\".singularize\n\n after_save_hook do\n instance_variable_get(\"@_#{opts[:name]}_remove\").each do |record|\n send(\"remove_#{name}\", record) if record\n end\n\n instance_variable_get(\"@_#{opts[:name]}_add\").each do |record|\n send(\"add_#{name}\", record) if record && !record.empty?\n end\n end\n end\n end", "def attach; end", "def save\n \n transaction do |transaction|\n check_usergroups! if self.usergroups and (not self.usergroups.empty?)\n super\n update_aspects\n transaction.commit\n end\n\n end", "def updates_after_create\n parent_policy = Policy.where('parent_id IS NULL').first\n agency_policy = parent_policy.dup\n agency_policy.organization = self\n agency_policy.parent_id = parent_policy.id\n agency_policy.description = \"#{self.short_name} Transit Policy\"\n agency_policy.object_key = nil\n agency_policy.save!\n\n User.where(organization_id: Grantor.first.id).each{|user| user.viewable_organizations = user.user_organization_filter.try(:get_organizations)}\n end", "def with_add_callbacks(document, already_related)\n execute_callback :before_add, document unless already_related\n yield\n execute_callback :after_add, document unless already_related\n end", "def update_users_and_parent\n # Update editors' and authors' contributions.\n authors.each do |user|\n SiteData.update_contribution(:del, authors_join_table, user.id)\n end\n editors.each do |user|\n SiteData.update_contribution(:del, editors_join_table, user.id)\n end\n\n return unless parent.description_id == id\n\n # Make sure parent doesn't point to a nonexisting object.\n parent.description_id = nil\n parent.save_without_our_callbacks\n end", "def after_save_hook\n execute_hooks_for(:after, :save)\n end", "def did_attach() end", "def do_related(verb, guid, name, other_guid, parent_model=model)\n logger.debug \"cc.association.#{verb}\", guid: guid, association: name, other_guid: other_guid\n\n singular_name = name.to_s.singularize\n\n @request_attrs = { singular_name => other_guid, verb: verb, relation: name, related_guid: other_guid }\n\n obj = find_guid(guid, parent_model)\n\n before_update(obj)\n\n parent_model.db.transaction do\n read_validation = verb == 'remove' ? :can_remove_related_object : :read_related_object_for_update\n validate_access(read_validation, obj, request_attrs)\n obj.send(\"#{verb}_#{singular_name}_by_guid\", other_guid)\n end\n\n after_update(obj)\n\n return [HTTP::NO_CONTENT] if verb == 'remove'\n\n [HTTP::CREATED, object_renderer.render_json(self.class, obj, @opts)]\n end", "def has_many(*args)\n require \"og/relation/has_many\"\n relations! << Og::HasMany.new(args, :owner_class => self, :collection => true)\n end", "def commit\n\t\t\t if valid?\n\t\t\t\t\tcallback_process = setup(klass)\n\t\t\t\t\tklass.send(event, callback_process)\n\t\t\t\t\tklass\n\t\t\t else\n\t\t\t\t\tInnsights::ErrorMessage.log(\"#{klass} doesn't respond to callback event #{event}\")\n\t\t\t end\n\t\t\tend", "def add_notification\n if followable_type == \"User\"\n Notification.create(\n target_id: followable_id,\n target_type: \"User\",\n notice_id: id,\n notice_type: \"Follow\",\n user_id: followable_id,\n notifier_id: follower_id\n )\n end\n end", "def notify_admins\n team.admins.each do |admin|\n admin.send_email(:team_account_funded_admin, team_payin: self) unless admin.id == person.id\n end\n end", "def update_menu\n parent = self._parent\n while parent.class != DcManual do \n parent = parent._parent \n end\n parent.do_before_save\n parent.save\nend", "def associated\n end", "def before_save_goal\n\t\t# \n\t\tif self.current_user_role == 'sm'\n\t\t\traise \"Super Manager don't need goal\"\n\t end\n\tend", "def send_confirmations_to_owner\n return @send_confirmations_to_owner\n end", "def thanks_to_vendor\n\n end", "def send_email_changed_notification; end", "def notify_new_findings\n # TODO: make the method avoid the creation of a Notification record\n end" ]
[ "0.6289245", "0.550039", "0.53623027", "0.5308498", "0.5289884", "0.5282263", "0.52443576", "0.5240714", "0.52076924", "0.5151897", "0.5144538", "0.5134809", "0.5107841", "0.50734717", "0.5060941", "0.50588334", "0.5025179", "0.5022611", "0.50220287", "0.5010111", "0.50022745", "0.4996475", "0.4991716", "0.49888423", "0.49864522", "0.49846086", "0.4957671", "0.4954076", "0.494831", "0.49480718", "0.4938696", "0.4924873", "0.49087432", "0.49018943", "0.48925808", "0.48916388", "0.4889442", "0.48785186", "0.48672718", "0.4866172", "0.4865092", "0.48619917", "0.48496458", "0.4846079", "0.4844104", "0.48399165", "0.48318887", "0.48299998", "0.4826166", "0.47914493", "0.4790666", "0.4786885", "0.4783297", "0.47805098", "0.4769794", "0.47651815", "0.47631615", "0.476315", "0.47548038", "0.47547278", "0.47545934", "0.47436112", "0.4740399", "0.47386378", "0.47340128", "0.4730462", "0.472958", "0.4729251", "0.4725893", "0.47235093", "0.47180083", "0.47169337", "0.47163132", "0.4711876", "0.47087193", "0.47087193", "0.47033253", "0.47025207", "0.4702115", "0.47014087", "0.4699919", "0.46985844", "0.46953872", "0.4691654", "0.4685973", "0.46789598", "0.46761417", "0.46709424", "0.46669406", "0.46652538", "0.4661593", "0.4657872", "0.46531767", "0.46527767", "0.4652507", "0.46438208", "0.46427524", "0.4641205", "0.46380392", "0.46313807", "0.46267778" ]
0.0
-1
Below Checks if the resource has been shared or not using tags inside creation.
def is_shared? if self.library_entries.where(shared: true).empty? return false else return true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shared?\n sharing != 'none'\n end", "def shared?\n sharing != 'none'\n end", "def shared?\n @roomer_scope == :shared\n end", "def create\n @post =Post.find(params[:post_id])\n @tag = @post.tags.build(tag_params)\n @tag.sharer =current_user.id.to_s\n respond_to do |format|\n if @tag.save\n format.html { redirect_to post_path(@post), notice: 'Post shared' }\n format.json { render :show, status: :created, location: post_path(@post) }\n else\n format.html { render :new }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def shared?\n !self.shared_assets.empty?\nend", "def is_shared\n return @is_shared\n end", "def shared?\n\t\tself.project_groups.count > 1\n\tend", "def shared?\n @shared ||= options[:shared]\n end", "def tags_empty?\n current_or_guest_user.owned_tags.empty?\n end", "def ensure_unique\n puts \"Ensuring uniqueness of tag #{self.tag_id.to_s} to taggable #{self.entity_id.to_s} for user #{self.user_id.to_s}\"\n end", "def resource_exists?\n reload!\n @exists = true\n rescue Google::Cloud::NotFoundError\n @exists = false\n end", "def is_tagged?\n ! @tags.empty?\n end", "def create\n @tag = Tag.new tag_params\n @tag.admin = current_user\n if @tag.save\n render :show, status: 200\n elsif @tag.errors.messages[:value].include? 'has already been taken' # there's probably a better way to do this\n render json: { error: '409 conflict with existing record' }, status: 409\n else\n render json: { error: '422 unprocessable entity' }, status: 422\n end\n end", "def resource?\n !reference?\n end", "def is_shareable?\n true\n end", "def not_currently_shared\n return false unless Share.where(recipient: recipient, user: user, birth_record: birth_record).kept.any?\n\n errors.add(:recipient, 'is currently shared with this entity')\n end", "def is_tagged?\n ! @tags.empty?\n end", "def shared? \n \t!self.shared_folders.empty? \n\tend", "def shared?\n \t!self.shared_folders.empty?\n end", "def has_tag\n return @has_tag unless @has_tag.nil?\n get_tag_information\n @has_tag\n end", "def being_created?(item)\n state_group(item) == :create\n end", "def exist?\n @created\n end", "def is_shared=(value)\n @is_shared = value\n end", "def shareable?(share_with)\n str = @asset.shared_with.to_s\n a = str.split(\",\")\n #Ensures that the file isn't being shared to ones self\n if share_with == current_user.id\n return false\n end\n #Ensures that the file isn't being shared to someone it has already been shared to.\n 0.upto(a.length-1) do |x|\n if a[x].to_i == share_with\n return false\n end\n end\n return true\n end", "def can_share\n return @can_share\n end", "def tagged?; end", "def share\n @share ? @share : 'yes'\n end", "def create?\n record.resourceable.owner == user || user.is?(:admin)\n end", "def correct_tags?\n missing_tags?\n unwanted_tags?\n duplicate_tags?\n end", "def check_resource! resource \n resources.include?(resource.to_s) ? resource_parsed(resource) : raise(\"resource should be in [tags, posts, bundles]\") \n end", "def exists?\n if self.class.oneimage_list().include?(resource[:name])\n self.debug \"Found image #{resource[:name]}\"\n true\n end\n end", "def taggable?\n definition['taggable'] == true\n end", "def check_status\n return if @stash_identifier.nil? || @resource.nil?\n state = @resource.current_resource_state.try(:resource_state)\n return if state == 'in_progress'\n return_error(messages: 'Your dataset cannot be updated now', status: 403) { yield } if state != 'submitted'\n duplicate_resource # because we're starting a new version\n end", "def has_tag?(tag)\n self.tags.include?(tag)\n end", "def shared?(resource)\n collaborators = Account.find_by_sql(<<-EOS\n select distinct on (a.id)\n a.id as id, a.organization_id as organization_id, a.role as role\n from accounts as a\n inner join collaborations as c1\n on c1.account_id = a.id\n inner join collaborations as c2\n on c2.account_id = #{id} and c2.project_id = c1.project_id\n inner join projects as p\n on p.id = c1.project_id and p.hidden = false\n inner join project_memberships as pm\n on pm.project_id = c1.project_id and pm.document_id = #{resource.document_id}\n where a.id != #{id}\n EOS\n )\n collaborators.any? {|account| account.owns_or_collaborates?(resource) }\n end", "def manage_tags?\n post_type.manage_tags?\n end", "def tagged?(tag)\n @tags.include?(tag)\n end", "def check_tag_present\n entries = get_entries\n entries.each do |entry|\n if entry[\"data-mention-id\"].eql?(@stream_post_id)\n tags = entry.all(input_elements[:tag_link_on_stream])\n tags.each do |tag_on_stream|\n return true if tag_on_stream.text.include?(@used_tag)\n end\n return false\n end\n end\n return false\n end", "def resources_with_tags(tags)\n resource_statuses.select do |resource|\n tags.any? do |tag|\n resource.tags.include? tag\n end\n end\n end", "def modified?\n ((self.created_at != self.updated_at) ||\n (segments.collect { |e| e.audio_asset.authored? && e.audio_asset.delivered? }.include?(true))) \n end", "def has_tag?(tag)\r\n self.tags.count(:name => tag.name)> 0\r\n end", "def taggable?\n description['taggable'] == true\n end", "def exists_bulk_method(states = [nil, :found])\n prepare_environment\n @item = @resource_type.new(@client, @data)\n return true if empty_data_check(states)\n @property_hash[:ensure] == :present\nend", "def share_to_tumblr?\n self.tumblr_post_id == TumblrSharing::Underway\n end", "def resource?\n true\n end", "def creating?\n !create_stack.empty?\n end", "def shared?\n self[:filename].nil? or self[:filename].start_with? \"content/\"\n end", "def create\n sharing(\"-a\", name)\n @property_hash[:ensure] = :present\n\n # Setters for configuring the share are not automatically called on create, so we call them\n resource.properties.each do |property|\n property.sync unless property.name == :ensure\n end\n end", "def identicalish_resources?(first, second)\n skipped_ivars = [ :@source_line, :@cookbook_name, :@recipe_name, :@params, :@elapsed_time, :@declared_type ]\n checked_ivars = ( first.instance_variables | second.instance_variables ) - skipped_ivars\n non_matching_ivars = checked_ivars.reject do |iv|\n if iv == :@action && ( [first.instance_variable_get(iv)].flatten == [:nothing] || [second.instance_variable_get(iv)].flatten == [:nothing] )\n # :nothing action on either side of the comparison always matches\n true\n else\n first.instance_variable_get(iv) == second.instance_variable_get(iv)\n end\n end\n Chef::Log.debug(\"ivars which did not match with the prior resource: #{non_matching_ivars}\")\n non_matching_ivars.empty?\n end", "def shared?\n !self.native? & (self.fb_object_id != FBSharing::Underway) \n end", "def remotely_useful?; self_owned? && remote_siblings.size > 1 end", "def tagged_by_user?(user)\n Tag.all({:id => taggings, :user_id => user.id}).count > 0\n end", "def include? entity, user_or_id, with_pullins=true\n # Trivial accept if the entity is physically in among the list items\n return true if @list.stores? entity\n user_id = user_or_id.is_a?(Integer) ? user_or_id : user_or_id.id\n ts = TaggingServices.new entity\n # It's included if the owner or this user has tagged it with the name tag\n return true if ts.exists? @list.name_tag_id, (user_id == @list.owner_id ? user_id : [user_id, @list.owner_id])\n # If not directly tagged, it's included if it's tagged with any of the list's tags, BY ANYONE (?)\n return false unless with_pullins && @list.pullin\n ts.exists? pulled_tag_ids\n end", "def tag_books(tag, books)\n puts \"Tagging #{books.length} books as #{tag}\"\n books.each do |b|\n unless Tag.exists?(book_id: b.id, name: tag)\n Tag.create(book_id: b.id, name: tag)\n end\n end\n puts \"Done tagging #{tag}\"\nend", "def already_shared(user_id, file_id)\n if $db.execute(\"SELECT * FROM shared_files WHERE file_id = ? AND user_id = ?\", file_id, user_id) != []\n return true\n end\n return false\nend", "def tagged?\n defined?(@tag) && !!@tag\n end", "def tag_used_multiple_times?(tag)\n values = @selected_files.map { |file| file[tag] }\n values.reduce(false) { |r, v| r || (v.size > 1) }\n end", "def can_share?\n can?('s')\n end", "def is_auto_tag_ownership_enabled?\n (self.tag_owner != nil)\n end", "def share?\n\t\t!Rails.env.development? and do_share && can_share?\n\tend", "def belongs_to_me? file\n #The only difference between shared files that have been added to your Drive\n #and those that haven't is that those that have have a file path (parents)\n return true if @config['sync_shared_in_drive'] and file.parents != nil and file.parents != []\n file.shared_with_me_time.nil? and file.owners != nil and file.owners.select{|owner| owner.me}.count > 0\n end", "def is_duplicate?()\n resources = DB[:resources]\n auto_cols = [:id, :ah_id, :rdatadateadded, :resource_id]\n cols_to_compare = resources.columns - auto_cols\n h = {}\n for col in cols_to_compare\n h[col] = self.send(col)\n end\n existing = resources.where(Sequel.negate(id: self.id)).where(h)\n if existing.count == 0\n return false\n end\n dep_tables = []\n for table in DB.tables\n dep_tables << table if DB[table].columns.include? :resource_id\n end\n for table in dep_tables\n ds = DB[table]\n cols_to_compare = ds.columns - auto_cols\n rows = self.send table\n for row in rows\n h = {}\n for col in cols_to_compare\n h[col] = row.send col\n end\n if table == :tags\n existing = ds.where(h)\n else\n existing = ds.where(Sequel.negate(id: row.id)).where(h)\n end\n if existing.count == 0\n return false\n end\n end\n end\n true\n end", "def exists?\n begin\n url_for(:resources_resource, credentials, id).head\n true\n rescue RestClient::Forbidden\n true\n rescue RestClient::ResourceNotFound\n false\n end\n end", "def exist?\n @resource.exist?\n end", "def has_tag?(tag)\n tags.include?(tag.to_s)\n end", "def own_shared_to?\r\n shared_to = self.shared_to_type.constantize.find(self.shared_to_id)\r\n shared_to.user_id == self.user_id ? true : false\r\n end", "def has_shared?(shareable)\n if shareable.is_a?(Journal)\n return shares.journals.pluck(:shareable_id).include?(shareable.id)\n elsif shareable.is_a?(Submission)\n return shares.submissions.pluck(:shareable_id).include?(shareable.id)\n end \n end", "def destroyable?\n if self.master_files.empty? and self.components.empty? and self.bibls.empty?\n return true\n else\n return false\n end \n end", "def has_tags?\n tags.is_a?(Hash) ? false : true\n end", "def resource_exists?\n ciudades\n end", "def creating?\n state == :CREATING\n end", "def creating?\n state == :CREATING\n end", "def creating?\n state == :CREATING\n end", "def creating?\n state == :CREATING\n end", "def creating?\n state == :CREATING\n end", "def tagged_by_user?(user)\n !(model_tags.detect{|tag| tag.user_ids.include?(user.id)}.nil?)\n end", "def resource_full?\n resource? && @grpc.definition && [email protected]?\n end", "def same_resource_owner?(access_token)\n if Doorkeeper.configuration.polymorphic_resource_owner?\n resource_owner == access_token.resource_owner\n else\n resource_owner_id == access_token.resource_owner_id\n end\n end", "def should_create_shared_contact\n _supplier = Supplier.find(supplier)\n _entity = Entity.find(_supplier.entity)\n # Maybe contact exists previously\n _contact = SharedContact.find_by_name_organization_type(last_name, first_name, organization_id, 2) rescue nil\n if _contact.nil?\n # Let's create a new contact\n _contact = create_shared_contact(_entity, _supplier)\n else\n # Contact exists, updates it\n _contact = update_shared_contact(_contact, _entity, _supplier)\n end\n # Update contact id\n self.update_column(:shared_contact_id, _contact.id) if !_contact.id.nil?\n true\n end", "def nested_resource?(new_resource)\n @current_resource_report && @current_resource_report.new_resource != new_resource\n end", "def exists?\n return File.exists?(\"/tmp/cloud-#{resource[:name]}\")\n end", "def exists?\n return File.exists?(\"/tmp/cloud-#{resource[:name]}\")\n end", "def exists?\n return File.exists?(\"/tmp/cloud-#{resource[:name]}\")\n end", "def has_tag?(t)\n tags.include?(t)\n end", "def has_tag? (tag)\n\n @tags.include?(tag)\n end", "def exists\n $tracer.trace(format_method(__method__))\n @name_links.exists && @remove_buttons.exists\n end", "def nested?\n self.resource_tuple.length > 1\n end", "def is_resource_owner?(resource)\n current_user && current_user.id == resource.user_id\n end", "def check_tags(tags)\n if tags['Purpose'] == 'Continuous Integration' && tags['Environment'] == 'QA'\n return 'yes'\n else\n return 'no'\n end\nend", "def identicalish_resources?(first, second)\n skipped_ivars = [ :@source_line, :@cookbook_name, :@recipe_name, :@params, :@elapsed_time, :@declared_type ]\n checked_ivars = ( first.instance_variables | second.instance_variables ) - skipped_ivars\n non_matching_ivars = checked_ivars.reject do |iv|\n if iv == :@action && ( [first.instance_variable_get(iv)].flatten == [:nothing] || [second.instance_variable_get(iv)].flatten == [:nothing] )\n # :nothing action on either side of the comparison always matches\n true\n else\n first.instance_variable_get(iv) == second.instance_variable_get(iv)\n end\n end\n Chef::Log.debug(\"ivars which did not match with the prior resource: #{non_matching_ivars}\")\n non_matching_ivars.empty?\n end", "def hastag2?\n ! @tag2.empty?\n end", "def has_resource(name)\n return @resources.has_key?(name) # Exists key in Hash\n # return @resources.include?(name) # Exists value into Array\n end", "def needs_updating?(change_set)\n # Always mint/update the ARK unless the resource already has an identifier\n return true unless change_set.resource.try(:identifier)\n # Only update under the following conditions:\n # - The resource has been published with a new identifier\n # - The source metadata identifier has changed\n published?(change_set) || published_with_new_title?(change_set) || change_set.changed?(:source_metadata_identifier)\n end", "def exists?\n prepare_environment\n load_template(@data['serverProfileTemplateUri'], 'new_profile')\n return @resource_type.find_by(@client, @data).any? if resource['ensure'].to_sym == :absent\n super([nil, :found, :get_available_targets, :get_available_networks, :get_available_servers, :get_compliance_preview,\n :get_messages, :get_profile_ports, :get_transformation, :absent])\n end", "def put_can_create?\n false\n end", "def existing?\n @existing\n end", "def can_ever_create_works?\n !creatable_works.empty?\n end", "def image_resource?\n change_set != \"recording\"\n end", "def check_resource_semantics!; end", "def render_sharing?\n true\n end" ]
[ "0.6124779", "0.6015607", "0.6000117", "0.5983364", "0.59217644", "0.5871944", "0.5824583", "0.5800974", "0.5755824", "0.5740492", "0.57334346", "0.5717369", "0.5702758", "0.5688727", "0.56761956", "0.5666828", "0.56554675", "0.5634675", "0.56060755", "0.55830944", "0.55728817", "0.5551128", "0.5537619", "0.55347437", "0.5530659", "0.55289304", "0.55140233", "0.55109614", "0.5510932", "0.5505807", "0.5505358", "0.54894316", "0.5482224", "0.5477017", "0.5473704", "0.54712915", "0.5468874", "0.5468095", "0.54325545", "0.54260397", "0.5422553", "0.5419479", "0.54167145", "0.5415301", "0.54150075", "0.540546", "0.5400425", "0.5399192", "0.538263", "0.53618354", "0.5350332", "0.5350288", "0.53424037", "0.5340908", "0.5337043", "0.53347075", "0.5323613", "0.53199244", "0.531866", "0.5312774", "0.5309915", "0.53049254", "0.52968705", "0.5294024", "0.5292195", "0.5290714", "0.52840185", "0.52787167", "0.5276928", "0.5273584", "0.52730787", "0.52730787", "0.52730787", "0.52730787", "0.52730787", "0.52725255", "0.5267664", "0.52655095", "0.5263085", "0.5261412", "0.5257579", "0.5257579", "0.5257579", "0.5257462", "0.52525127", "0.5245411", "0.52436537", "0.5242874", "0.5234011", "0.52321315", "0.522282", "0.5220195", "0.5219517", "0.52092785", "0.5204385", "0.5199323", "0.51982534", "0.51964456", "0.5183797", "0.5183065" ]
0.59244835
4
Below Sends a notification to reciepient of tags in creation of resource, also adds a library entry to their archive.
def notify_and_share_admins mentioned_admins.each do |mentioned| # Here put email entry = self.library_entries.create(sender_id: self.admin.id, receiver_id: mentioned.id, admin_library_id: mentioned.library.id, shared: true) if entry.valid? Notification.create(recipient: mentioned, actor: self.admin, action: "shared", notifiable: self) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(tag)\n api_client.tags.multi_add(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end", "def create_notification; end", "def notify_resource_added(resource, request)\n email = OrderMailer.create_resource_added(resource, request)\n Thread.new(email) do |e|\n OrderMailer.deliver(email)\n end\n end", "def notify\n return if destroy_if_old\n\n increase_busy_counter\n\n create_push\n end", "def notify_after_create\n NotifyJob.perform('create', self) if web_hook_actions.include? :create\n end", "def action_create_new_radlib(radlib_title, radlib_text_array, original_sentences)\n\n if validate_create_new_radlib(radlib_title, radlib_text_array)\n\n new_radlib = RadlibStory.new ({ :create => true,\n :radlib_title => radlib_title,\n :radlib_text_array => radlib_text_array,\n :author_uid => @uid,\n :original_sentences => original_sentences})\n\n add_radlib_to_created(new_radlib.radlib_id)\n\n # Run Analytics on new data\n Analytics.analyze_user(self)\n\n result = { :success => true,\n :radlib_id => new_radlib.radlib_id,\n :radlib_url => Yetting.domain + \"r/#{new_radlib.radlib_id}\",\n :error_name => nil,\n :error_code => nil,\n :reason => nil,\n :help_text => nil,\n :backtrace => nil}\n end\n\n rescue Exception => e\n raise e unless RADLIB_CREATE_ERRORS.has_key?(e.message.to_sym)\n result = {\n :success => false,\n :radlib_id => nil,\n :radlib_url => nil,\n :error_name => e.message.to_s,\n :error_code => ErrorCodes::RADLIB_CREATE_ERRORS[e.message.to_sym][0],\n :reason => ErrorCodes::RADLIB_CREATE_ERRORS[e.message.to_sym][1],\n :help_text => ErrorCodes::RADLIB_CREATE_ERRORS[e.message.to_sym][2],\n :backtrace => e.backtrace.inspect\n }\n end", "def create\n @package = Package.new(params[:package])\n cleanup_package_name(@package.name)\n\n @package.created_by = current_user.id\n @package.updated_by = current_user.id\n\n @package.tags = process_tags(params[:tags], params[:package][:task_id])\n\n respond_to do |format|\n if @package.save\n expire_all_fragments\n flash[:notice] = 'Package was successfully created.'\n\n if Rails.env.production?\n url = get_package_link(params, @package, :create)\n\n if Setting.activated?(@package.task, Setting::ACTIONS[:created])\n Notify::Package.create(current_user, url, @package, Setting.all_recipients_of_package(@package, nil, :create))\n end\n\n unless params[:div_package_create_notification_area].blank?\n Notify::Package.create(current_user, url, @package, params[:div_package_create_notification_area])\n end\n end\n\n format.html { redirect_to(:controller => :packages, :action => :show,\n :id => escape_url(@package.name), :task_id => escape_url(@package.task.name), :user => params[:user]) }\n else\n\n @user = params[:user]\n format.html { render :action => :new }\n end\n end\n end", "def create\n if current_user && current_user.email == '[email protected]'\n resource = Resource.new(resource_params)\n #array of tag_ids from f.check_box_tag comes in as an array of strings\n tag_ids = params[:tag_ids].map(&:to_i)\n tag_array = []\n tag_ids.each do |id|\n tag = Tag.find(id)\n tag_array.push(tag)\n end\n if resource.save\n resource.tags << tag_array\n redirect_to resources_path\n end\n else\n redirect_to root_path\n flash[:error] = \"You do not have permission to perform this action.\"\n end\n end", "def create_remote_tag tag_name\n in_secondary_repository do\n create_local_tag tag_name\n run 'git push --tags'\n end\nend", "def create_notification(attributes)\n BrickFTP::API::Notification.create(attributes)\n end", "def create_notification(attributes)\n BrickFTP::API::Notification.create(attributes)\n end", "def push(notif)\n\n end", "def notify(rf, destination)\n logger.info('ArchiveProxy') { 'Notifying Archive Service' }\n logger.info('ArchiveProxy') { \"destination: #{destination}\" }\n\n p_id = ProjectProxy.new(@rest_client).create(rf).id\n logger.debug('ArchiveProxy') { \"Project Created #{p_id}\" }\n s_id = SessionProxy.new(@rest_client).create(p_id, rf).id\n logger.debug('ArchiveProxy') { \"Session Created #{s_id}\" }\n r_id = RecordingProxy.new(@rest_client).create(p_id, s_id, rf).id\n logger.debug('ArchiveProxy') { \"Recording Created #{r_id}\" }\n MediumProxy.new(@rest_client).create(p_id, s_id, r_id, rf)\n logger.debug('ArchiveProxy') { \"Recording Media Created #{r_id}\" }\n\n return true\n rescue => error\n logger.error('ArchiveProxy') { 'Error in Archive Service Notification' }\n logger.error('ArchiveProxy') { error.message }\n logger.error('ArchiveProxy') { error.backtrace }\n return false\n end", "def publish_pod_lib()\n\t\t \t\tverbose_message(\"publishing pod repo=#{@podrepo} spec=#{@podspec}\")\n\t\t \t\tshell_command(\"bundle exec pod repo push #{@podrepo} #{@podspec} --allow-warnings\")\n\t\t \tend", "def add_tags_with_http_info(identifier, body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AlertApi.add_tags ...\"\n end\n # verify the required parameter 'identifier' is set\n if @api_client.config.client_side_validation && identifier.nil?\n fail ArgumentError, \"Missing the required parameter 'identifier' when calling AlertApi.add_tags\"\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 AlertApi.add_tags\"\n end\n if @api_client.config.client_side_validation && opts[:'identifier_type'] && !['id', 'alias', 'tiny'].include?(opts[:'identifier_type'])\n fail ArgumentError, 'invalid value for \"identifier_type\", must be one of id, alias, tiny'\n end\n # resource path\n local_var_path = \"/v2/alerts/{identifier}/tags\".sub('{' + 'identifier' + '}', identifier.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'identifierType'] = opts[:'identifier_type'] if !opts[:'identifier_type'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(body)\n auth_names = ['GenieKey']\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 => 'SuccessResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AlertApi#add_tags\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create_release(tag, message)\n\n if not is_valid_tag(tag)\n raise \"Invalid tag.\"\n end\n\n if message.empty?\n raise \n message = \"Release for #{tag}\"\n end\n\n message = {\n \"tag_name\": tag,\n \"target_commitish\": \"master\",\n \"name\": tag,\n \"body\": message,\n \"draft\": false,\n \"prerelease\": false\n }.to_json\n\n r = api_post(\"/releases\", message)\n\n if not r.kind_of? Net::HTTPCreated\n raise \"Creation of release unsuccessful.\"\n end\nend", "def action_install\n remote_file.run_action(:create)\n package.run_action(:install)\n new_resource.installed = true\n end", "def create\n authorize @ticket\n if @ticket.update_attributes(tag_list: @tags)\n render :json => @ticket.reload.tags, :status => :created\n else\n error!(:invalid_resource, @ticket.errors, \"Tags have not been saved\")\n end\n end", "def growl_register\n\t\t\t@application = Kodiak::APP_NAME\n\t\t\t@icon = \"#{Kodiak::CONFIG_PATH}/#{Kodiak::CONFIG_ICON}\"\n\t @default_notifications = [\"Kodiak Success\"]\n\t @notifications = [\"Kodiak Success\", \"Kodiak Failure\"]\n @growl.register(:as_application => @application, :all_notifications => @notifications, :default_notifications => @default_notifications)\n end", "def push name='create'\n \n end", "def create_standalone_remote_tag tag_name\n in_secondary_repository do\n run 'git checkout -b temp'\n run 'touch a.txt'\n run 'git add -A'\n run 'git commit -m \"temp\"'\n run \"git tag -a #{tag_name} -m '#{tag_name}'\"\n run 'git push --tags'\n end\nend", "def create\n tag_value = subscription_params[\"user_entry\"]\n\n #If the tag_value is empty, we match everything, so build a notification for the entire Tell collection\n #Else search through Tell collection by subscription type, generating notifications for matching tags\n case subscription_params[\"subscription_type\"]\n #Type = title\n when \"0\"\n @subscription = current_user.subscriptions.build({\"title\"=>tag_value, \"subscription_type\"=>0})\n\n tells = Tell.where(title: tag_value)\n #Type = teller\n when \"1\"\n @subscription = current_user.subscriptions.build({\"teller\"=>tag_value, \"subscription_type\"=>1})\n\n tells = Tell.where(tellerName: tag_value)\n #Type = keyword\n when \"2\"\n @subscription = current_user.subscriptions.build({\"keyword\"=>tag_value, \"subscription_type\"=>2})\n\n tells = Tell.where(keyword: tag_value)\n else\n puts \"Something went wrong...\"\n end\n\n if tag_value == \"\"\n tells = Tell.all\n end\n \n tells.each do |tell|\n @subscription.notifications.build({\"tell_id\"=>tell.id})\n end\n\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to @subscription, notice: 'Subscription was successfully created.' }\n format.json { render :show, status: :created, location: @subscription }\n else\n format.html { render :new }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end", "def notification_on_create\n create_notification(:create)\n end", "def register(resource_type, filename, object)\n\t resource = resource_type.new(@server, filename, object)\n\t add(resource)\n\t resource\n\tend", "def create\n @notification = Notification.new(params[:notification])\n @notification.user_id = current_user.id\n\n respond_to do |format|\n if @notification.save\n push_notification(@notification.id, @notification.car.device_token, @notification.text) if @notification.car.device_token\n format.html { redirect_to notifications_path, notice: t(\"activerecord.models.notification\") + t(\"message.created\") }\n format.json { render json: @notification, status: :created, location: @notification }\n else\n format.html { render action: \"new\" }\n format.json { render json: @notification.errors, status: :unprocessable_entity }\n end\n end\n end", "def async_notify_on_creation\n Delayed::Job.enqueue(\n NewPostingNotifier.new(self.id,\"New Posting by #{self.user.nickname}: #{self.title}\", ADMIN_EMAIL_ADDRESS),\n { :run_at => Time.now()+(CONSTANTS['delay_new_posting_notifications'].to_i).seconds }\n )\n end", "def register_subresource(resource)\n super.tap do |added|\n if added && action_on_update\n Chef::Log.debug(\"[#{self}] Registering #{action_on_update_immediately ? 'immediate ' : ''}#{action_on_update} notification from #{resource}\")\n resource.notifies action_on_update.to_sym, self, (action_on_update_immediately ? :immediately : :delayed)\n end\n end\n end", "def create(body: :unset, priority: :unset, ttl: :unset, title: :unset, sound: :unset, action: :unset, data: :unset, apn: :unset, gcm: :unset, sms: :unset, facebook_messenger: :unset, fcm: :unset, segment: :unset, alexa: :unset, to_binding: :unset, identity: :unset, tag: :unset)\n data = Twilio::Values.of({\n 'Identity' => identity,\n 'Tag' => tag,\n 'Body' => body,\n 'Priority' => priority,\n 'Ttl' => ttl,\n 'Title' => title,\n 'Sound' => sound,\n 'Action' => action,\n 'Data' => Twilio.serialize_object(data),\n 'Apn' => Twilio.serialize_object(apn),\n 'Gcm' => Twilio.serialize_object(gcm),\n 'Sms' => Twilio.serialize_object(sms),\n 'FacebookMessenger' => Twilio.serialize_object(facebook_messenger),\n 'Fcm' => Twilio.serialize_object(fcm),\n 'Segment' => segment,\n 'Alexa' => Twilio.serialize_object(alexa),\n 'ToBinding' => to_binding,\n })\n\n payload = @version.create(\n 'POST',\n @uri,\n data: data\n )\n\n NotificationInstance.new(@version, payload, service_sid: @solution[:service_sid],)\n end", "def notify_authors_of_new_item(solr_doc)\n doc = SolrDocument.new(solr_doc)\n ldap = Cul::LDAP.new\n\n unis = solr_doc.fetch('author_uni_ssim', [])\n preferred_emails = EmailPreference.preferred_emails(unis)\n\n preferred_emails.each do |uni, email|\n # Skip if notification was already sent.\n next if Notification.sent_new_item_notification?(solr_doc['cul_doi_ssi'], uni)\n\n begin\n name = (author = ldap.find_by_uni(uni)) ? author.name : nil\n success = true\n UserMailer.new_item_available(doc, uni, email, name).deliver_now\n rescue StandardError => e\n logger.error \"Error Sending Email: #{e.message}\"\n logger.error e.backtrace.join(\"\\n \")\n success = false\n end\n Notification.record_new_item_notification(doc[:cul_doi_ssi], email, uni, success)\n end\n end", "def create_tag(dir, branch, tag, message)\n\tDir.chdir(dir) do |path|\n\t\tcmds = [\"git checkout #{branch}\", \n\t\t\t\t\"git pull\",\n\t\t\t\t\"git tag -a #{tag} -m '#{message}'\"\n\t\t\t\t]\n\t\tcmds.delete_at(1) unless remote_branch_exists?(path, branch)\n\t\tapprove_and_execute(cmds, \"in #{path}\")\n\tend\nend", "def create\n @asset = Asset.find(params[:asset_id])\n \t@tag = @asset.tags.build(params[:tag])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to(asset_manager_asset_tag_path(@asset, @tag), :notice => 'Tag was successfully created.') }\n format.xml { render :xml => asset_manager_asset_tag_path(@asset, @tag), :status => :created, :location => @tag }\n else\n format.html { render :action => :new }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n params[:archive][:archive_title] = \"#{params[:archive][:archive_term].parameterize}_#{Time.now.to_i}\"\n @archive = Archive.new params[:archive]\n\n respond_to do |format|\n if @archive.save\n require 'chain_api'\n #account = Chain::ChainAPI.new({address: accountaddress['accountaddress']}).listtransactions\n Resque.enqueue(ArchiveCreationPricer, @archive)\n #tx = Chain::ChainAPI.new({account: '5e434ab9d6c5fb2870351df70dd62f7f5f568f8be26da1da52655ceb0d7a8375', address: default_account_address}).sendfrom\n\n #client = return_twitter_client\n\n #last_archive_item = @archive\n #term = last_archive_item.archive_term\n\n #if last_archive_item.archive_type == 'username'\n # tweets = client.user_timeline(term, options = {count: 200, include_rts: 1})\n # tweets.each do |tweet|\n # record = last_archive_item.records.create({\n # record_type: 'tweet',\n # })\n # record.save\n\n # #response = HTTParty.post(\"#{Figaro.env.florincoin_blockchain_ip}tip?token=foobar8&team_id=foobar&team_domain=foobar&service_id=foobar&channel_id=foobar&channel_name=sw_bots&timestamp=foobar.000198&user_id=foobar&user_name=carlos&text=tip&tweet_text=#{Rack::Utils.escape(tweet['text'])}&trigger_word=litecointipper\", \n # #headers: {\n # # 'Content-Type' => 'application/json'\n # # }\n # #)\n\n # tweet = record.create_tweet({\n # tweet_text: tweet['text'],\n # created_date: tweet['created_at']\n # })\n # end\n # \n # #last_id = tweets.last.id\n # #5.times do |index| \n # # tweetz = client.user_timeline(term, options = {count: 200, include_rts: 1, max_id: last_id})\n # # tweetz.each do |tweet|\n # # record = last_archive_item.records.create({\n # # record_type: 'tweet',\n # # })\n # # record.save\n # # tweet = record.create_tweet({\n # # tweet_text: tweet['text'],\n # # created_date: tweet['created_at']\n # # })\n # # end\n # # last_id = tweets.last.id\n # #end\n #elsif last_archive_item.archive_type == 'search'\n # tweets = client.search(term, result_type: 'recent').take(200).collect\n # #last_id = 0\n # tweets.each do |tweet|\n # record = last_archive_item.records.create({\n # record_type: 'tweet',\n # })\n # record.save\n # tweet = record.create_tweet({\n # tweet_text: \"#{tweet.user.screen_name}: #{tweet.text}\",\n # created_date: tweet['created_at']\n # })\n # #last_id = tweet.id\n # end\n # \n # #15.times do |index| \n # # tweets = client.search(term, result_type: 'recent', max_id: last_id).take(200).collect\n # # tweets.each do |tweet|\n # # record = last_archive_item.records.create({\n # # record_type: 'tweet',\n # # })\n # # record.save\n # # tweet = record.create_tweet({\n # # tweet_text: tweet['text'],\n # # created_date: tweet['created_at']\n # # })\n\n # # last_id = tweet.id\n # # end\n # #end\n #end\n\n format.html { redirect_to @archive, notice: 'Archive was successfully created.' }\n format.json { render json: @archive, status: :created, location: @archive }\n else\n format.html { render action: \"new\" }\n format.json { render json: @archive.errors, status: :unprocessable_entity }\n end\n end\n end", "def notify_new_finding\n # TODO: make the method avoid the creation of a Notification record\n end", "def create\n if document_tag_params[:tag_id].to_i != 0\n @issuer_document_tag = IssuerDocumentTag.new(document_id: document_tag_params[:document_id], tag_id: document_tag_params[:tag_id])\n else\n @tag_type = TagType.find_by(name: document_tag_params[:tag_type])\n @new_tag = Tag.create(name: document_tag_params[:tag_id], tag_type_id: @tag_type.id)\n @issuer_document_tag = IssuerDocumentTag.new(document_id: document_tag_params[:document_id], tag_id: @new_tag.id)\n end\n\n respond_to do |format|\n if @issuer_document_tag.save\n format.html { redirect_to edit_document_path(@issuer_document_tag.document), notice: 'Se ha añadido el tag exitosamente.' }\n format.json { render :show, status: :created, location: @issuer_document_tag.document }\n else\n format.html { render :new }\n format.json { render json: @issuer_document_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def trigger_post_receive(oldrev, newrev, ref, user)\n # Create push event\n self.observe_push(oldrev, newrev, ref, user)\n\n # Close merged MR\n self.update_merge_requests(oldrev, newrev, ref, user)\n\n # Execute web hooks\n self.execute_hooks(oldrev, newrev, ref, user)\n\n # Create satellite\n self.satellite.create unless self.satellite.exists?\n end", "def action_deploy\n notifying_block do\n directory new_resource.path do\n owner new_resource.owner\n group new_resource.group\n mode '755'\n end\n end\n end", "def create\n @library = Library.new(library_params)\n\n respond_to do |format|\n if @library.save\n format.html { redirect_to api_ver_library_path(id: @library.red_id), notice: 'Library was successfully created.' }\n format.json { render json: @library, status: :created }\n else\n format.html { render :new }\n format.json { render json: @library.errors, status: :unprocessable_entity }\n end\n end\n end", "def before_save\n # cwd: utunes_app\n logger.info(\"=======> before_save invoked!\")\n \n version_str = sprintf(\"%.2d\", version )\n bundle_title = \"hc12_v#{version_str}\"\n \n #\n # copy template folder\n #\n bundle_folder = \"lib/bundles\"\n bundle_name=\"build_\" + bundle_title\n bundle_fq_name = bundle_folder + \"/\" + bundle_name\n \n template_folder = bundle_folder + \"/\" + \"templates\"\n template_name = \"build_hc12_vnn\"\n template_fq_name = template_folder + \"/\" + template_name\n \n logger.info(\"cp -R #{template_fq_name} #{bundle_fq_name}\")\n logger.info( %x[cp -R #{template_fq_name} #{bundle_fq_name}] )\n \n #\n # move image files to new bundle script folder\n #\n images_folder = \"public/upload\"\n \n image_ls_name = \"hc12_ls.bin\"\n image_fq_ls_name = images_folder + \"/\" + image_ls_name\n \n image_hs_name = \"hc12_hs.bin\"\n image_fq_hs_name = images_folder + \"/\" + image_hs_name\n \n image_fq_ls_target = \"#{bundle_fq_name}/hc12_images/hc12ft.txt\"\n image_fq_hs_target = \"#{bundle_fq_name}/hc12_images/hc12hs.txt\"\n \n logger.info(\"mv #{image_fq_ls_name} #{image_fq_ls_target}\")\n logger.info( %x[mv #{image_fq_ls_name} #{image_fq_ls_target}] )\n \n logger.info(\"mv #{image_fq_hs_name} #{image_fq_hs_target}\")\n logger.info( %x[mv #{image_fq_hs_name} #{image_fq_hs_target}] )\n \n #\n # creation version file\n #\n File.open(bundle_fq_name+\"/hc12_images/version\", \"w\") do |verfile|\n verfile.printf(version_str)\n end\n \n end", "def auto_create_tag\n\t\n\tget_tags.each do |tag|\n\t\t@items << Nanoc3::Item.new(\n\t\t\"<%= render 'tag', :tag => '#{tag}' %>\",\n\t { :title => \"Category: #{tag}\", :is_hidden => true, :tag => \"#{tag}\"}, # do not include in sitemap.xml\n\t \"/tags/#{tag}/\", # identifier\n\t :binary => false\n\t)\n\n\tend\n\tnil\nend", "def tag(ref, label, date, message)\n file = tempfile(\"message\", message)\n\n Dir.chdir(root) do\n cmd = %[svn copy -r #{ref} -F \"#{mfile.path}\" . #{tag_directory}/#{label}]\n puts cmd if $DEBUG\n `#{cmd}` unless $DRYRUN\n end\n end", "def notify_updating\n @msg = \"Deployment Started\"\n post\n end", "def notify_new_findings\n # TODO: make the method avoid the creation of a Notification record\n end", "def create\n # Build a ticket associated with the current user and fill with strong parameters\n @ticket = current_user.help_requests.build(ticket_params)\n # New Hash\n add_info = {}\n # New Nested Array\n add_info[:tagged_users] = []\n # Scan for tagged users in the report:\n @ticket.desc.scan(USER_TAG_REGEX) do |name|\n # Find a tagged user in the database\n user = User.find_by_name(name)\n # Add the tagged user to the hash of tagged users\n add_info[:tagged_users] << user.name unless user == nil\n end\n # Save a JSON representation of the add_info hash to the record\n @ticket.addinfo = JSON.generate(add_info)\n # Save the new record in the database\n @ticket.save\n # Send the user to their homepage\n redirect_to me_path\n end", "def publish!\n release_file = build_role 'release', release\n\n timestamp.replace(release_file)\n\n timestamp_file = build_role 'timestamp', timestamp\n\n bucket.create(release_file.path_with_hash, release_file.body)\n bucket.create(timestamp_file.path, timestamp_file.body)\n end", "def create_digital_object(archival_object) \n @countMutex.synchronize do\n @count = @count + 1\n end\n osn = archival_object.ref_id\n \n begin\n actionable_urn = fetch_urn(osn) \n rescue Exception => e\n return {'error' => e.message, 'osn' => osn}\n end\n begin\n actionable_thumbnail_urn = fetch_thumbnail_urn(osn)\n rescue Exception => e\n return {'error' => e.message, 'osn' => osn}\n end\n if (!actionable_thumbnail_urn.nil? && !actionable_thumbnail_urn.empty?)\n actionable_thumbnail_urn = NRS_SERVER + actionable_thumbnail_urn\n end\n \n # Tell all the clients a job has finished\n if (!actionable_urn.nil? && !actionable_urn.empty?)\n actionable_urn = NRS_SERVER + actionable_urn\n \n #create the digital object\n do_json_response = call_digital_object_api(archival_object, actionable_urn, actionable_thumbnail_urn)\n if (!do_json_response.is_a? Numeric)\n return {'error' => do_json_response['error'], 'osn' => osn}\n end\n \n #link the digital object to the archival object\n ao_json_response = link_ao_do(archival_object, do_json_response) \n if (!ao_json_response.is_a? Numeric)\n #Remove the newly created DO if this fails\n digitalobject = DigitalObject.to_jsonmodel(do_json_response.to_i)\n #TODO This isn't working - fixme\n raise Sequel::Rollback\n return {'error' => ao_json_response['error'], 'osn' => osn}\n end\n else\n return {'no_urn' => \"No URNs were found for #{@owner_code} : #{osn}\", 'osn' => osn}\n end\n return {'urn_created' => 'Success', 'osn' => osn}\n end", "def add_book_google\n book = Book.create(book_params)\n \n if book.valid?\n #Book was added to library\n #Add book to users bookshelf\n user = User.find_by_id(params[:user_id])\n \n shelf = user.bookshelves.first\n shelf.books << book\n \n shelf = user.bookshelves.first\n pp shelf.shelfitems\n \n if params[:finished] == \"true\"\n shelf.shelfitems.last.finished = true\n #shelf.shelfitems.last\n shelf.shelfitems.last.save\n end\n #si.finished = params[:finished]\n #si.save\n \n render json: {msg: \"Successfully created \" + book.title, shelf: shelf.books}, :status => :created\n else\n render json: {e: \"Error creating book\"}, :status => :error\n end\n end", "def create\n @review = Review.new(params[:review])\n\n pusher = Grocer.pusher(certificate: \"/Users/kevinjoslin/rails_projects/music_app/apns/certificate.pem\", passphrase: \"joslin12\")\n\n notification = Grocer::Notification.new(device_token: \"ba8ab6a96955bd53d64fc7311a40b0880d46b56f72f6ddc42cf5b99b6ec69f9a\", alert: \"New Review Available\", badge: 42, sound: \"siren.aiff\")\n\n pusher.push(notification)\n\n\n respond_to do |format|\n if @review.save\n\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render json: @review, status: :created, location: @review }\n\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def notify_by_tags(platforms, tags, &block)\n @client.post 'notify/toTags',\n :platforms => Platform.new(platforms).build_list,\n :tags => tags.join(','),\n :payload => Message.dsl(&block).to_json\n end", "def create_hook!\n hook = client.create_hook(\n full_name,\n 'web',\n {\n url: Constants::HOOK_URL,\n content_type: 'json'\n },\n {\n events: ['release'],\n active: true\n }\n )\n\n self.github_hook_id = hook.id\n end", "def after_create_notify_client_service\n\t\t\t\t\trequire \"open-uri\"\n\t\t\t\t\trequire \"net/http\"\n\t\t\t\t\trequire \"openssl\"\n\n\t\t\t\t\turi = URI.parse(self.install_url)\n\t\t\t\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\t\t\thttp.use_ssl = true if uri.scheme == \"https\"\n\n\t\t\t\t\trequest = Net::HTTP::Post.new(uri.request_uri)\n\t\t\t\t\trequest[\"Content-Type\"] = \"application/json\"\n\t\t\t\t\trequest.body = {\n\t\t\t\t\t\tclient_id: self.id,\n\t\t\t\t\t\tsecret: self.secret,\n\t\t\t\t\t\turl: ((MicroService::Client.configuration)? MicroService::Client.configuration.url : \"\"),\n\t\t\t\t\t\ttimestamp: self.created_at.to_i,\n\t\t\t\t\t}.to_json\n\n\t\t\t\t\tresponse = http.request(request)\n\n\t\t\t\t\t# Failed to register with external service\n\t\t\t\t\tif !response.kind_of? Net::HTTPSuccess\n\t\t\t\t\t\traise ::MicroService::Client::InstallError\n\t\t\t\t\tend\n\t\t\t\tend", "def create\n\t# 把訊息寫進 log 內, 可用heroku logs -a rescue-team 看.\n Rails.logger.info request.body.read\n\t\n\t# parse 警訊, 翻譯成 object 存起來.\n\t#@doc = Nokogiri::XML(request.body.read)\n\talert = RCAP::Alert.from_xml(request.body.read)\n\tRails.logger.info alert.sent\n\t#Rails.logger.info alert.to_h['identifier']\n\t#Rails.logger.info alert.infos\n\n\t# 把訊息寫進 database 內, 等 ifttt 來收新資料.\n\talert.infos.first.parameters.each do |para|\n\t\tif para.to_s =~ /\\\"/\n\t\t\tary = para.to_s.split(\";\")\n\t\t\t#ary[0] #級數\n\t\t\t#ary[1] #城市\n\t\t\tRails.logger.info ary[1].gsub(\"\\\"\", \"\") + \" \" + ary[0].split(\" \")[1]\n\t\t\t@uploader = Uploader.new :place => ary[1].gsub(\"\\\"\", \"\"), :content => ary[0].split(\" \")[1], :time => alert.sent\n\t\t\[email protected]\n\t\tend\n\tend\n\t#hash[\"alert\"][\"info\"][\"description\"]\n\t\t\n\n\t# 處理 ruby on rails 網頁介面的資料\n\t#@uploader = Uploader.new(uploader_params)\n\t#@uploader.save\n\t\n\t# 通知 ifttt 來收新資料\n\tRails.logger.info \"Ping IFTTT...\"\n\tThread.new {ping_ifttt}\n\t\n\t# 傳回 response, 讓 push 端知道我們成功收到訊息了.\n\trender :xml => \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\" ?> <Data><Status>true</Status></Data>\"\n end", "def create_notification\n subject = \"#{student_request.name} \"\n body = \"#{student_request.name} (#{student_request.email}) needs tutorial.\"\n tutor_request.notify(subject, body, self)\n end", "def on_new_resource(resource)\n debug \"Created: #{resource}\"\n OMF::JobService.scheduler.on_new_job(resource)\n end", "def create\n authorize! :create, LibraryItem\n @library_item = current_account.library_items.new(library_item_params)\n add_flash :notice => I18n.t('library_item.created') if @library_item.save\n respond_with @library_item\n end", "def create\n redirect_to :admin_subscriptions, alert: \"Supply a tag name\" and return if params[:tag_name].blank?\n\n Thread.new do |t|\n\n callback_url = instagram_callback_url\n\n request_params = {\n callback_url: callback_url,\n verify_token: APP_CONFIG.instagram.verify_token,\n object: \"tag\",\n aspect: \"media\",\n object_id: params[:tag_name],\n client_id: AppConfig.instagram.client_id,\n client_secret: AppConfig.instagram.client_secret\n }\n\n Star::Requester.post \"subscriptions\", request_params.to_param\n end\n\n sleep 1\n redirect_to :admin_subscriptions, :notice => \"OK, sending subscription request\"\n end", "def growl_notify\n\t\t\toptions = { :title => @application,\n\t\t\t\t\t\t\t\t\t:description => @message.gsub(/[\\n]+/, \"\"),\n\t\t\t\t\t\t\t\t\t:application_name => @application,\n\t\t\t\t\t\t\t\t\t:image_from_location => @icon,\n\t\t\t\t\t\t\t\t\t:sticky => false,\n\t\t\t\t\t\t\t\t\t:priority => 0,\n\t\t\t\t\t\t\t\t\t:with_name => notifications.first }\n @growl.notify options\t\t\t\n\t\tend", "def create_tags\n\tend", "def add_new_library_book\n\t\tputs \"To add new book to library, You need to enter book name and book's author name\"\n\t\tprint \"\\tEnter New Book name:\"\n\t\tnew_book_name=gets.chomp\n\t\tprint \"\\tEnter Author name:\"\n\t\tnew_book_author_name=gets.chomp\n\t\t@last_book_id=@last_book_id+1\n\t\tbook=Book.new(@last_book_id,new_book_name,new_book_author_name,-1)\n\t\[email protected](book)\n\t\tputs \"New book '#{new_book_name}' has been added to library with book ID #{@last_book_id}\"\n\tend", "def publish_if_updated(method, options = {})\n return if version_released?\n @builder.build(@gemspec).tap { |gem|\n tag_prefix = options[:tag_prefix] || 'v'\n @pusher.push gem, method, options\n @git_remote.add_tag \"#{@tag_prefix}#{@version}\"\n }\n end", "def add_entry(name)\n Library.create(name: name)\n end", "def perform(repo)\n repo.update_catalog_metadata\n repo.add_preservation_and_mets_xml\n repo.delete_clone\n repo.create_iiif_manifest if Settings.bulk_import.create_iiif_manifest\n repo.publish if repo.published\n end", "def create\n @store = Store.new(params[:store])\n\n \n\n respond_to do |format|\n if @store.save\n # Create the tibbr resource for the store\n action_typ = \"og:comment\"\n publish_req = {:message=>{:rich_content=>\"New Store !\"}, :action_type=>action_typ, :client_id=> session[:app_id], :resource=>{:app_id => session[:app_id], :key => \"ID_#{@store.id}\", :title => \"#{@store.name}_#{@store.name}\",:description => \"test\", :scope => \"public\", :type => \"ad:store\", :owners => [@current_user.id], :url => \"#{APP_CONFIG[Rails.env]['retail']['root']}#stores/#{@store.country}/#{@store.city}/#{@store.id}\", :action_links => [{:url => \"#{APP_CONFIG[Rails.env]['retail']['root']}#stores/#{@store.country}/#{@store.city}/#{@store.id}\", :label => \"View\", :display_target => \"app\"}] }}.to_json;\n\n #encryptor = Encryptor.new(application_config_decrypt_key, \"\")\n encryptor = Encryptor.new(\"947aafe0-e8b1-11e2-9fa4-a4199b34c982\", \"\")\n signed_hash_string = encryptor.encrypt(publish_req)\n\n # Tibbr::ExternalResourceAction.publish ({:client_id=> session[:app_id], :signed_hash=> publish_req})\n \n Tibbr::ExternalResourceAction.publish ({:client_id=> session[:app_id], :signed_hash=> signed_hash_string})\n \n tib_res = Tibbr::ExternalResource.find_by_resource_key({:resource => {:key => \"ID_#{@store.id}\", :resource_type => \"ad:store\"}, :client_id => session[:app_id]})\n \n @store.tibbr_id = tib_res.id\n @store.tibbr_key = \"ID_#{@store.id}\"\n\n \n @store.save\n format.html { redirect_to @store, notice: 'Store was successfully created.' }\n format.json { render json: @store, status: :created, location: @store }\n else\n format.html { render action: \"new\" }\n format.json { render json: @store.errors, status: :unprocessable_entity }\n end\n end\n end", "def push(info)\n\t\tadd(info)\n\tend", "def generate_entry_for_tag(pull_requests, issues, newer_tag_name, newer_tag_link, newer_tag_time, older_tag_name) # rubocop:disable Metrics/ParameterLists\n github_site = @options[:github_site] || \"https://github.com\"\n project_url = \"#{github_site}/#{@options[:user]}/#{@options[:project]}\"\n\n create_sections\n\n @content = generate_header(newer_tag_name, newer_tag_link, newer_tag_time, older_tag_name, project_url)\n @content += generate_body(pull_requests, issues)\n @content\n end", "def publishResourceAdd(app_id, run_id, resource)\n # Cache\n cache = RoomPlacesCachePublish.get_cache(app_id, run_id)\n\n cache.resources_add([resource])\n\t#nutella.net.publish('location/resources/added', {:resources => [resource]})\nend", "def create\n repo = Repo.find(params[:repo_id])\n\n label_name = params[:label_name].downcase\n \n respond_to do |format|\n format.html { \n # Which ActsAsTaggableOn Context do we want to tag?\n if params[\"add_label\"]\n repo.label_list << label_name\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\"\n elsif params[\"remove_label\"]\n repo.label_list << label_name\n repo.label_list.delete(label_name)\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\"\n elsif params[\"add_framework\"]\n repo.framework_list << label_name\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\" \n elsif params[\"remove_framework\"]\n repo.framework_list << label_name\n repo.framework_list.delete(label_name)\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\" \n elsif params[\"add_language\"]\n repo.language_list << label_name\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\" \n elsif params[\"remove_language\"]\n repo.language_list << label_name\n repo.language_list.delete(label_name)\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\" \n else\n #no particular action wish was send along\n redirect_to :back, notice: \"Tagging action did not succeed. Please mail my creators that I did not receive instruction where to put this tag or label.\" \n end \n }\n end\n end", "def notification_about_deployment(to, project, environment, revision, user, from = self.from, sent_on = Time.now, subject = \"New version deployed on #{sent_on.strftime('%c')} by #{user}\")\n subject subject\n recipients to\n from from\n sent_on sent_on\n body :project => project, :environment => environment, :sent_on => sent_on, :revision => revision, :user => user\n content_type \"text/plain\"\n end", "def link_digital_object\n payload = archival_object.source\n payload[\"instances\"] = archival_object.non_figgy_instances\n payload[\"instances\"] += [new_instance]\n aspace_client.post(archival_object.uri, payload.to_json)\n end", "def create_engine(garage)\n garage.create(:engine, { sn: 10001 }) do |reply_msg|\n if reply_msg.success?\n engine = reply_msg.resource\n\n engine.on_subscribed do\n info \">>> Connected to newly created resource #{reply_msg[:res_id]} with serial number #{reply_msg[:sn]}\"\n on_engine_created(engine)\n end\n\n OmfCommon.eventloop.after(15) do\n info \">>> SENDING: to release engine\"\n garage.release(engine) do |reply_msg|\n info \"Engine #{reply_msg[:res_id]} released\"\n OmfCommon.comm.disconnect\n end\n end\n else\n error \">>> Resource creation failed - #{reply_msg[:reason]}\"\n end\n end\nend", "def add_ar(ar_template)\n return Error.new('ID not defined') if !@pe_id\n\n rc = @client.call(VN_METHODS[:add_ar], @pe_id, ar_template)\n rc = nil if !OpenNebula.is_error?(rc)\n\n return rc\n end", "def after_create(resource)\n add_activity(:create, resource)\n end", "def assign_tag(resource_arn, tag_list, region=@config['region'])\n begin\n tag_list.each do |each_pair|\n tag_resp = MU::Cloud::AWS.lambda(region: region, credentials: @config['credentials']).tag_resource({\n resource: resource_arn,\n tags: each_pair\n })\n end\n rescue Exception => e\n MU.log e, MU::ERR\n end\n end", "def create\n @tagsub = Tagsub.new(:home_id => params[:home_id].to_i, \n :tag_id => params[:id].to_i)\n\n respond_with(@tagsub) do |format|\n if @tagsub.save\n flash[:notice] = 'Tag was successfully subscribed.'\n format.html { render :action => \"index\" }\n format.mobile { render :template => \"tags/index.html.erb\" }\n format.xml { render :xml => @tagsub, :status => :created, :location => @tagsub }\n else\n format.html { render :action => \"index\" }\n format.mobile { render :template => \"tags/index.html.erb\" }\n format.xml { render :xml => @tagsub.errors, :status => :unprocessable_entity }\n end\n end\n end", "def notify\n MU.structToHash(cloud_desc)\n end", "def notify\n MU.structToHash(cloud_desc)\n end", "def process_push\n factory = \"::#{object_type}\".constantize\n local_object = factory.find(object_local_id)\n syncer = factory.synchronizer\n syncer.push_object(local_object)\n \n self.state = 'done'\n self.save\n end", "def add_tags\n if @tags.nil?\n @tags = IFFID3.new\n else\n raise AIFFError, 'an ID3 tag already exists'\n end\n end", "def create_taggings_from_atom(atom)\n Tagging.transaction do \n taggings_from_atom(atom)\n end\n end", "def create\n @task_tag = TaskTag.new(task_tag_params)\n attach_file(:icon)\n respond_to do |format|\n if @task_tag.save\n format.html { redirect_to @task_tag, notice: 'Task tag was successfully created.' }\n format.json { render :show, status: :created, location: @task_tag }\n else\n format.html { render :new }\n format.json { render json: @task_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def attachment_added(obj)\n if @current_journal && !obj.new_record?\n @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :value => obj.filename)\n end\n end", "def after_package_create(package)\n end", "def after_package_create(package)\n end", "def create\n @library = Library.new(params[:library])\n @library.user = @user\n\n if @library.save\n @user.libraries.reload\n redirect_to user_path, :notice => I18n.t('libraries.create.success')\n else\n render :action => 'new', :layout => 'dialog'\n end\n end", "def create\n Puppet.debug( \"#{self.resource.type}: CREATE #{resource[:name]}\" ) \n end", "def issue_library_book_to_member\n\t\tmember_id,member_name=get_registered_member_id_and_name\n\t\tbook_id,book_name=get_available_book_id_and_name\n\t\tregister_book_to_member(book_id,member_id)\n\t\tputs \"\\tDone!! A book '#{book_name}' has been issued to #{member_name} \"\n\tend", "def create\n \tset_tag_list\n\n @recipe = @current_user.recipes.build(params[:recipe])\n @recipe.status = @recipe.get_status\n item_client_ip(@recipe)\n # @recipe.is_draft = params[:is_draft]\n # @recipe.is_draft = @recipe.get_is_draft\n # @recipe.published_at = @recipe.get_published_at\n \n ActiveRecord::Base.transaction do \n\t\t\tif @recipe.save\n\t\t\t\t# @recipe.tag_list = params[:tags].strip if params[:tags] && !params[:tags].strip.blank?\n\t\t\t\treg_homepage(@recipe)\n\t\t\t\tafter_create_ok\n\t\t\telse\n\t\t\t\tafter_create_error\n\t\t\tend\n\t\tend\n end", "def apply_tags(resource, tags)\r\n\t\t\t\tif tags\r\n\t\t\t\t\tallTags = tags.split(/[\\s,]+/)\r\n\r\n\t\t\t\t\tallTags.each do |tag|\r\n\t\t\t\t\t\toldTag = Tag.find_by_tag(tag)\r\n\t\t\t\t\t\tif oldTag\r\n\t\t\t\t\t\t\toldTag.resources << resource\r\n\t\t\t\t\t\t\toldTag.save\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tnewTag = Tag.create(:tag => tag)\r\n\t\t\t\t\t\t\tnewTag.save\r\n\t\t\t\t\t\t\tresource.tags << newTag\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend", "def tag_add(id, tag)\n wf_event_id?(id)\n wf_string?(tag)\n api.put([id, 'tag', tag].uri_concat)\n end", "def add(library)\n library = Library.new(library) unless Library === library\n\n #raise TypeError unless Library === library\n #begin\n entry = (@ledger[library.name] ||= [])\n\n case entry\n #when NilClass\n # raise \"serious shit! nil entry in ledger table!\"\n when Array\n entry << library unless entry.include?(library)\n else\n # Library is already active so compare and make sure they are the\n # same, otherwise warn. (Should this ever raise an error?)\n if entry != library # TODO: Is this the right equals comparison?\n warn \"Added library has already been activated.\"\n end\n end\n #rescue Exception => error\n # warn error.message if ENV['debug']\n #end\n\n library\n end", "def notify(bucket)\n @queue.push({:Event => \"New Message\", :Bucket => bucket})\n end", "def commit_and_annotate(environment_metadata = {})\n return if config.fake_mode?\n\n git.capturing.add work_dir, *@vendor.git_add_extra_paths\n git.capturing.commit :m => @vendor.conjure_commit_message, :allow_empty => true\n git.capturing.notes({:ref => 'vendor'}, 'add', {:m => conjure_note(environment_metadata)}, 'HEAD')\n git.capturing.tag( { :a => true, :m => tag_message }, tag_name )\n say_status :default, :tag, tag_name\n end", "def add pid, title, description, cid, tracker\n\t\[email protected] Hash[\n\t\t\t'pid' => pid, \n\t\t\t'title' => title, \n\t\t\t'description' => description,\n\t\t\t'creator' => cid, \n\t\t\t'tracker' => tracker,\n\t\t\t'status' => 'new',\n\t\t\t'assigned' => '-1']\n\tend", "def initialize(*args)\n super\n self[:notify] = [\n \"Service[splunk]\",\n \"Service[splunkd]\",\n ].select { |ref| catalog.resource(ref) }\n end", "def create_resource(resource_descr, type_to_create, authorizer)\n debug \"central create_resource: resource '#{resource_descr.inspect}' type: '#{resource_type}'\"\n raise 'Method not implemented because the Central Manager just need to pass the same requisition to the other' \\\n ' brokers and create the concatenated results'\n end", "def notify\n base = MU.structToHash(cloud_desc)\n base.delete(:etag)\n base[\"cloud_id\"] = @cloud_id\n\n base\n end", "def add_tag_to_contact\n\t\t\t\t# add a tag to this contact\n\t\t\t\t# collect and clean the params\n\t\t\t\ttag_text = params[:tag_text].match(/[A-Za-z0-9-]+/)[0]\n\t\t\t\tcontact_id = params[:contact_id].match(/[A-Fa-f0-9]+/)[0]\n\t\t\t\t# let's see if this tag exists. if so, set tag to equal its corresponding object \n\t\t\t\ttag = Tag.where(:tag => tag_text).first\n\t\t\t\t# see if we got one\n\t\t\t\tif !tag\n\t\t\t\t\t# if we don't find the tag, make one\n\t\t\t\t\ttag = Tag.new\n\t\t\t\t\ttag.tag = tag_text\n\t\t\t\t\ttag.save\n\t\t\t\tend\n\t\t\t\t# after we have a tag, let's add it to the contact\n\t\t\t\t# find the parent contact\n\t\t\t\tcontact = Contact.where(:id => contact_id).first\n\t\t\t\tif !contact\n\t\t\t\t\t# something way fucked happened\n\t\t\t\tend\n\t\t\t\t# append tag to tags list\n\t\t\t\tcontact.tags << tag\n\t\t\t\t# save it\n\t\t\t\tcontact.save\n\t\t\t\t\n\t\t\t\t# send it back to the client\n\t\t\t\trender json: {:status => \"success\", :contact => contact}\n\t\t\tend", "def create\n @vtodo = Vtodo.new\n @vtodo.summary = params[:vtodo][:summary]\n @vtodo.description = params[:vtodo][:description]\n @vtodo.status = ''\n list = params[:vtodo][:tags].split(\",\").each {|t| t.strip!}\n list.each do |item|\n tag = Tag.new\n tag = Tag.find_or_create_by_subject(item)\n tag.subject = item\n #tag.save \n @vtodo.tags << tag\n end\n\n respond_to do |format|\n if @vtodo.save\n flash[:notice] = 'Vtodo was successfully created.'\n format.html { redirect_to(@vtodo) }\n format.xml { render :xml => @vtodo, :status => :created, :location => @vtodo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @vtodo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def publishResourceEnter(app_id, run_id, resource, baseStationRid)\n publishResourcesEnter(app_id, run_id, [resource], baseStationRid)\nend", "def create\n super\n # slack通知\n c = Payment.create_customer(resource.email, resource.name)\n resource.update(pay_customer_id: c.id)\n notifier = Slack::Notifier.new(Rails.application.config.slack_webhook_url)\n notifier.ping(\"新しく管理人が登録されました!\")\n end", "def add_document(resource_item)\n @message.add_attachment(current_user, resource_item, @message.smsg_refno)\n end", "def create\n ActiveRecord::Base.transaction do\n begin\n if @tag.nil?\n @tag = Tag.create!({text: @text, user: @current_user})\n end\n\n project_tag = ProjectTag.create!({tag: @tag, project: @project})\n render json: @tag, serializer: TagSerializer,\n root: \"tag\"\n rescue Exception => e\n render_error \"There was a problem creating the tag: #{e}.\"\n end\n end\n end" ]
[ "0.56392974", "0.55547184", "0.55182064", "0.5336845", "0.52876914", "0.52383935", "0.5194981", "0.51937073", "0.51870763", "0.5153625", "0.5153625", "0.51319426", "0.5128382", "0.5125124", "0.51175123", "0.51127535", "0.50938576", "0.50897944", "0.50681025", "0.50607336", "0.5053663", "0.5042568", "0.5015223", "0.49815354", "0.49715018", "0.4958337", "0.49551234", "0.49464592", "0.49336696", "0.49240282", "0.4923071", "0.49182478", "0.49143115", "0.4913993", "0.4912872", "0.49072346", "0.48945364", "0.4890133", "0.488633", "0.48830345", "0.48816326", "0.48810893", "0.4874249", "0.48674297", "0.48668587", "0.48659465", "0.48530355", "0.48513854", "0.48486584", "0.48412836", "0.4840466", "0.48378998", "0.48348853", "0.48329797", "0.48312473", "0.48247504", "0.48241866", "0.48200372", "0.4818175", "0.48170194", "0.48165703", "0.481455", "0.4813878", "0.48068178", "0.48019984", "0.47962052", "0.47932744", "0.4786692", "0.47791955", "0.47775137", "0.47764775", "0.47753763", "0.47739837", "0.4772866", "0.4772866", "0.47689924", "0.47642627", "0.4759241", "0.47547162", "0.47533303", "0.47515696", "0.47515696", "0.4750493", "0.4748891", "0.47468385", "0.4741996", "0.47406867", "0.4739686", "0.4730145", "0.47278434", "0.47236928", "0.4719347", "0.47186607", "0.47162423", "0.4712645", "0.4709876", "0.47086287", "0.4705475", "0.47029406", "0.47009125", "0.4698683" ]
0.0
-1
Get similarity from hamming_distance
def averagehash_similarity(hash_a, hash_b) 1 - averagehash_distance(hash_a, hash_b) / 64.0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def image_similarity(hash_a, hash_b)\n 1 - image_hamming_distance(hash_a, hash_b) / 64.0\n end", "def hamming_distance(other)\n self_array = self.to_a\n other_array = other.to_a\n self_array.zip(other_array).reduce(0) do |hamming, symbols|\n hamming += symbols[0] == symbols[1] ? 0 : 1\n end\n end", "def phash_similarity(hash_a, hash_b)\n 1 - phash_distance(hash_a, hash_b) / 64.0\n end", "def hamming_dist(obj)\n a_bits = @value.unpack(\"B*\").join.chars\n b_bits = str(obj).unpack(\"B*\").join.chars\n\n length_dist = (a_bits.length - b_bits.length).abs\n a_bits, b_bits = b_bits, a_bits if length_dist > 0\n\n a_bits[0, b_bits.length].zip(b_bits).reduce(0) do |sum, values|\n sum + (values[0] == values[1] ? 0 : 1)\n end => diff_dist\n\n diff_dist + length_dist\n end", "def similarity_to other, threshold = nil\n Babushka::Levenshtein.distance self, other, threshold\n end", "def similarity(m1, m2)\n if m1.is_a?(SparseVector) && m2.is_a?(SparseVector)\n m1.cosine(m2)\n elsif m2.size == m1.size\n a_dot_b = 0.0\n a_sq_sum = 0.0\n b_sq_sum = 0.0\n m1.each2(m2) do |x1,x2|\n a_dot_b = x1 * x2\n a_sq_sum += x1 * x1\n b_sq_sum += x2 * x2\n end\n a_dot_b / ( Math.sqrt(a_sq_sum) * Math.sqrt(b_sq_sum) )\n else\n 0.0\n end\n end", "def image_hamming_distance(hash_a, hash_b)\n hash_a.is_a?(ImageHash) or raise ArgumentError.new('hash_a is not an ImageHash')\n hash_b.is_a?(ImageHash) or raise ArgumentError.new('hash_b is not an ImageHash')\n\n ph_hamming_distance(hash_a.data, hash_b.data)\n end", "def similarity_score(word_1, word_2)\n raise NotImplementedError # TODO\nend", "def hamming_distance(first_word, second_word)\n if first_word.length == second_word.length\n first_word = first_word.split('')\n second_word = second_word.split('')\n distance = 0\n first_word.each_with_index do |a, i|\n if a != second_word[i]\n distance += 1\n end\n end\n distance\n else\n nil\n end\nend", "def hamming_distance2(x,y)\n (x ^ y).to_s(2).split(\"\").select{|el| el == \"1\"}.length\n # or\n # (x^y).to_s(2).split('').reduce(0){|s, e| s += e.to_i}\n # or\n # (x^y).to_s(2).count(\"1\")\nend", "def distance( h )\n to_cube.distance(h.to_cube)\n end", "def distance( h )\n to_cube.distance(h.to_cube)\n end", "def similarity_to(other,options={})\n shared_words = shared_words_with(other,options)\n shared_words.length * 2.0 / (words.length + other.words.length)\n end", "def hamming_distance(x, y)\n dist = 0\n\n bits = x^y\n\n while bits > 0\n bits = bits >> 1\n if (bits & 1)\n dist += 1\n end\n end\n\n return dist\nend", "def calculate_similarity(movie_in_common)\n simil = 0.0\n movie_in_common.each do |x|\n #find index of the common movie/ratings\n rating1 = cache_1[1][cache_1[0].index(x)]\n rating2 = cache_2[1][cache_2[0].index(x)]\n simil += (5-(rating1.to_i - rating2.to_i).abs)/5.0\n end\n return simil\n end", "def hamming_distance str1, str2\n result = 0\n \n str1.split('').each_index do |i|\n result += 1 if str1[i] != str2[i]\n end\n\n p result\nend", "def calc_similarity(query, doc)\n tokens = Set.new(query.keys + doc.keys)\n\n a = Vector.elements(tokens.map { |n| query[n] || 0 }, false)\n b = Vector.elements(tokens.map { |n| doc[n] || 0 }, false)\n\n return a.inner_product(b) / (a.magnitude * b.magnitude)\n end", "def similarity (user1, user2)\n\t\tuser1= user1.to_s\n\t\tuser2 = user2.to_s\n\t\tuser1_index = @user_rating_index[user1]\n\t\tuser2_index = @user_rating_index[user2]\n\t\ttotal_diff = 0\n\t\tcounter=0\n\n\t\tuser1_index.each_key do |movie|\n\t\t\tif user2_index.has_key? (movie) \n\t\t\t\tdiff = (user1_index[movie].to_i - user2_index[movie].to_i).abs #abs value difference to be summed then divided by total\n\t\t\t\ttotal_diff += diff\n\t\t\t\tcounter+=1\n\t\t\tend\n\t\tend\n\t\tif counter == 0\n\t\t\treturn 5.0\n\t\tend\n\t\treturn (total_diff.to_f/counter) \n\tend", "def similarity_matrix\n tfidf_similarity_model.similarity_matrix\n end", "def hamming_distance(a, b)\n raise \"Unequal buffers passed.\" if a.length != b.length\n a.bytes.zip(b.bytes).map { |a, b| (a ^ b).to_s(2) }.join.count('1')\n end", "def similarity(user1, user2)\n\t\tall_movie = @userhash[user1].map{|e| e[0]} | @userhash[user2].map{|e| e[0]}\n\t\tshared_movie = @userhash[user1].map{|e| e[0]} & @userhash[user2].map{|e| e[0]}\n\t\tscoretotal = 0\n\t\tshared_movie.each do |movie|\n\t\t\tscoretotal += (@moviehash[movie][user1] - @moviehash[movie][user2]).abs\n\t\tend\n\t\tnumdiff = all_movie.length-shared_movie.length\n\t\tsimilarity = (1-(scoretotal+numdiff*4.0)/all_movie.length/5.0).round(2)\n\tend", "def recognize_similarity_hash_distance(request, opts = {})\n data, _status_code, _headers = recognize_similarity_hash_distance_with_http_info(request, opts)\n data\n end", "def similarity(other_user)\n return 0 if common_bands(other_user).empty?\n\n 1 / (1 + cumulative_euclidean_distance(other_user))\n end", "def hamming_distance(string1, string2)\n h = 0\n (0..string1.length - 1).each do |i|\n h += 1 if string1[i] != string2[i]\n end\n h\nend", "def similarity_matrix\n multiply_self(normalize)\n end", "def distance_from(other)\n Phashion.hamming_distance(fingerprint, other.fingerprint)\n end", "def cosine_similarity(a, b)\n dot_product(a, b) / (magnitude(a) * magnitude(b))\n end", "def hamming_distance(p, q)\n # Hamming Distance Problem: Compute the Hamming distance between two strings.\n # Input: Two strings of equal length.\n # Output: The Hamming distance between these strings.\n\n # We say that position i in k-mers p1 … pk and q1 … qk is a mismatch if p(i) ≠ q(i). \n # For example, CGAAT and CGGAC have two mismatches. \n # The number of mismatches between strings p and q is called the Hamming distance \n # between these strings and is denoted HammingDistance(p, q).\n distance = 0\n (0..(p.length - 1)).each {|i| distance += 1 if p[i] != q[i] } \n\n return distance\n end", "def calc_distance(hasha, hashb)\n\t\t\treturn hash_as_num(hasha) ^ hash_as_num(hashb) \n\t\tend", "def phash_distance(hash_a, hash_b)\n hash_a.is_a?(PHash) or raise ArgumentError.new('hash_a is not an PHash')\n hash_b.is_a?(PHash) or raise ArgumentError.new('hash_b is not an PHash')\n\n #bits_a = hash_a.data.to_s.unpack('b*')[0].split(//)\n #bits_b = hash_b.data.to_s.unpack('b*')[0].split(//)\n #puts \"Distance b/w #{hash_a.data.to_s.unpack('b*')[0].split(//)} & #{hash_b.data.to_s.unpack('b*')}\"\n\n return phash_hamming_distance(hash_a.data, hash_b.data)\n end", "def similarity\n size1 = pixel_count(@image_path_1)\n size2 = pixel_count(@image_path_2)\n\n if size1 < size2\n big = @image_path_2\n small = @image_path_1\n else\n big = @image_path_1\n small = @image_path_2\n end\n\n min_size = size(small)\n width = min_size[0] * @resize_factor\n height = min_size[1] * @resize_factor\n\n a = \"convert #{Shellwords.escape(small)} #{Shellwords.escape(big)} -resize '#{width}'x'#{height}'\\! MIFF:- | compare -metric AE -fuzz \\\"#{@color_fuzz}%\\\" - null: 2>&1\"\n result = `#{a}`\n\n result.to_i / (width * height)\n end", "def cosine_similarity(a, b)\n dot_product(a, b) / (magnitude(a) * magnitude(b))\n end", "def similarity(user1, user2) \n movie_in_common = find_common_movies(user1,user2)\n\n if movie_in_common.empty?\n return 0.0\n end\n simil = calculate_similarity(movie_in_common)\n return (simil/movie_in_common.size).round(2)\n end", "def similarity(user1, user2)\n if @userdata.has_key? user1.to_s.to_sym and @userdata.has_key? user2.to_s.to_sym\n\n sim_rating = 0\n user1ratings = @userdata[user1.to_s.to_sym]\n user2ratings = @userdata[user2.to_s.to_sym]\n user2ids = []\n user2ratings.each{ |id, rating| user2ids.push id }\n user1ratings.each{ |id, rating| sim_rating += 5 - (rating - user2ratings[user2ids.index id][1]).abs if user2ids.include? id}\n return sim_rating\n else\n puts \"User not found\"\n return nil\n end\n end", "def similarity(user1, user2)\n @user_list[user1].similarity(@user_list[user2])\n end", "def similarity(user1, user2) \n\t\tsimil = 0;\n\t\tuser1_movie_list = reviews_hash[user1.to_i].transpose\n\t\tuser2_movie_list = reviews_hash[user2.to_i].transpose\n\t\tmovie_in_common = user1_movie_list[0] & user2_movie_list[0]\n\t\tmovie_in_common.each do |x|\n\t\t\t#find index of the common movie/ratings\n\t\t\tindex1 = user1_movie_list[0].index(x)\n\t\t\tindex2 = user2_movie_list[0].index(x)\n\t\t\tsimil1 = user1_movie_list[1][index1]\n\t\t\tsimil2 = user2_movie_list[1][index2]\n\t\t\tsimil += (5-(simil1.to_i - simil2.to_i).abs)/5.0\n\t\tend\n\t\tbegin \n\t\t\treturn (simil * 1.0/movie_in_common.size)\n\t\trescue\n\t\t\treturn 0.0\n\t\tend\n\tend", "def msd_similarity(origin, msd)\n intersection = if origin.pos == msd.pos\n origin.grammemes.inject(0) do |sim, (k, v)|\n msd[k] == v ? sim + 1 : sim\n end\n else\n 0\n end\n\n union = (origin.grammemes.keys | msd.grammemes.keys).length\n\n intersection - union\n end", "def similarity(user1, user2)\n\t\tif @userdata.has_key? user1.to_s.to_sym and @userdata.has_key? user2.to_s.to_sym\n\n\t\t\tsim_rating = 0\n\t\t\tuser1ratings = @userdata[user1.to_s.to_sym]\n\t\t\tuser2ratings = @userdata[user2.to_s.to_sym]\n\t\t\tuser2ids = []\n\t\t\tuser2ratings.each{ |id, rating| user2ids.push id }\n\t\t\tuser1ratings.each{ |id, rating| sim_rating += 5 - (rating - user2ratings[user2ids.index id][1]).abs if user2ids.include? id}\n\t\t\t\t\treturn sim_rating\n\t\telse\n\t\t\tputs \"User not found\"\n\t\t\treturn nil\n\t\tend\n\tend", "def calc_distance(hasha, hashb)\n\t\treturn hash_as_num(hasha) ^ hash_as_num(hashb) \n\tend", "def hamm(x, y)\n x, y = *([x,y].map{|z| z.split(\"\")})\n x.zip(y).inject(0){|z,s| z += if s[0] == s[1] then 0 else 1 end}\nend", "def similarity(user1, user2) \n\t\tsimil = 0;\n\t\tuser1_movie_list = reviews_hash[user1.to_i].transpose\n\t\tuser2_movie_list = reviews_hash[user2.to_i].transpose\n\t\tmovie_in_common = user1_movie_list[0] & user2_movie_list[0]\n\t\tmovie_in_common.each do |x|\n\t\t\t#find index of the common movie/ratings\n\t\t\tindex1 = user1_movie_list[0].index(x)\n\t\t\tindex2 = user2_movie_list[0].index(x)\n\t\t\tsimil1 = user1_movie_list[1][index1]\n\t\t\tsimil2 = user2_movie_list[1][index2]\n\t\t\tsimil += 1.0/((simil1.to_i - simil2.to_i).abs + 1) # 1/(rating difference + 1)\n\t\tend\n\t\treturn simil.round(2)\n\tend", "def calculate_similarity(user_search_term = nil)\n assign_category_jaccard_score unless user_categories.empty?\n assign_score_for_relevant_work_links\n assign_levenstein_score(user_search_term)\n end", "def similarity(user1, user2)\n user1_rate = compute_user_rate(user1)\n user2_rate = compute_user_rate(user2)\n dot_product = user1_rate.reduce(0) { |sum, (k, v)| sum + v * user2_rate[k] }\n user1_magnitude = compute_magnitude(user1_rate)\n user2_magnitude = compute_magnitude(user2_rate)\n dot_product / (user1_magnitude * user2_magnitude)\n end", "def similarity(user, row)\n (user.transpose.dot(row.transpose)) / (row.norm * user.norm)\nend", "def edit_distance_similarity (target)\n return 1-(self.edit_distance(target) / [self.length, target.length].max.to_f)\n end", "def phash_distance(first, second)\n # Get hamming distance between two phash(image hash) to check\n # similarity between images\n\n unless first && second\n raise ArgumentError, Error::MISSING_PHASH_VALUE\n end\n hamming_distance(first, second)\n end", "def similarity(user1,user2)\n #retrieves the recorded related to user1 and user2\n #then create an array which contains the movie ids which both user have rated them\n u1=@users[user1]\n u2=@users[user2]\n u1_movies=u1.collect{|itm| itm[1]}\n u2_movies=u2.collect{|itm| itm[1]}\n common_movies=u1_movies & u2_movies\n \n if common_movies.empty?\n return 0\n end\n \n #Similarity is defined as the average of (4 - distance between rating of user 1 and 2) for movie id\n #which both usres have rated\n similarity=0.0\n common_movies.each do |movie|\n rating1=u1.rassoc(movie)[2]\n rating2=u2.rassoc(movie)[2]\n similarity+=4-(rating1-rating2).abs\n end\n return similarity/common_movies.size\n end", "def similarity(user1, user2)\n\n user1 = user1.to_s\n user2 = user2.to_s\n \n weight_num = 0.20\n weight_movies = 0.40\n weight_rating = 0.40\n \n user1_num_movies = @user_database[user1].length\n user2_num_movies = @user_database[user2].length\n score_num_movies = ((user1_num_movies + user2_num_movies).to_f / ([user1_num_movies, user2_num_movies].max * 2)) * 100.0 \n \n #hash consists of movieID(string) => rating(float)\n user1_hash = {}\n user2_hash = {} \n @user_database[user1].each do |movieID, rating, time|\n user1_hash[movieID] = rating.to_f\n end\n @user_database[user2].each do |movieID, rating, time|\n user2_hash[movieID] = rating.to_f\n end \n common_movies = user1_hash.keys & user2_hash.keys\n num_common_movies = common_movies.length\n score_common_movies = (num_common_movies / [user1_hash.keys.length, user2_hash.keys.length].max ) * 100.0\n \n rating_difference = 0\n common_movies.each do |movieID|\n rating_difference += (user1_hash[movieID] - user2_hash[movieID]).abs\n end\n \n #in case of num_common_movies being 0, then penalize the rating score by 100\n if num_common_movies == 0\n avg_rating_diff = 100 \n else\n avg_rating_diff = rating_difference / num_common_movies.to_f\n end\n \n score_rating = 100 - avg_rating_diff\n \n similarity_score = (weight_num * score_num_movies + weight_movies * score_common_movies + weight_rating * score_rating)\n \n return similarity_score\n \n end", "def HammingDistance(strArr)\n hamming = 0\n\n (0...strArr[0].length).each do |i|\n if strArr[0][i] != strArr[1][i]\n hamming += 1\n end\n end\n\n hamming\nend", "def find_similarity(user1Hash, user2Hash)\n similarityValue = -1 # If no common movies watched, return -1\n countMovies = 0.0\n user1Hash.each do |movie, rating|\n if user2Hash.has_key?(movie)\n countMovies += 1\n similarityValue += 4 - (rating.to_i - user2Hash[movie].to_i).abs \n end\n end\n similarityValue != -1 ? (similarityValue + 1) / countMovies : similarityValue\n end", "def similarity_with(user)\n query_result = UserConnectionQuery.new.similarity(\n user_1: self,\n user_2: user\n ).first\n if query_result then query_result.similarity else nil end\n end", "def similarity(word,label)\n if @cosines.include?(word)\n sim = similarity_cluster(word,label)\n elsif word.include?(\"_\")\n word = word.split(\"_\")[0]\n sim = similarity_cluster(word,label)\n else\n STDERR.puts \"\\'#{word}\\' not in list of pre-computed cosines, sim(#{word},#{label}) = 0\" if @debug\n sim = 0.0\n end\n return sim\n end", "def pearson_similarity (u1,u2)\n\t\tsimilarity = @train_data[u1].movie_and_rating.keys & @train_data[u2].movie_and_rating.keys\n\t\tif similarity.empty?\n\t\t\treturn 0\n\t\tend\n\t\tsum_1 = 0\n\t\tsum_2 = 0\n\t\tsum_1_sq = 0\n\t\tsum_2_sq = 0\n\t\tproduct = 0\n\n\t\tsimilarity.each do |mov|\n\t\t\tsum_1 += @train_data[u1].return_rating(mov)\n\t\t\tsum_1_sq += @train_data[u1].return_rating(mov)**2\n\t\t\tsum_2 += @train_data[u2].return_rating(mov)\n\t\t\tsum_2_sq += @train_data[u2].return_rating(mov)**2\n\t\t\tproduct += @train_data[u1].return_rating(mov)*@train_data[u2].return_rating(mov)\n\t\tend\n\n\t\tnumerator = product - (sum_1*sum_2/similarity.length)\n\t\tdenom = Math.sqrt((sum_1_sq-(sum_1**2)/similarity.length)*(sum_2_sq-(sum_2**2)/similarity.length))\n\n\t\tif denom == 0 \n\t\t\treturn 0\n\t\tend\n\t\treturn numerator/denom\n\tend", "def HammingDistance(arr)\n first_str = arr[0].chars\n sec_str = arr[1].chars\n hamm_dis_count = []\n (0..first_str.size).each do |index|\n if first_str[index] != sec_str[index]\n hamm_dis_count << first_str[index]\n end\n end\n hamm_dis_count.size\nend", "def similarity(doc1_id, doc2_id)\n @tfidf ||= calculate\n CosineSimilarity.new.calculate(@tfidf[doc1_id], @tfidf[doc2_id])\n end", "def similarity u1, u2\n u1_r = @usr_rating[u1]\n u2_r = @usr_rating[u2]\n common = u1_r.keys & u2_r.keys\n\n mean_diff = 0\n common.each do |mv|\n mean_diff += diff(u1_r[mv], u2_r[mv]).to_f / common.length\n end\n return ((5 - mean_diff)/5).round(2)\n end", "def score(s, d)\n i, j, k = deflate(s).length, deflate(d).length, deflate(s + d).length\n # how to calculate significance of similarity?\n k < (i + j)\n end", "def fragment_similarity(fragment,other_model)\n other_model.fragment_commonality(fragment) / fragment_commonality(fragment)\n end", "def distance_metric(product1, product2) (get_value(product1) - get_value(product2)).abs end", "def similarity_by_euclidean_for_items(item1, item2, list)\n common_users = find_common_users(item1, item2, list)\n \n result = 0.0\n return result if common_users.size < 1\n \n common_users.each do |u|\n result += (u.rating_for(item1.id) - u.rating_for(item2.id))**2\n end\n result = 1 / (1 + result)\n # result = 1 / (1 + Math.sqrt(result)) TODO: make tests to see the difference\n end", "def similar\n World.similar(self)\n end", "def similar\n World.similar(self)\n end", "def similarity_hash(user_id)\n @movie_database.users(user_id).inject({}) do |user_similarity, user|\n user_similarity.merge({user => similarity(user_id, user)})\n end\n end", "def euclidean_distance(s1, s2)\n d2 = 0.0\n get_features.each do |f|\n if s1.has_key? f and s2.has_key? f\n d2 += (s1[f]-s2[f])**2\n end\n end\n \n Math.sqrt(d2)\n end", "def similarity(user1, user2)\n count = 0\n similar = 0\n #to make a shorter comparison, we loop on the shorter movie list\n if movies(user1).length > movies(user2).length\n u1 = user2\n u2 = user1\n else\n u1 = user1\n u2 = user2\n end\n\n @usermap[u1].each do |m1, r1|\n #if user1 and user2 have both rated one movie m, we compare the rating they made\n #and the difference bewteen these two ratings indicates their similarity. The smaller\n #the difference is, the more similar these users are.\n if @usermap[u2].has_key?(m1)\n count += 1\n similar += 5 - (r1 - @usermap[u2][m1]).abs\n end\n end\n\n if count == 0\n 0\n else\n #we calculate the average to get a more convincing similarity constant\n similar/count.to_f\n end\n end", "def similarity(user1, user2)\n user1Hash = @allUsersHash[user1]\n user2Hash = @allUsersHash[user2]\n return \"ERROR: USER ID #{user1} is not in the database\" if user1Hash.empty?\n return \"ERROR: USER ID #{user2} is not in the database\" if user2Hash.empty?\n find_similarity(user1Hash, user2Hash)\n end", "def cosine_similarity(x1, y1, x2, y2)\n dp = (x1 * x2) + (y1 * y2)\n mag1 = Math.sqrt((x1 ** 2) + (y1 ** 2))\n mag2 = Math.sqrt((x2 ** 2) + (y2 ** 2))\n return 0 if mag1 == 0 || mag2 == 0\n return (dp / (mag1 * mag2))\n end", "def similarities u1\n sims = Hash.new()\n (@usr_rating.keys - [u1]).each do |u2|\n sims.store(u2, similarity(u1, u2))\n end\n return sims\n end", "def similarity(user1,user2)\n\t\tsim = 0\n\t\tfirst_user = @user_set[\"#{user1}\"].sort_by{|k, v| k.to_i}.to_h\n\t\tsecond_user = @user_set[\"#{user2}\"].sort_by{|k, v| k.to_i}.to_h\n\t\tin_common = first_user.keys & second_user.keys\n\t\tin_common.each do |movie|\n\t\t\tif (first_user[movie].to_i.between?(second_user[movie].to_i-1, second_user[movie].to_i+1))\n\t\t\t\tsim += 1\n\t\t\tend\n\t\tend\n\t\treturn sim\n\tend", "def dist_to(operand,k=3)\n matches = 0\n @@counter += 1\n temp_hash = Hash.new\n @word_array[0..k-1].each {|word| temp_hash[word.word] = 1}\n operand.word_array[0..k-1].each {|word| matches += 1 if !temp_hash[word.word].nil? }\n #min_possible_count = [k, @word_array[0..k-1].length, operand.word_array[0..k-1].length].max\n\n dist = k - matches\n #puts \"#{@word_array[0..k-1]}\\n#{operand.word_array[0..k-1]}\\n#{dist}\"\n \n return dist \n end", "def human_distance(other)\n distance_to(other).round(1)\n end", "def sim_distance(preferences, person1, person2)\n have_movies_in_common = preferences[person1].detect {|movie, rating| preferences[person2].keys.include?(movie) }\n \n # if they have no ratings in common, return 0 \n return 0 unless have_movies_in_common\n \n # Add up the squares of all the differences \n sum_of_squares = 0\n preferences[person1].each do |movie, rating| \n sum_of_squares += (rating - preferences[person2][movie])**2 if preferences[person2].keys.include?(movie) \n end\n\n return 1/(1 + sum_of_squares)\nend", "def similarity(user1,user2)\n user1,user2=user2,user1 if user1 > user2\n result=@similarity_cache[[user1,user2]]\n if result.nil?\n result=@similarity_func.call(data,user1,user2)\n @similarity_cache[[user1,user2]]=result\n end\n result\n end", "def get_distance(s1, s2)\n a1 = s1.split(//)\n a2 = s2.split(//)\n\n max, min = s1.size > s2.size ? [a1, a2] : [a2, a1]\n\n range = [(max.size / 2 - 1), 0].max\n indexes = Array.new(min.size, -1)\n flags = Array.new(max.size, false)\n\n matches = 0\n (0...min.size).each do |mi|\n c1 = min[mi]\n ([mi - range, 0].max...[mi + range + 1, max.size].min).each do |i|\n next unless !flags[i] && c1 == max[i]\n\n indexes[mi] = i\n flags[i] = true\n matches += 1\n break\n end\n end\n\n ms1 = Array.new(matches, nil)\n ms2 = Array.new(matches, nil)\n\n si = 0\n (0...min.size).each do |i|\n if indexes[i] != -1\n ms1[si] = min[i]\n si += 1\n end\n end\n\n si = 0\n (0...max.size).each do |i|\n if flags[i]\n ms2[si] = max[i]\n si += 1\n end\n end\n\n transpositions = 0\n (0...ms1.size).each do |mi|\n transpositions += 1 if ms1[mi] != ms2[mi]\n end\n\n prefix = 0\n (0...min.size).each do |mi|\n prefix += 1 if s1[mi] == s2[mi]\n break unless s1[mi] == s2[mi]\n end\n\n if 0 == matches\n 0.0\n else\n m = matches.to_f\n t = (transpositions / 2)\n j = ((m / s1.size) + (m / s2.size) + ((m - t) / m)) / 3.0\n return j < THRESHOLD ? j : j + [0.1, 1.0 / max.size].min * prefix * (1 - j)\n end\n end", "def text_similarity(text,other_model)\n other_model.text_commonality(text) / text_commonality(text)\n end", "def calculate_similarity(other_doc)\n self.terms.inject(0.0) do |dot_product, term|\n dot_product + (self.tfidf(term.word) * other_doc.tfidf(term.word))\n end\n end", "def similarity(another)\n return 0.0 if @type != another.type\n similarity = Resource.compare(before, another.after) * 0.8\n similarity += @name == another.name ? 0.2 : 0\n similarity\n end", "def anagram_distance(word1, word2)\n if word1.length != word2.length\n return -1;\n end\n\n hash = {};\n\n word1.each_char do |ch|\n hash[ch] = hash[ch].nil? ? 1 : hash[ch]+1\n end\n\n word2.each_char do |ch|\n if !hash[ch].nil? && hash[ch] > 0\n hash[ch] -=1\n end\n end\n\n hash.values.sum\nend", "def hamming_distance(arr)\n count = 0\n arr.first.each_char.with_index do |char, idx|\n count += 1 if char != arr.last[idx]\n end\n count\nend", "def similarity(user1, user2, user_rates)\n user1_rate = user_rates[user1]\n user2_rate = user_rates[user2]\n dot_product = user1_rate.reduce(0) { |sum, (k, v)| sum + v * user2_rate[k] }\n user1_magnitude = compute_magnitude(user1_rate)\n user2_magnitude = compute_magnitude(user2_rate)\n dot_product / (user1_magnitude * user2_magnitude)\n end", "def distance\n distance_and_arc[:distance]\n end", "def distance\n distance_and_arc[:distance]\n end", "def distance( s1, s2 )\n input = Input.new( s1, s2 )\n return empty_score( input ) if input.empty?\n score = jaro_distance_internal( input )\n\n if score > boost_threshold then\n score += winkler_score( input, score )\n end\n return score\n end", "def similarity(user1_id, user2_id)\n raise 'At least one user specified does not exist.' unless @movie_database.users_include?(user1_id, user2_id)\n user_common_movies = @movie_database.movies_in_common(user1_id, user2_id)\n\n return 0.0 if user_common_movies.empty? # most common case\n\n rating_sum = user_common_movies.inject(0) { |sum, movie| sum + user_rating_difference(movie, user1_id, user2_id) }\n max_rating_sum = 4 * user_common_movies.length\n 100.0 - (rating_sum.to_f / max_rating_sum.to_f * 100.0).round(1)\n end", "def sentence_similarity(sentence,other_model)\n other_model.sentence_commonality(sentence) / sentence_commonality(sentence)\n end", "def similarity(user1, user2)\n similar_movies_avg = []\n\n #fill in user1_data and user2_data\n #find similar watched movies, remove differences in both lists\n $unique_user_data[user1.to_i - 1].each_key {|movieId, rating|\n if $unique_user_data[user2.to_i - 1].has_key?(movieId)\n similar_movies_avg.push((rating.to_i - $unique_user_data[user2.to_i - 1][movieId].to_i).abs)\n end\n }\n #find average\n return similar_movies_avg.inject{ |sum, el| sum + el }.to_f / similar_movies_avg.size\n end", "def similarity(u1,u2)\n\t\tsimilarity=0\n\t\[email protected]_movie_by_user(u1,:base)\n\t\[email protected]_movie_by_user(u2,:base)\n\t\twatched_u1.each do |movie,rate|\n\t\t\tif watched_u2.has_key?(movie)\n\t\t\t\tsimilarity+=5-(watched_u2[movie].to_i-watched_u1[movie].to_i).abs\n\t\t\tend\n\t\tend\n\t\treturn similarity\n\tend", "def hamming(array1, array2)\n m11, m10, m01, m00 = binary_compare(array1, array2)\n d = m10 + m01\n return :hamming, d \nend", "def calculate_distance(translated_text, answer)\n DamerauLevenshtein.distance(prepare(translated_text), prepare(answer))\n end", "def similarity(other, *args)\n signature.similarity(other.signature, *args)\n end", "def most_similar(u)\t\n\t\t@simhash = @userhash.reject{|x| x==u}.map{|user,_| [user,similarity(u,user)]}.sort_by{|_,v| -v}.first 10\n\tend", "def similarity_for_items(item1, item2, list = nil)\n # cache disabled\n # cached_sim = get_cached_similarity_for item1, item2\n # return cached_sim if cached_sim\n sim = 0.0\n case SIMILARITY_METHOD\n when 'euclidean'\n sim = similarity_by_euclidean_for_items item1, item2, list\n when 'pearson'\n sim = similarity_by_pearson_for_items item1, item2, list\n when 'jaccard'\n sim = similarity_by_jaccard_for_items item1, item2, list\n end\n sim.round(5)\n #set_similarity_cache_for item1, item2, sim\n end", "def get_cached_similarity_for(item1, item2)\n @cached_similarities[\"#{item1}_#{item2}\"] || @cached_similarities[\"#{item2}_#{item1}\"]\n end", "def recalculate_similarity\n query_one = Like.select(:user_id).where(product_id: product_one_id).order('user_id asc').to_sql\n query_two = Like.select(:user_id).where(product_id: product_two_id).order('user_id asc').to_sql\n user_ids_one = ActiveRecord::Base.connection.execute(query_one).column_values(0)\n user_ids_two = ActiveRecord::Base.connection.execute(query_two).column_values(0)\n intersection = (user_ids_one & user_ids_two).size\n union = (user_ids_one | user_ids_two).size\n \n if intersection == 0 || union == 0\n self.similarity = 0\n else\n self.similarity = intersection.to_f / union.to_f\n end\n self.save\n end", "def distance_measurement; end", "def str_distance(str1, str2)\n ans = str_distance_helper(str1, str2)\n @dist_cache = Hash.new { |hash, key| hash[key] = {} }\n ans\n end", "def similarity_score(classification, text)\n similarity_score_for_features(classification, features_of(text))\n end", "def jaro_distance(s1, s2)\n result = C::jaro_distance(s1, s2)\n raise(\"memory allocation error\") if result < 0.0\n result\n end", "def levenshtein_similarity_to(other)\n String::Similarity.levenshtein(self, other)\n end", "def distance(m1, m2)\n n = m1.size\n sum = 0.0\n n.times do |i|\n n.times do |j|\n dif = m2[i][j] - m1[i][j]\n sum += dif * dif\n end\n end\n sum\nend" ]
[ "0.7249526", "0.68237704", "0.6807329", "0.6580053", "0.65625024", "0.65555805", "0.6479773", "0.647514", "0.6463074", "0.645051", "0.6417677", "0.6417677", "0.6414233", "0.63889927", "0.6383619", "0.6331813", "0.6316473", "0.6313823", "0.6295776", "0.6278993", "0.62774575", "0.6260414", "0.6247488", "0.62269306", "0.6198839", "0.61696327", "0.6169456", "0.61521757", "0.6127736", "0.6118347", "0.6111252", "0.6106298", "0.61040866", "0.61006105", "0.6091166", "0.60907465", "0.606335", "0.6058132", "0.60395014", "0.60198975", "0.60134095", "0.60105157", "0.6005633", "0.60010886", "0.59987915", "0.5994399", "0.5966646", "0.59657735", "0.59655917", "0.59612423", "0.59504765", "0.59461355", "0.59028536", "0.58804846", "0.5862979", "0.58616287", "0.58563954", "0.5816183", "0.5804974", "0.5797659", "0.57909006", "0.57909006", "0.57869965", "0.5777958", "0.577513", "0.5742116", "0.5714259", "0.57059246", "0.5702072", "0.5691823", "0.5691194", "0.56886905", "0.56832904", "0.5662616", "0.5659349", "0.56496644", "0.5641001", "0.5640635", "0.5616097", "0.5613269", "0.56087816", "0.56087816", "0.56049097", "0.5594588", "0.55885595", "0.5583754", "0.5577479", "0.5558172", "0.5529611", "0.55281925", "0.55279833", "0.5524998", "0.5523685", "0.55226505", "0.5499874", "0.5492128", "0.54880553", "0.54824877", "0.54804903", "0.5462573" ]
0.6478651
7
Use callbacks to share common setup or constraints between actions.
def set_participation @participation = Participation.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 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 setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def 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 startcompany(action)\n @done = true\n action.setup\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 setup\n #implement in subclass;\n end", "def after_set_callback; 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 setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; 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 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 shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.53314966", "0.53114754", "0.52984965", "0.52977055", "0.5296272", "0.5260649", "0.5245076", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.5235081", "0.52321917", "0.5228592", "0.5220735", "0.52198535", "0.52139324", "0.5208539", "0.5206585", "0.5178542", "0.5175199", "0.5173538", "0.5167041", "0.51614195", "0.51577675", "0.5153909", "0.51528823", "0.5152225", "0.51429904", "0.5141399", "0.51345575", "0.51145", "0.5114052", "0.5114052", "0.5110216", "0.5108656", "0.50935394", "0.5089196", "0.5081936", "0.5079627", "0.50675833", "0.5056105", "0.5053687", "0.5050475", "0.5050475", "0.503471", "0.5028311", "0.501982", "0.50157547", "0.5013552", "0.50014806", "0.50011593", "0.49976763", "0.4990292", "0.4990292", "0.49882022", "0.4981269", "0.49792367", "0.49766538", "0.4967978", "0.49667212", "0.4958987", "0.49572337", "0.49550423", "0.4954479", "0.4952353", "0.494726", "0.4944055", "0.4935437", "0.4931248", "0.49283475", "0.49281213", "0.49268973", "0.4921738", "0.49204507", "0.4918924", "0.49182287", "0.4916538", "0.49158585", "0.49156788" ]
0.0
-1
list of numbers, and returns a new Array that contains the product of each pair of numbers from the arguments that have the same index. You may assume that the arguments contain the same number of elements.
def multiply_list(arr1, arr2) new_array = [] index = 0 while index < arr1.size new_array << arr1[index] * arr2[index] index += 1 end new_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pair_product(arr, num) \n\nend", "def multiply_all_pairs(arr_1, arr_2)\n arr_1.product(arr_2).map { |arr| arr.reduce(&:*) }.sort\nend", "def multiply_list(numbers1, numbers2)\n products = []\n numbers1.each_with_index do |num, ind|\n products << num * numbers2[ind]\n end\n products\nend", "def multiply_all_pairs(arry1, arry2)\n arry3 = arry1.product(arry2)\n\n arry3.map do |arr|\n arr.reduce(:*)\n end.sort\nend", "def multiply_all_pairs(array_1, array_2)\n array_1.product(array_2).map { |num1, num2| num1 * num2 }.sort\nend", "def multiply_all_pairs(array_1, array_2)\n array_1.product(array_2).map { |num1, num2| num1 * num2 }.sort\nend", "def multiply_all_pairs(array_1, array_2)\n array_1.product(array_2).map { |num1, num2| num1 * num2 }.sort\nend", "def multiply_all_pairs(array_1, array_2)\n array_1.product(array_2).map { |num1, num2| num1 * num2 }.sort\nend", "def multiply_all_pairs(arr1, arr2)\n p arr1.product(arr2).map { |num1, num2| num1 * num2 }.sort\nend", "def multiply_list(arr1, arr2)\n [arr1, arr2].transpose.map do |pair|\n pair.reduce(:*)\n end\nend", "def multiply_all_pairs(arr1, arr2)\n arr1.product(arr2).map {|combined_array| combined_array.inject(:*)}.sort\nend", "def multiply_all_pairs(arr1, arr2)\n arr1.product(arr2).map { |sub_arr| sub_arr.reduce(:*) }.sort\nend", "def multiply_all_pairs(arr1, arr2)\n arr1.product(arr2).map { |sub_arr| sub_arr.reduce(:*) }.sort\nend", "def multiply_all_pairs(array1, array2)\n array1.product(array2).map { |subarray| subarray.inject(:*) }.sort\nend", "def combine(*args)\n if args.all? {|x| x.is_a? Array}\n para = args.shift\n args.each do |x|\n para = para.product(x)\n end\n para.map {|x| x.flatten(1)}\n else\n raise ArgumentError, 'All arguments must be Array'\n end\n end", "def multiply_all_pairs(array1, array2)\n array1.product(array2).map { |num1, num2| num1 * num2 }.sort\nend", "def get_product_integers(array_of_integers)\n\n results = []\n array_of_integers.each_with_index do |num1,index1|\n product = 1\n array_of_integers.each_with_index do |num2,index2|\n next if index1 == index2\n product *= num2\n end\n results << product\n end\n p results\n\n end", "def multiply_list(arr1, arr2)\n arr1.zip(arr2).map { |pair| pair.reduce(:*) }.flatten\nend", "def multiply_all_pairs(num_arr1, num_arr2)\n product_arr = []\n\n num_arr1.each do |x|\n num_arr2.each do |y|\n product_arr << x * y\n end\n end\n product_arr.sort\nend", "def products_except_me(numbers)\n numbers.map.with_index do |num, idx|\n sub_arr = numbers[0...idx] + numbers[idx + 1..-1]\n sub_arr.reduce(:*)\n end\nend", "def multiply_all_pairs(array_1, array_2)\n array_1.product(array_2).map {|item_1, item_2| item_1 * item_2 }.sort\nend", "def multiply_list(array1, array2)\n result = []\n array1.each_with_index do |num, index|\n result.push(num * array2[index])\n end\n \nresult\n \n \n \nend", "def multiply_all_pairs(array1, array2)\n # using 2 loops\n # products = []\n # array_1.each do |item_1|\n # array_2.each do |item_2|\n # products << item_1 * item_2\n # end\n # end\n # products.sort\n array1.product(array2).map { |subarray| subarray.reduce(:*) }.sort\nend", "def product(*args)\n args.map! { |x| Rubinius::Type.coerce_to(x, Array, :to_ary) }\n\n # Check the result size will fit in an Array.\n sum = args.inject(size) { |n, x| n * x.size }\n\n if sum > Fixnum::MAX\n raise RangeError, \"product result is too large\"\n end\n\n # TODO rewrite this to not use a tree of Proc objects.\n\n # to get the results in the same order as in MRI, vary the last argument first\n args.reverse!\n\n result = []\n args.push self\n\n outer_lambda = args.inject(result.method(:push)) do |trigger, values|\n lambda do |partial|\n values.each do |val|\n trigger.call(partial.dup << val)\n end\n end\n end\n\n outer_lambda.call([])\n\n result\n end", "def multiply_list(arr1, arr2)\n result = []\n arr1.each_with_index { |num, idx| result << num * arr2[idx] }\n result\nend", "def integer_products integers\n\t# use each with index to loop through integers and find product of all other integers\n\t# better solution:\n\t# create an array that corresponds to the product of each integer before each index, and an array of the product of each integer after each index\n\tproduct_so_far = 1\n\tproducts_before_index = []\n\tintegers.each_with_index do |int, index|\n\t\tproducts_before_index[index] = product_so_far\n\t\tproduct_so_far*= integers[index]\n\tend\n\n\tproducts_after_index = []\n\tproduct_so_far = 1\n\ti = integers.length - 1\n\twhile i >= 0\n\t\tproducts_after_index[i] = product_so_far\n\t\tproduct_so_far*= integers[i]\n\t\ti-= 1\n\tend\n\n\treturn [products_before_index, products_after_index]\n\nend", "def multiply_list(array1, array2)\n results = []\n n = 0\n\n array1.size.times do |num|\n results << array1[n]*array2[n]\n n += 1\n end\n\n results\nend", "def products_except_me(numbers)\n numbers.map.with_index do |num,idx|\n sub_array=numbers[0...idx] + numbers[idx+1..-1]\n array_product(sub_array)\n end\nend", "def product_array(input_array)\n return_array = []\n input_array.each_with_index do |x, i|\n # puts \"x is #{x} and i is #{i}\"\n product = 1\n input_array.each_with_index do |y,j|\n if i!=j\n product *= y\n end\n end\n return_array << product\n end\n return return_array\nend", "def calculate_products_of_all_other_elements(nums)\n product_of_other_elements = Array.new(nums.count, 1)\n\n nums.count.times do |i|\n nums.count.times do |j|\n next if i == j\n\n product_of_other_elements[i] = product_of_other_elements[i] * nums[j]\n end\n end\n\n product_of_other_elements\nend", "def multiply_list(array1, array2)\n result = []\n array1.each_index { |index| result << array1[index] * array2[index]}\n result\nend", "def multiply_list(array_1, array_2)\n result = []\n\n array_1.each_with_index do |num, index|\n result << num * array_2[index]\n end\n result\nend", "def product_array(num_array)\n product_arr = []\n num_array.each_with_index do |num1, i|\n product = 1\n num_array.each_with_index do |num2, j|\n product *= num2 unless i == j\n end\n product_arr.push(product)\n end\n product_arr\nend", "def prod_arr(x)\n len = x.length\n product = Array.new(len,1)\n\n for i in 0...len\n for j in 0...len\n next if i == j\n product[i] *= x[j]\n end\n end\n return product\nend", "def multiply_list(array_1, array_2)\n results = []\n array_1.each_with_index {|num,idx| results << (num * array_2[idx])}\n results\nend", "def multiply_all_pairs(array1, array2)\n array1.product(array2).map { |x,y| x * y }.sort\nend", "def get_other_products(nums)\n nums_copy = nums.dup\n other_products = Array.new(nums.length)\n\n nums.each_with_index do | num, curr_idx |\n nums_copy.delete_at(curr_idx)\n other_products[curr_idx] = nums_copy.reduce(:*)\n nums_copy = nums.dup\n end\n return other_products\nend", "def cart_prod(*args)\n final_output = [[]]\n until args.empty?\n t, final_output = final_output, []\n b, *args = args\n t.each { |a|\n b.each { |n|\n final_output << a + [n]\n }\n }\n end\n final_output\nend", "def multiply_list(array_1, array_2)\n result = []\n array_1.size.times do |index|\n result << array_1[index] * array_2[index]\n end\n result\nend", "def multiply_all_pairs2(arr1, arr2)\n arr1.product(arr2).map { |a, b| a * b }.sort\nend", "def multiply_all_pairs(array1, array2)\r\n result = []\r\n\r\n product =\r\n array1.each do |element|\r\n array2.each do |element2|\r\n result << element * element2\r\n end\r\n end\r\n\r\n result.sort\r\nend", "def multiply_all_pairs(arr1, arr2)\n products = []\n arr1.each do |arr1_num|\n arr2.each do |arr2_num|\n products << arr1_num * arr2_num\n end\n end\n products.sort\nend", "def multiply_list(arr1, arr2)\n result = []\n\n arr1.each_with_index { |_, index| result << (arr1[index] * arr2[index]) }\n\n result\nend", "def pairwise_product(other)\n result = []\n each_index {|i| result << self[i]*other[i] }\n return result\n end", "def multiply_all_pairs(array1, array2)\n products = []\n array1.each do |num1|\n array2.each do |num2|\n products << num1 * num2\n end\n end\n products.sort\nend", "def products_except_me(numbers)\n\n result = []\n numbers.each_index do |i|\n subarr = numbers[0...i] + numbers[i+1..-1]\n result << subarr.reduce(:*)\n\n end\n result\nend", "def multiply_list(arr1, arr2)\n arr1.zip(arr2).map { |arr| arr.inject(:*) }\nend", "def multiply_all_pairs(array_1, array_2)\n results = []\n\n array_1.each do |arr_1_num|\n array_2.each {|arr_2_num| results << (arr_1_num * arr_2_num)}\n end\n results.sort\nend", "def multiply_list(arr1, arr2)\n results = []\n arr1.each_with_index do |item, index|\n results << item * arr2[index]\n end\n results\nend", "def multiply_all_pairs(array_1, array_2)\n result = []\n\n array_1.each do |current_number_array_1|\n array_2.each do |current_number_array_2|\n result << current_number_array_1 * current_number_array_2\n end\n end\n\n result.sort\nend", "def arr_product(arr)\n product = arr.reduce(:*)\n arr.map { |el| product / el }\nend", "def multiply_all_pairs(arr1, arr2)\n\tproducts = []\n\n\tarr1.each do |num1|\n\t\tarr2.each do |num2|\n\t\tproducts << num1 * num2\n\t\tend\n\tend\n\tproducts.sort\nend", "def multiply_list(arr1, arr2)\n new_arr = []\n arr1.size.times do |ind|\n new_arr << arr1[ind] * arr2[ind]\n end\n new_arr\nend", "def multiply_list(array1, array2)\n array1.each_with_index.map do |current_integer, index|\n current_integer * array2[index]\n end\nend", "def multiply_all_pairs(array_1, array_2)\n products = []\n array_1.each do |item_1|\n array_2.each do |item_2|\n products << item_1 * item_2\n end\n end\n products.sort\nend", "def multiply_list(arr, arr1)\n arr.zip(arr1).map {|a, b| a.send(:*, b)}\nend", "def multiply_all_pairs(nums1, nums2)\n products = []\n nums1.each do |num1|\n nums2.each do |num2|\n products << num1 * num2\n end\n end\n products.sort\nend", "def multiply_list(arr1, arr2)\n arr1.zip(arr2).map{|sub_arr| sub_arr.inject(:*)}\nend", "def multiply_all_pairs(list1, list2)\n list1.product(list2).map { |num1, num2| num1 * num2 }.sort\nend", "def multiply_all_pairs(arr1, arr2)\n result = []\n arr1.each { |num1| arr2.each { |num2| result << num1 * num2}}\n result.sort\nend", "def element_times_index(numbers)\n\tmulti = []\n \n\ti = 0\n\twhile i < numbers.length\n\t\titem = numbers[i]*i\n\t\tmulti << item\n\t\ti += 1\n end\n\n\treturn multi\nend", "def product(numbers)\n numbers.reduce(1) { |acc, x| acc * x }\nend", "def multiply_all_pairs(arr1, arr2)\n product = []\n count = 0\n\n until count == arr1.size\n arr2.each do |item|\n product << arr1[count] * item\n end\n count +=1\n end\n product.sort\nend", "def multiply_all_pairs(array1, array2)\n products = []\n array1.each do |item1|\n array2.each do |item2|\n products << item1 * item2\n end\n end\n products.sort\nend", "def multiply_list(array1, array2)\n array1.zip(array2).map { |subarr| subarr.reduce(:*) }\nend", "def multiply_all_pairs(array1, array2)\n result = []\n\n array1.each do |num|\n array2.each do |num2|\n result << num2 * num\n end\n end\n result.sort\nend", "def multiply_all_pairs(a1, a2)\n product_array = []\n a1.each do |a1_elem|\n a2.each do |a2_elem|\n product_array << a1_elem * a2_elem\n end\n end\n product_array.sort\nend", "def multiply_all_pairs(numbers1, numbers2)\n products = []\n numbers1.each do |num1|\n numbers2.each { |num2| products << num1 * num2 }\n end\n products.sort\nend", "def product_method(array)\n array.reduce(:*)\nend", "def multiply_list(arr1, arr2)\n new_arr = []\n arr1.each_with_index do |num, index| \n new_arr << num * arr2[index] \n end\n p new_arr\nend", "def multiply_list(arr1, arr2)\n # mult_arr = Array.new(arr1.size)\n # mult_arr.map.with_index { |_, i| arr1[i] * arr2[i] }\n\n # one-liner using Array#zip:\n arr1.zip(arr2).map { |arr| arr.reduce(:*) }\nend", "def multiply_list(arr1, arr2)\r\nresult = []\r\ncounter = 0\r\n\r\narr1.length.times do |num|\r\n result << arr1[counter] * arr2[counter]\r\n counter += 1\r\nend\r\np result\r\nend", "def multiply_all_pairs(first_arr, second_arr)\n result = []\n first_arr.each do |item|\n second_arr.each { |multiplyer| result << item * multiplyer }\n end\n result.sort\nend", "def product(numbers)\n numbers.inject(1) { |result, num| num.is_a?(Numeric) ? result * num : result }\n end", "def multiply_all_pairs(arr1, arr2)\n result = []\n arr1.each do |num1|\n arr2.each { |num2| result << num1 * num2 }\n end\n result.sort\nend", "def array_product_bruteforce(a)\r\n\tprod = Array.new(a.size)\r\n\ti = 0\r\n\r\n\twhile i < a.size\r\n\t\tc = a[0..a.size]\r\n\t\tc.delete_at(i)\r\n\t\tprod[i] = c.inject(:*)\r\n\t\ti += 1\r\n\tend\r\n\treturn prod\r\nend", "def multiply_lists(arr1, arr2)\n result = []\n index = 0\n loop do \n result << arr1[index]*arr2[index]\n index += 1\n break if index == arr1.size\n end \n result\nend", "def multiply_all_pairs(arr1, arr2)\n arr1.map { |num1| arr2.map { |num2| num1 * num2 } }.flatten.sort\nend", "def multiply_all_pairs(arr1, arr2)\n final = []\n arr1.each do |n1|\n arr2.each do |n2|\n final << n1 * n2\n end\n end\n final.sort\nend", "def array_element_mult(array_a, array_b)\n array_a.zip(array_b).map {|x,y| x*y}\n end", "def multiply_list(arr1, arr2)\n # arr = []\n # arr1.each_with_index { |elem, i| arr << elem * arr2[i] }\n # arr\n arr1.zip(arr2).map { |sub_arr| sub_arr.reduce(:*) }\nend", "def products_of_all_other_nums(array)\n\n\tresult = Array.new() { [] }", "def multiply_all_pairs(arr1, arr2)\n arr1.map do |num1| \n arr2.map { |num2| num1 * num2 }\n end.flatten.sort\nend", "def product\n reduce(1, &:*)\n end", "def custom_multiply(array, number)\n result = []\n number.times { array.each { |element| result << element}}\n result\nend", "def multiply_list(arry1, arry2)\n index = 0\n arry3 = []\n\n while index < arry1.length\n arry3 << arry1[index] * arry2[index]\n index += 1\n end\n arry3\nend", "def multiply_list(arr1, arr2)\n products_arr = []\n idx = 0\n until idx >= arr1.length\n products_arr << arr1[idx] * arr2[idx]\n idx += 1\n end\n products_arr\nend", "def multiply_all_pairs(arr1, arr2)\n result_array = []\n arr1.each do |num1|\n arr2.each do |num2|\n result_array << num1 * num2\n end\n end\n result_array.sort\nend", "def multiply_list(array1, array2)\n array1.map.with_index { |_, i| array1[i] * array2[i] }\nend", "def multiply_arrnums_by_index(numbers) # array of ints\n new_array = [] # empty array\n i = 0 # start at indice 0\n while i < numbers.length\n new_array << numbers[i] * i # shovel value of int val of the indice * the indice\n # numb_to_mult = numbers[i]\n # numb_multd = numbers[i] * numb_to_mult\n # new_array << numb_multd\n i += 1 # next iteration\n end\n return new_array\nend", "def multiply_me(array, int)\r\n\r\n arr = [] # empty array created\r\n\r\n i = 0 # iteration starts to multiply each item\r\n while i < array.length\r\n arr << array[i] * int # products collected\r\n i += 1\r\n end\r\n\r\n arr # result\r\nend", "def multiple(*nums)\n nums.inject(:*)\nend", "def multiply_list(array1, array2)\n new_array = []\n array1.count.times do \n new_array << (array1.pop) * (array2.pop)\n end\n new_array.reverse\nend", "def product_array(a)\n len=a.length\n product=Array.new(len,1) # Initilaize product array elements to 1\n temp=1\n\n #Loop to store product of left elements\n for i in 0...len\n product[i]=temp\n temp*=a[i]\n end\n\n temp=1 #reset temp variable to 1\n\n #Loop to multiply stored left products with right products\n for i in (len-1).downto(0)\n product[i]*=temp\n temp*=a[i]\n end\n\n return product\nend", "def multiply_list(arr1, arr2)\n arr1.zip(arr2).map {|a, b| a * b }\nend", "def multiply_list(arr1, arr2)\n arr1.zip(arr2).map {|a, b| a * b }\nend", "def multiply_all_pairs(array1, array2)\n all_multiples = []\n\n array1.each do |arry1_el|\n array2.each do |arry2_el|\n all_multiples << arry2_el * arry1_el\n end\n end\n\n all_multiples.sort\nend", "def multiply_all_pairs(array1, array2)\n new_array = []\n array1.each do |x|\n array2.each do |y|\n new_array << x * y\n end\n end\n new_array.sort\nend", "def multiply_list(arr1, arr2)\n products = []\n counter = 0\n\n loop do\n products << (arr1[counter] * arr2[counter])\n\n counter += 1\n break if counter == arr1.length\n end\n\n products\nend" ]
[ "0.7583335", "0.72570467", "0.720952", "0.7183639", "0.7179565", "0.7179565", "0.7179565", "0.7179565", "0.71789443", "0.71599126", "0.71469074", "0.7145325", "0.7145325", "0.71430737", "0.7142083", "0.7137819", "0.70929086", "0.70840955", "0.70671356", "0.7058998", "0.70489544", "0.7044279", "0.7040809", "0.70368165", "0.70202196", "0.6999864", "0.6990857", "0.698629", "0.69843334", "0.6981205", "0.6978418", "0.6973514", "0.69722134", "0.6970609", "0.6963956", "0.6958381", "0.69528306", "0.69359845", "0.69338155", "0.6926498", "0.6924002", "0.6922787", "0.6921464", "0.6918891", "0.69052655", "0.68996185", "0.6895573", "0.6888604", "0.68823135", "0.6881521", "0.68564284", "0.6851898", "0.684873", "0.68479216", "0.6845151", "0.6841603", "0.6835904", "0.6812825", "0.68124866", "0.68082386", "0.6802823", "0.67998236", "0.6796089", "0.67941225", "0.67939675", "0.67937905", "0.67926174", "0.6791609", "0.6787827", "0.6776509", "0.6757238", "0.6753756", "0.67537445", "0.6745108", "0.67372483", "0.67352796", "0.6735033", "0.6713175", "0.6711712", "0.6707752", "0.67062724", "0.6702398", "0.6689178", "0.66769356", "0.66618377", "0.66532904", "0.66416293", "0.6633151", "0.6611556", "0.66068447", "0.6586749", "0.65836644", "0.6583194", "0.6580893", "0.6576762", "0.6576762", "0.65729576", "0.6571325", "0.65585214" ]
0.65666217
99
Strips all HTML tags out of the given string.
def strip_html(string) # FIXME will need something more sophisticated than this, because it sucks string.gsub(/<[^>]*(>+|\s*\z)/m, '').strip end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_tags(str)\n str.gsub(/\\</, \"&lt;\").gsub(/\\>/, \"&gt;\").gsub(/\\&/, \"&amp;\")\n end", "def strip_html(string=\"\")\n begin\n string = strip_tags(string)\n string = string.gsub(/<\\/?[^>]*>/, \"\")\n string = string.gsub(/\\&+\\w*\\;/, \" \") # replace &nbsp; with a space\n string.html_safe\n rescue\n raw(\"<!-- error stripping html from: #{string} -->\")\n end\n end", "def strip_tags(html); end", "def strip_tags(html); end", "def strip_tags(html); end", "def strip_html_tags(text)\n return text.gsub!(/(<[^>]*>)|\\n|\\t/s) {\" \"}\n end", "def strip_html(string=\"\")\n begin\n string = string.gsub(/<\\/?[^>]*>/, \"\")\n string = string.gsub(/\\&+\\w*\\;/, \" \") # replace &nbsp; with a space\n string.html_safe\n rescue\n raw(\"<!-- error stripping html from: #{string} -->\")\n end\n end", "def strip_html(string=\"\")\n begin\n string = string.gsub(/<\\/?[^>]*>/, \"\")\n string = string.gsub(/\\&+\\w*\\;/, \" \") # replace &nbsp; with a space\n string.html_safe\n rescue\n raw(\"<!-- error stripping html from: #{string} -->\")\n end\n end", "def strip_tags(string)\n if defined?(Loofah)\n # Instead of strip_tags we will use Loofah to strip tags from now on\n Loofah.fragment(string).text(encode_special_chars: false)\n else\n helpers.strip_tags(string)\n end\n end", "def rm_single_tags(str)\n str.gsub(/<[^<>]*\\/>/, \"\")\n end", "def strip_html(str)\n str.gsub HTML_TAG, \"\" if str\n end", "def wp_strip_all_tags(string, remove_breaks = false)\n string = string.gsub(/<(script|style)[^>]*?>.*?<\\/\\\\1>/, '')\n string = strip_tags(string)\n\n if remove_breaks\n string = string.gsub(/[\\r\\n\\t ]+/, ' ')\n end\n string.strip\n end", "def strip_tags(html)\n Sanitize.clean(html.strip).strip\n end", "def strip_tags(html)\n Sanitize.clean(html.strip).strip\n end", "def strip_tags string\n string.gsub(/<\\/?[^>]*>/, \"\")\nend", "def ensure_no_tags(str)\n return str unless str.html_safe?\n \n str = str.to_str # get it out of HTMLSafeBuffer, which messes things up\n str = strip_tags(str) \n\n str = HTMLEntities.new.decode(str)\n\n return str\n end", "def strip_tags(html)\n return html if html.blank?\n if html.index(\"<\")\n text = \"\"\n tokenizer = ::HTML::Tokenizer.new(html)\n while token = tokenizer.next\n node = ::HTML::Node.parse(nil, 0, 0, token, false)\n # result is only the content of any Text nodes\n text << node.to_s if node.class == ::HTML::Text\n end\n # strip any comments, and if they have a newline at the end (ie. line with\n # only a comment) strip that too\n text.gsub(/<!--(.*?)-->[\\n]?/m, \"\")\n else\n html # already plain text\n end\n end", "def strip_tags(html)\n strip(Sanitize.clean(html, :elements => [], :attributes => []))\n end", "def strip_tags(html)\n html.gsub(/<\\/?[^>]*>/, \"\") if html\n end", "def strip_tags(html)\n # First we need to get rid of any embedded code.\n html = strip_embedded(html)\n\n # Remove comments\n html = html.gsub(/<!--.*?--\\s*>/m, \"\\xEF\\xBF\\xBC\")\n\n # SGML Declarations\n html = html.gsub(/<!.*?>/m, \"\\xEF\\xBF\\xBC\")\n\n # Remove script and css blocks\n html = html.gsub(/<script.*?>.*?<\\/script>/m, \"\\xEF\\xBF\\xBC\")\n html = html.gsub(/<style.*?>.*?<\\/style>/m, \"\\xEF\\xBF\\xBC\")\n\n # Strip html tags\n html = html.gsub(/<\\/? # opening tag with optional slash\n (\n [^<>\"'] | # match anything unquoted\n \".*?\" | # match double quotes…\n '.*?' # and single ones\n )* # any combination of the three\n > # close tag\n /xm, \"\\xEF\\xBF\\xBC\") # placeholder\n\n # Handle placeholders\n html = html.gsub(/^[ \\t]*\\xEF\\xBF\\xBC[ \\t]*(\\n|\\r|\\r\\n)/xm, '') # Remove lines with only tags\n html = html.gsub(/\\xEF\\xBF\\xBC/xm, '') # Remove other placeholders\n return html\nend", "def strip_html_tags!\n @raw.gsub!(/<[^>]+?>/, ' ')\n end", "def strip_and_convert(str)\n CGI.unescapeHTML(strip_tags(str))\n end", "def strip_html(text)\n unless text.nil?\n strip_tags(text)\n end\n end", "def strip_html\n gsub(HTML_TAG_PATTERN, \"\")\n end", "def strip_html (s)\ns.gsub(/<[^>]*(>+|\\s*\\z)/m, '');\nend", "def strip_tags_delicately\n self.gsub(/<.[^<]*>/, ' ')\n end", "def strip_html(param_string)\n param_string.gsub!('<', '&lt;')\n param_string.gsub!('>', '&gt;')\n param_string.gsub(/\\\"/,\"&quot;\")\n return param_string\n end", "def strip_html( html )\n html.gsub(/<\\/?[^>]*>/, '')\n end", "def clean_html_string(string)\n string.\n inner_text.\n gsub(/\\s+/, \" \").\n strip\n end", "def sanitize_text(text)\n doc = Nokogiri::HTML.fragment(text)\n UNSUPPORTED_HTML_TAGS.each do |tag|\n doc.search(tag).each(&:remove)\n end\n doc.inner_html\n end", "def strip_dangerous_html_tags(allowed_tags = 'a|span|strong|b|img|i|s|p|br|h1|h2|h3|h4|h5|h6|blockquote|footer', attributes = {'img' => ['src', 'alt'], 'a' => ['href', 'title', 'target']})\n if allowed_tags.present?\n Sanitize.fragment(self, {elements: allowed_tags.split('|'), attributes: attributes})\n else\n self.gsub('<', \"&lt;\").gsub('>', \"&gt;\")\n end\n end", "def html_remove\n gsub(/<\\/?[^>]+>/, '')\n end", "def clean_html(str)\n\t str = str.gsub(/<script(.*)>(.*)<\\/script>/i, \"\")\n\t str = str.gsub(/<frame(.*)>(.*)<\\/frame>/i, \"\")\n\t str = str.gsub(/<iframe(.*)>(.*)<\\/iframe>/i, \"\")\n\t\n\t return str\n end", "def strip_tags(line)\n line.gsub(/<\\/?[^>]*>/, \"\")\n end", "def sanitize(text)\n text.gsub('<', '&lt;').gsub('>', '&gt;')\n end", "def strip_html(str,allow=['dm','dl'])\n str = str.strip || ''\n allow_arr = allow.join('|') << '|\\/'\n str.gsub(/<(\\/|\\s)*[^(#{allow_arr})][^>]*>/,'').strip\n end", "def strip_bbcode(string); end", "def unescapeHTML(string)\n\tstr = string.dup\n\tstr.gsub!(/&(.*?);/n) {\n\t\tmatch = $1.dup\n\t\tcase match\n\t\t\twhen /\\Aamp\\z/ni then '&'\n\t\t\twhen /\\Aquot\\z/ni then '\"'\n\t\t\twhen /\\Agt\\z/ni then '>'\n\t\t\twhen /\\Alt\\z/ni then '<'\n\t\t\twhen /\\A#(\\d+)\\z/n then Integer($1).chr\n\t\t\twhen /\\A#x([09af]+)\\\n\t\t\tz/ni then $1.hex.chr\n\t\tend\n\t\t}\n\tstr\nend", "def reverse_html_tags\n self.gsub('&lt;', \"<\").gsub('&gt;', \">\")\n end", "def xhtml_sanitize(html)\n return html unless sanitizeable?(html)\n tokenizer = HTML::Tokenizer.new(html.to_utf8)\n results = []\n\n while token = tokenizer.next\n node = XHTML::Node.parse(nil, 0, 0, token, false)\n results << case node.tag?\n when true\n if ALLOWED_ELEMENTS.include?(node.name)\n process_attributes_for node\n node.to_s\n else\n node.to_s.gsub(/</, \"&lt;\").gsub(/>/, \"&gt;\")\n end\n else\n node.to_s.unescapeHTML.escapeHTML\n end\n end\n\n results.join\n end", "def strip_style_tag (s)\ns.gsub(/<style.*<\\/style>/i, '');\nend", "def sanitize_html( html, okTags='' )\n\n return if html.blank?\n\n # no closing tag necessary for these\n soloTags = [\"br\",\"hr\"]\n\n # Build hash of allowed tags with allowed attributes\n tags = okTags.downcase().split(',').collect!{ |s| s.split(' ') }\n allowed = Hash.new\n tags.each do |s|\n key = s.shift\n allowed[key] = s\n end\n\n # Analyze all <> elements\n stack = Array.new\n result = html.gsub( /(<.*?>)/m ) do | element |\n if element =~ /\\A<\\/(\\w+)/ then\n # </tag>\n tag = $1.downcase\n if allowed.include?(tag) && stack.include?(tag) then\n # If allowed and on the stack\n # Then pop down the stack\n top = stack.pop\n out = \"</#{top}>\"\n until top == tag do\n top = stack.pop\n out << \"</#{top}>\"\n end\n out\n end\n\n elsif element =~ /\\A<(\\w+)\\s*\\/>/\n # <tag />\n tag = $1.downcase\n if allowed.include?(tag) then\n \"<#{tag} />\"\n end\n\n elsif element =~ /\\A<(\\w+)/ then\n # <tag ...>\n tag = $1.downcase\n if allowed.include?(tag) then\n if ! soloTags.include?(tag) then\n stack.push(tag)\n end\n if allowed[tag].length == 0 then\n # no allowed attributes\n \"<#{tag}>\"\n else\n # allowed attributes?\n out = \"<#{tag}\"\n while ( $' =~ /(\\w+)=(\"[^\"]+\")/ )\n attr = $1.downcase\n valu = $2\n if allowed[tag].include?(attr) then\n out << \" #{attr}=#{valu}\"\n end\n end\n out << \">\"\n end\n end\n end\n end\n\n # eat up unmatched leading >\n while result.sub!(/\\A([^<]*)>/m) { $1 } do end\n\n # eat up unmatched trailing <\n while result.sub!(/<([^>]*)\\Z/m) { $1 } do end\n\n # clean up the stack\n if stack.length > 0 then\n result << \"</#{stack.reverse.join('></')}>\"\n end\n\n result\n end", "def strip_html(allow)\n str = self.strip || ''\n allow_arr = allow.join('|')\n str = str.gsub(/<\\s*/,'<')\n str = str.gsub(/<\\/\\s*/,'</')\n # First part of | prevents matches of </allowed. Second case prevents matches of <allowed\n # and keeps the / chacter from matching the ?! allowed.\n str.gsub(/<(\\/(?!(#{allow_arr}))|(?!(\\/|#{allow_arr})))[^>]*?>/mi,'')\n end", "def unescapeHTML(string)\n str = string.dup\n str.gsub!(/&(.*?);/n) {\n match = $1.dup\n case match\n when /\\Aamp\\z/ni then '&'\n when /\\Aquot\\z/ni then '\"'\n when /\\Agt\\z/ni then '>'\n when /\\Alt\\z/ni then '<'\n when /\\A#(\\d+)\\z/n then Integer($1).chr\n when /\\A#x([0-9a-f]+)\\z/ni then $1.hex.chr\n end\n }\n str\nend", "def each_non_tag(str)\n full_str = ''\n tag_delimit = /(<(?:(?!<).)*>)/ # use non-capturing group w/ negative lookahead\n str.split(tag_delimit).each do |token|\n if token.start_with? '<'\n full_str << token # don't process tags\n else\n full_str << yield(token)\n end\n end\n return full_str\n end", "def rm_html_entities(str)\n str.gsub(/&\\w+;/, \"\")\n end", "def safe_xhtml_sanitize(html, options = {})\n sanitized = xhtml_sanitize(html.purify)\n doc = Nokogiri::XML::Document.parse(\"<div xmlns='http://www.w3.org/1999/xhtml'>#{sanitized}</div>\", nil, (options[:encoding] || 'UTF-8'), 0)\n sanitized = doc.root.children.to_xml(:indent => (options[:indent] || 2), :save_with => 2 )\n rescue Nokogiri::XML::SyntaxError\n sanitized = sanitized.escapeHTML\n end", "def sanitize(html)\n HTML5::HTMLParser.\n parse_fragment(html, :tokenizer => HTML5::HTMLSanitizer, :encoding => 'utf-8').\n to_s\n end", "def sanitize(html)\n HTML5::HTMLParser.\n parse_fragment(html, :tokenizer => HTML5::HTMLSanitizer, :encoding => 'utf-8').\n to_s\n end", "def sanitize_excerpt(html, okTags)\n # no closing tag necessary for these\n soloTags = [\"br\",\"hr\"]\n\n # Build hash of allowed tags with allowed attributes\n tags = okTags.downcase().split(',').collect!{ |s| s.split(' ') }\n allowed = Hash.new\n tags.each do |s|\n key = s.shift\n allowed[key] = s\n end\n\n # Analyze all <> elements\n stack = Array.new\n result = html.gsub( /(<.*?>)/m ) do | element |\n if element =~ /\\A<\\/(\\w+)/ then\n # </tag>\n tag = $1.downcase\n if allowed.include?(tag) && stack.include?(tag) then\n # If allowed and on the stack\n # Then pop down the stack\n top = stack.pop\n out = \"</#{top}>\"\n until top == tag do\n top = stack.pop\n out << \"</#{top}>\"\n end\n out\n end\n elsif element =~ /\\A<(\\w+)\\s*\\/>/\n # <tag />\n tag = $1.downcase\n if allowed.include?(tag) then\n \"<#{tag} />\"\n end\n elsif element =~ /\\A<(\\w+)/ then\n # <tag ...>\n tag = $1.downcase\n if allowed.include?(tag) then\n if ! soloTags.include?(tag) then\n stack.push(tag)\n end\n if allowed[tag].length == 0 then\n # no allowed attributes\n \"<#{tag}>\"\n else\n # allowed attributes?\n out = \"<#{tag}\"\n while ( $' =~ /(\\w+)=(\"[^\"]+\")/ )\n attr = $1.downcase\n valu = $2\n if allowed[tag].include?(attr) then\n out << \" #{attr}=#{valu}\"\n end\n end\n out << \">\"\n end\n end\n end\n end\n\n # eat up unmatched leading >\n while result.sub!(/\\A([^<]*)>/m) { $1 } do end\n\n # eat up unmatched trailing <\n while result.sub!(/<([^>]*)\\Z/m) { $1 } do end\n\n # clean up the stack\n if stack.length > 0 then\n result << \"</#{stack.reverse.join('></')}>\"\n end\n\n result\n end", "def clean_up_text\n text.gsub!(/<br/, \"\\n<br\")\n text.gsub!(/<p/, \"\\n<p\")\n text.gsub!(/<\\/?span(.*?)?>/, '')\n text.gsub!(/<\\/?div(.*?)?>/, '')\n end", "def strip_html(text)\n Nokogiri::HTML.fragment(text).content\n end", "def gsub_tags(string, &block)\n raise \"No block given\" unless block_given?\n\n fragment = Nokogiri::HTML::DocumentFragment.parse string\n fragment.traverse do |node|\n node.content = yield(node.content) if node.text?\n end\n fragment.to_html\n end", "def unescape_html(str)\n str.gsub(/&(.*?);/n) do\n match = $1.dup\n case match\n when /\\Aamp\\z/ni then '&'\n when /\\Aquot\\z/ni then '\"'\n when /\\Agt\\z/ni then '>'\n when /\\Alt\\z/ni then '<'\n when /\\A#0*(\\d+)\\z/n then\n if Integer($1) < 256\n Integer($1).chr\n else\n if Integer($1) < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)\n [Integer($1)].pack(\"U\")\n else\n \"&##{$1};\"\n end\n end\n when /\\A#x([0-9a-f]+)\\z/ni then\n if $1.hex < 256\n $1.hex.chr\n else\n if $1.hex < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)\n [$1.hex].pack(\"U\")\n else\n \"&#x#{$1};\"\n end\n end\n else\n \"&#{match};\"\n end\n end\n end", "def remove_paragraph_tags mytext\n mytext.sub!(/^<p>\\s*<\\/p>/,\"\")\n mytext.sub!(/(<br>)*<p>\\s*<\\/p>$/,\"\")\n mytext.sub!(/^<p>/,'')\n mytext.sub!(/<\\/p>?/,'')\n return mytext\n end", "def removeTag(text,tag)\n return 0 unless text\n text=text.to_s\n text=text.gsub(\"<\"+tag+\">\", \"\")\n text=text.gsub(\"</\"+tag+\">\", \"\")\n \n return text.to_s\nend", "def close_tags\n text = @modified_string\n\n open_tags = []\n text.scan(/<([a-zA-Z0-9]+?)(\\s[^>]*)?>/).each { |t| open_tags.unshift(t[0]) }\n text.scan(/<\\/\\s*?([a-zA-Z0-9]+)\\s*?>/).each { |t| open_tags.slice!(open_tags.index(t[0])) unless open_tags.index(t[0]).nil? }\n open_tags.each { |t| text += \"</#{t}>\" unless %w(img br hr).include?(t.to_s) }\n\n @modified_string = text\n return self\n end", "def cleanup_string(string, strip: true)\n return \"\" if string.nil?\n raise ArgumentError, \"Expected a string or an object that implements #to_str\" unless string.respond_to?(:to_str)\n\n s = strip_tags(string.to_str)\n s = s.dup if s.frozen?\n s.gsub!(/\\s+/, \" \")\n s.strip! if strip\n\n s\n end", "def clean_html(html)\n Sanitize.clean(html) rescue html\n end", "def strip_script_tag (s)\ns.gsub(/<script.*<\\/script>/i, '');\nend", "def fix_html(ary)\n text = \"\"\n\n ary.each do |s|\n temp = s.gsub('<', '&lt;').gsub('>', '&gt;')\n temp = temp.gsub('&b', '<b>').gsub('&/b', '</b>')\n temp = temp.gsub('&i', '<i>').gsub('&/i', '</i>')\n\n text += \" &nbsp;&nbsp;&nbsp;&nbsp;#{temp}<br />\\n\"\n end\n\n return text\nend", "def conv_html(txt)\n txt.\n gsub(/&gt;/, '>').\n gsub(/&lt;/, '<').\n gsub(/&quot;/, '\"').\n gsub(/&amp;/, '&')\n \n end", "def ie(x)\n strip_tags(x).html_safe\n end", "def parse_unpaired_tags(wiki_text)\n wiki_text.gsub!(%r{<[a-zA-Z]*/>}im, \"\")\n wiki_text\n end", "def clean_string(string)\n string = string.gsub(/\\r|\\n/,'').sub(/^ */,'').sub(/\\s*$/,'').gsub(/ +/,' ')\n coder = HTMLEntities.new()\n string = coder.decode(string) # Remove html entities\n return string\n end", "def remove_html_tag(tag_name); end", "def convert_html_safe(str)\n return str.html_safe\n end", "def strip_tag(*tags, &block)\n tags.each do |tag|\n gsub! Regexp.new(\"<\\s*#{tag}(?:\\s+[^>]*)*>(.*?)<\\s*\\/#{tag}\\s*>\", Regexp::IGNORECASE + Regexp:: MULTILINE) do\n if block\n \"#{$1}#{yield}\"\n else\n $1\n end\n end\n # check we don't have any malformed or nested instances left\n gsub! Regexp.new(\"<\\s*#{tag}(?:\\s+[^>]*)*>\", Regexp::IGNORECASE + Regexp:: MULTILINE), ''\n gsub! Regexp.new(\"<\\s*\\/#{tag}\\s*>\", Regexp::IGNORECASE + Regexp:: MULTILINE), ''\n end\n end", "def cleanText(txt)\r\n clean = txt.gsub(\"<\", \"&lt;\")\r\n clean.gsub!(\">\", \"&gt;\")\r\n\r\n puts \"cleaned text: #{txt} -> #{clean}\" if $DEBUG\r\n clean\r\n\r\n end", "def strip_doctype_html(input)\n input.to_s.gsub(Regexp.new(DOCTYPE_HTML), NOTHING)\n end", "def unescapeHTML(string)\n enc = string.encoding\n unless enc.ascii_compatible?\n if enc.dummy?\n origenc = enc\n enc = Encoding::Converter.asciicompat_encoding(enc)\n string = enc ? string.encode(enc) : string.b\n end\n string = string.gsub(Regexp.new('&(apos|amp|quot|gt|lt|#[0-9]+|#x[0-9A-Fa-f]+);'.encode(enc))) do\n case $1.encode(Encoding::US_ASCII)\n when 'apos' then \"'\".encode(enc)\n when 'amp' then '&'.encode(enc)\n when 'quot' then '\"'.encode(enc)\n when 'gt' then '>'.encode(enc)\n when 'lt' then '<'.encode(enc)\n when /\\A#0*(\\d+)\\z/ then $1.to_i.chr(enc)\n when /\\A#x([0-9a-f]+)\\z/i then $1.hex.chr(enc)\n end\n end\n string.encode!(origenc) if origenc\n return string\n end\n return string unless string.include? '&'\n charlimit = case enc\n when Encoding::UTF_8; 0x10ffff\n when Encoding::ISO_8859_1; 256\n else 128\n end\n string = string.b\n string.gsub!(/&(apos|amp|quot|gt|lt|\\#[0-9]+|\\#[xX][0-9A-Fa-f]+);/) do\n match = $1.dup\n case match\n when 'apos' then \"'\"\n when 'amp' then '&'\n when 'quot' then '\"'\n when 'gt' then '>'\n when 'lt' then '<'\n when /\\A#0*(\\d+)\\z/\n n = $1.to_i\n if n < charlimit\n n.chr(enc)\n else\n \"&##{$1};\"\n end\n when /\\A#x([0-9a-f]+)\\z/i\n n = $1.hex\n if n < charlimit\n n.chr(enc)\n else\n \"&#x#{$1};\"\n end\n else\n \"&#{match};\"\n end\n end\n string.force_encoding enc\n end", "def normalise_html(html)\n Nokogiri::HTML5.fragment(html).to_s.gsub(\"\\n\", \"\")\n end", "def sanitize_html(content)\n require 'cgi'\n CGI.escapeHTML(content)\n end", "def html_escape(options={})\n except = options[:except] || %w()\n close_tags\n @modified_string.gsub!(/<\\/?(.*?)(\\s.*?)?\\/?>/) do |tag|\n if except.include?($1)\n # sanitize attributes\n tag.gsub(/\\s(.+?)=('|\").*?\\2(?=.*?>)/) do |a|\n [\"href\", \"src\", \"lang\"].include?($1) ? a : \"\"\n end\n else\n h(tag)\n end\n end\n # Convert all unclosed left tag brackets (<) into &lt;\n @modified_string.gsub!(/<+([^>]*)\\Z/, '&lt;\\1')\n # Convert all unopened right tag brackets (>) into &gt;\n @modified_string.gsub!(/\\A([^<]*)>+/, '\\1&gt;')\n self\n end", "def sanitize_feed_content(html, sanitize_tables = false)\n options = sanitize_tables ? {} : { tags: %w[table thead tfoot tbody td tr th] }\n sanitized = html.strip do |html|\n html.gsub! /&amp;(#\\d+);/ do |_s|\n \"&#{Regexp.last_match(1)};\"\n end\n end\n sanitized\n end", "def strip_script_tags!(content)\n content.gsub!(/(^|\\s*)<script[^>]*>(\\s*\\n)?(\\/\\/<\\!\\[CDATA\\[\\n)?/, '')\n content.gsub!(/(\\n\\/\\/\\]\\]>)?\\s*<\\/script>\\s*(\\n|$)/, '')\n content\n end", "def htmlClean(html)\n html\nend", "def escape_html( string )\n\t\t\treturn \"nil\" if string.nil?\n\t\t\tstring = string.inspect unless string.is_a?( String )\n\t\t\tstring.\n\t\t\t\tgsub(/&/, '&amp;').\n\t\t\t\tgsub(/</, '&lt;').\n\t\t\t\tgsub(/>/, '&gt;').\n\t\t\t\tgsub(/\\n/, '&#8629;').\n\t\t\t\tgsub(/\\t/, '&#8594;')\n\t\tend", "def escape_html( string )\n\t\t\treturn \"nil\" if string.nil?\n\t\t\tstring = string.inspect unless string.is_a?( String )\n\t\t\tstring.\n\t\t\t\tgsub(/&/, '&amp;').\n\t\t\t\tgsub(/</, '&lt;').\n\t\t\t\tgsub(/>/, '&gt;').\n\t\t\t\tgsub(/\\n/, '&#8629;').\n\t\t\t\tgsub(/\\t/, '&#8594;')\n\t\tend", "def mark_text(str)\n\t str = clean_html(str)\n\t \n\t return str\n end", "def ae_some_html(s)\n return '' if s.nil? \n \n # converting newlines\n s.gsub!(/\\r\\n?/, \"\\n\")\n \n # escaping HTML to entities\n s = s.to_s.gsub('&', '&amp;').gsub('<', '&lt;').gsub('>', '&gt;')\n \n # blockquote tag support\n s.gsub!(/\\n?&lt;blockquote&gt;\\n*(.+?)\\n*&lt;\\/blockquote&gt;/im, \"<blockquote>\\\\1</blockquote>\")\n \n # other tags: b, i, em, strong, u\n %w(b i em strong u).each { |x|\n s.gsub!(Regexp.new('&lt;(' + x + ')&gt;(.+?)&lt;/('+x+')&gt;',\n Regexp::MULTILINE|Regexp::IGNORECASE), \n \"<\\\\1>\\\\2</\\\\1>\")\n }\n \n # A tag support\n # href=\"\" attribute auto-adds http://\n s = s.gsub(/&lt;a.+?href\\s*=\\s*['\"](.+?)[\"'].*?&gt;(.+?)&lt;\\/a&gt;/im) { |x|\n '<a href=\"' + ($1.index('://') ? $1 : 'http://'+$1) + \"\\\">\" + $2 + \"</a>\"\n }\n \n # replacing newlines to <br> ans <p> tags\n # wrapping text into paragraph\n s = \"<p>\" + s.gsub(/\\n\\n+/, \"</p>\\n\\n<p>\").\n gsub(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') + \"</p>\"\n \n s \n end", "def ae_some_html(s)\n return '' if s.nil? \n \n # converting newlines\n s.gsub!(/\\r\\n?/, \"\\n\")\n \n # escaping HTML to entities\n s = s.to_s.gsub('&', '&amp;').gsub('<', '&lt;').gsub('>', '&gt;')\n \n # blockquote tag support\n s.gsub!(/\\n?&lt;blockquote&gt;\\n*(.+?)\\n*&lt;\\/blockquote&gt;/im, \"<blockquote>\\\\1</blockquote>\")\n \n # other tags: b, i, em, strong, u\n %w(b i em strong u).each { |x|\n s.gsub!(Regexp.new('&lt;(' + x + ')&gt;(.+?)&lt;/('+x+')&gt;',\n Regexp::MULTILINE|Regexp::IGNORECASE), \n \"<\\\\1>\\\\2</\\\\1>\")\n }\n \n # A tag support\n # href=\"\" attribute auto-adds http://\n s = s.gsub(/&lt;a.+?href\\s*=\\s*['\"](.+?)[\"'].*?&gt;(.+?)&lt;\\/a&gt;/im) { |x|\n '<a href=\"' + ($1.index('://') ? $1 : 'http://'+$1) + \"\\\">\" + $2 + \"</a>\"\n }\n \n # replacing newlines to <br> ans <p> tags\n # wrapping text into paragraph\n s = \"<p>\" + s.gsub(/\\n\\n+/, \"</p>\\n\\n<p>\").\n gsub(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') + \"</p>\"\n \n s \n end", "def convert_html(str, attrs, exclusive = false)\n tags = @html_tags.select { |start, bitmap|\n exclusive == exclusive?(bitmap)\n }.keys.join '|'\n\n 1 while str.gsub!(/<(#{tags})>(.*?)<\\/\\1>/i) { |orig|\n attr = @html_tags[$1.downcase]\n html_length = $1.length + 2\n seq = NULL * html_length\n attrs.set_attrs($`.length + html_length, $2.length, attr)\n seq + $2 + seq + NULL\n }\n end", "def strip_html(text)\n @name =\n # Remove HTML from the text\n Sanitize.clean(text).\n # Replace newlines with a space\n gsub(/\\n|\\r/, ' ').\n # Replaces runs of spaces by a single space\n squeeze(' ').\n # Remove leading and trailing whitespace\n strip\nend", "def as_text\n return self if self.blank?\n mytext = self.gsub(/<p>(.*?)<\\/p>/mi,'\\1'+\"\\n\\n\")\n mytext = mytext.gsub(/<br(.*?)>/mi,\"\\n\") \n mytext = mytext.gsub(/<p(.*?)>/mi,\"\\n\\n\") \n mytext = mytext.gsub(/<\\/p>/mi,\"\") \n mytext = mytext.gsub(/<div(.*?)>/mi, \"\")\n mytext = mytext.gsub(/<\\/div>/mi,\"\") \n # Go ahead and strip all the other html tags as well\n mytext = mytext.gsub(/<\\/?[^>]*>/, \"\")\n CGI.unescapeHTML(mytext).strip\n end", "def correct_unclosed_html_tags(element)\n [:i, :sup].each do |tag|\n strip_stray_close_tags(element,tag)\n append_missing_close_tags(element,tag)\n end\n end", "def remove_cruft(string)\n string.gsub(/<a [^>]*>([^<]*)<\\/a>/, '\\1').gsub('[?]', '')\n end", "def clean text\n text.gsub(/(\\n|\\t|\\r)/, ' ').gsub(/>\\s*</, '><').squeeze(' ')\n end", "def get_text_contents(html_string)\n\t# Remove HTML and scripts\n\thtml_regex = /<head>.*?<\\/head>|<script>.*?<\\/script>|<noscript>.*?<\\/noscript>/m\n\ttext_string = html_string.gsub(html_regex,\"\")\n\n\t# Remove tags\n\ttag_regex = /<[^<>]*?>/m\n\ttext_string.gsub!(tag_regex,\"\")\n\n\t# Replace multiple spaces with one\n\ttext_string.gsub!(/\\s{2,}/m,\" \")\n\n\t# Remove STX\n\ttext_string.gsub!(/\\^B/,\"\")\n\n\treturn text_string\nend", "def sanitize(html)\n doc = Nokogiri::HTML::DocumentFragment.parse(html)\n if Mako.config.sanitize_images\n doc.css('img').each do |n|\n begin\n n.name = 'a'\n n.content = n['alt'] ? \"📷 #{n['alt']}\" : '📷 Image'\n n['href'] = URI.parse(n['src']).absolutize!(uri)\n rescue URI::InvalidURIError\n # if there's a problem, just ignore it\n next\n end\n end\n end\n doc.css('h1,h2,h3,h4,h5,h6').each { |n| n.name = 'p'; n.set_attribute('class', 'bold') }\n doc.to_s\n end", "def simple_format_no_tags(text, _html_options = {}, options = {})\n text = '' if text.nil?\n text = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n text = sanitize(text) unless options[:sanitize] == false\n text = text.to_str\n text.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n # text.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n text.html_safe\n end", "def text\n html.gsub(REGEX_TAGS, \"\")\n end", "def sanitize_tag(in_tag)\n in_tag.gsub(/[^\\w%=\\-\\\\+]+/,\"\")\n end", "def safe_js_string(js_string)\n\t\treturn '' if js_string.nil?\n\t\tjs_string.gsub('</','<\\/').html_safe\n\tend", "def sanitize_blog_body(str)\n ret = str.gsub(\"<h4 class=\\\"itemTitle\\\"></h4>\", \" \")\n ret.gsub!(\"<br />\",\"\\n\")\n \n ret\n end", "def close_tags(text)\n open_tags = []\n text.scan(/\\<([^\\>\\s\\/]+)[^\\>\\/]*?\\>/).each { |t| open_tags.unshift(t) }\n text.scan(/\\<\\/([^\\>\\s\\/]+)[^\\>]*?\\>/).each { |t| open_tags.slice!(open_tags.index(t)) }\n open_tags.each {|t| text += \"</#{t}>\" }\n text\n end", "def htmlify_except(nodes)\n nodes.reduce(to_html) do |output, node|\n output.gsub(node.to_html, node.to_xhtml)\n end\n end", "def simple_format_no_tags(text, html_options = {}, options = {})\n\t\ttext = '' if text.nil?\n\t\ttext = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n\t\ttext = sanitize(text) unless options[:sanitize] == false\n\t\ttext = text.to_str\n\t\ttext.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n#\t\ttext.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n\t\ttext.html_safe\n\tend", "def simple_format_no_tags(text, html_options = {}, options = {})\n\t\ttext = '' if text.nil?\n\t\ttext = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n\t\ttext = sanitize(text) unless options[:sanitize] == false\n\t\ttext = text.to_str\n\t\ttext.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n#\t\ttext.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n\t\ttext.html_safe\n\tend", "def simple_format_no_tags(text, html_options = {}, options = {})\n\t\ttext = '' if text.nil?\n\t\ttext = smart_truncate(text, options[:truncate]) if options[:truncate].present?\n\t\ttext = sanitize(text) unless options[:sanitize] == false\n\t\ttext = text.to_str\n\t\ttext.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n#\t\ttext.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n\t\ttext.html_safe\n\tend" ]
[ "0.8111277", "0.80916935", "0.78479964", "0.78479964", "0.78479964", "0.7809479", "0.78033006", "0.78033006", "0.77888924", "0.7759668", "0.7759273", "0.7709444", "0.76937675", "0.76937675", "0.76315415", "0.75587356", "0.75368816", "0.74897814", "0.748955", "0.74626416", "0.74463874", "0.72847056", "0.71923745", "0.71671784", "0.7126853", "0.7047239", "0.7035196", "0.69778407", "0.69586486", "0.6917422", "0.6879477", "0.68581504", "0.68268436", "0.6761187", "0.671509", "0.67114735", "0.6597081", "0.65858454", "0.6579608", "0.6578135", "0.65340906", "0.653276", "0.6469664", "0.64020836", "0.6385942", "0.6346845", "0.6346108", "0.63376", "0.63376", "0.631538", "0.6296477", "0.62719125", "0.6265401", "0.6186967", "0.61755514", "0.61338425", "0.6113991", "0.60663337", "0.6054031", "0.603442", "0.6033834", "0.6033539", "0.6031484", "0.60245717", "0.6016897", "0.5991874", "0.5982282", "0.59747505", "0.596706", "0.5963131", "0.59622836", "0.5931959", "0.5926555", "0.5922832", "0.5891815", "0.5879328", "0.58747476", "0.58745587", "0.58745587", "0.587297", "0.58464956", "0.58464956", "0.5844903", "0.5838784", "0.5835132", "0.5829447", "0.5827296", "0.5812352", "0.5797715", "0.5784683", "0.57631415", "0.5753709", "0.5747166", "0.5728366", "0.57233673", "0.5716759", "0.57123953", "0.57078713", "0.57078713", "0.57078713" ]
0.8014589
2
This test ensures that check_args will fail, given that the user passes in no parameters into the program.
def test_nil_args refute check_args(nil) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_check_args_invalid2\n args = CheckArgs.new\n assert_equal false, args.check_args([1, 2])\n end", "def test_check_args_false\n c = Checker.new\n assert_equal false, c.check_args([1, 1, 1, 1])\n assert_equal false, c.check_args([1,1])\n assert_equal false, c.check_args(['something', 111])\n assert_equal false, c.check_args([1, -1, 1])\n assert_equal false, c.check_args([1, 1, -1])\n end", "def test_positive\n args = Arguments.new\n assert_equal false, args.check_args(5)\n end", "def test_check_num_args_invalid2\n args = CheckNumArgs.new\n assert_equal false, args.check_args([1])\n end", "def test_check_num_args_invalid3\n args = CheckNumArgs.new\n assert_equal false, args.check_args([1, 2])\n end", "def test_check_args_valid\n args = CheckArgs.new\n assert_equal true, args.check_args([-5, 2, 3])\n end", "def test_no_arg\n\tassert_output(nil, abort) {GoldRush.argchecker()}\n end", "def test_args_check_less\n\t\targs_checker = ArgsChecker::new\n\t\tarr = []\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend", "def test_positive\r\n args = Args.new\r\n assert_equal false, args.check_args(6)\r\n end", "def test_check_args_invalid_zero\n args = CheckArgs.new\n assert_equal false, args.check_args([2, 0, 0])\n end", "def test_check_args_invalid_negative\n args = CheckArgs.new\n assert_equal false, args.check_args([6, -2, -3])\n end", "def test_no_arg\n\tassert_output(nil, abort) {GoldRush.argchecker(-1)}\n end", "def test_one_ints\n args = Arguments.new\n assert_equal false, args.check_args([1])\n end", "def test_negative\r\n args = Args.new\r\n assert_equal false, args.check_args(\"hello\")\r\n end", "def test_missing_argument_invalid_argument\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1,'s'])\n\tend", "def test_args_check_nil\n\t\targs_checker = ArgsChecker::new\n\t\tarr = nil\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend", "def test_empty\r\n args = Args.new\r\n assert_equal false, args.check_args(\" \")\r\n end", "def test_two_proper_args\n assert check_args([1, 1])\n end", "def test_check_num_args_invalid_zero\n args = CheckNumArgs.new\n assert_equal false, args.check_args([0,0,0])\n end", "def test_check_num_args_valid\n args = CheckNumArgs.new\n assert_equal true, args.check_args([1,1,1])\n end", "def test_two_ints\n args = Arguments.new\n assert_equal false, args.check_args([1, 2])\n end", "def test_check_args_invalid_string\n args = CheckArgs.new\n assert_equal false, args.check_args(['HI'])\n end", "def test_zero\n args = Arguments.new\n assert_equal false, args.check_args(0)\n end", "def test_check_args_invalid_string2\n args = CheckArgs.new\n assert_equal false, args.check_args(['HI', 4, 'There'])\n end", "def test_check_num_args_invalid_negative\n args = CheckNumArgs.new\n assert_equal false, args.check_args([0,-1,-1])\n end", "def test_zero\r\n args = Args.new\r\n assert_equal false, args.check_args(0)\r\n end", "def test_check_num_args_valid2\n args = CheckNumArgs.new\n args.check_args([1,1,1])\n assert_kind_of Integer, 1\n end", "def test_arg_check_oneArg\n \t@args = ArgumentCheck.new\n \tassert_equal(true, @args.arg_check([1]))\n end", "def validate_arguments()\n usage unless ARGV.count > 0\nend", "def test_three_ints\n args = Arguments.new\n assert_equal true, args.check_args([1, 2, 3])\n end", "def test_two_valid_arguments\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1])\n\tend", "def validate_args (args)\n\t# todo\nend", "def test_arg_check_3string\n \t@args = ArgumentCheck.new\n \tassert_equal(false, @args.arg_check(['poop', 'poopy', 'poopypoop']))\n end", "def test_check_num_args_string1\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO'])\n end", "def test_check_num_args_string2\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO', 'THERE'])\n end", "def check_arg()\n if ARGV.length > 1\n print \"ERROR: Too many command line args.\\n\"\n print \"USAGE: #{$PROGRAM_NAME} [--FixThemAll]\\n\"\n exit ERR_EXIT_ARGS2MANY\n end\n if ARGV.length == 1 && ARGV[0] != '--FixThemAll'\n print \"ERROR: Invalid argument on command line: '#{ARGV[0]}'\\n\"\n print \"USAGE: #{$PROGRAM_NAME} [--FixThemAll]\\n\"\n exit ERR_EXIT_ARGINVALID\n end\nend", "def test_check_num_args_string3\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO', 'THERE', 'KENOBI'])\n end", "def test_zero_prospectors\n\t\tassert check_args([1, 0])\n\tend", "def test_arg_check_length_fail\n def exit(x); 1; end;\n ret = arg_check_length 2\n assert_equal ret, -1\n end", "def test_string\n args = Arguments.new\n assert_equal false, args.check_args(\"puppy\")\n end", "def test_arg_check_turns_valid\n ret = arg_check_turns '1'\n assert_equal ret, 0\n end", "def ensure_any_args\n if ARGV.size == 0\n $stderr.puts \"ERROR: Must provide the name of a koan\"\n exit -1\n end\nend", "def test_bad_argument\n assert_equal 1, go_with_args(%w(--this_is_really_redonculouslywrong))\n assert_match(/Error: bad arguments/, @stderr_io.string )\n end", "def test_negative_argument\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1,-2])\n\tend", "def test_arg_check_prospectors_valid\n ret = arg_check_prospectors '1'\n assert_equal ret, 0\n end", "def test_arg_check_prospectors_negative\n def exit(x); 1; end\n ret = arg_check_prospectors '-1'\n assert_equal ret, -3\n end", "def test_nonzero_arguments\n args_checker = ArgsChecker.new\n arr = [1]\n assert_equal false, args_checker.check_mode(arr)\n end", "def test_abnormal_usage\n test_args = [-9, -9, -9]\n args = Args.new test_args\n\n args.stub(:exit, 1) do\n assert_output(\"Usage:\\nruby ruby_rush.rb *seed* *num_prospectors* *num_turns\\n*seed* should be an integer\\n*num_prospectors* should be a non-negative integer\\n*num_turns* should be a non-negative integer\\n\"){args.validate_args}\n end\n end", "def test_neg_prospectors\n\t\trefute check_args([1, -1])\n\tend", "def test_arg_check_turns_negative\n def exit(x); 1; end\n ret = arg_check_turns '-1'\n assert_equal ret, -4\n end", "def wrong_num_parameters?\n (ARGV.size != 1)\n end", "def test_arg_check_2string\n \t@args = ArgumentCheck.new\n \tassert_equal(false, @args.arg_check(['poop', 'poopy']))\n end", "def test_args_check_greater\n\t\targs_checker = ArgsChecker::new\n\t\tarr = [2, 4]\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend", "def check_args(arguments)\r\n if arguments.length != 3\r\n puts 'There must be exactly three arguments: *seed*, *num_prospectors*, *num_turns*'\r\n return false\r\n elsif arguments[1].to_i.negative? || arguments[2].to_i.negative?\r\n puts 'Usage:'\r\n puts 'ruby ruby_rush.rb *seed* *num_prospectors* *num_turns*'\r\n puts '*seed* should be an integer'\r\n puts '*num_prospectors* should be a non-negative integer'\r\n puts '*num_turns* should be a non-negative integer'\r\n return false\r\n end\r\n true\r\nend", "def check_no_extra_args!\n if @argv.length > 0\n Braid::Command.handle_error(\n Braid::BraidError.new('Extra argument(s) passed to command.'))\n end\n end", "def test_it_should_take_no_arguments\n assert_equal(0, cli_class.instance_method(:generate).arity)\n end", "def check_arguments\n convert_boolean_strings\n check_output\n check_log_level\n check_input_entry\n check_input_types\n end", "def validate_args\n if name_args.size < 1\n ui.error('No cookbook has been specified')\n show_usage\n exit 1\n end\n if name_args.size > 2\n ui.error('Too many arguments are being passed. Please verify.')\n show_usage\n exit 1\n end\n end", "def test_negative_should_take_no_arguments\n assert_equal(0, cli_class.instance_method(:negative).arity)\n end", "def check_args(args)\n args.count == 2 && args[0].to_i > 0 && args[1].to_i > 0\n rescue StandardError\n false\n end", "def check_if_user_gave_input\n abort(\"mkdiruby: missing input\") if ARGV.empty?\n abort(\"mkdiruby: input contains more than one argument\") if ARGV.count > 1\nend", "def check_args(args)\r\n args.count == 1\r\n File.exist?(ARGV[0].to_s)\r\nrescue StandardError\r\n false\r\nend", "def check_args(args)\n begin\n results = [Integer(args[0]), Integer(args[1])] \n rescue ArgumentError, TypeError\n puts 'Invalid input.' \n end\n args.count == 2 && results[1] >= 1\nrescue StandardError\n false\nend", "def test_string_argument\n\t\tc = Check.new\n\t\tassert c.check_arguments([1,'1',1])\n\tend", "def arguments_passed?\n !!(ARGV[0] && ARGV[1] && ARGV[2])\n end", "def validate_arguments(args={})\n return if args.count == 1 && args.key?(:all)\n\n only_options = args[:only] || Set.new\n except_options = args[:except] || Set.new\n skip_options = args[:skip] || Set.new\n\n unless (only_options & except_options).empty? &&\n (only_options & skip_options).empty?\n\n raise IncorrectArgumentException.new(\n nil,\n <<-TXT\n The same arguments shouldn't be used\n with different keys excluding except and skip\n TXT\n )\n end\n\n if args[:skip] == 'all' && args.count > 1\n raise IncorrectArgumentException.new(\n nil,\n <<-TXT\n Option 'skip' with argument 'all' shouldn't be used\n with another options\n TXT\n )\n end\n end", "def check_arguments\n if (@ec2_user_id.nil? || @aws_access_key_id.nil? || @aws_secret_access_key.nil? || @host_role.nil? || ! ( @do_snapshot || @do_restore )) then\n raise ArgumentError, \"Missing command line parameter\"\n end\n end", "def check_requirement!(*args)\n args_length = args.length\n required_length = @required.length\n\n if args_length < required_length\n raise ArgumentError, \"Wrong number of arguments \" \\\n \"(#{args_length} for #{required_length}). \" \\\n \"Expected `#{@required.join(', ')}` as required arguments, \" \\\n \"but got `#{args.join(\", \")}`.\"\n end\n end", "def arguments_valid?\n true # no required arguments\n end", "def CheckArguments\n arg_n = Ops.subtract(Builtins.size(WFM.Args), 1)\n\n arg_list = []\n\n while Ops.greater_or_equal(arg_n, 0)\n if WFM.Args(arg_n) == path(\".test\")\n Mode.SetTest(\"test\")\n elsif WFM.Args(arg_n) == path(\".testp\")\n Mode.SetTest(\"test\") # .testp implies .test\n @test_popup = true\n elsif Ops.is_string?(WFM.Args(arg_n))\n s = Builtins.tostring(WFM.Args(arg_n))\n if s == \"--install\"\n @action = :install\n elsif s == \"--remove\"\n @action = :remove\n elsif s == \"--update\"\n @action = :update\n else\n arg_list = Builtins.add(arg_list, s)\n end\n elsif Ops.is_list?(WFM.Args(arg_n))\n Builtins.foreach(Convert.to_list(WFM.Args(arg_n))) do |arg|\n arg_list = Builtins.add(arg_list, Builtins.tostring(arg))\n end\n end\n arg_n = Ops.subtract(arg_n, 1)\n end\n\n Builtins.y2milestone(\"action: %1\", @action)\n deep_copy(arg_list)\n end", "def test_clean_exit_with_no_arguments\n @stdin_io = StringIO.new\n assert( Numeric === go_with_args() )\n end", "def test_double_argument\n\t\tc = Check.new\n\t\tassert c.check_arguments([1,1.2,1])\n\tend", "def test_generate_should_take_no_arguments\n assert_equal(0, cli_class.instance_method(:generate).arity)\n end", "def test_arg_check_seed_valid\n ret = arg_check_seed '1'\n assert_equal ret, 0\n end", "def valid_args?(args={})\n valid = false\n arguments.each do |name, argument|\n if argument[:required]\n return false if args[name] == nil\n end\n valid = argument.valid_input?(args[name])\n end\n return valid\n end", "def validate_arguments(args={})\n return if args.count == 1 && args.keys.include?(:all)\n only_options = args[:only] || Set.new\n except_options = args[:except] || Set.new\n skip_options = args[:skip] || Set.new\n unless (only_options & except_options).empty? &&\n (only_options & skip_options).empty?\n raise IncorrectArgumentException.new(nil, 'The same arguments shouldn\\'t be used with different keys excluding except and skip')\n end\n if args[:skip] == 'all' && args.count > 1\n raise IncorrectArgumentException.new(nil, 'Option \\'skip\\' with argument \\'all\\' shouldn\\'t be used with another options')\n end\n end", "def check_arg_structure(args)\n valid = true\n valid &&= args.class == Array\n \n args.each do |a|\n valid &&= a.class == Array \n valid &&= a.size == 2\n a.each do |s|\n valid &&= s.class == String\n end\n end\n\n raise \"Imported function arguments in invalid form\" unless valid\n end", "def check_arg_structure(args)\n valid = true\n valid &&= args.class == Array\n \n args.each do |a|\n valid &&= a.class == Array \n valid &&= a.size == 2\n a.each do |s|\n valid &&= s.class == String\n end\n end\n\n raise \"Imported function arguments in invalid form\" unless valid\n end", "def test_calling_global_methods_with_wrong_number_of_arguments\n exception = assert_raise(ArgumentError) do\n my_global_method\n end\n assert_match(/arguments/, exception.message)\n\n exception = assert_raise(ArgumentError) do\n my_global_method(1,2,3)\n end\n assert_match(/wrong/, exception.message)\n end", "def validate_args_count(expected, got)\n if (expected.is_a?(Numeric) and expected != got) or\n (expected.is_a?(Range) and !(expected === got))\n raise ArgumentError, \"wrong number of arguments for '#{name}' (#{got} for #{expected})\"\n end\n end", "def arguments_valid?\n true \n # to do\n end", "def arguments_valid?\n # Should be no remaining arguments\n true if @arguments.length == 0\n end", "def validate(args = {})\n end", "def test_check_seed_valid_int_negative\n test_args = [-1, 2, 3]\n args = Args.new test_args\n assert_equal(-1, args.check_seed(test_args[0]))\n end", "def arguments_given?\n [email protected]?\n end", "def check_args(hash)\n if !hash.include? :hostname\n raise ArgumentError, \"You must provide a hostname\"\n elsif !hash.include? :service_name\n raise ArgumentError, \"You must provide a service name\"\n elsif !hash.include? :return_code\n raise ArgumentError, \"You must provide a return code\"\n elsif !hash.include? :status\n raise ArgumentError, \"You must provide a status\"\n end\n end", "def invalid_args(msg)\n puts \"#{msg}\\n\\n\"\n puts $opts\n exit\nend", "def assert _args\n \"assert _args;\" \n end", "def errorCheck()\n\t# Debug output\n\tif $DEBUG then STDERR.puts \"in errorCheck()\" end\n\n\t# no args -> quit\n\tif ARGV.length == 0\n\t\tputs \"incorrect argument(s). usage: 'ruby name2number.rb <name1> <name2> <name3>..\"\n\t\texit\n\tend\n\n\t# special characters / numbers -> quit\n\tARGV.each do |arg|\n\t\tif arg !~ /^[a-zA-Z]+$/ then\n\t\t\tputs \"non-alphabetical character(s) detected. usage: 'ruby name2number.rb <name1> <name2> <name3>..\"\n\t\t\texit\n\t\tend \n\tend\nend", "def mandatory_argument_should_exist(command, arg_name, arg_list, arg_number)\n expect { @helper.run_test_omnibus_command(command, arg_list) }\n .to raise_error(SystemExit) { |e| expect(e.status).to eq(1) }\n end", "def setup_args_valid?(argsArr)\r\n if nil==argsArr[0] or argsArr[0]==\"\"\r\n return \"Bot token cannot be empty or nil.\"\r\n elsif nil==argsArr[1] or argsArr[1]==\"\"\r\n return \"Bot clientId cannot be empty or nil.\"\r\n elsif nil==argsArr[2]\r\n return \"Bot command prefix cannot be nil.\"\r\n end\r\n\r\n return nil\r\n end", "def valid?(setup)\n setup.args.length >= required_args && (max_args == -1 || setup.args.length <= max_args)\n end", "def arguments_valid?\n true \n end", "def arg_required(*args)\n args.each{|obj| raise ArgumentError, \"Argument cannot be nil\" if obj.nil? }\n end", "def arg_check_length(arg_l)\n if arg_l < 3\n puts 'Usage:\\n'\n puts 'ruby ruby_rush.rb <seed> <num_prospectors> <num_turns>\\n'\n puts '<seed> should be an integer\\n'\n puts '<num_prospectors> should be a non-negative integer\\n'\n puts '<num_turns> should be a non-negative integer\\n\\n'\n exit(1)\n return -1\n end\n 0\nend", "def arguments_valid?\n true\n end", "def arguments_valid?\n true\n end", "def test_arguments\n\texpect_error(42, /illegal argument/)\n\texpect_error([], /illegal argument/)\n\n\tbegin\n\t # We already tested tempfile arguments elsewhere (see\n\t # test_from_tempfile).\n\t str = StringSubclass.new('abc') # should be OK\n\trescue NQXML::ParserError => ex\n\t assert_fail(\"unexpected parser error on line #{ex.line}: #{$!}\")\n\tend\n end", "def incorrect_arg_size?(args)\n return false if has_splat_args?\n required_arg_size = @args.take_while {|e| e[1].nil? }.size\n args.size < required_arg_size || args.size > required_arg_size\n end", "def test_correct_extra_arg\n a_parse = Argparser.new\n assert !a_parse.correct?([-20, 5, 1, 0])\n end" ]
[ "0.8553085", "0.83903754", "0.8330345", "0.82804996", "0.8194575", "0.8193247", "0.817947", "0.81570274", "0.8156736", "0.8154093", "0.8090222", "0.80836034", "0.8063563", "0.8061744", "0.804967", "0.80055535", "0.79884136", "0.79606944", "0.79516125", "0.7902074", "0.7893587", "0.78652984", "0.7848784", "0.7834308", "0.7827328", "0.7787831", "0.7719024", "0.771825", "0.7671688", "0.76659435", "0.76358217", "0.75854325", "0.7560472", "0.75489235", "0.7521512", "0.7478181", "0.74527365", "0.7406654", "0.73604393", "0.73442006", "0.7342851", "0.7336859", "0.7323617", "0.7303357", "0.72674996", "0.72498685", "0.72251844", "0.7197321", "0.7192755", "0.71595424", "0.7144694", "0.70888823", "0.7075443", "0.7068681", "0.70673513", "0.7045624", "0.7037412", "0.703128", "0.7004487", "0.6947573", "0.6941278", "0.6930766", "0.6904039", "0.6888202", "0.681541", "0.68106806", "0.68002886", "0.67746204", "0.67571247", "0.67390245", "0.6728116", "0.672015", "0.6704819", "0.67043084", "0.66900593", "0.66845185", "0.66837513", "0.66837513", "0.6652347", "0.65920657", "0.65707004", "0.6569933", "0.6565518", "0.6559854", "0.6552424", "0.65413827", "0.6537983", "0.65331584", "0.6527821", "0.6521084", "0.6516782", "0.6512324", "0.65104574", "0.6476987", "0.64539236", "0.64523596", "0.64315045", "0.63986015", "0.63926405", "0.6379397" ]
0.78706366
21
This test checks to make sure that check_args passes, given that the user sends exactly two parameters, with the first being an integer, and the second a nonnegative integer.
def test_two_proper_args assert check_args([1, 1]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_two_ints\n args = Arguments.new\n assert_equal false, args.check_args([1, 2])\n end", "def test_check_num_args_valid2\n args = CheckNumArgs.new\n args.check_args([1,1,1])\n assert_kind_of Integer, 1\n end", "def test_one_ints\n args = Arguments.new\n assert_equal false, args.check_args([1])\n end", "def test_check_num_args_invalid2\n args = CheckNumArgs.new\n assert_equal false, args.check_args([1])\n end", "def test_three_ints\n args = Arguments.new\n assert_equal true, args.check_args([1, 2, 3])\n end", "def test_check_num_args_valid\n args = CheckNumArgs.new\n assert_equal true, args.check_args([1,1,1])\n end", "def test_check_num_args_invalid3\n args = CheckNumArgs.new\n assert_equal false, args.check_args([1, 2])\n end", "def test_check_args_valid\n args = CheckArgs.new\n assert_equal true, args.check_args([-5, 2, 3])\n end", "def test_check_args_false\n c = Checker.new\n assert_equal false, c.check_args([1, 1, 1, 1])\n assert_equal false, c.check_args([1,1])\n assert_equal false, c.check_args(['something', 111])\n assert_equal false, c.check_args([1, -1, 1])\n assert_equal false, c.check_args([1, 1, -1])\n end", "def test_positive\n args = Arguments.new\n assert_equal false, args.check_args(5)\n end", "def test_check_num_args_invalid_negative\n args = CheckNumArgs.new\n assert_equal false, args.check_args([0,-1,-1])\n end", "def test_args_check_less\n\t\targs_checker = ArgsChecker::new\n\t\tarr = []\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend", "def test_check_args_invalid2\n args = CheckArgs.new\n assert_equal false, args.check_args([1, 2])\n end", "def test_two_valid_arguments\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1])\n\tend", "def test_check_args_invalid_zero\n args = CheckArgs.new\n assert_equal false, args.check_args([2, 0, 0])\n end", "def test_check_num_args_invalid_zero\n args = CheckNumArgs.new\n assert_equal false, args.check_args([0,0,0])\n end", "def test_positive\r\n args = Args.new\r\n assert_equal false, args.check_args(6)\r\n end", "def test_check_args_invalid_negative\n args = CheckArgs.new\n assert_equal false, args.check_args([6, -2, -3])\n end", "def test_arg_check_oneArg\n \t@args = ArgumentCheck.new\n \tassert_equal(true, @args.arg_check([1]))\n end", "def check_args(args)\n begin\n results = [Integer(args[0]), Integer(args[1])] \n rescue ArgumentError, TypeError\n puts 'Invalid input.' \n end\n args.count == 2 && results[1] >= 1\nrescue StandardError\n false\nend", "def validate_args (args)\n\t# todo\nend", "def test_check_num_args_string2\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO', 'THERE'])\n end", "def test_arg_check_turns_valid\n ret = arg_check_turns '1'\n assert_equal ret, 0\n end", "def test_args_check_greater\n\t\targs_checker = ArgsChecker::new\n\t\tarr = [2, 4]\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend", "def check_args(args)\n args.count == 2 && args[0].to_i > 0 && args[1].to_i > 0\n rescue StandardError\n false\n end", "def test_check_num_args_string3\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO', 'THERE', 'KENOBI'])\n end", "def test_check_num_args_string1\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO'])\n end", "def test_args_check_nil\n\t\targs_checker = ArgsChecker::new\n\t\tarr = nil\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend", "def test_zero\n args = Arguments.new\n assert_equal false, args.check_args(0)\n end", "def test_missing_argument_invalid_argument\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1,'s'])\n\tend", "def test_double_argument\n\t\tc = Check.new\n\t\tassert c.check_arguments([1,1.2,1])\n\tend", "def test_negative\r\n args = Args.new\r\n assert_equal false, args.check_args(\"hello\")\r\n end", "def test_zero\r\n args = Args.new\r\n assert_equal false, args.check_args(0)\r\n end", "def test_nil_args\n refute check_args(nil)\n end", "def test_zero_prospectors\n\t\tassert check_args([1, 0])\n\tend", "def test_arg_check_3string\n \t@args = ArgumentCheck.new\n \tassert_equal(false, @args.arg_check(['poop', 'poopy', 'poopypoop']))\n end", "def test_check_args_invalid_string2\n args = CheckArgs.new\n assert_equal false, args.check_args(['HI', 4, 'There'])\n end", "def test_negative_argument\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1,-2])\n\tend", "def check_args(arguments)\r\n if arguments.length != 3\r\n puts 'There must be exactly three arguments: *seed*, *num_prospectors*, *num_turns*'\r\n return false\r\n elsif arguments[1].to_i.negative? || arguments[2].to_i.negative?\r\n puts 'Usage:'\r\n puts 'ruby ruby_rush.rb *seed* *num_prospectors* *num_turns*'\r\n puts '*seed* should be an integer'\r\n puts '*num_prospectors* should be a non-negative integer'\r\n puts '*num_turns* should be a non-negative integer'\r\n return false\r\n end\r\n true\r\nend", "def validate_args_count(expected, got)\n if (expected.is_a?(Numeric) and expected != got) or\n (expected.is_a?(Range) and !(expected === got))\n raise ArgumentError, \"wrong number of arguments for '#{name}' (#{got} for #{expected})\"\n end\n end", "def test_int_check_pass\n assert_equal int_check([]), true # EDGE CASE\n assert_equal int_check(['1']), true # pass\n assert_equal int_check(['1', '1']), true # pass\n assert_equal int_check(['1', '1', '1']), true # pass\n end", "def test_nonzero_arguments\n args_checker = ArgsChecker.new\n arr = [1]\n assert_equal false, args_checker.check_mode(arr)\n end", "def test_string_argument\n\t\tc = Check.new\n\t\tassert c.check_arguments([1,'1',1])\n\tend", "def test_arg_check_prospectors_valid\n ret = arg_check_prospectors '1'\n assert_equal ret, 0\n end", "def test_neg_prospectors\n\t\trefute check_args([1, -1])\n\tend", "def test_arg_check_turns_negative\n def exit(x); 1; end\n ret = arg_check_turns '-1'\n assert_equal ret, -4\n end", "def test_arg_check_2string\n \t@args = ArgumentCheck.new\n \tassert_equal(false, @args.arg_check(['poop', 'poopy']))\n end", "def test_check_args_invalid_string\n args = CheckArgs.new\n assert_equal false, args.check_args(['HI'])\n end", "def check_arg_structure(args)\n valid = true\n valid &&= args.class == Array\n \n args.each do |a|\n valid &&= a.class == Array \n valid &&= a.size == 2\n a.each do |s|\n valid &&= s.class == String\n end\n end\n\n raise \"Imported function arguments in invalid form\" unless valid\n end", "def check_arg_structure(args)\n valid = true\n valid &&= args.class == Array\n \n args.each do |a|\n valid &&= a.class == Array \n valid &&= a.size == 2\n a.each do |s|\n valid &&= s.class == String\n end\n end\n\n raise \"Imported function arguments in invalid form\" unless valid\n end", "def test_no_arg\n\tassert_output(nil, abort) {GoldRush.argchecker(-1)}\n end", "def check_arguments\n convert_boolean_strings\n check_output\n check_log_level\n check_input_entry\n check_input_types\n end", "def test_arg_check_length_fail\n def exit(x); 1; end;\n ret = arg_check_length 2\n assert_equal ret, -1\n end", "def arg_check(args, types = nil, server = nil)\n return args unless types\n\n args.each_with_index.map do |arg, i|\n next arg if types[i].nil? || types[i] == String\n\n if types[i] == Integer\n begin\n Integer(arg, 10)\n rescue ArgumentError\n nil\n end\n elsif types[i] == Float\n begin\n Float(arg)\n rescue ArgumentError\n nil\n end\n elsif types[i] == Time\n begin\n Time.parse arg\n rescue ArgumentError\n nil\n end\n elsif types[i] == TrueClass || types[i] == FalseClass\n if arg.casecmp('true').zero? || arg.downcase.start_with?('y')\n true\n elsif arg.casecmp('false').zero? || arg.downcase.start_with?('n')\n false\n end\n elsif types[i] == Symbol\n arg.to_sym\n elsif types[i] == Encoding\n begin\n Encoding.find arg\n rescue ArgumentError\n nil\n end\n elsif types[i] == Regexp\n begin\n Regexp.new arg\n rescue ArgumentError\n nil\n end\n elsif types[i] == Rational\n begin\n Rational(arg)\n rescue ArgumentError\n nil\n end\n elsif types[i] == Range\n begin\n if arg.include? '...'\n Range.new(*arg.split('...').map(&:to_i), true)\n elsif arg.include? '..'\n Range.new(*arg.split('..').map(&:to_i))\n end\n rescue ArgumentError\n nil\n end\n elsif types[i] == NilClass\n nil\n elsif [Discordrb::User, Discordrb::Role, Discordrb::Emoji].include? types[i]\n result = parse_mention arg, server\n result if result.instance_of? types[i]\n elsif types[i] == Discordrb::Invite\n resolve_invite_code arg\n elsif types[i].respond_to?(:from_argument)\n begin\n types[i].from_argument arg\n rescue StandardError\n nil\n end\n else\n raise ArgumentError, \"#{types[i]} doesn't implement from_argument\"\n end\n end\n end", "def test_check_seed_valid_int_negative\n test_args = [-1, 2, 3]\n args = Args.new test_args\n assert_equal(-1, args.check_seed(test_args[0]))\n end", "def test_arg_check_prospectors_negative\n def exit(x); 1; end\n ret = arg_check_prospectors '-1'\n assert_equal ret, -3\n end", "def test_no_arg\n\tassert_output(nil, abort) {GoldRush.argchecker()}\n end", "def validate_arguments(args={})\n return if args.count == 1 && args.key?(:all)\n\n only_options = args[:only] || Set.new\n except_options = args[:except] || Set.new\n skip_options = args[:skip] || Set.new\n\n unless (only_options & except_options).empty? &&\n (only_options & skip_options).empty?\n\n raise IncorrectArgumentException.new(\n nil,\n <<-TXT\n The same arguments shouldn't be used\n with different keys excluding except and skip\n TXT\n )\n end\n\n if args[:skip] == 'all' && args.count > 1\n raise IncorrectArgumentException.new(\n nil,\n <<-TXT\n Option 'skip' with argument 'all' shouldn't be used\n with another options\n TXT\n )\n end\n end", "def check_requirement!(*args)\n args_length = args.length\n required_length = @required.length\n\n if args_length < required_length\n raise ArgumentError, \"Wrong number of arguments \" \\\n \"(#{args_length} for #{required_length}). \" \\\n \"Expected `#{@required.join(', ')}` as required arguments, \" \\\n \"but got `#{args.join(\", \")}`.\"\n end\n end", "def test_string\n args = Arguments.new\n assert_equal false, args.check_args(\"puppy\")\n end", "def valid_arguments?\n arguments_passed? && right_type?\n end", "def check_arguments arguments\n arguments.each_with_index do |argument, index|\n next if argument.is_a? Numeric\n next if argument.is_a? String\n next if argument.is_a? Symbol\n next if argument.is_a? Hash\n next if argument.is_a? NilClass\n next if argument.is_a? TrueClass\n next if argument.is_a? FalseClass\n\n raise ArgumentError, \"Cannot send complex data for block argument #{index + 1}: #{argument.class.name}\"\n end\n\n arguments\n end", "def test_num_check_pass\n assert_nil num_check(['1', '1', '1']) # pass\n assert_nil num_check(['k', 'k', 'k']) # pass\n end", "def test_abnormal_usage\n test_args = [-9, -9, -9]\n args = Args.new test_args\n\n args.stub(:exit, 1) do\n assert_output(\"Usage:\\nruby ruby_rush.rb *seed* *num_prospectors* *num_turns\\n*seed* should be an integer\\n*num_prospectors* should be a non-negative integer\\n*num_turns* should be a non-negative integer\\n\"){args.validate_args}\n end\n end", "def test_num_check_fail\n assert_equal num_check([]), false # pass\n assert_equal num_check(['1']), false # pass\n assert_equal num_check(['1', '1']), false # pass\n assert_equal num_check(['k', 'k', 'k', 'k']), false # pass\n end", "def test_int_check_fail\n assert_equal int_check(['k', 'k', 'k']), false # pass\n assert_equal int_check(['a', 's', 'd', 'f']), false # pass\n end", "def test_empty\r\n args = Args.new\r\n assert_equal false, args.check_args(\" \")\r\n end", "def arguments_passed?\n !!(ARGV[0] && ARGV[1] && ARGV[2])\n end", "def verify_args(method, args)\n matches = Chassis.signatures[method].select do |key|\n args[key]\n end\n \n misses = Chassis.signatures[method] - matches\n \n unless misses.empty?\n raise \"Required arguments missing for '#{method}': #{misses.join(\", \")}\"\n end\n end", "def check_arguments_count(input_params)\n return if input_params.count >= declared_params.count\n raise ArgumentError, \"#{declared_params.count} parameters expected.\"\n end", "def test_positive_int\n cfg = ReqArgCfg.new(:id).as(:positive_int)\n assert_raises ArgumentError do\n ReqArg.new('0', cfg)\n end\n end", "def params_check(*args) \n if args.length == 1\n if args[0].class == Array\n if params[args[0][0]][args[0][1]] && !params[args[0][0]][args[0][1]].empty?\n true\n end\n else \n if params[args[0]] && !params[args[0]].empty?\n true\n end\n end\n elsif args.length == 2\n if args[0].class == Array\n if params[args[0][0]][args[0][1]] && params[args[0][0]][args[0][1]] == args[1]\n true\n end\n else\n if params[args[0]] && params[args[0]] == args[1]\n true\n end\n end \n end\n end", "def test_bad_argument\n assert_equal 1, go_with_args(%w(--this_is_really_redonculouslywrong))\n assert_match(/Error: bad arguments/, @stderr_io.string )\n end", "def isNumber _args\n \"isNumber _args;\" \n end", "def arguments(required, *optional)\n puts \"required: #{required}\"\n puts \"optional: #{optional}\"\nend", "def test_correct_extra_arg\n a_parse = Argparser.new\n assert !a_parse.correct?([-20, 5, 1, 0])\n end", "def assert _args\n \"assert _args;\" \n end", "def validate_arguments(args={})\n return if args.count == 1 && args.keys.include?(:all)\n only_options = args[:only] || Set.new\n except_options = args[:except] || Set.new\n skip_options = args[:skip] || Set.new\n unless (only_options & except_options).empty? &&\n (only_options & skip_options).empty?\n raise IncorrectArgumentException.new(nil, 'The same arguments shouldn\\'t be used with different keys excluding except and skip')\n end\n if args[:skip] == 'all' && args.count > 1\n raise IncorrectArgumentException.new(nil, 'Option \\'skip\\' with argument \\'all\\' shouldn\\'t be used with another options')\n end\n end", "def test_arg_check_seed_valid\n ret = arg_check_seed '1'\n assert_equal ret, 0\n end", "def CheckArguments\n arg_n = Ops.subtract(Builtins.size(WFM.Args), 1)\n\n arg_list = []\n\n while Ops.greater_or_equal(arg_n, 0)\n if WFM.Args(arg_n) == path(\".test\")\n Mode.SetTest(\"test\")\n elsif WFM.Args(arg_n) == path(\".testp\")\n Mode.SetTest(\"test\") # .testp implies .test\n @test_popup = true\n elsif Ops.is_string?(WFM.Args(arg_n))\n s = Builtins.tostring(WFM.Args(arg_n))\n if s == \"--install\"\n @action = :install\n elsif s == \"--remove\"\n @action = :remove\n elsif s == \"--update\"\n @action = :update\n else\n arg_list = Builtins.add(arg_list, s)\n end\n elsif Ops.is_list?(WFM.Args(arg_n))\n Builtins.foreach(Convert.to_list(WFM.Args(arg_n))) do |arg|\n arg_list = Builtins.add(arg_list, Builtins.tostring(arg))\n end\n end\n arg_n = Ops.subtract(arg_n, 1)\n end\n\n Builtins.y2milestone(\"action: %1\", @action)\n deep_copy(arg_list)\n end", "def validate(args = {})\n end", "def arguments_valid?\n true \n # to do\n end", "def params_check(*args)\n if args.length == 1\n if args[0].class == Array\n if params[args[0][0]][args[0][1]] && !params[args[0][0]][args[0][1]].nil?\n true\n end\n else \n if params[args[0]] && !params[args[0]].nil?\n true\n end\n end\n elsif args.length == 2\n if args[0].class == Array\n if params[args[0][0]][args[0][1]] && params[args[0][0]][args[0][1]] == args[1]\n true\n end\n else\n if params[args[0]] && params[args[0]] == args[1]\n true\n end\n end \n end\n end", "def check_arity(obj, n_args)\n ary = obj.arity\n\n if ary >= 0\n n_args == ary\n else\n n_args >= (ary+1).abs \n end\n end", "def check_arguments(params, *args)\n contains = true\n args.each do |arg|\n contains = false unless params.key? arg.to_sym\n end\n contains\n end", "def arguments_valid?\n true\n end", "def valid_args?(args={})\n valid = false\n arguments.each do |name, argument|\n if argument[:required]\n return false if args[name] == nil\n end\n valid = argument.valid_input?(args[name])\n end\n return valid\n end", "def test_negative_should_take_no_arguments\n assert_equal(0, cli_class.instance_method(:negative).arity)\n end", "def arguments_valid?\n true \n end", "def validate_numarg (num) \n raise NonNumericArgumentError if !num.numeric?\n num\nend", "def arguments_valid?\n # TO DO - implement your real logic here\n true if (1..2).include? @arguments.length \n end", "def check_arguments(exp_num, args, cond=nil)\n cond = Proc.new{|n| !n.nil?} if cond.nil?\n return exp_num == args.select{|n| cond.call(n)}.size\n end", "def test_check_valid\n assert_equal check_valid([2, '1', '5']), [0, 2, 1, 5]\n end", "def wrong_num_parameters?\n (ARGV.size != 1)\n end", "def test_no_arg_case\n assert_equal \"wrong number of arguments (given 1, expected 0)\",\n @subject.recreate(Signature.new(\n positional_params: Params.new(all: []),\n positional_args: [1],\n keyword_params: Params.new(all: []),\n keyword_args: {}\n ))\n assert_equal \"wrong number of arguments (given 2, expected 0)\",\n @subject.recreate(Signature.new(\n positional_params: Params.new(all: []),\n positional_args: [1, 2],\n keyword_params: Params.new(all: []),\n keyword_args: {}\n ))\n end", "def arguments_valid?\n return false if @arguments.length != 2\n @number = @arguments[0].to_i\n @value = @arguments[1].to_i\n true if (@number > 0 && @value > (@number-1) && @value < (@number*6+1)) \n end", "def arg_check_length(arg_l)\n if arg_l < 3\n puts 'Usage:\\n'\n puts 'ruby ruby_rush.rb <seed> <num_prospectors> <num_turns>\\n'\n puts '<seed> should be an integer\\n'\n puts '<num_prospectors> should be a non-negative integer\\n'\n puts '<num_turns> should be a non-negative integer\\n\\n'\n exit(1)\n return -1\n end\n 0\nend", "def arguments_valid?\n true\n end", "def check_args(hash)\n if !hash.include? :hostname\n raise ArgumentError, \"You must provide a hostname\"\n elsif !hash.include? :service_name\n raise ArgumentError, \"You must provide a service name\"\n elsif !hash.include? :return_code\n raise ArgumentError, \"You must provide a return code\"\n elsif !hash.include? :status\n raise ArgumentError, \"You must provide a status\"\n end\n end", "def arguments_valid?\n # TO DO - implement your real logic here\n true if @arguments.length == 2\n end" ]
[ "0.87442356", "0.85890675", "0.8543306", "0.8303799", "0.8285439", "0.8243621", "0.81646657", "0.81568164", "0.80655825", "0.8044522", "0.7974889", "0.7962927", "0.79463613", "0.7940352", "0.79275155", "0.7923058", "0.7868439", "0.7772626", "0.76505864", "0.76136786", "0.75081486", "0.74949855", "0.74825966", "0.74025685", "0.73987585", "0.73681396", "0.73389375", "0.73254263", "0.73130584", "0.729259", "0.72547287", "0.7253689", "0.7234119", "0.7216232", "0.720779", "0.710844", "0.7093708", "0.7077415", "0.70714575", "0.7041667", "0.7040908", "0.70384437", "0.70232743", "0.6973683", "0.69371164", "0.6926016", "0.6839989", "0.68271023", "0.6781078", "0.6781078", "0.67676437", "0.67602545", "0.6733901", "0.6704966", "0.6680288", "0.6663694", "0.6633137", "0.6500814", "0.6495183", "0.6486828", "0.64529866", "0.6436468", "0.64163274", "0.6414142", "0.64015234", "0.6401476", "0.6396386", "0.63681185", "0.635752", "0.63515854", "0.6340178", "0.63244134", "0.6321617", "0.63193244", "0.6318011", "0.6316372", "0.63093144", "0.6306275", "0.6300874", "0.62953395", "0.62597215", "0.625509", "0.62508494", "0.62470686", "0.6226824", "0.6215395", "0.61881876", "0.61751294", "0.6172401", "0.6169273", "0.6163856", "0.61327696", "0.61006445", "0.6096927", "0.60890055", "0.6088877", "0.6084626", "0.6080105", "0.6068292", "0.60678554" ]
0.8391691
3
This test checks to make sure that check_args will fail, given that the user sends a negative integer into the prospectors parameter
def test_neg_prospectors refute check_args([1, -1]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_arg_check_prospectors_negative\n def exit(x); 1; end\n ret = arg_check_prospectors '-1'\n assert_equal ret, -3\n end", "def test_zero_prospectors\n\t\tassert check_args([1, 0])\n\tend", "def test_arg_check_prospectors_valid\n ret = arg_check_prospectors '1'\n assert_equal ret, 0\n end", "def test_check_num_args_invalid_negative\n args = CheckNumArgs.new\n assert_equal false, args.check_args([0,-1,-1])\n end", "def test_args_check_less\n\t\targs_checker = ArgsChecker::new\n\t\tarr = []\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend", "def test_check_args_invalid_negative\n args = CheckArgs.new\n assert_equal false, args.check_args([6, -2, -3])\n end", "def test_check_args_false\n c = Checker.new\n assert_equal false, c.check_args([1, 1, 1, 1])\n assert_equal false, c.check_args([1,1])\n assert_equal false, c.check_args(['something', 111])\n assert_equal false, c.check_args([1, -1, 1])\n assert_equal false, c.check_args([1, 1, -1])\n end", "def test_check_args_invalid_zero\n args = CheckArgs.new\n assert_equal false, args.check_args([2, 0, 0])\n end", "def test_positive\n args = Arguments.new\n assert_equal false, args.check_args(5)\n end", "def test_check_num_args_invalid_zero\n args = CheckNumArgs.new\n assert_equal false, args.check_args([0,0,0])\n end", "def test_positive\r\n args = Args.new\r\n assert_equal false, args.check_args(6)\r\n end", "def test_check_num_args_invalid2\n args = CheckNumArgs.new\n assert_equal false, args.check_args([1])\n end", "def test_check_args_valid\n args = CheckArgs.new\n assert_equal true, args.check_args([-5, 2, 3])\n end", "def test_check_num_args_invalid3\n args = CheckNumArgs.new\n assert_equal false, args.check_args([1, 2])\n end", "def test_negative_argument\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1,-2])\n\tend", "def test_negative\r\n args = Args.new\r\n assert_equal false, args.check_args(\"hello\")\r\n end", "def test_one_ints\n args = Arguments.new\n assert_equal false, args.check_args([1])\n end", "def test_args_check_greater\n\t\targs_checker = ArgsChecker::new\n\t\tarr = [2, 4]\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend", "def test_check_num_args_valid\n args = CheckNumArgs.new\n assert_equal true, args.check_args([1,1,1])\n end", "def test_args_check_nil\n\t\targs_checker = ArgsChecker::new\n\t\tarr = nil\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend", "def test_raises_incorrect_prospectors_input\n assert_raises \"Should raise error when prospectors input is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.prospectors_check(0)\n end\n \n assert_raises \"Should raise error when prospectors input is not an integer!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n rb_rush.prospectors_check(1.1)\n end\n \n assert_raises \"Should raise error when prospectors input is not an integer and is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.prospectors_check(-1.1)\n end\n \n assert_raises \"Should raise error when prospectors input is not a number!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.prospectors_check(\"\")\n end\n \n end", "def test_two_ints\n args = Arguments.new\n assert_equal false, args.check_args([1, 2])\n end", "def test_check_num_args_valid2\n args = CheckNumArgs.new\n args.check_args([1,1,1])\n assert_kind_of Integer, 1\n end", "def test_missing_argument_invalid_argument\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1,'s'])\n\tend", "def test_check_args_invalid2\n args = CheckArgs.new\n assert_equal false, args.check_args([1, 2])\n end", "def test_two_proper_args\n assert check_args([1, 1])\n end", "def test_abnormal_usage\n test_args = [-9, -9, -9]\n args = Args.new test_args\n\n args.stub(:exit, 1) do\n assert_output(\"Usage:\\nruby ruby_rush.rb *seed* *num_prospectors* *num_turns\\n*seed* should be an integer\\n*num_prospectors* should be a non-negative integer\\n*num_turns* should be a non-negative integer\\n\"){args.validate_args}\n end\n end", "def test_arg_check_prospectors_decimal\n def exit(x); 1; end\n ret = arg_check_prospectors '1.6'\n assert_equal ret, -3\n end", "def test_zero\n args = Arguments.new\n assert_equal false, args.check_args(0)\n end", "def test_zero\r\n args = Args.new\r\n assert_equal false, args.check_args(0)\r\n end", "def test_arg_check_turns_negative\n def exit(x); 1; end\n ret = arg_check_turns '-1'\n assert_equal ret, -4\n end", "def check_args(arguments)\r\n if arguments.length != 3\r\n puts 'There must be exactly three arguments: *seed*, *num_prospectors*, *num_turns*'\r\n return false\r\n elsif arguments[1].to_i.negative? || arguments[2].to_i.negative?\r\n puts 'Usage:'\r\n puts 'ruby ruby_rush.rb *seed* *num_prospectors* *num_turns*'\r\n puts '*seed* should be an integer'\r\n puts '*num_prospectors* should be a non-negative integer'\r\n puts '*num_turns* should be a non-negative integer'\r\n return false\r\n end\r\n true\r\nend", "def check_args(args)\n args.count == 2 && args[0].to_i > 0 && args[1].to_i > 0\n rescue StandardError\n false\n end", "def validate_args (args)\n\t# todo\nend", "def test_three_ints\n args = Arguments.new\n assert_equal true, args.check_args([1, 2, 3])\n end", "def test_nonzero_arguments\n args_checker = ArgsChecker.new\n arr = [1]\n assert_equal false, args_checker.check_mode(arr)\n end", "def test_arg_check_turns_valid\n ret = arg_check_turns '1'\n assert_equal ret, 0\n end", "def test_arg_check_3string\n \t@args = ArgumentCheck.new\n \tassert_equal(false, @args.arg_check(['poop', 'poopy', 'poopypoop']))\n end", "def test_no_arg\n\tassert_output(nil, abort) {GoldRush.argchecker(-1)}\n end", "def test_two_valid_arguments\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1])\n\tend", "def test_negative_should_take_no_arguments\n assert_equal(0, cli_class.instance_method(:negative).arity)\n end", "def check_args(args)\n begin\n results = [Integer(args[0]), Integer(args[1])] \n rescue ArgumentError, TypeError\n puts 'Invalid input.' \n end\n args.count == 2 && results[1] >= 1\nrescue StandardError\n false\nend", "def test_check_num_args_string3\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO', 'THERE', 'KENOBI'])\n end", "def test_check_num_args_string2\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO', 'THERE'])\n end", "def test_nil_args\n refute check_args(nil)\n end", "def test_check_num_args_string1\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO'])\n end", "def validate_args_count(expected, got)\n if (expected.is_a?(Numeric) and expected != got) or\n (expected.is_a?(Range) and !(expected === got))\n raise ArgumentError, \"wrong number of arguments for '#{name}' (#{got} for #{expected})\"\n end\n end", "def test_no_arg\n\tassert_output(nil, abort) {GoldRush.argchecker()}\n end", "def test_check_seed_valid_int_negative\n test_args = [-1, 2, 3]\n args = Args.new test_args\n assert_equal(-1, args.check_seed(test_args[0]))\n end", "def test_add_option03h\n assert_raise( RuntimeError ) { \n ArgumentManager.add_option(\n [ 'p' ],\n :type => :integer,\n :min => -1,\n :max => +1,\n :df_int => 5\n )\n }\n end", "def test_check_invalid_prospectors\n assert_equal check_valid([2, 0, 1]), [1, nil, nil, nil]\n end", "def test_check_args_invalid_string2\n args = CheckArgs.new\n assert_equal false, args.check_args(['HI', 4, 'There'])\n end", "def test_arg_check_oneArg\n \t@args = ArgumentCheck.new\n \tassert_equal(true, @args.arg_check([1]))\n end", "def test_bad_argument\n assert_equal 1, go_with_args(%w(--this_is_really_redonculouslywrong))\n assert_match(/Error: bad arguments/, @stderr_io.string )\n end", "def test_check_args_invalid_string\n args = CheckArgs.new\n assert_equal false, args.check_args(['HI'])\n end", "def test_arg_check_length_fail\n def exit(x); 1; end;\n ret = arg_check_length 2\n assert_equal ret, -1\n end", "def test_correct_extra_arg\n a_parse = Argparser.new\n assert !a_parse.correct?([-20, 5, 1, 0])\n end", "def test_add_option03f\n assert_raise( RuntimeError ) { \n ArgumentManager.add_option(\n [ 'n' ],\n :type => :integer,\n :min => +1,\n :max => -1\n )\n } \n end", "def test_arg_check_2string\n \t@args = ArgumentCheck.new\n \tassert_equal(false, @args.arg_check(['poop', 'poopy']))\n end", "def test_num_workers_invalid_inputs\n assert_raises ArgumentError do\n @project_calc.calculate_project_cost(base_price: 12456.95, num_workers: nil, product_categories: ['electronics', 'books'])\n end\n assert_raises ArgumentError do\n @project_calc.calculate_project_cost(base_price: 12456.95, num_workers: 0, product_categories: ['electronics', 'books'])\n end\n assert_raises ArgumentError do\n @project_calc.calculate_project_cost(base_price: 12456.95, num_workers: -8, product_categories: ['electronics', 'books'])\n end\n end", "def test_neg_check_success\n assert_nil neg_check(['0', '0', '0']) # pass\n assert_nil neg_check(['0', '2', '3'])# pass\n end", "def test_string\n args = Arguments.new\n assert_equal false, args.check_args(\"puppy\")\n end", "def CheckArguments\n arg_n = Ops.subtract(Builtins.size(WFM.Args), 1)\n\n arg_list = []\n\n while Ops.greater_or_equal(arg_n, 0)\n if WFM.Args(arg_n) == path(\".test\")\n Mode.SetTest(\"test\")\n elsif WFM.Args(arg_n) == path(\".testp\")\n Mode.SetTest(\"test\") # .testp implies .test\n @test_popup = true\n elsif Ops.is_string?(WFM.Args(arg_n))\n s = Builtins.tostring(WFM.Args(arg_n))\n if s == \"--install\"\n @action = :install\n elsif s == \"--remove\"\n @action = :remove\n elsif s == \"--update\"\n @action = :update\n else\n arg_list = Builtins.add(arg_list, s)\n end\n elsif Ops.is_list?(WFM.Args(arg_n))\n Builtins.foreach(Convert.to_list(WFM.Args(arg_n))) do |arg|\n arg_list = Builtins.add(arg_list, Builtins.tostring(arg))\n end\n end\n arg_n = Ops.subtract(arg_n, 1)\n end\n\n Builtins.y2milestone(\"action: %1\", @action)\n deep_copy(arg_list)\n end", "def test_positive_int\n cfg = ReqArgCfg.new(:id).as(:positive_int)\n assert_raises ArgumentError do\n ReqArg.new('0', cfg)\n end\n end", "def mandatory_argument_should_exist(command, arg_name, arg_list, arg_number)\n expect { @helper.run_test_omnibus_command(command, arg_list) }\n .to raise_error(SystemExit) { |e| expect(e.status).to eq(1) }\n end", "def arg_check_length(arg_l)\n if arg_l < 3\n puts 'Usage:\\n'\n puts 'ruby ruby_rush.rb <seed> <num_prospectors> <num_turns>\\n'\n puts '<seed> should be an integer\\n'\n puts '<num_prospectors> should be a non-negative integer\\n'\n puts '<num_turns> should be a non-negative integer\\n\\n'\n exit(1)\n return -1\n end\n 0\nend", "def test_raises_incorrect_turns_input\n assert_raises \"Should raise error when turns input is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(0)\n end\n \n assert_raises \"Should raise error when turns input is not an integer!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(1.1)\n end\n \n assert_raises \"Should raise error when turns input is not an integer and is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(-1.1)\n end\n \n assert_raises \"Should raise error when turns input is not a number!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(\"\")\n end\n end", "def test_print_books_negative\n\t\tassert_raises(\"Cannot have fewer than 0 books\") { print_books(-1,-1) }\n\tend", "def test_double_argument\n\t\tc = Check.new\n\t\tassert c.check_arguments([1,1.2,1])\n\tend", "def wrong_num_parameters?\n (ARGV.size != 1)\n end", "def test_negative_should_have_the_right_option_count\n assert_equal(all_options.count, cli_options.count)\n end", "def check_requirement!(*args)\n args_length = args.length\n required_length = @required.length\n\n if args_length < required_length\n raise ArgumentError, \"Wrong number of arguments \" \\\n \"(#{args_length} for #{required_length}). \" \\\n \"Expected `#{@required.join(', ')}` as required arguments, \" \\\n \"but got `#{args.join(\", \")}`.\"\n end\n end", "def test(n)\r\n unless n >= 5\r\n raise ArgumentError, \"Zbyt maly argument: #{n} < 5\"\r\n else\r\n puts \"Ok!\"\r\n end\r\nend", "def test_correct_neg_val_print\n a_parse = Argparser.new\n assert_output(nil) do\n _unused = a_parse.correct?([-20, -5, 0])\n end\n end", "def check_arg()\n if ARGV.length > 1\n print \"ERROR: Too many command line args.\\n\"\n print \"USAGE: #{$PROGRAM_NAME} [--FixThemAll]\\n\"\n exit ERR_EXIT_ARGS2MANY\n end\n if ARGV.length == 1 && ARGV[0] != '--FixThemAll'\n print \"ERROR: Invalid argument on command line: '#{ARGV[0]}'\\n\"\n print \"USAGE: #{$PROGRAM_NAME} [--FixThemAll]\\n\"\n exit ERR_EXIT_ARGINVALID\n end\nend", "def validate_arguments()\n usage unless ARGV.count > 0\nend", "def arg_error\r\n puts \"Usage:\\nruby ruby_rush.rb *seed* *num_prospectors* *num_turns*\\n*seed* should be an integer\\n*num_prospectors*\"\\\r\n \" should be a non-negative integer\\n*num_turns* should be a non-negative integer\"\r\n exit 1\r\nend", "def test_neg_check_fail\n assert_equal neg_check(['0', '-1', '0']), false # return false\n assert_equal neg_check(['0', '0', '-1']), false # return false\n assert_equal neg_check(['0', '-9', '-9']), false # return false\n end", "def verify_args(method, args)\n matches = Chassis.signatures[method].select do |key|\n args[key]\n end\n \n misses = Chassis.signatures[method] - matches\n \n unless misses.empty?\n raise \"Required arguments missing for '#{method}': #{misses.join(\", \")}\"\n end\n end", "def validate_args\n if name_args.size < 1\n ui.error('No cookbook has been specified')\n show_usage\n exit 1\n end\n if name_args.size > 2\n ui.error('Too many arguments are being passed. Please verify.')\n show_usage\n exit 1\n end\n end", "def check_args(hash)\n if !hash.include? :hostname\n raise ArgumentError, \"You must provide a hostname\"\n elsif !hash.include? :service_name\n raise ArgumentError, \"You must provide a service name\"\n elsif !hash.include? :return_code\n raise ArgumentError, \"You must provide a return code\"\n elsif !hash.include? :status\n raise ArgumentError, \"You must provide a status\"\n end\n end", "def test_invalid_coup_params\n #scooters too big\n assert_false(CoupChallenge.new(scooters: Array.new(101), c: 1, p: 1).check_inputs)\n \n #scooters too small\n assert_false(CoupChallenge.new(scooters: [], c: 1, p: 1).check_inputs)\n \n #c too big\n assert_false(CoupChallenge.new(scooters: [1], c: 1000, p: 1).check_inputs)\n \n #c too small\n assert_false(CoupChallenge.new(scooters: [1], c: 0, p: 1).check_inputs)\n \n #p too big\n assert_false(CoupChallenge.new(scooters: [1], c: 1, p: 1001).check_inputs)\n \n #p too small\n assert_false(CoupChallenge.new(scooters: [1], c: 1, p: 0).check_inputs)\n \n #scooters[i] too big\n assert_false(CoupChallenge.new(scooters: [1001], c: 1, p: 1001).check_inputs)\n \n #scooters[i] too small\n assert_false(CoupChallenge.new(scooters: [-1], c: 1, p: 1001).check_inputs)\n end", "def test_print_dinos_negative\n\t\tassert_raises(\"Cannot have fewer than 0 dinosaur toys\") { print_dinos(-1,-1) }\n\tend", "def validate_argument(arg)\n raise ArgumentError, \"Argument #{arg} is not Fixnum\" unless arg.is_a? Fixnum\n raise ArgumentError, \"Argument #{arg} is negative\" if arg < 0\n end", "def check_arguments\n convert_boolean_strings\n check_output\n check_log_level\n check_input_entry\n check_input_types\n end", "def check_arguments arguments\n arguments.each_with_index do |argument, index|\n next if argument.is_a? Numeric\n next if argument.is_a? String\n next if argument.is_a? Symbol\n next if argument.is_a? Hash\n next if argument.is_a? NilClass\n next if argument.is_a? TrueClass\n next if argument.is_a? FalseClass\n\n raise ArgumentError, \"Cannot send complex data for block argument #{index + 1}: #{argument.class.name}\"\n end\n\n arguments\n end", "def arguments_valid?\n true \n # to do\n end", "def check_arguments_count(input_params)\n return if input_params.count >= declared_params.count\n raise ArgumentError, \"#{declared_params.count} parameters expected.\"\n end", "def test_arg_check_turns_decimal\n def exit(x); 1; end\n ret = arg_check_turns '1.6'\n assert_equal ret, -4\n end", "def test_string_argument\n\t\tc = Check.new\n\t\tassert c.check_arguments([1,'1',1])\n\tend", "def validate(args = {})\n end", "def wrong_args_message(size, min, max)\n e = min == max ? min : \"#{min}..#{max}\"\n \"Wrong number of arguments. Received #{size} instead of #{e}.\"\n end", "def test_add_option03a\n assert_nothing_raised( Exception ) { \n ArgumentManager.add_option(\n [ 'i' ],\n :type => :integer,\n :df_int => 0\n )\n }\n end", "def test_empty\r\n args = Args.new\r\n assert_equal false, args.check_args(\" \")\r\n end", "def validate\n (raise ArgumentError, 'Wrong number of arguments, expected 1' if ARGV.length != 1)\n (raise IndexError, 'Input parameter has to be a natural number' unless /\\A\\d+\\z/.match(@price))\n (raise IndexError, 'Minimal price is 8 cents' if @price.to_i < 8)\n end", "def arguments_valid?\n true \n end", "def test_add_option03c\n assert_nothing_raised( Exception ) {\n ArgumentManager.add_option(\n [ 'k' ],\n :type => :integer,\n :mandatory => true,\n :df_int => 0\n )\n }\n end", "def test_add_option03b\n assert_nothing_raised( Exception ) { \n ArgumentManager.add_option(\n [ 'j' ],\n :type => :integer\n )\n }\n end", "def arguments_valid?\n true\n end", "def test_add_option03d\n assert_nothing_raised( Exception ) {\n ArgumentManager.add_option(\n [ 'l' ],\n :type => :integer,\n :mandatory => true\n )\n }\n end" ]
[ "0.82463735", "0.82371026", "0.82313204", "0.7844593", "0.7760241", "0.77132714", "0.7702076", "0.7564594", "0.75642926", "0.75500464", "0.7549203", "0.7542663", "0.7521135", "0.74918616", "0.7389225", "0.7334671", "0.7329245", "0.73220724", "0.72621655", "0.7236182", "0.7224513", "0.7203173", "0.72011495", "0.7198675", "0.71840423", "0.71453065", "0.7107941", "0.70804006", "0.7078446", "0.70677024", "0.70145017", "0.6986204", "0.6944898", "0.69237506", "0.69091326", "0.68954796", "0.6828755", "0.6803909", "0.67782986", "0.67707586", "0.67678", "0.6749595", "0.6708587", "0.6700723", "0.6668566", "0.66681165", "0.6660612", "0.66194284", "0.65471345", "0.6522796", "0.65189636", "0.6503333", "0.6484311", "0.64832675", "0.64544284", "0.64346284", "0.6432045", "0.64190966", "0.64080304", "0.6404147", "0.6394783", "0.63879275", "0.63258237", "0.6302539", "0.62915397", "0.6257788", "0.62545073", "0.62377936", "0.6171545", "0.61707884", "0.61649936", "0.61465883", "0.6139089", "0.613538", "0.61172044", "0.6112064", "0.610127", "0.60892457", "0.6087468", "0.6083333", "0.60740364", "0.6072682", "0.6067422", "0.6059219", "0.6055464", "0.60482454", "0.60451174", "0.6036917", "0.6026616", "0.60242295", "0.60183907", "0.60181606", "0.6012736", "0.59990233", "0.5982342", "0.59667844", "0.5943967", "0.59437186", "0.5931352", "0.5929887" ]
0.83980465
0
This test checks to make sure that check_args still passes, given that the user sends zero into the prospectors parameter EDGE CASE
def test_zero_prospectors assert check_args([1, 0]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_neg_prospectors\n\t\trefute check_args([1, -1])\n\tend", "def test_arg_check_prospectors_valid\n ret = arg_check_prospectors '1'\n assert_equal ret, 0\n end", "def test_args_check_less\n\t\targs_checker = ArgsChecker::new\n\t\tarr = []\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend", "def test_check_args_false\n c = Checker.new\n assert_equal false, c.check_args([1, 1, 1, 1])\n assert_equal false, c.check_args([1,1])\n assert_equal false, c.check_args(['something', 111])\n assert_equal false, c.check_args([1, -1, 1])\n assert_equal false, c.check_args([1, 1, -1])\n end", "def test_check_args_invalid_zero\n args = CheckArgs.new\n assert_equal false, args.check_args([2, 0, 0])\n end", "def test_arg_check_prospectors_negative\n def exit(x); 1; end\n ret = arg_check_prospectors '-1'\n assert_equal ret, -3\n end", "def test_positive\r\n args = Args.new\r\n assert_equal false, args.check_args(6)\r\n end", "def test_zero\r\n args = Args.new\r\n assert_equal false, args.check_args(0)\r\n end", "def test_check_num_args_invalid_zero\n args = CheckNumArgs.new\n assert_equal false, args.check_args([0,0,0])\n end", "def test_positive\n args = Arguments.new\n assert_equal false, args.check_args(5)\n end", "def test_zero\n args = Arguments.new\n assert_equal false, args.check_args(0)\n end", "def test_args_check_nil\n\t\targs_checker = ArgsChecker::new\n\t\tarr = nil\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend", "def test_check_num_args_invalid_negative\n args = CheckNumArgs.new\n assert_equal false, args.check_args([0,-1,-1])\n end", "def test_check_args_valid\n args = CheckArgs.new\n assert_equal true, args.check_args([-5, 2, 3])\n end", "def test_nonzero_arguments\n args_checker = ArgsChecker.new\n arr = [1]\n assert_equal false, args_checker.check_mode(arr)\n end", "def test_check_args_invalid_negative\n args = CheckArgs.new\n assert_equal false, args.check_args([6, -2, -3])\n end", "def test_negative\r\n args = Args.new\r\n assert_equal false, args.check_args(\"hello\")\r\n end", "def test_two_proper_args\n assert check_args([1, 1])\n end", "def test_check_args_invalid2\n args = CheckArgs.new\n assert_equal false, args.check_args([1, 2])\n end", "def test_check_num_args_invalid2\n args = CheckNumArgs.new\n assert_equal false, args.check_args([1])\n end", "def test_no_arg\n\tassert_output(nil, abort) {GoldRush.argchecker()}\n end", "def test_negative_argument\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1,-2])\n\tend", "def test_no_arg\n\tassert_output(nil, abort) {GoldRush.argchecker(-1)}\n end", "def test_args_check_greater\n\t\targs_checker = ArgsChecker::new\n\t\tarr = [2, 4]\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend", "def test_check_num_args_invalid3\n args = CheckNumArgs.new\n assert_equal false, args.check_args([1, 2])\n end", "def test_nil_args\n refute check_args(nil)\n end", "def test_raises_incorrect_prospectors_input\n assert_raises \"Should raise error when prospectors input is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.prospectors_check(0)\n end\n \n assert_raises \"Should raise error when prospectors input is not an integer!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n rb_rush.prospectors_check(1.1)\n end\n \n assert_raises \"Should raise error when prospectors input is not an integer and is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.prospectors_check(-1.1)\n end\n \n assert_raises \"Should raise error when prospectors input is not a number!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.prospectors_check(\"\")\n end\n \n end", "def test_one_ints\n args = Arguments.new\n assert_equal false, args.check_args([1])\n end", "def test_check_num_args_valid\n args = CheckNumArgs.new\n assert_equal true, args.check_args([1,1,1])\n end", "def test_two_valid_arguments\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1])\n\tend", "def test_missing_argument_invalid_argument\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1,'s'])\n\tend", "def test_arg_check_prospectors_decimal\n def exit(x); 1; end\n ret = arg_check_prospectors '1.6'\n assert_equal ret, -3\n end", "def test_arg_check_turns_valid\n ret = arg_check_turns '1'\n assert_equal ret, 0\n end", "def test_two_ints\n args = Arguments.new\n assert_equal false, args.check_args([1, 2])\n end", "def test_abnormal_usage\n test_args = [-9, -9, -9]\n args = Args.new test_args\n\n args.stub(:exit, 1) do\n assert_output(\"Usage:\\nruby ruby_rush.rb *seed* *num_prospectors* *num_turns\\n*seed* should be an integer\\n*num_prospectors* should be a non-negative integer\\n*num_turns* should be a non-negative integer\\n\"){args.validate_args}\n end\n end", "def validate_args (args)\n\t# todo\nend", "def test_arg_check_3string\n \t@args = ArgumentCheck.new\n \tassert_equal(false, @args.arg_check(['poop', 'poopy', 'poopypoop']))\n end", "def test_exercise_115\n verify_method :exercise_115,\n :with => [{param: [0.8, 0.8], expect: true},\n {param: [0.1, 0.1], expect: true},\n {param: [0.9, 0.9], expect: true},\n {param: [1, 1], expect: false},\n {param: [0, 0], expect: false}]\n end", "def test_arg_check_oneArg\n \t@args = ArgumentCheck.new\n \tassert_equal(true, @args.arg_check([1]))\n end", "def test_check_num_args_valid2\n args = CheckNumArgs.new\n args.check_args([1,1,1])\n assert_kind_of Integer, 1\n end", "def check_args(args)\n args.count == 2 && args[0].to_i > 0 && args[1].to_i > 0\n rescue StandardError\n false\n end", "def test_check_invalid_prospectors\n assert_equal check_valid([2, 0, 1]), [1, nil, nil, nil]\n end", "def test_double_argument\n\t\tc = Check.new\n\t\tassert c.check_arguments([1,1.2,1])\n\tend", "def test_empty\r\n args = Args.new\r\n assert_equal false, args.check_args(\" \")\r\n end", "def test_reject_community\n assert !public_trap_passes?(\"test\")\n assert !public_trap_passes?([\"foo\", \"bar\"])\n assert !public_trap_passes?([])\n end", "def test_three_ints\n args = Arguments.new\n assert_equal true, args.check_args([1, 2, 3])\n end", "def test_arg_check_2string\n \t@args = ArgumentCheck.new\n \tassert_equal(false, @args.arg_check(['poop', 'poopy']))\n end", "def check_args(arguments)\r\n if arguments.length != 3\r\n puts 'There must be exactly three arguments: *seed*, *num_prospectors*, *num_turns*'\r\n return false\r\n elsif arguments[1].to_i.negative? || arguments[2].to_i.negative?\r\n puts 'Usage:'\r\n puts 'ruby ruby_rush.rb *seed* *num_prospectors* *num_turns*'\r\n puts '*seed* should be an integer'\r\n puts '*num_prospectors* should be a non-negative integer'\r\n puts '*num_turns* should be a non-negative integer'\r\n return false\r\n end\r\n true\r\nend", "def test_negative_should_take_no_arguments\n assert_equal(0, cli_class.instance_method(:negative).arity)\n end", "def test_arg_check_turns_negative\n def exit(x); 1; end\n ret = arg_check_turns '-1'\n assert_equal ret, -4\n end", "def test_check_num_args_string1\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO'])\n end", "def test_neg_check_success\n assert_nil neg_check(['0', '0', '0']) # pass\n assert_nil neg_check(['0', '2', '3'])# pass\n end", "def test_exercise_1115\n verify_method :exercise_1115,\n :with => [{params: [[0], 1], expect: [1]},\n {params: [[0], 2], expect: [1, 0]},\n {params: [[1, 1], 2], expect: [0, 2]},\n {params: [[1, 2, 3, 3, 3, 4], 5], expect: [0, 1, 1, 3, 1]}]\n end", "def test_under_production_over_consumption_of_arguments\n assert_raises VishArgumentError do\n result = interpret 'low=->(f, g) { 1 };%low()'\n end\n end", "def test_check_args_invalid_string\n args = CheckArgs.new\n assert_equal false, args.check_args(['HI'])\n end", "def CheckArguments\n arg_n = Ops.subtract(Builtins.size(WFM.Args), 1)\n\n arg_list = []\n\n while Ops.greater_or_equal(arg_n, 0)\n if WFM.Args(arg_n) == path(\".test\")\n Mode.SetTest(\"test\")\n elsif WFM.Args(arg_n) == path(\".testp\")\n Mode.SetTest(\"test\") # .testp implies .test\n @test_popup = true\n elsif Ops.is_string?(WFM.Args(arg_n))\n s = Builtins.tostring(WFM.Args(arg_n))\n if s == \"--install\"\n @action = :install\n elsif s == \"--remove\"\n @action = :remove\n elsif s == \"--update\"\n @action = :update\n else\n arg_list = Builtins.add(arg_list, s)\n end\n elsif Ops.is_list?(WFM.Args(arg_n))\n Builtins.foreach(Convert.to_list(WFM.Args(arg_n))) do |arg|\n arg_list = Builtins.add(arg_list, Builtins.tostring(arg))\n end\n end\n arg_n = Ops.subtract(arg_n, 1)\n end\n\n Builtins.y2milestone(\"action: %1\", @action)\n deep_copy(arg_list)\n end", "def test_check_num_args_string2\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO', 'THERE'])\n end", "def setup_args_valid?(argsArr)\r\n if nil==argsArr[0] or argsArr[0]==\"\"\r\n return \"Bot token cannot be empty or nil.\"\r\n elsif nil==argsArr[1] or argsArr[1]==\"\"\r\n return \"Bot clientId cannot be empty or nil.\"\r\n elsif nil==argsArr[2]\r\n return \"Bot command prefix cannot be nil.\"\r\n end\r\n\r\n return nil\r\n end", "def test_exercise_113\n verify_method :exercise_113,\n :with => [{param: '1 2 3', expect: false},\n {param: '1 1 1', expect: true}]\n end", "def test_check_num_args_string3\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO', 'THERE', 'KENOBI'])\n end", "def checks=(_arg0); end", "def test_exercise_1113\n verify_method :exercise_1113,\n :with => [{param: [[0]], expect: [[0]]},\n {param: [[0, 1]],\n expect: [[0],\n [1]]},\n {param: [[0, 1],\n [2, 3]],\n expect: [[0, 2],\n [1, 3]]}]\n\n end", "def test_check_args_invalid_string2\n args = CheckArgs.new\n assert_equal false, args.check_args(['HI', 4, 'There'])\n end", "def test_invalid_coup_params\n #scooters too big\n assert_false(CoupChallenge.new(scooters: Array.new(101), c: 1, p: 1).check_inputs)\n \n #scooters too small\n assert_false(CoupChallenge.new(scooters: [], c: 1, p: 1).check_inputs)\n \n #c too big\n assert_false(CoupChallenge.new(scooters: [1], c: 1000, p: 1).check_inputs)\n \n #c too small\n assert_false(CoupChallenge.new(scooters: [1], c: 0, p: 1).check_inputs)\n \n #p too big\n assert_false(CoupChallenge.new(scooters: [1], c: 1, p: 1001).check_inputs)\n \n #p too small\n assert_false(CoupChallenge.new(scooters: [1], c: 1, p: 0).check_inputs)\n \n #scooters[i] too big\n assert_false(CoupChallenge.new(scooters: [1001], c: 1, p: 1001).check_inputs)\n \n #scooters[i] too small\n assert_false(CoupChallenge.new(scooters: [-1], c: 1, p: 1001).check_inputs)\n end", "def test_string\n args = Arguments.new\n assert_equal false, args.check_args(\"puppy\")\n end", "def test_no_arg_case\n assert_equal \"wrong number of arguments (given 1, expected 0)\",\n @subject.recreate(Signature.new(\n positional_params: Params.new(all: []),\n positional_args: [1],\n keyword_params: Params.new(all: []),\n keyword_args: {}\n ))\n assert_equal \"wrong number of arguments (given 2, expected 0)\",\n @subject.recreate(Signature.new(\n positional_params: Params.new(all: []),\n positional_args: [1, 2],\n keyword_params: Params.new(all: []),\n keyword_args: {}\n ))\n end", "def check_params; true; end", "def check_arguments arguments\n arguments.each_with_index do |argument, index|\n next if argument.is_a? Numeric\n next if argument.is_a? String\n next if argument.is_a? Symbol\n next if argument.is_a? Hash\n next if argument.is_a? NilClass\n next if argument.is_a? TrueClass\n next if argument.is_a? FalseClass\n\n raise ArgumentError, \"Cannot send complex data for block argument #{index + 1}: #{argument.class.name}\"\n end\n\n arguments\n end", "def test_raises_incorrect_turns_input\n assert_raises \"Should raise error when turns input is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(0)\n end\n \n assert_raises \"Should raise error when turns input is not an integer!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(1.1)\n end\n \n assert_raises \"Should raise error when turns input is not an integer and is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(-1.1)\n end\n \n assert_raises \"Should raise error when turns input is not a number!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(\"\")\n end\n end", "def check_arg_structure(args)\n valid = true\n valid &&= args.class == Array\n \n args.each do |a|\n valid &&= a.class == Array \n valid &&= a.size == 2\n a.each do |s|\n valid &&= s.class == String\n end\n end\n\n raise \"Imported function arguments in invalid form\" unless valid\n end", "def check_arg_structure(args)\n valid = true\n valid &&= args.class == Array\n \n args.each do |a|\n valid &&= a.class == Array \n valid &&= a.size == 2\n a.each do |s|\n valid &&= s.class == String\n end\n end\n\n raise \"Imported function arguments in invalid form\" unless valid\n end", "def test_exercise_1128\n verify_method :exercise_1128,\n :with => [{param: [0, 0, 1, 2, 3, 3], expect: [0, 1, 2, 3]},\n {param: [0, 1, 2, 3], expect: [0, 1, 2, 3]},\n {param: [0, 0], expect: [0]},\n {param: [0], expect: [0]}]\n end", "def test_correct_extra_arg\n a_parse = Argparser.new\n assert !a_parse.correct?([-20, 5, 1, 0])\n end", "def arguments_valid?\n true \n # to do\n end", "def check_assertion_args(assertion,failure_message)\n\tif not assertion.bool? then\n\t\traise(CHECK_ARG_ERROR_CLASS,\"Assertion expression must evaluate to a boolean, but is (Class: #{assertion.class.name.to_s} Value: #{assertion})\")\n\tend\n\tif not failure_message.text? then\n\t\traise(CHECK_ARG_ERROR_CLASS,\"Failure message must evaluate to a text, but is (Class: #{failure_message.class.name.to_s}: Value: #{failure_message.to_s})\")\n\tend\nend", "def test_check_seed_valid_int_negative\n test_args = [-1, 2, 3]\n args = Args.new test_args\n assert_equal(-1, args.check_seed(test_args[0]))\n end", "def check_arguments\n convert_boolean_strings\n check_output\n check_log_level\n check_input_entry\n check_input_types\n end", "def validate_args_count(expected, got)\n if (expected.is_a?(Numeric) and expected != got) or\n (expected.is_a?(Range) and !(expected === got))\n raise ArgumentError, \"wrong number of arguments for '#{name}' (#{got} for #{expected})\"\n end\n end", "def check_args(args)\n begin\n results = [Integer(args[0]), Integer(args[1])] \n rescue ArgumentError, TypeError\n puts 'Invalid input.' \n end\n args.count == 2 && results[1] >= 1\nrescue StandardError\n false\nend", "def offenses_to_check=(_arg0); end", "def arguments_valid?\n true \n end", "def assert _args\n \"assert _args;\" \n end", "def test_num_workers_invalid_inputs\n assert_raises ArgumentError do\n @project_calc.calculate_project_cost(base_price: 12456.95, num_workers: nil, product_categories: ['electronics', 'books'])\n end\n assert_raises ArgumentError do\n @project_calc.calculate_project_cost(base_price: 12456.95, num_workers: 0, product_categories: ['electronics', 'books'])\n end\n assert_raises ArgumentError do\n @project_calc.calculate_project_cost(base_price: 12456.95, num_workers: -8, product_categories: ['electronics', 'books'])\n end\n end", "def check_inv(value,opt_failure_message = '')\n check_assertion(value,value.invariant?,CHECK_INV_VIOLATION_CLASS,'Class Invariant violated',opt_failure_message)\nend", "def test_invalid_integer_argument\n assert_raises \"TypeError: Invalid command line arguments.\" do\n @grapher.make_graph([1])\n end\n end", "def vest _args\n \"vest _args;\" \n end", "def test_int_check_pass\n assert_equal int_check([]), true # EDGE CASE\n assert_equal int_check(['1']), true # pass\n assert_equal int_check(['1', '1']), true # pass\n assert_equal int_check(['1', '1', '1']), true # pass\n end", "def test_exercise_1111\n verify_method :exercise_1111,\n :with => [{param: [[true]], expect: \" 1\\n1*\\n\"},\n {param: [[false]], expect: \" 1\\n1 \\n\"},\n {param: [[true, false]], expect: \" 12\\n1* \\n\"},\n {param: [[true, false], [true, false]], expect: \" 12\\n1* \\n2* \\n\"}]\n end", "def test_it_should_take_no_arguments\n assert_equal(0, cli_class.instance_method(:generate).arity)\n end", "def verify_not_before=(_arg0); end", "def verify_not_before=(_arg0); end", "def run(args)\n verbose_ary, count_ary = args[1..-1].partition {|item| item =~ /full/i}\n verbose = !verbose_ary.empty?\n\n if count_ary.size > 1\n errmsg \"Expecting only at most one parameter other than 'full'\"\n return\n end\n \n if 1 == count_ary.size\n begin\n count = Integer(count_ary[0])\n rescue\n errmsg \"Expecting count to be an integer; got #{count_ary[0]}\"\n return\n end\n elsif 0 == count_ary.size\n count = proc.stack_size\n else\n errmsg \"Wrong number of parameters. Expecting at most 2.\"\n return\n end\n\n @proc.print_stack_trace(@proc.top_frame, \n {:verbose => verbose, :count => count})\n end", "def test_check_coins_zero\r\n assert_nil @g.check_coins('0')\r\n end", "def arguments_valid?\n true\n end", "def test_correct_neg_val_print\n a_parse = Argparser.new\n assert_output(nil) do\n _unused = a_parse.correct?([-20, -5, 0])\n end\n end", "def wrong_num_parameters?\n (ARGV.size != 1)\n end", "def arguments_valid?\n true\n end", "def check_parameters\n\n # Sections\n\n # Namelist Tests\n # Grids\n # Parallelisation\n # Initialisation\n # Diagnostics\n # Misc\n\n ##################\n # Namelist Tests #\n ##################\n\n rcp.namelists.each do |namelist, hash|\n next if hash[:should_include].kind_of? String and not eval(hash[:should_include])\n if en = hash[:enumerator]\n #ep 'en', en, namelist\n next unless send(en[:name])\n send(en[:name]).times do |i|\n run_namelist_tests(namelist, hash, i+1)\n end\n else\n run_namelist_tests(namelist, hash)\n end\n end\n\n ###############\n # Grid Errors #\n ###############\n\n # naky\n warning(\"Setting naky when non-linear mode is on is not recommended.\") if @naky and @nonlinear_mode == \"on\"\n\n warning(\"You have set both ny and naky; naky will override ny.\") if @ny and @naky\n\n error(\"abs(shat) should not be less that 1.0e-6\") if @shat and @shat.abs < 1.0e-6 and not agk?\n error(\"abs(s_hat_input) should not be less that 1.0e-6\") if @s_hat_input and @s_hat_input.abs < 1.0e-6 and not agk?\n\n # delt\n\n error(\"Please specify delt\") unless @delt\n error(\"delt <= 0\") if @delt <= 0.0\n warning(\"Nonlinear run with delt_minimum unspecified.\") if @nonlinear_mode==\"on\" and not @delt_minimum\n\n error(\"delt (#@delt) < delt_minimum\") if @delt and @delt_minimum and @delt < @delt_minimum\n\n # negrid\n warning('negrid < 8 is not a good idea!') if @negrid and @negrid < 8\n\n # nakx\n warning(\"You have set both nx and ntheta0; ntheta0 will override nx.\") if @nx and @ntheta0\n\n warning(\"Do you have a reason for setting equal_arc = true (default)? If not set false.\") if @equilibrium_option==\"eik\" and (!@equal_arc or @equal_arc.fortran_true?)\n\n warning(\"Recommend nperiod > 1 for linear runs.\") if @nonlinear_mode == \"off\" and (!@nperiod or @nperiod == 1)\n warning(\"Recommend nperiod = 1 for nonlinear runs.\") if @nonlinear_mode == \"on\" and (@nperiod > 1)\n\n warning(\"Consider using field_option = local and associated optimizations.\") if @field_option and @field_option == \"implicit\"\n\n #################################\n # Parallelisation/Layout Errors #\n #################################\n\n # Best linear run layout is lexys\n warning(\"The best layout for linear runs is usually lexys.\") if @nonlinear_mode==\"off\" and not @layout==\"lexys\"\n\n # Best nonlinear run layout is xyles\n warning(\"The best layout for nonlinear runs is usually xyles.\") if @nonlinear_mode==\"on\" and not @layout==\"xyles\"\n\n # Check whether we are parallelising over x\n warning(\"Parallelising over x: suggest total number of processors should be: #{max_nprocs_no_x}\") if actual_number_of_processors > max_nprocs_no_x and not @grid_option == \"single\"\n\n #########################\n # Initialisation Errors #\n #########################\n\n # Check if restart folder exists\n if @restart_file and @restart_file =~ /^(?<folder>[^\\/]+)\\//\n folder = $~[:folder]\n warning(\"Folder #{folder}, specified in restart_file, not present. NetCDF save may fail\") unless FileTest.exist?(folder)\n end\n\n error(\"Setting @restart_file as an empty string will result in hidden restart files.\") if @restart_file == \"\"\n\n error(\"ginit_option is 'many' but is_a_restart is false\") if @ginit_option == \"many\" and not @is_a_restart\n\n error(\"read_response is 'true' but run is not a restart. Make sure the \"\\\n \"@response_id is set to a run with response files.\") if \n @read_response and @read_response.fortran_true? and \n not @is_a_restart and not @response_id\n\n error(\"chop_side should not be used (remove test if default changes from T to F)\") if !@chop_side or @chop_side.fortran_true?\n\n #####################\n # Diagnostic errors #\n #####################\n\n #Check whether useful diagnostics have been omitted.\n\n not_set = [:write_verr, :save_for_restart, :write_nl_flux, :write_final_fields, :write_final_moments].find_all do |diagnostic|\n not (send(diagnostic) and send(diagnostic).fortran_true?)\n end\n\n if not_set.size > 0\n str = not_set.inject(\"\") do |s, diagnostic|\n s + \"\\n\\t#{diagnostic} --- \" + rcp.namelists[diagnostics_namelist][:variables][diagnostic][:description] rescue s\n end\n warning(\"The following useful diagnostics were not set:\" + str) if str.length > 0\n end\n\n warning(\"You are running in nonlinear mode but have not switched the nonlinear flux diagnostic.\") if not (@write_nl_flux and @write_nl_flux.fortran_true?) and @nonlinear_mode == \"on\"\n\n #{\n #write_verr: \"Velocity space diagnostics will not be output for this run\"\n #}.each do |var, warn|\n #warning(v\"#{var} not set or .false. --- \" + warn) unless send(var) and send(var).fortran_true?\n #end\n\n error(\"Please specify nwrite\") unless @nwrite\n error(\"Please specify nstep\") unless @nstep\n\n\n warning(\"You will write out diagnostics less than 50 times\") if @nstep/@nwrite < 50\n\n ########################\n # Miscellaneous errors #\n ########################\n\n error(\"The run name for this run is too long. Please move some of the variable settings to the local defaults file.\") if @relative_directory.size + @run_name.size > MAX_NAME_SIZE\n\n warning(\"You are submitting a nonlinear run with no dissipation.\") if @nonlinear_mode == \"on\" and @hyper_option==\"none\" and @collision_model==\"none\"\n\n warning(\"You have no spatial implicitness: (bakdif) for one of your species. Be prepared for numerical instabilities!\") if (1..@nspec).to_a.find{|i| bd = send(\"bakdif_#{i}\") and bd == 0}\n\n warning(\"The system will abort with rapid timestep changes...\") if !@abort_rapid_time_step_change or @abort_rapid_time_step_change.fortran_true?\n\n warning(\"local_field_solve is an old variable that should not really be used.\") if @local_field_solve and @local_field_solve.fortran_true?\n\n #############################\n # Boundary Condition Errors #\n #############################\n\n warning(\"Boundary option should be periodic for shat = 1e-6.\") if (!@boundary_option or @boundary_option != \"periodic\") and ((@s_hat_input and @s_hat_input.abs == 1.0e-6) or (@shat and @shat.abs == 1.0e-6))\n\n warning(\"Boundary option should be default (unconnected) for single and range mode with shat > 0.\") if (@boundary_option != \"default\") and ((@s_hat_input and @s_hat_input.abs > 1.0e-6) or (@shat and @shat.abs > 1.0e-6)) and (@grid_option == \"single\" or @grid_option == \"range\")\n\n warning(\"Boundary option should be linked for box mode with shat > 0.\") if (!@boundary_option or @boundary_option != \"linked\") and ((@s_hat_input and @s_hat_input.abs > 1.0e-6) or (@shat and @shat.abs > 1.0e-6)) and @grid_option == \"box\" \n\n error(\"Set nonad_zero = true.\") if @nonad_zero and not @nonad_zero.fortran_true?\n\n\n ###################\n # Spectrogk tests #\n ###################\n #\n if spectrogk?\n if @force_5d and @force_5d.fortran_true?\n warning(\"Must specify interpolation method with phi_method.\") if not (@phi_method)\n end\n end\n\n ################\n # Damping Rate #\n ################\n\n error(\"Linear runs with hyperviscosity are NOT recommended!\") if @nonlinear_mode==\"off\" and (@hyper_option and @hyper_option==\"visc_only\") and (@d_hypervisc and @d_hypervisc!=0)\n\n warning(\"Amplitude dependent part of hyperviscosity being ignored since const_amp = true\") if (@hyper_option and @hyper_option==\"visc_only\") and (@const_amp and @const_amp.fortran_true?)\n\n ###################\n # Geometry Errors #\n ###################\n\n error(\"You must set bishop = 4 for Miller(local) geometry. Remember also that s_hat_input will override shat\") if (@bishop!=4 and (@local_eq and @local_eq.fortran_true?))\n\n error(\"Shift should be > 0 for s-alpha equilibrium.\") if @equilibrium_option==\"s-alpha\" and (@shift and @shift < 0)\n error(\"Shift should be < 0 for Miller equilibrium.\") if @equilibrium_option==\"eik\" and @local_eq.fortran_true? and (@shift and @shift > 0)\n\n error(\"irho must be 2 for Miller equilibrium.\") if @equilibrium_option==\"eik\" and @local_eq.fortran_true? and (@irho and @irho!=2)\n\n warning(\"Note that shat != s_hat_input\") if @shat and @s_hat_input and @shat!=@s_hat_input\n\n ##################\n # Species Errors #\n ##################\n\n error(\"Must set z = -1 for electron species.\") if (@type_2 and @z_2 and @type_2=='electron' and @z_2 != -1)\n\n\n #################\n # Optimisations #\n #################\n\n if CODE_OPTIONS[:gs2] and CODE_OPTIONS[:gs2][:show_opt]\n eputs(\"Optimisation Summary:\")\n optimisation_flags.each do |flag|\n eputs(\"------------------------- #{flag}: #{send(flag)}\\n* #{rcp.variables_with_help[flag].gsub(/\\n/, \"\\n\\t\").sub(/\\A([^.]*.).*\\Z/m, '\\1')}\") \n end\n #not_set = [:operator, :save_for_restart, :write_nl_flux, :write_final_fields, :write_final_moments].find_all do |diagnostic|\n #not (send(diagnostic) and send(diagnostic).fortran_true?)\n #end\n\n #if not_set.size > 0\n #str = not_set.inject(\"\") do |s, diagnostic|\n #s + \"\\n\\t#{diagnostic} --- \" + rcp.namelists[diagnostics_namelist][:variables][diagnostic][:description] rescue s\n #end\n #warning(\"The following useful diagnostics were not set:\" + str) if str.length > 0\n #end\n end\n \n \n\n\nend", "def true(_argvs)\n return nil\n end", "def test_exercise_1122\n verify_method :exercise_1122,\n :with => [{\n params: [0, [0, 1, 2, 3, 4, 5]],\n expect: \"lo: 0, hi: 5\\n\\tlo: 0, hi: 1\\n\"\n },\n {\n params: [5, [0, 1, 2, 3, 4, 5]],\n expect: \"lo: 0, hi: 5\\n\\tlo: 3, hi: 5\\n\\t\\tlo: 5, hi: 5\\n\"\n }]\n end" ]
[ "0.7834248", "0.744875", "0.7168305", "0.7045851", "0.7036272", "0.7018964", "0.69827515", "0.69250745", "0.69118404", "0.68903834", "0.68785965", "0.67459553", "0.6724565", "0.6702082", "0.6691073", "0.6641137", "0.6612126", "0.658975", "0.6554192", "0.6510438", "0.64931476", "0.648677", "0.6484412", "0.64691633", "0.64611983", "0.64335465", "0.6415857", "0.6374316", "0.6367707", "0.6334595", "0.6283956", "0.6277983", "0.62761885", "0.62615454", "0.6229612", "0.6229012", "0.61858284", "0.6178127", "0.61393464", "0.61132157", "0.61067486", "0.6095362", "0.6049757", "0.6021012", "0.598431", "0.59540063", "0.5949365", "0.59485936", "0.59311026", "0.5927264", "0.5908841", "0.5905279", "0.58990884", "0.58920205", "0.58795404", "0.586619", "0.58392763", "0.5838173", "0.5837134", "0.5829411", "0.5826403", "0.57893693", "0.576987", "0.57556707", "0.57367635", "0.57337946", "0.5713507", "0.5709792", "0.570494", "0.56979245", "0.56979245", "0.56840587", "0.5676973", "0.56744087", "0.56549954", "0.5645928", "0.56412876", "0.5628675", "0.56265414", "0.5624949", "0.56185675", "0.5611189", "0.55997753", "0.5597336", "0.5594645", "0.5592379", "0.55895436", "0.55642205", "0.55561924", "0.55561113", "0.55561113", "0.5547818", "0.5518055", "0.55169785", "0.5506559", "0.550307", "0.55022335", "0.55019975", "0.5497868", "0.5494809" ]
0.8048007
0
GET /litters/1 GET /litters/1.xml
def show #not using #@litter = Litter.find(params[:id]) #respond_to do |format| # format.html # show.html.erb # format.xml { render :xml => @litter } #end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lyric }\n end\n end", "def show\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lyric }\n end\n end", "def show\n @litter = Litter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @litter }\n end\n end", "def index\n @litters = Litter.all\n end", "def index\n @litters = Litter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @litters }\n end\n end", "def index\n @leks = Lek.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @leks }\n end\n end", "def index\n @lieus = Lieu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lieus }\n end\n end", "def show\n @slitting = Slitting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @slitting }\n end\n end", "def show\n @litra = Litra.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @litra }\n end\n end", "def show\n @lek = Lek.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lek }\n end\n end", "def show\n @lendable = Lendable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lendable }\n end\n end", "def show\n @lift = Lift.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lift }\n end\n end", "def show\n @lote = Lote.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lote }\n end\n end", "def show\n @lr40 = Lr40.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lr40 }\n end\n end", "def set_litter\n @litter = Litter.find(params[:id])\n end", "def show\n @kennel_litter = KennelLitter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kennel_litter }\n end\n end", "def index\n @dataset_researchers = Lien.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dataset_researchers }\n end\n end", "def show\n @lr70 = Lr70.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lr70 }\n end\n end", "def new\n @litter = Litter.new\n @sires = Sire.find(:all,:order=>\"name\")\n @dames = Dame.find(:all,:order=>\"name\")\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @litter }\n end\n end", "def show\n @lr45 = Lr45.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lr45 }\n end\n end", "def show\n @lien = Lien.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lien }\n end\n end", "def index\n @lotteries = Lottery.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lotteries }\n end\n end", "def show\n @klant = Klant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @klant }\n end\n end", "def show\n @lotto_type = LottoType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lotto_type }\n end\n end", "def show\n @lb202556 = Lb202556.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lb202556 }\n end\n end", "def show\n @lore = Lore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lore }\n end\n end", "def new\n @lyric = Lyric.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lyric }\n end\n end", "def show\n @lent = Lent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lent }\n end\n end", "def new\n @slitting = Slitting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slitting }\n end\n end", "def show\n @legislacion = Legislacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @legislacion }\n end\n end", "def show\n @liga_blaz_blue = LigaBlazBlue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @liga_blaz_blue }\n end\n end", "def show\n @league = League.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @league }\n end\n end", "def show\n @league = League.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @league }\n end\n end", "def show\n @league = League.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @league }\n end\n end", "def show\n @league = League.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @league }\n end\n end", "def show\n @lieu = Lieu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lieu }\n end\n end", "def set_litigante\n @litigante = Litigante.find(params[:id])\n end", "def show\n @lift = Lift.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lift }\n end\n end", "def show\n @lector = Lector.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lector }\n end\n end", "def show\n @lei = Lei.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lei }\n end\n end", "def show\n @lr13 = Lr13.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lr13 }\n end\n end", "def show\n @lecture = Lecture.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lecture }\n end\n end", "def show\n @glossary = Glossary.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @glossary.to_xml }\n end\n end", "def index\n @loans = Loan.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @loans }\n end\n end", "def show\n @laborer = Laborer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @laborer }\n end\n end", "def show\n @lottery = Lottery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lottery }\n end\n end", "def show\n @lighting = Lighting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lighting }\n end\n end", "def show\n @old_twit = OldTwit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @old_twit }\n end\n end", "def show\n @wrestler = Wrestler.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @wrestler }\n end\n end", "def show\n @lb30 = Lb30.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lb30 }\n end\n end", "def index_loans_for_bundle\n @bundles = Bundle.find(params[:id])\n\n respond_to do |format|\n format.html { render 'loans/index'}\n format.xml { render :xml => @bundles }\n end\n end", "def show\n @lab = @course.labs.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @lab }\n end\n end", "def show\n @slitter = Slitter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @slitter }\n end\n end", "def set_lyric\n @lyric = Lyric.find(params[:id])\n end", "def index\n @labs = @course.labs.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @labs }\n end\n end", "def tournaments\n get('sports/en/tournaments.xml')\n end", "def index\n @laws = Law.ordered_roots\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laws }\n end\n end", "def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end", "def lws_api_get(path)\n options = {headers: solr_headers}\n response = HTTParty.get(\"#{FlareConfig.lws_api_url}#{path}\", options)\n Rails.logger.info(\"RESPONSE CODE: #{response.code}\")\n if response.code == 200\n result = JSON.parse(response.body)\n else\n nil\n end\n end", "def index\n @uitgelichts = Uitgelicht.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uitgelichts }\n end\n end", "def index\n name = @xml.elements['/name'].text\n @sentence = \"Hello #{name} !\"\n render_xml\n end", "def index\r\n @legers = Leger.all\r\n\r\n end", "def show\n @intelligence = Intelligence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @intelligence }\n end\n end", "def show\n @league_type = LeagueType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @league_type }\n end\n end", "def new\n @litter = Litter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @litter }\n end\n end", "def index\n @lifts = Lift.all\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lifts }\n end\n end", "def create\n @litter = Litter.new(params[:litter])\n @sires = Sire.find(:all,:order=>\"name\")\n @dames = Dame.find(:all,:order=>\"name\")\n\n respond_to do |format|\n if @litter.save\n format.html { redirect_to(litters_path, :notice => 'Litter was successfully created.') }\n format.xml { render :xml => @litter, :status => :created, :location => @litter }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @litter.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n @webling = Webling.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @webling }\n end\n end", "def show\n @liga_blaz_blue_general = LigaBlazBlueGeneral.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @liga_blaz_blue_general }\n end\n end", "def show\n @livro = Livro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @livro }\n end\n end", "def show\n @rant = Rant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rant }\n end\n end", "def show\n @liga_sf4 = LigaSf4.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @liga_sf4 }\n end\n end", "def index\n @litigantes = Litigante.all\n end", "def show\n @researcher = Researcher.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @researcher }\n end\n end", "def lws_api_get(path)\n # See also catalog_controller for use of ENV['LWS_...']\n url ||= ENV['LWS_API_URL']\n url ||= \"#{ENV['LWS_CORE_URL']}/api\" if ENV['LWS_CORE_URL']\n \n # http://localhost:8888/api/collections\n resp = Net::HTTP.get_response(URI.parse(\"#{url || 'http://127.0.0.1:8888/api'}#{path}\"))\n result = JSON.parse(resp.body)\n end", "def new\n @lek = Lek.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lek }\n end\n end", "def show\n @lane = Lane.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lane }\n end\n end", "def show\n @ladder_truck150 = LadderTruck150.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ladder_truck150 }\n end\n end", "def show\n @uitgelicht = Uitgelicht.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @uitgelicht }\n end\n end", "def show\n @leilao = Leilao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @leilao }\n end\n end", "def show\n @lsrs_cmp = LsrsCmp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lsrs_cmp }\n end\n end", "def legislators(options = {})\n get('/legislators', options)\n end", "def read(id=nil)\r\n request = Net::HTTP.new(@uri.host, @uri.port)\r\n if id.nil?\r\n response = request.get(\"#{@uri.path}.xml\") \r\n else\r\n response = request.get(\"#{@uri.path}/#{id}.xml\") \r\n end\r\n response.body\r\n end", "def getdifficulty\n request :getdifficulty\n end", "def show\n @needle = Needle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @needle }\n end\n end", "def index\n @lessons = Lesson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lessons }\n end\n end", "def show\n @wordlist = Query.wordlistByName(params[:name])\n puts @wordlist\n @wordlist = @wordlist.first\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @wordlist }\n end\n end", "def new\n @lendable = Lendable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lendable }\n end\n end", "def librarian_view\n @response, @document = search_service.fetch(params[:id])\n respond_to do |format|\n format.html { render layout: false }\n format.json\n end\n end", "def show\n @kennel = Kennel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @kennel }\n end\n end", "def show\n @olark = Olark.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @olark }\n end\n end", "def show\n @lede = Lede.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lede }\n end\n end", "def show\n @lance_unico = LanceUnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lance_unico }\n end\n end", "def show\n @rute = Rute.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rute }\n end\n end", "def show\n @lsrs_soildata = LsrsSoil.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lsrs_soildata }\n end\n end", "def index\n @realtors = Realtor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @realtors }\n end\n end", "def show\n @sleuths = HTTParty.get('https://webservice.wikipathways.org/findPathwaysByText?query=' + @sleuth.ext_gene + '&species=homo+sapiens&format=json',\n :headers =>{'Content-Type' => 'application/json'} )\n @pubs = HTTParty.get('https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&term='+ @sleuth.ext_gene,\n :headers =>{'Content-Type' => 'application/json'} )\n end", "def show\n @strelki = Strelki.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @strelki }\n end\n end", "def show\n @league_table = LeagueTable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @league_table }\n end\n end", "def show\n @termekek = Termekek.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @termekek }\n end\n end" ]
[ "0.63912684", "0.63912684", "0.61387765", "0.61214346", "0.61113304", "0.61082613", "0.59447324", "0.59383154", "0.5912425", "0.5904268", "0.5895175", "0.5830907", "0.58266836", "0.5791102", "0.5783864", "0.57419795", "0.56926167", "0.56793976", "0.56711996", "0.56511086", "0.56377006", "0.56372195", "0.5630357", "0.5613916", "0.5609873", "0.56031734", "0.5590095", "0.5583973", "0.5539341", "0.55081534", "0.54867727", "0.5473369", "0.5473369", "0.5473369", "0.5473369", "0.5446139", "0.5443724", "0.5440462", "0.5436344", "0.54331785", "0.53980756", "0.53586817", "0.5351294", "0.5333451", "0.5332743", "0.53270143", "0.5326943", "0.5325388", "0.5321178", "0.5314491", "0.53139764", "0.53104603", "0.5298779", "0.52933776", "0.52688265", "0.5261483", "0.52530944", "0.5244491", "0.5238833", "0.52321404", "0.5230436", "0.5219795", "0.52145064", "0.521306", "0.52117735", "0.520647", "0.51960754", "0.51832783", "0.51770085", "0.5166741", "0.5159951", "0.51590663", "0.5155991", "0.515431", "0.5149938", "0.5147667", "0.5141329", "0.51412827", "0.5138909", "0.5137786", "0.5134293", "0.5132636", "0.51322407", "0.5131954", "0.5128379", "0.51278615", "0.5125419", "0.5124802", "0.5121773", "0.511526", "0.5107505", "0.51071316", "0.5107068", "0.51010984", "0.50921166", "0.5090011", "0.5089507", "0.5088007", "0.5086629", "0.5085233" ]
0.63987803
0
GET /litters/new GET /litters/new.xml
def new @litter = Litter.new @sires = Sire.find(:all,:order=>"name") @dames = Dame.find(:all,:order=>"name") respond_to do |format| format.html # new.html.erb format.xml { render :xml => @litter } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @lyric = Lyric.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lyric }\n end\n end", "def new\n @slitting = Slitting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slitting }\n end\n end", "def new\n @litter = Litter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @litter }\n end\n end", "def new\n @lendable = Lendable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lendable }\n end\n end", "def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end", "def new\n @lotto_type = LottoType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lotto_type }\n end\n end", "def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lore }\n end\n end", "def new\n @lek = Lek.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lek }\n end\n end", "def new\n @lote = Lote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lote }\n end\n end", "def new\n @lb202556 = Lb202556.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lb202556 }\n end\n end", "def new\n @old_twit = OldTwit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @old_twit }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end", "def new\n @lr40 = Lr40.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lr40 }\n end\n end", "def new\n @lr70 = Lr70.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lr70 }\n end\n end", "def new\n @lift = Lift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lift }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end", "def new\n @stockist = Stockist.new\n assign_lovs\n\n respond_to do |format|\n format.html # new.haml\n format.xml { render :xml => @stockist }\n end\n end", "def new\n @lr45 = Lr45.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lr45 }\n end\n end", "def new\n @kennel_litter = KennelLitter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kennel_litter }\n end\n end", "def new\n @lift = Lift.new\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lift }\n end\n end", "def new\n @lottery = Lottery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lottery }\n end\n end", "def new\n @lb30 = Lb30.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lb30 }\n end\n end", "def new\n @kennel = Kennel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @kennel }\n end\n end", "def new\n @league = League.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @league }\n end\n end", "def new\n @league = League.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @league }\n end\n end", "def new\n @rant = Rant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rant }\n end\n end", "def new\n @lighting = Lighting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lighting }\n end\n end", "def new\n @lookup_set = LookupSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_set }\n end\n end", "def new\n @strelki = Strelki.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @strelki }\n end\n end", "def new\n @tuple = Tuple.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tuple }\n end\n end", "def new\n if get_login.nil? then\n raise 'only logged in users can create new leagues'\n end\n @league = League.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @league }\n end\n end", "def new\n @lieu = Lieu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lieu }\n end\n end", "def new\n @want = Want.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @want }\n end\n end", "def new\n @liga_blaz_blue = LigaBlazBlue.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @liga_blaz_blue }\n end\n end", "def new\n @slitter = Slitter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @slitter }\n end\n end", "def new\n @needle = Needle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @needle }\n end\n end", "def new\n @sti = Sti.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sti }\n end\n end", "def new\n @lid = Lid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lid }\n end\n end", "def new\n @legislacion = Legislacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @legislacion }\n end\n end", "def new\n @lr13 = Lr13.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lr13 }\n end\n end", "def new\n @geoname = Geoname.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @geoname }\n end\n end", "def new_rest\n @question_localized = QuestionLocalized.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @question_localized }\n end\n end", "def new\n @lector = Lector.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lector }\n end\n end", "def new\n @olark = Olark.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @olark }\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n end\n end", "def new\n @local = Local.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @local }\n end\n end", "def new\n @lyric = Lyric.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lyric }\n end\n end", "def new\n @lookup_pettracer = LookupPettracer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_pettracer }\n end\n end", "def new\n @lookup_pettracer = LookupPettracer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_pettracer }\n end\n end", "def new\n @trail = Trail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trail }\n end\n end", "def new\n @trail = Trail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trail }\n end\n end", "def new\n @thred = Thred.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thred }\n end\n end", "def new\n @researcher = Researcher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @researcher }\n end\n end", "def new\n @teaching_route = TeachingRoute.new\n @names = Person.selectionList\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teaching_route }\n end\n end", "def new\n @teaching_route = TeachingRoute.new\n @names = Person.selectionList\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teaching_route }\n end\n end", "def create\n @lien = Lien.new(params[:lien])\n\n respond_to do |format|\n if @lien.save\n flash[:notice] = 'Lien was successfully created.'\n format.html { redirect_to(@lien) }\n format.xml { render :xml => @lien, :status => :created, :location => @lien }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lien.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @rol = Rol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rol }\n end\n end", "def new\n @rol = Rol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rol }\n end\n end", "def new\n @lecture = Lecture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lecture }\n end\n end", "def new\n @uitgelicht = Uitgelicht.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @uitgelicht }\n end\n end", "def new\n @livingroom = Livingroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @livingroom }\n end\n end", "def new\n @lane = Lane.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lane }\n end\n end", "def new\n @gene_ontology = GeneOntology.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gene_ontology }\n end\n end", "def new\n @shelf = Shelf.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shelf }\n end\n end", "def new\n @old_route_tag = OldRouteTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @old_route_tag }\n end\n end", "def new\n @wrestler = Wrestler.new\n @teams = Team.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wrestler }\n end\n end", "def new\n @regiment = Regiment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @regiment }\n end\n end", "def create\n @litter = Litter.new(params[:litter])\n @sires = Sire.find(:all,:order=>\"name\")\n @dames = Dame.find(:all,:order=>\"name\")\n\n respond_to do |format|\n if @litter.save\n format.html { redirect_to(litters_path, :notice => 'Litter was successfully created.') }\n format.xml { render :xml => @litter, :status => :created, :location => @litter }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @litter.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @intelligence = Intelligence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @intelligence }\n end\n end", "def new\n @loan = Loan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @loan }\n end\n end", "def new\n @old_point_tag = OldPointTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @old_point_tag }\n end\n end", "def new\n @url_migration = UrlMigration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_migration }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tender }\n end\n end", "def new\n @uri_type = UriType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @uri_type }\n end\n end", "def new\n @lei = Lei.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lei }\n end\n end", "def new\n @term = Term.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @term }\n end\n end", "def new\n @term = Term.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @term }\n end\n end", "def new\n @term = Term.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @term }\n end\n end", "def new\n @novel = Novel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @novel }\n end\n end", "def new\n @screw = Screw.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @screw }\n end\n end", "def new\n unless session[:admin]\n redirect_to lents_url\n return\n end\n\n @lent = Lent.new\n @free_cars = Car.where(condition: Car::Free).map{|x| x[:id]}\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lent }\n end\n end", "def new\n @rink = Rink.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rink }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @import }\n end\n end", "def new_rest\n @answer_localized = AnswerLocalized.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @answer_localized }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nomina }\n end\n end", "def new\n @lancamento = Lancamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lancamento }\n end\n end", "def new\n @lablocational = Lablocational.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lablocational }\n end\n end", "def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @meant_it_rel = MeantItRel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @meant_it_rel }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team }\n end\n end", "def new\n @league_type = LeagueType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @league_type }\n end\n end", "def new\n @slittingproduction = Slittingproduction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slittingproduction }\n end\n end", "def new\n @sitetype = Sitetype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sitetype }\n end\n end", "def new\n @webling = Webling.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @webling }\n end\n end", "def new\n @lens_model = LensModel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lens_model }\n end\n end", "def new\n @tutorials = Tutorials.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tutorials }\n end\n end", "def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end", "def new\n @vocabtype = Vocabtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vocabtype }\n end\n end", "def new\n @t1 = T1.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @t1 }\n end\n end", "def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lore }\n end\n end" ]
[ "0.69403857", "0.6917806", "0.69017977", "0.6810246", "0.67802703", "0.6756856", "0.66992843", "0.66913545", "0.6688937", "0.66363126", "0.66139746", "0.65635985", "0.6557131", "0.6554281", "0.6514636", "0.64975435", "0.6496912", "0.648578", "0.6465575", "0.6420901", "0.6393896", "0.63830954", "0.6370754", "0.6363942", "0.6363942", "0.6360192", "0.635989", "0.63569474", "0.63511723", "0.63485485", "0.6341833", "0.6335967", "0.63359493", "0.6334878", "0.6334249", "0.633145", "0.63249767", "0.63230276", "0.6322159", "0.6304435", "0.6303827", "0.62964135", "0.6294692", "0.6294172", "0.62906045", "0.6285335", "0.62723315", "0.6270088", "0.6269857", "0.62689507", "0.62689507", "0.62686884", "0.62641865", "0.62639695", "0.62639695", "0.62628144", "0.6255365", "0.6255365", "0.62468636", "0.6244564", "0.6243923", "0.6235486", "0.6233644", "0.62331223", "0.6231576", "0.6230857", "0.622277", "0.6221757", "0.6219998", "0.6217281", "0.62155414", "0.6207428", "0.6204102", "0.6202249", "0.6199911", "0.61959666", "0.61959666", "0.61959666", "0.6189847", "0.61896646", "0.61833286", "0.6181847", "0.6178196", "0.6176569", "0.61761993", "0.6165686", "0.6165663", "0.61647826", "0.6151047", "0.61509705", "0.61480916", "0.61448365", "0.6144009", "0.6136221", "0.61299217", "0.6127848", "0.61274", "0.612187", "0.61212945", "0.6118875" ]
0.68690044
3
POST /litters POST /litters.xml
def create @litter = Litter.new(params[:litter]) @sires = Sire.find(:all,:order=>"name") @dames = Dame.find(:all,:order=>"name") respond_to do |format| if @litter.save format.html { redirect_to(litters_path, :notice => 'Litter was successfully created.') } format.xml { render :xml => @litter, :status => :created, :location => @litter } else format.html { render :action => "new" } format.xml { render :xml => @litter.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @kennel_litter = KennelLitter.new(params[:kennel_litter])\n\n respond_to do |format|\n if @kennel_litter.save\n format.html { redirect_to @kennel_litter, notice: 'Kennel litter was successfully created.' }\n format.json { render json: @kennel_litter, status: :created, location: @kennel_litter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kennel_litter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lek = Lek.new(params[:lek])\n\n respond_to do |format|\n if @lek.save\n format.html { redirect_to(@lek, :notice => 'Lek was successfully created.') }\n format.xml { render :xml => @lek, :status => :created, :location => @lek }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lek.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @lyric = Lyric.new(params[:lyric])\n\n respond_to do |format|\n if @lyric.save\n format.html { redirect_to(@lyric, :notice => 'Lyric was successfully created.') }\n format.xml { render :xml => @lyric, :status => :created, :location => @lyric }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lyric.errors, :status => :unprocessable_entity }\n end\n end\n end", "def litter_params\n params.require(:litter).permit(:theme, :intake_date, :intake_time, :intake_type, :location_found, :foster_id)\n end", "def create\n @lyric = Lyric.new(params[:lyric])\n\n respond_to do |format|\n if @lyric.save\n format.html { redirect_to @lyric, notice: 'Lyric was successfully created.' }\n format.json { render json: @lyric, status: :created, location: @lyric }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lyric.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @slitting = Slitting.new(params[:slitting])\n\n respond_to do |format|\n if @slitting.save\n flash[:notice] = 'Slitting was successfully created.'\n format.html { redirect_to(@slitting) }\n format.xml { render :xml => @slitting, :status => :created, :location => @slitting }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @slitting.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @litigante = Litigante.new(litigante_params)\n\n respond_to do |format|\n if @litigante.save\n format.html { redirect_to @litigante, notice: 'Litigante was successfully created.' }\n format.json { render :show, status: :created, location: @litigante }\n else\n format.html { render :new }\n format.json { render json: @litigante.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_litter\n @litter = Litter.find(params[:id])\n end", "def create\n @lyric = Lyric.new(lyric_params)\n\n respond_to do |format|\n if @lyric.save\n format.html { redirect_to @lyric, notice: 'Lyric was successfully created.' }\n format.json { render json: @lyric, status: :created, location: @lyric }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lyric.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @litters = Litter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @litters }\n end\n end", "def create\n @liftset = Liftset.new(liftset_params)\n\n respond_to do |format|\n if @liftset.save\n format.html { redirect_to @liftset, notice: 'Liftset was successfully created.' }\n format.json { render action: 'show', status: :created, location: @liftset }\n else\n format.html { render action: 'new' }\n format.json { render json: @liftset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @litter = Litter.new(params[:litter])\n @pig = Pig.find(@litter.sow_id)\n @no_of_piglets = params[:no_of_piglets].to_i\n \n @no_of_piglets.times do\n Pig.create(name: @pig.name + ' piglet', status: alive_id, dob: Time.now, litter: @litter)\n end\n\n respond_to do |format|\n if @litter.save\n format.html { redirect_to @litter, notice: 'Litter was successfully created with ' + @no_of_piglets.to_s + ' piglets' }\n format.json { render json: @litter, status: :created, location: @litter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @litter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @slitter = Slitter.new(params[:slitter])\n\n respond_to do |format|\n if @slitter.save\n format.html { redirect_to @slitter, notice: 'Slitter was successfully created.' }\n format.json { render json: @slitter, status: :created, location: @slitter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @slitter.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @litter = Litter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @litter }\n end\n end", "def new\n @kennel_litter = KennelLitter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kennel_litter }\n end\n end", "def litter_params\n params.require(:litter).permit(:name, :arrival_date, :available_date, :birth_date,\n :breed_id, :breeder_id, :dam_id, :sire_id, :male_count,\n :female_count, litter_treatments_attributes:[:_destroy, :id, :litter_id, :treatment_type_id, :treatment_date])\n end", "def post_outcome_request\n raise IMS::LTI::InvalidLTIConfigError, \"\" unless has_required_attributes?\n\n res = post_service_request(@lis_outcome_service_url,\n 'application/xml',\n generate_request_xml)\n\n @outcome_response = extend_outcome_response(OutcomeResponse.new)\n @outcome_response.process_post_response(res)\n end", "def create\n @lode = Lode.new(lode_params)\n respond_to do |format|\n if @lode.save\n format.html { redirect_to new_lode_path(resource: @lode.resource), notice: 'Lode was successfully created.' }\n format.json { render :show, status: :created, location: resources_path(@lode.resource) }\n else\n format.html { render :new }\n format.json { render json: @lode.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @research = Research.new(params[:research])\n @research.legislator = current_legislator\n respond_to do |format|\n if @research.save\n flash[:notice] = 'Your research request has been submitted. Keep your eye on an email from White House 2 with updates on your request.'\n format.html { redirect_to(@research) }\n format.xml { render :xml => @research, :status => :created, :location => @research }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @research.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @led = Led.new(led_params)\n\n respond_to do |format|\n if @led.save\n format.html { redirect_to @led, notice: 'Led was successfully created.' }\n format.json { render :show, status: :created, location: @led }\n else\n format.html { render :new }\n format.json { render json: @led.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lei = Lei.new(params[:lei])\n\n respond_to do |format|\n if @lei.save\n format.html { redirect_to @lei, notice: 'Lei was successfully created.' }\n format.json { render json: @lei, status: :created, location: @lei }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lei.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lift = Lift.new(params[:lift])\n\n respond_to do |format|\n if @lift.save\n flash[:notice] = 'Lift was successfully created.'\n format.html { redirect_to(@lift) }\n format.xml { render :xml => @lift, :status => :created, :location => @lift }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lift.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @lift = Lift.new(params[:lift])\n\n respond_to do |format|\n if @lift.save\n format.html { redirect_to @lift, notice: 'Lift was successfully created.' }\n format.json { render json: @lift, status: :created, location: @lift }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lift.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @litter = Litter.new(litter_params)\n # @litter.litter_treatments.each do |t|\n # t.treatment_date = t.treatment_date.strftime('%Y-%d-%m')\n # end\n\n\n respond_to do |format|\n if @litter.save\n format.html { redirect_to @litter, notice: 'Litter was successfully created.' }\n format.json { render :show, status: :created, location: @litter }\n else\n format.html { render :new }\n format.json { render json: @litter.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_litigante\n @litigante = Litigante.find(params[:id])\n end", "def create\n @lr40 = Lr40.new(params[:lr40])\n\n respond_to do |format|\n if @lr40.save\n format.html { redirect_to(@lr40, :notice => 'Lr40 was successfully created.') }\n format.xml { render :xml => @lr40, :status => :created, :location => @lr40 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lr40.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @litters = Litter.all\n end", "def create\n @lendable = Lendable.new(params[:lendable])\n\n respond_to do |format|\n if @lendable.save\n format.html { redirect_to(@lendable, :notice => 'Lendable was successfully created.') }\n format.xml { render :xml => @lendable, :status => :created, :location => @lendable }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lendable.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @lote = Lote.new(params[:lote])\n\n respond_to do |format|\n if @lote.save\n flash[:notice] = 'Lote was successfully created.'\n format.html { redirect_to(@lote) }\n format.xml { render :xml => @lote, :status => :created, :location => @lote }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lote.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @slitting = Slitting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slitting }\n end\n end", "def update\n @litter = Litter.find(params[:id])\n\n respond_to do |format|\n if @litter.update_attributes(params[:litter])\n format.html { redirect_to @litter, notice: 'Litter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @litter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @webling = Webling.new(params[:webling])\n\n respond_to do |format|\n if @webling.save\n format.html { redirect_to @webling, notice: 'Webling was successfully created.' }\n format.json { render json: @webling, status: :created, location: @webling }\n else\n format.html { render action: \"new\" }\n format.json { render json: @webling.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lr45 = Lr45.new(params[:lr45])\n\n respond_to do |format|\n if @lr45.save\n format.html { redirect_to(@lr45, :notice => 'Lr45 was successfully created.') }\n format.xml { render :xml => @lr45, :status => :created, :location => @lr45 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lr45.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @labelling = Labelling.new(params[:labelling])\n\n respond_to do |format|\n if @labelling.save\n format.html { redirect_to @labelling, notice: 'Labelling was successfully created.' }\n format.json { render json: @labelling, status: :created, location: @labelling }\n else\n format.html { render action: \"new\" }\n format.json { render json: @labelling.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @lyric = Lyric.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lyric }\n end\n end", "def new\n @litter = Litter.new\n @sires = Sire.find(:all,:order=>\"name\")\n @dames = Dame.find(:all,:order=>\"name\")\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @litter }\n end\n end", "def create\n @lien = Lien.new(params[:lien])\n\n respond_to do |format|\n if @lien.save\n flash[:notice] = 'Lien was successfully created.'\n format.html { redirect_to(@lien) }\n format.xml { render :xml => @lien, :status => :created, :location => @lien }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lien.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @kennel_litter = KennelLitter.find(params[:id])\n\n respond_to do |format|\n if @kennel_litter.update_attributes(params[:kennel_litter])\n format.html { redirect_to @kennel_litter, notice: 'Kennel litter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kennel_litter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lede = Lede.new(params[:lede])\n\n respond_to do |format|\n if @lede.save\n format.html { redirect_to @lede, notice: 'Lede was successfully created.' }\n format.json { render json: @lede, status: :created, location: @lede }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lede.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lable = Lable.new(lable_params)\n\n respond_to do |format|\n if @lable.save\n format.html { redirect_to @lable, notice: 'Lable was successfully created.' }\n format.json { render :show, status: :created, location: @lable }\n else\n format.html { render :new }\n format.json { render json: @lable.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @liga_tymy_are = LigaTymyAre.new(liga_tymy_are_params)\n\n respond_to do |format|\n if @liga_tymy_are.save\n format.html { redirect_to @liga_tymy_are, notice: 'Liga tymy are was successfully created.' }\n format.json { render :show, status: :created, location: @liga_tymy_are }\n else\n format.html { render :new }\n format.json { render json: @liga_tymy_are.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @seeker = Seeker.new(seeker_params)\n @seeker.user_id = User.find(session[:user_id]).uid\n @seeker.skill_list.add(params[:seeker][:skill_list].to_s.downcase, parse: true)\n\n respond_to do |format|\n if @seeker.save\n format.html { redirect_to root_path, notice: 'Seeker was successfully created.' }\n format.json { render action: 'show', status: :created, location: @seeker }\n else\n format.html { render action: 'new' }\n format.json { render json: @seeker.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lutein = Lutein.new(lutein_params)\n\n respond_to do |format|\n if @lutein.save\n format.html { redirect_to @lutein, notice: 'Lutein was successfully created.' }\n format.json { render :show, status: :created, location: @lutein }\n else\n format.html { render :new }\n format.json { render json: @lutein.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n if params[:journey_id]\n @journey = Journey.find(params[:journey_id])\n render_403 and return if @journey.user_id != current_user.id\n else\n @journey = Journey.create(user_id: current_user.id)\n end\n\n @url = \"/journeys/#{@journey.id}/legs\"\n @method = :POST\n @journey_leg = JourneyLeg.new(journey_leg_params.merge(journey_id: @journey.id))\n\n respond_to do |format|\n if @journey_leg.save\n format.html { redirect_to @journey, notice: 'Journey leg was successfully created.' }\n format.json { render json: @journey, status: :created, location: @journey }\n format.xml { render xml: @journey, status: :created, location: @journey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @journey_leg.errors, status: :unprocessable_entity }\n format.xml { render xml: @journey_leg.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @renter = Renter.new(renter_params)\n\n respond_to do |format|\n if @renter.save\n format.html { redirect_to @renter, notice: 'Renter was successfully created.' }\n format.json { render :show, status: :created, location: @renter }\n else\n format.html { render :new }\n format.json { render json: @renter.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @lek = Lek.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lek }\n end\n end", "def create\n if signed_in?\n @litra = Litra.new(params[:litra])\n\n respond_to do |format|\n if @litra.save\n format.html { redirect_to @litra, notice: 'Litra was successfully created.' }\n format.json { render json: @litra, status: :created, location: @litra }\n else\n format.html { render action: \"new\" }\n format.json { render json: @litra.errors, status: :unprocessable_entity }\n end\n end\n end\nend", "def create\n @trail = Trail.new(params[:trail])\n\n respond_to do |format|\n if @trail.save\n format.html { redirect_to @trail, notice: 'Trail was successfully created.' }\n format.json { render json: @trail, status: :created, location: @trail }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trail.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @linhkien = Linhkien.new(linhkien_params)\n\n respond_to do |format|\n if @linhkien.save\n format.html { redirect_to @linhkien, notice: 'Linhkien was successfully created.' }\n format.json { render :show, status: :created, location: @linhkien }\n else\n format.html { render :new }\n format.json { render json: @linhkien.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @kitten = Kitten.new(params[:kitten])\n\n respond_to do |format|\n if @kitten.save\n format.html { redirect_to @kitten, notice: 'Kitten was successfully created.' }\n format.json { render json: @kitten, status: :created, location: @kitten }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kitten.errors, status: :unprocessable_entity }\n end\n end\n end", "def trek_params\n params.require(:trek).permit(:name, :url, :diff, :distance, :duration, :desc, :mountains=>[])\n end", "def create\n @lore = Lore.new(params[:lore])\n\n respond_to do |format|\n if @lore.save\n format.html { redirect_to(@lore, :notice => 'Lore was successfully created.') }\n format.xml { render :xml => @lore, :status => :created, :location => @lore }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lore.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @legislacion = Legislacion.new(params[:legislacion])\n\n respond_to do |format|\n if @legislacion.save\n flash[:notice] = 'Legislacion se ha creado con exito.'\n format.html { redirect_to(admin_legislacions_url) }\n format.xml { render :xml => @legislacion, :status => :created, :location => @legislacion }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @legislacion.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post\n Rentlinx.client.post(self)\n end", "def create\n @lk = Lk.new(lk_params)\n\n respond_to do |format|\n if @lk.save\n format.html { redirect_to @lk, notice: 'Lk was successfully created.' }\n format.json { render :show, status: :created, location: @lk }\n else\n format.html { render :new }\n format.json { render json: @lk.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lamp = Lamp.new(lamp_params)\n @lamp.product.company_id = current_user.company.id if @lamp.product\n @lamp.product.node_id = params[:node_id] if params[:node_id]\n current_user.company.tag(@lamp, with: lamp_params[:tag_list], on: current_user.company.name.parameterize.underscore.to_sym)\n\n respond_to do |format|\n if @lamp.save\n format.html { redirect_to @lamp, notice: 'Lamp was successfully created.' }\n format.json { render :show, status: :created, location: @lamp }\n else\n format.html { render :new }\n format.json { render json: @lamp.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_lyric\n @lyric = Lyric.find(params[:id])\n end", "def create\n @lotto_type = LottoType.new(params[:lotto_type])\n\n respond_to do |format|\n if @lotto_type.save\n format.html { redirect_to(@lotto_type, :notice => 'Lotto type was successfully created.') }\n format.xml { render :xml => @lotto_type, :status => :created, :location => @lotto_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lotto_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @lr70 = Lr70.new(params[:lr70])\n\n respond_to do |format|\n if @lr70.save\n format.html { redirect_to(@lr70, :notice => 'Lr70 was successfully created.') }\n format.xml { render :xml => @lr70, :status => :created, :location => @lr70 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lr70.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @leks = Lek.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @leks }\n end\n end", "def create\n @leisure = Leisure.new(leisure_params)\n\n respond_to do |format|\n if @leisure.save\n format.html { redirect_to @leisure, notice: 'Leisure was successfully created.' }\n format.json { render :show, status: :created, location: @leisure }\n else\n format.html { render :new }\n format.json { render json: @leisure.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lector = Lector.new(params[:lector])\n\n respond_to do |format|\n if @lector.save\n format.html { redirect_to @lector, notice: 'El nuevo lector se ha guardado correctamente.' }\n format.json { render json: @lector, status: :created, location: @lector }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lector.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @renter = Renter.new(renter_params)\n if @renter.save\n flash[:success] = \"Yeni kiracı başarıyla eklendi.\"\n redirect_to renters_path\n else\n render 'new'\n end\n end", "def lager_params\n params.require(:lager).permit(:name, :beschreibung, :dateiORkunde, :inhalt, :docAnzahl)\n end", "def create\n @trail = Trail.new(trail_params)\n\n respond_to do |format|\n if @trail.save\n format.html { redirect_to @trail, notice: 'Trail was successfully created.' }\n format.json { render :show, status: :created, location: @trail }\n else\n format.html { render :new }\n format.json { render json: @trail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @litigante.update(litigante_params)\n format.html { redirect_to @litigante, notice: 'Litigante was successfully updated.' }\n format.json { render :show, status: :ok, location: @litigante }\n else\n format.html { render :edit }\n format.json { render json: @litigante.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lector = Lector.new(lector_params)\n\n respond_to do |format|\n if @lector.save\n format.html { redirect_to lectors_path, notice: 'El lector fue creado con éxito.' }\n format.json { render :show, status: :created, location: @lector }\n else\n format.html { render :new }\n format.json { render json: @lector.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @strelki = Strelki.new(params[:strelki])\n\n respond_to do |format|\n if @strelki.save\n flash[:notice] = 'Strelki was successfully created.'\n format.html { redirect_to(@strelki) }\n format.xml { render :xml => @strelki, :status => :created, :location => @strelki }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @strelki.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @slitter = Slitter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @slitter }\n end\n end", "def update\n @litter = Litter.find(params[:id])\n @sires = Sire.find(:all,:order=>\"name\")\n @dames = Dame.find(:all,:order=>\"name\")\n\n respond_to do |format|\n if @litter.update_attributes(params[:litter])\n format.html { redirect_to(litters_path, :notice => 'Litter was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @litter.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @trail = Trail.new(trail_params)\n\n respond_to do |format|\n if @trail.save\n format.html { redirect_to @trail, notice: 'Trail was successfully created.' }\n format.json { render action: 'show', status: :created, location: @trail }\n else\n format.html { render action: 'new' }\n format.json { render json: @trail.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @laundromat = Laundromat.new(params[:laundromat])\n\n respond_to do |format|\n if @laundromat.save\n format.html { redirect_to @laundromat, notice: 'Laundromat was successfully created.' }\n format.json { render json: @laundromat, status: :created, location: @laundromat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @laundromat.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lottery = Lottery.new(params[:lottery])\n\n respond_to do |format|\n if @lottery.save\n format.html { redirect_to([:admin,@lottery], :notice => 'Lottery was successfully created.') }\n format.xml { render :xml => @lottery, :status => :created, :location => @lottery }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lottery.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @old_twit = OldTwit.new(params[:old_twit])\n\n respond_to do |format|\n if @old_twit.save\n format.html { redirect_to(@old_twit, :notice => 'Old twit was successfully created.') }\n format.xml { render :xml => @old_twit, :status => :created, :location => @old_twit }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @old_twit.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @lamp = Lamp.new(lamp_params)\n\n respond_to do |format|\n if @lamp.save\n format.html { redirect_to @lamp, notice: 'Lamp was successfully created.' }\n format.json { render :show, status: :created, location: @lamp }\n else\n format.html { render :new }\n format.json { render json: @lamp.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @rant = Rant.new(params[:rant])\n\n respond_to do |format|\n if @rant.save\n format.html { redirect_to(@rant, :notice => 'Rant was successfully created.') }\n format.xml { render :xml => @rant, :status => :created, :location => @rant }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @rant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_led\n @led = Led.find(params[:id])\n end", "def create\n @leito = Leito.new(params[:leito])\n\n respond_to do |format|\n if @leito.save\n format.html { redirect_to @leito, notice: 'Leito was successfully created.' }\n format.json { render json: @leito, status: :created, location: @leito }\n else\n format.html { render action: \"new\" }\n format.json { render json: @leito.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lek = Lek.find(params[:id])\n\n respond_to do |format|\n if @lek.update_attributes(params[:lek])\n format.html { redirect_to(@lek, :notice => 'Lek was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lek.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @termekek = Termekek.new(params[:termekek])\n\n respond_to do |format|\n if @termekek.save\n format.html { redirect_to(@termekek, :notice => 'Termekek was successfully created.') }\n format.xml { render :xml => @termekek, :status => :created, :location => @termekek }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @termekek.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @kitty = Kitty.new(params[:kitty])\n\n respond_to do |format|\n if @kitty.save\n format.html { redirect_to @kitty, notice: 'Kitty was successfully created.' }\n format.json { render json: @kitty, status: :created, location: @kitty }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kitty.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lr13 = Lr13.new(params[:lr13])\n\n respond_to do |format|\n if @lr13.save\n format.html { redirect_to(@lr13, :notice => 'Lr13 was successfully created.') }\n format.xml { render :xml => @lr13, :status => :created, :location => @lr13 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lr13.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end", "def create\n @trek = Trek.new(params[:trek])\n\n respond_to do |format|\n if @trek.save\n format.html { redirect_to @trek, notice: 'Trek was successfully created.' }\n format.json { render json: @trek, status: :created, location: @trek }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trek.errors, status: :unprocessable_entity }\n end\n end\n end", "def leisure_params\n params.require(:leisure).permit(:person_id, :leisure_type_id, :leisure_name)\n end", "def create\n @twittter = Twittter.new(twittter_params)\n\n respond_to do |format|\n if @twittter.save\n format.html { redirect_to @twittter, notice: 'Twittter was successfully created.' }\n format.json { render :show, status: :created, location: @twittter }\n else\n format.html { render :new }\n format.json { render json: @twittter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tur = Tur.new(params[:tur])\n\n respond_to do |format|\n if @tur.save\n format.html { redirect_to(@tur, :notice => 'Tur was successfully created.') }\n format.xml { render :xml => @tur, :status => :created, :location => @tur }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tur.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @bottling = Bottling.new(params[:bottling])\n\n respond_to do |format|\n if @bottling.save\n format.html { redirect_to @bottling, notice: 'bottling was successfully created.' }\n format.json { render json: @bottling, status: :created, location: @bottling }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bottling.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lieu = Lieu.new(params[:lieu])\n\n respond_to do |format|\n if @lieu.save\n format.html { redirect_to(@lieu, :notice => 'Lieu was successfully created.') }\n format.xml { render :xml => @lieu, :status => :created, :location => @lieu }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lieu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @lid = Lid.new(params[:lid])\n\n respond_to do |format|\n if @lid.save\n format.html { redirect_to @lid, notice: 'Lid was successfully created.' }\n format.json { render json: @lid, status: :created, location: @lid }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lid.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @l_ink = LInk.new(l_ink_params)\n\n respond_to do |format|\n if @l_ink.save\n format.html { redirect_to @l_ink, notice: 'L ink was successfully created.' }\n format.json { render :show, status: :created, location: @l_ink }\n else\n format.html { render :new }\n format.json { render json: @l_ink.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lime = Lime.new(lime_params)\n\n respond_to do |format|\n if @lime.save\n format.html { redirect_to @lime, notice: 'Lime was successfully created.' }\n format.json { render :show, status: :created, location: @lime }\n else\n format.html { render :new }\n format.json { render json: @lime.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ty = Tie.new(ty_params)\n\n respond_to do |format|\n if @ty.save\n format.html { redirect_to @ty, notice: 'Tie was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ty }\n else\n format.html { render action: 'new' }\n format.json { render json: @ty.errors, status: :unprocessable_entity }\n end\n end\n end", "def litigante_params\n params.require(:litigante).permit(:case_id, :participante, :rut, :persona, :nombre)\n end", "def create\n @tenki = Tenki.new(tenki_params)\n\n respond_to do |format|\n if @tenki.save\n format.html { redirect_to @tenki, notice: 'Tenki was successfully created.' }\n format.json { render :show, status: :created, location: @tenki }\n else\n format.html { render :new }\n format.json { render json: @tenki.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lager = Lager.new(lager_params)\n\n respond_to do |format|\n if @lager.save\n format.html { redirect_to @lager, notice: 'Lager was successfully created.' }\n format.json { render :show, status: :created, location: @lager }\n else\n format.html { render :new }\n format.json { render json: @lager.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @lyric = Lyric.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lyric }\n end\n end", "def set_illust\n @illust = Illust.find(params[:id])\n end", "def new\n @lote = Lote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lote }\n end\n end", "def create\n @lb202556 = Lb202556.new(params[:lb202556])\n\n respond_to do |format|\n if @lb202556.save\n format.html { redirect_to(@lb202556, :notice => 'Lb202556 was successfully created.') }\n format.xml { render :xml => @lb202556, :status => :created, :location => @lb202556 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lb202556.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.58933794", "0.5871854", "0.5768389", "0.5711532", "0.5554142", "0.5550719", "0.5523534", "0.5460405", "0.5421551", "0.5379116", "0.5370069", "0.53374654", "0.53227514", "0.5320137", "0.53036284", "0.52864105", "0.5275796", "0.5270278", "0.52615225", "0.525776", "0.5226336", "0.5205654", "0.5187056", "0.5171035", "0.51643974", "0.5158648", "0.5145191", "0.5139258", "0.5131895", "0.51060027", "0.51011467", "0.50803316", "0.50542766", "0.5034375", "0.50312966", "0.50272244", "0.5003941", "0.5001506", "0.4998506", "0.4998099", "0.49957538", "0.4975343", "0.49633208", "0.49534398", "0.49458703", "0.49455032", "0.49324772", "0.49283257", "0.49244958", "0.4915182", "0.49139792", "0.49115852", "0.49115548", "0.49002793", "0.48975995", "0.48966318", "0.48850468", "0.48837838", "0.48680776", "0.48582155", "0.48543862", "0.48543358", "0.48533818", "0.48520777", "0.48505947", "0.48409972", "0.48396423", "0.48347956", "0.48294285", "0.4828859", "0.48274928", "0.48271483", "0.48074815", "0.48062438", "0.4799062", "0.47982183", "0.47977245", "0.47958323", "0.47843447", "0.47822782", "0.47800553", "0.47730252", "0.47631618", "0.47573656", "0.47521824", "0.47515216", "0.4746132", "0.47429335", "0.4742121", "0.4739451", "0.47365353", "0.47346318", "0.47330716", "0.4730697", "0.47306645", "0.47297442", "0.47296333", "0.47264054", "0.47199702", "0.47181275" ]
0.58717823
2
PUT /litters/1 PUT /litters/1.xml
def update @litter = Litter.find(params[:id]) @sires = Sire.find(:all,:order=>"name") @dames = Dame.find(:all,:order=>"name") respond_to do |format| if @litter.update_attributes(params[:litter]) format.html { redirect_to(litters_path, :notice => 'Litter was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @litter.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @litter = Litter.find(params[:id])\n\n respond_to do |format|\n if @litter.update_attributes(params[:litter])\n format.html { redirect_to @litter, notice: 'Litter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @litter.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n if @lyric.update_attributes(params[:lyric])\n flash[:notice] = 'Lyric was successfully updated.'\n format.html { redirect_to(@lyric) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lyric.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n if @lyric.update_attributes(params[:lyric])\n format.html { redirect_to(@lyric, :notice => 'Lyric was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lyric.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @kennel_litter = KennelLitter.find(params[:id])\n\n respond_to do |format|\n if @kennel_litter.update_attributes(params[:kennel_litter])\n format.html { redirect_to @kennel_litter, notice: 'Kennel litter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kennel_litter.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @slitter = Slitter.find(params[:id])\n\n respond_to do |format|\n if @slitter.update_attributes(params[:slitter])\n format.html { redirect_to @slitter, notice: 'Slitter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @slitter.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @slitting = Slitting.find(params[:id])\n\n respond_to do |format|\n if @slitting.update_attributes(params[:slitting])\n flash[:notice] = 'Slitting was successfully updated.'\n format.html { redirect_to(@slitting) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @slitting.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @litigante.update(litigante_params)\n format.html { redirect_to @litigante, notice: 'Litigante was successfully updated.' }\n format.json { render :show, status: :ok, location: @litigante }\n else\n format.html { render :edit }\n format.json { render json: @litigante.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lift = Lift.find(params[:id])\n\n respond_to do |format|\n if @lift.update_attributes(params[:lift])\n flash[:notice] = 'Lift was successfully updated.'\n format.html { redirect_to(@lift) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lift.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end", "def update\n @lek = Lek.find(params[:id])\n\n respond_to do |format|\n if @lek.update_attributes(params[:lek])\n format.html { redirect_to(@lek, :notice => 'Lek was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lek.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_litter\n @litter = Litter.find(params[:id])\n end", "def update\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n if @lyric.update_attributes(params[:lyric])\n format.html { redirect_to @lyric, notice: 'Lyric was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lyric.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lector = Lector.find(params[:id])\n\n respond_to do |format|\n if @lector.update_attributes(params[:lector])\n format.html { redirect_to @lector, notice: 'Las modificaciones al Lector se han guardado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lector.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lotto_type = LottoType.find(params[:id])\n\n respond_to do |format|\n if @lotto_type.update_attributes(params[:lotto_type])\n format.html { redirect_to(@lotto_type, :notice => 'Lotto type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lotto_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @lote = Lote.find(params[:id])\n\n respond_to do |format|\n if @lote.update_attributes(params[:lote])\n flash[:notice] = 'Lote was successfully updated.'\n format.html { redirect_to(@lote) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lote.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @lift = Lift.find(params[:id])\n\n respond_to do |format|\n if @lift.update_attributes(params[:lift])\n format.html { redirect_to @lift, notice: 'Lift was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lift.errors, status: :unprocessable_entity }\n end\n end\n end", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def update\n @lien = Lien.find(params[:id])\n\n respond_to do |format|\n if @lien.update_attributes(params[:lien])\n flash[:notice] = 'Lien was successfully updated.'\n format.html { redirect_to(@lien) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lien.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end", "def set_litigante\n @litigante = Litigante.find(params[:id])\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update\n @lendable = Lendable.find(params[:id])\n\n respond_to do |format|\n if @lendable.update_attributes(params[:lendable])\n format.html { redirect_to(@lendable, :notice => 'Lendable was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lendable.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @liftset.update(liftset_params)\n format.html { redirect_to @liftset, notice: 'Liftset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @liftset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lei = Lei.find(params[:id])\n\n respond_to do |format|\n if @lei.update_attributes(params[:lei])\n format.html { redirect_to @lei, notice: 'Lei was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lei.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lore = Lore.find(params[:id])\n\n respond_to do |format|\n if @lore.update_attributes(params[:lore])\n format.html { redirect_to(@lore, :notice => 'Lore was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lore.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @illust.update(illust_params)\n format.html { redirect_to @illust, notice: 'Illust was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @illust.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ontology = SYMPH::Ontology.find(params[:id])\n\n respond_to do |format|\n if @ontology.update_attributes(params[:ontology])\n flash[:notice] = 'Ontology was successfully updated.'\n format.html { redirect_to(ontologies_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ontology.errors, :status => :unprocessable_entity }\n end\n end\n\t\n end", "def update\n respond_to do |format|\n if @lyric.update(lyric_params)\n format.html { redirect_to @lyric, notice: 'Lyric was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lyric.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @intelligence = Intelligence.find(params[:id])\n\n respond_to do |format|\n if @intelligence.update_attributes(params[:intelligence])\n flash[:notice] = 'Intelligence was successfully updated.'\n format.html { redirect_to(intelligences_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @intelligence.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @klant = Klant.find(params[:id])\n\n respond_to do |format|\n if @klant.update_attributes(params[:klant])\n flash[:notice] = 'Klant was successfully updated.'\n format.html { redirect_to(@klant) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @klant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @lieu = Lieu.find(params[:id])\n\n respond_to do |format|\n if @lieu.update_attributes(params[:lieu])\n format.html { redirect_to(@lieu, :notice => 'Lieu was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lieu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end", "def update\n @lottery = Lottery.find(params[:id])\n\n respond_to do |format|\n if @lottery.update_attributes(params[:lottery])\n format.html { redirect_to([:admin,@lottery], :notice => 'Lottery was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lottery.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @rayon = Rayon.find(params[:id])\n\n respond_to do |format|\n if @rayon.update_attributes(params[:rayon])\n format.html { redirect_to @rayon, notice: 'Rayon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rayon.errors, status: :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def update\n @leito = Leito.find(params[:id])\n\n respond_to do |format|\n if @leito.update_attributes(params[:leito])\n format.html { redirect_to @leito, notice: 'Leito was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @leito.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sti = Sti.find(params[:id])\n\n respond_to do |format|\n if @sti.update_attributes(params[:sti])\n flash[:notice] = 'Sti was successfully updated.'\n format.html { redirect_to(@sti) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sti.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update\n if signed_in?\n @litra = Litra.find(params[:id])\n\n respond_to do |format|\n if @litra.update_attributes(params[:litra])\n format.html { redirect_to @litra, notice: 'Litra was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @litra.errors, status: :unprocessable_entity }\n end\n end\n end\nend", "def update\n @strelki = Strelki.find(params[:id])\n\n respond_to do |format|\n if @strelki.update_attributes(params[:strelki])\n flash[:notice] = 'Strelki was successfully updated.'\n format.html { redirect_to(@strelki) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @strelki.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @bottle = Bottle.find(params[:id])\n\n respond_to do |format|\n if @bottle.update_attributes(params[:bottle])\n format.html { redirect_to(@bottle, :notice => 'Bottle was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bottle.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @kitten = Kitten.find(params[:id])\n\n respond_to do |format|\n if @kitten.update_attributes(params[:kitten])\n format.html { redirect_to @kitten, notice: 'Kitten was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kitten.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @t1 = T1.find(params[:id])\n\n respond_to do |format|\n if @t1.update_attributes(params[:t1])\n flash[:notice] = 'T1 was successfully updated.'\n format.html { redirect_to(@t1) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @t1.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.path)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n end", "def update\n @wrestler = Wrestler.find(params[:id])\n\n respond_to do |format|\n if @wrestler.update_attributes(params[:wrestler])\n format.html { redirect_to(@wrestler, :notice => 'Wrestler was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @wrestler.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @league = League.find(params[:id])\n\n respond_to do |format|\n if @league.update_attributes(params[:league])\n flash[:notice] = 'League was successfully updated.'\n format.html { redirect_to(@league) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @league.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @lane = Lane.find(params[:id])\n\n respond_to do |format|\n if @lane.update_attributes(params[:lane])\n format.html { redirect_to(@lane, :notice => 'Lane was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lane.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @lb202556 = Lb202556.find(params[:id])\n\n respond_to do |format|\n if @lb202556.update_attributes(params[:lb202556])\n format.html { redirect_to(@lb202556, :notice => 'Lb202556 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lb202556.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @league = League.find(params[:id])\n\n respond_to do |format|\n if @league.update_attributes(params[:league])\n format.html { redirect_to(@league, :notice => 'League was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @league.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @lot = Lot.find(params[:id])\n\n respond_to do |format|\n if @lot.update_attributes(params[:lot])\n format.html { redirect_to myadmin_lots_path, :notice => 'Lot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @lot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @lid = Lid.find(params[:id])\n\n respond_to do |format|\n if @lid.update_attributes(params[:lid])\n format.html { redirect_to @lid, notice: 'Lid was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lid.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lr45 = Lr45.find(params[:id])\n\n respond_to do |format|\n if @lr45.update_attributes(params[:lr45])\n format.html { redirect_to(@lr45, :notice => 'Lr45 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lr45.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @labelling = Labelling.find(params[:id])\n\n respond_to do |format|\n if @labelling.update_attributes(params[:labelling])\n format.html { redirect_to @labelling, notice: 'Labelling was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @labelling.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @shelf = Shelf.find(params[:id])\n\n respond_to do |format|\n if @shelf.update_attributes(params[:shelf])\n flash[:notice] = 'Shelf was successfully updated.'\n format.html { redirect_to(@shelf) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shelf.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tier = Tier.find(params[:id])\n\n respond_to do |format|\n if @tier.update_attributes(params[:tier])\n format.html { redirect_to @tier, :notice => 'Tier was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tier.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @trail = Trail.find(params[:id])\n\n respond_to do |format|\n if @trail.update_attributes(params[:trail])\n format.html { redirect_to @trail, notice: 'Trail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @trail = Trail.find(params[:id])\n\n respond_to do |format|\n if @trail.update_attributes(params[:trail])\n format.html { redirect_to @trail, notice: 'Trail was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @kit = Kit.find(params[:id])\n\n respond_to do |format|\n if @kit.update_attributes(params[:kit])\n format.html { redirect_to @kit, notice: 'Kit was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lieu = Lieu.find(params[:id])\n\n respond_to do |format|\n if @lieu.update_attributes(params[:lieu])\n format.html { redirect_to @lieu, notice: 'Lieu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lieu.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @webling = Webling.find(params[:id])\n\n respond_to do |format|\n if @webling.update_attributes(params[:webling])\n format.html { redirect_to @webling, notice: 'Webling was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @webling.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @heli_kit = HeliKit.find(params[:id])\n\n respond_to do |format|\n if @heli_kit.update_attributes(params[:heli_kit])\n format.html { redirect_to @heli_kit, notice: 'Heli kit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @heli_kit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @question_localized = QuestionLocalized.find(params[:id])\n\n respond_to do |format|\n if @question_localized.update_attributes(params[:question_localized])\n flash[:notice] = 'QuestionLocalized was successfully updated.'\n format.html { redirect_to(@question_localized) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question_localized.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @staffer = Staffer.find(params[:id])\n\n respond_to do |format|\n if @staffer.update_attributes(params[:staffer])\n format.html { redirect_to @staffer, notice: 'Staffer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @staffer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @legislacion = Legislacion.find(params[:id])\n\n respond_to do |format|\n if @legislacion.update_attributes(params[:legislacion])\n flash[:notice] = 'Legislacion se ha actualizado con exito.'\n format.html { redirect_to(admin_legislacions_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @legislacion.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @lecture = Lecture.find(params[:id])\n\n respond_to do |format|\n if @lecture.update_attributes(params[:lecture])\n flash[:notice] = 'Lecture was successfully updated.'\n format.html { redirect_to(admin_lecture_path(@lecture)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lecture.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lifeline.update(lifeline_params)\n format.html { redirect_to @lifeline, notice: 'Lifeline was successfully updated.' }\n format.json { render :show, status: :ok, location: @lifeline }\n else\n format.html { render :edit }\n format.json { render json: @lifeline.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @local_league = LocalLeague.find(params[:id])\n\n respond_to do |format|\n if @local_league.update_attributes(params[:local_league])\n format.html { redirect_to @local_league, notice: 'Local league was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @local_league.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tutorials = Tutorials.find(params[:id])\n\n respond_to do |format|\n if @tutorials.update_attributes(params[:tutorials])\n flash[:notice] = 'Tutorials was successfully updated.'\n format.html { redirect_to(@tutorials) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tutorials.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_lyric\n @lyric = Lyric.find(params[:id])\n end", "def update\n @needle = Needle.find(params[:id])\n\n respond_to do |format|\n if @needle.update_attributes(params[:needle])\n format.html { redirect_to(@needle, :notice => 'Needle was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @needle.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @league_type = LeagueType.find(params[:id])\n\n respond_to do |format|\n if @league_type.update_attributes(params[:league_type])\n format.html { redirect_to(@league_type, :notice => 'League type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @league_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @old_twit = OldTwit.find(params[:id])\n\n respond_to do |format|\n if @old_twit.update_attributes(params[:old_twit])\n format.html { redirect_to(@old_twit, :notice => 'Old twit was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @old_twit.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @olark = Olark.find(params[:id])\n\n respond_to do |format|\n if @olark.update_attributes(params[:olark])\n format.html { redirect_to(@olark, :notice => 'Olark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @olark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @leilao = Leilao.find(params[:id])\n\n respond_to do |format|\n if @leilao.update_attributes(params[:leilao])\n flash[:notice] = 'Leilao was successfully updated.'\n format.html { redirect_to(@leilao) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @leilao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_illust\n @illust = Illust.find(params[:id])\n end", "def update\n respond_to do |format|\n if @lable.update(lable_params)\n format.html { redirect_to @lable, notice: 'Lable was successfully updated.' }\n format.json { render :show, status: :ok, location: @lable }\n else\n format.html { render :edit }\n format.json { render json: @lable.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @rant = Rant.find(params[:id])\n\n respond_to do |format|\n if @rant.update_attributes(params[:rant])\n format.html { redirect_to(@rant, :notice => 'Rant was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @rant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @oligo = Oligo.find(params[:id])\n\n respond_to do |format|\n if @oligo.update_attributes(params[:oligo])\n flash[:notice] = 'Oligo was successfully updated.'\n format.html { redirect_to :action => :index }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @oligo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lamp.update(lamp_params)\n format.html { redirect_to @lamp, notice: 'Lamp was successfully updated.' }\n format.json { render :show, status: :ok, location: @lamp }\n else\n format.html { render :edit }\n format.json { render json: @lamp.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @laundromat = Laundromat.find(params[:id])\n\n respond_to do |format|\n if @laundromat.update_attributes(params[:laundromat])\n format.html { redirect_to @laundromat, notice: 'Laundromat was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @laundromat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @stockist = Stockist.find(params[:id])\n\n respond_to do |format|\n if @stockist.update_attributes(params[:stockist])\n flash[:notice] = 'Stockist was successfully updated.'\n format.html { redirect_to(admin_stockist_path(@stockist)) }\n format.xml { head :ok }\n else\n assign_lovs\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @stockist.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @renter = Renter.find(params[:id])\n\n respond_to do |format|\n if @renter.update_attributes(params[:renter])\n format.html { redirect_to @renter, notice: 'Renter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @renter.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @kitty = Kitty.find(params[:id])\n\n respond_to do |format|\n if @kitty.update_attributes(params[:kitty])\n format.html { redirect_to @kitty, notice: 'Kitty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kitty.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @local_tag = LocalTag.find(params[:id])\n\n respond_to do |format|\n if @local_tag.update(local_tag_params)\n format.html { redirect_to @local_tag, notice: 'Local tag was successfully updated.' }\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @local_tag.errors, status: :unprocessable_entity }\n format.xml { render xml: @local_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @renter = Renter.find(params[:id])\n\n respond_to do |format|\n if @renter.update_attributes(params[:renter])\n format.html { redirect_to @renter, :notice => 'Renter was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @renter.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @trail.update(trail_params)\n format.html { redirect_to @trail, notice: 'Trail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @livro = Livro.find(params[:id])\n respond_to do |format|\n if @livro.update_attributes(params[:livro])\n flash[:notice] = 'Livro was successfully updated.'\n format.html { redirect_to(@livro) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @livro.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @airlin = Airlin.find(params[:id])\n\n respond_to do |format|\n if @airlin.update_attributes(params[:airlin])\n format.html { redirect_to @airlin, notice: 'Airlin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @airlin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lr13 = Lr13.find(params[:id])\n\n respond_to do |format|\n if @lr13.update_attributes(params[:lr13])\n format.html { redirect_to(@lr13, :notice => 'Lr13 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lr13.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @trail.update(trail_params)\n format.html { redirect_to @trail, notice: 'Trail was successfully updated.' }\n format.json { render :show, status: :ok, location: @trail }\n else\n format.html { render :edit }\n format.json { render json: @trail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @technician = Technician.find(params[:id])\n\n respond_to do |format|\n if @technician.update_attributes(params[:technician])\n format.html { redirect_to(@technician, :notice => 'Technician was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @technician.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @therapist = Therapist.find(params[:id])\n\n respond_to do |format|\n if @therapist.update_attributes(params[:therapist])\n format.html { redirect_to @therapist, notice: 'Therapist was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @therapist.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n @microposst = Microposst.find(params[:id])\n\n respond_to do |format|\n if @microposst.update_attributes(params[:microposst])\n format.html { redirect_to @microposst, notice: 'Microposst was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @microposst.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @aisle = Aisle.find(params[:id])\n\n respond_to do |format|\n if @aisle.update_attributes(params[:aisle])\n format.html { redirect_to(@aisle, :notice => 'Aisle was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @aisle.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @spirit = Spirit.find(params[:id])\n\n respond_to do |format|\n if @spirit.update_attributes(params[:spirit])\n format.html { redirect_to @spirit, notice: 'Spirit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spirit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lr40 = Lr40.find(params[:id])\n\n respond_to do |format|\n if @lr40.update_attributes(params[:lr40])\n format.html { redirect_to(@lr40, :notice => 'Lr40 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lr40.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @microplst = Microplst.find(params[:id])\n\n respond_to do |format|\n if @microplst.update_attributes(params[:microplst])\n format.html { redirect_to @microplst, notice: 'Microplst was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @microplst.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @termekek = Termekek.find(params[:id])\n\n respond_to do |format|\n if @termekek.update_attributes(params[:termekek])\n format.html { redirect_to(@termekek, :notice => 'Termekek was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @termekek.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @land = Land.find(params[:id])\n @land.attributes=params[:land]\n respond_to do |format|\n if help_process\n flash[:notice] = 'Land was successfully updated.'\n format.html { redirect_to(@land) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @land.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.63708353", "0.59842366", "0.5973589", "0.591118", "0.5889541", "0.58868515", "0.5852491", "0.58411384", "0.58282727", "0.580237", "0.57161844", "0.5715342", "0.57120943", "0.56999475", "0.5675926", "0.5674598", "0.56395155", "0.56371707", "0.56246245", "0.5606287", "0.5558309", "0.5523718", "0.5520946", "0.5516729", "0.551459", "0.5501333", "0.54908055", "0.54871404", "0.54334164", "0.54217935", "0.5409708", "0.53920317", "0.53874296", "0.5384258", "0.5360407", "0.5350033", "0.53498065", "0.534714", "0.5333449", "0.53279305", "0.53241575", "0.53115755", "0.5311526", "0.5303458", "0.52945644", "0.52755976", "0.52684444", "0.5266499", "0.5253961", "0.5249766", "0.52436984", "0.5235878", "0.5234578", "0.5234028", "0.52272856", "0.52231604", "0.522128", "0.5220952", "0.5218928", "0.5215852", "0.5210993", "0.51904655", "0.5183555", "0.51790816", "0.51775885", "0.51773965", "0.5175751", "0.5172936", "0.5171998", "0.51693076", "0.51610327", "0.5158979", "0.5155923", "0.5155789", "0.5152092", "0.5146297", "0.51351094", "0.5132986", "0.5129154", "0.51171637", "0.51139796", "0.51136863", "0.5111149", "0.51059455", "0.50993574", "0.50944024", "0.5091126", "0.5090824", "0.5089956", "0.5087546", "0.50814325", "0.508116", "0.50761735", "0.50665295", "0.5061414", "0.50605285", "0.5059325", "0.5058006", "0.50579804", "0.50508183" ]
0.6212464
1
DELETE /litters/1 DELETE /litters/1.xml
def destroy @litter = Litter.find(params[:id]) @litter.destroy respond_to do |format| format.html { redirect_to(litters_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @lek = Lek.find(params[:id])\n @lek.destroy\n \n\n respond_to do |format|\n format.html { redirect_to(leks_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def delete!\n Recliner.delete(uri)\n end", "def destroy\n @lien = Lien.find(params[:id])\n @lien.destroy\n\n respond_to do |format|\n format.html { redirect_to(liens_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lien = Lien.find(params[:id])\n @lien.destroy\n\n respond_to do |format|\n format.html { redirect_to(liens_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lift = Lift.find(params[:id])\n @lift.destroy\n\n respond_to do |format|\n format.html { redirect_to(lifts_url) }\n format.xml { head :ok }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @lore = Lore.find(params[:id])\n @lore.destroy\n\n respond_to do |format|\n format.html { redirect_to(lores_url) }\n format.xml { head :ok }\n end\n end", "def delete(name); end", "def delete(name); end", "def destroy\n @lyric = Lyric.find(params[:id])\n @lyric.destroy\n\n respond_to do |format|\n format.html { redirect_to(lyrics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lyric = Lyric.find(params[:id])\n @lyric.destroy\n\n respond_to do |format|\n format.html { redirect_to(lyrics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end", "def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end", "def destroy\n @legislacion = Legislacion.find(params[:id])\n @legislacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_legislacions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tuple = Tuple.find(params[:id])\n @tuple.destroy\n\n respond_to do |format|\n format.html { redirect_to(tuples_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @aisle = Aisle.find(params[:id])\n @aisle.destroy\n\n respond_to do |format|\n format.html { redirect_to(aisles_url) }\n format.xml { head :ok }\n end\n end", "def delete(name)\n\n end", "def destroy\n @lendable = Lendable.find(params[:id])\n @lendable.destroy\n\n respond_to do |format|\n format.html { redirect_to(lendables_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lieu = Lieu.find(params[:id])\n @lieu.destroy\n\n respond_to do |format|\n format.html { redirect_to(lieus_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @hydrant = Hydrant.find(params[:id])\n @hydrant.destroy\n\n respond_to do |format|\n format.html { redirect_to(hydrants_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lotes = Lote.find(params[:id])\n @lotes.destroy\n\n respond_to do |format|\n format.html { redirect_to(lotes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @uitgelicht = Uitgelicht.find(params[:id])\n @uitgelicht.destroy\n\n respond_to do |format|\n format.html { redirect_to(uitgelichts_url) }\n format.xml { head :ok }\n end\n end", "def delete\n blacklight_items.each do |r|\n solr.delete_by_id r[\"id\"]\n solr.commit\n end\n end", "def destroy\n @slitting = Slitting.find(params[:id])\n @slitting.destroy\n\n respond_to do |format|\n format.html { redirect_to(slittings_url) }\n format.xml { head :ok }\n end\n end", "def delete(name)\n @ctx.delete(@path + name)\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def destroy\n @leilao = Leilao.find(params[:id])\n @leilao.destroy\n\n respond_to do |format|\n format.html { redirect_to(leilaos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @t1 = T1.find(params[:id])\n @t1.destroy\n\n respond_to do |format|\n format.html { redirect_to(t1s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @helocagree = Helocagree.find(params[:id])\n @helocagree.destroy\n\n respond_to do |format|\n format.html { redirect_to(helocagrees_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lb202556 = Lb202556.find(params[:id])\n @lb202556.destroy\n\n respond_to do |format|\n format.html { redirect_to(lb202556s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n Clenum.destroy params[:ids].split(',')\n\n respond_to do |format|\n format.html { redirect_to(clenums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @rant = Rant.find(params[:id])\n @rant.destroy\n\n respond_to do |format|\n format.html { redirect_to(rants_url) }\n format.xml { head :ok }\n end\n end", "def destroy()\n urn_check()\n @sparql.delete([ @urn, :p, :o ])\n @sparql.delete([ :s, :p, @urn ])\n end", "def destroy\n @lei = Lei.find(params[:id])\n @lei.destroy\n\n respond_to do |format|\n format.html { redirect_to leis_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bottle = Bottle.find(params[:id])\n @bottle.destroy\n\n respond_to do |format|\n format.html { redirect_to(bottles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lr45 = Lr45.find(params[:id])\n @lr45.destroy\n\n respond_to do |format|\n format.html { redirect_to(lr45s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lecture = Lecture.find(params[:id])\n @lecture.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_lectures_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @nom = Nom.find(params[:id])\n @nom.destroy\n\n respond_to do |format|\n format.html { redirect_to(noms_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @liftset.destroy\n respond_to do |format|\n format.html { redirect_to liftsets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @needle = Needle.find(params[:id])\n @needle.destroy\n\n respond_to do |format|\n format.html { redirect_to(needles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @oligo = Oligo.find(params[:id])\n @oligo.destroy\n\n respond_to do |format|\n format.html { redirect_to(oligos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n pedigree = @person.pedigree\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to(pedigree_url(pedigree)) }\n format.xml { head :ok }\n end\n end", "def destroy\n \n @ontology = SYMPH::Ontology.find(params[:id])\n @ontology.disable\n @ontology.destroy\n \n respond_to do |format|\n format.html { redirect_to :action => :index }\n format.xml { head :ok }\n end\n end", "def destroy\n @wrestler = Wrestler.find(params[:id])\n @wrestler.destroy\n\n respond_to do |format|\n format.html { redirect_to(wrestlers_url) }\n format.xml { head :ok }\n end\n end", "def delete_all(xpath); end", "def destroy\r\n @razdel1 = Razdel1.find(params[:id])\r\n @razdel1.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(razdel1s_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @land = Land.find(params[:id])\n @land.destroy\n\n respond_to do |format|\n format.html { redirect_to(lands_url) }\n format.xml { head :ok }\n end\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def destroy\n @lesson_learned = LessonLearned.find(params[:id])\n @lesson_learned.destroy\n\n # Now remove it from Solr\n @rsolr.delete_by_id(@lesson_learned.id)\n @rsolr.commit\n\n respond_to do |format|\n format.html { redirect_to lesson_learneds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tagline = Tagline.find(params[:id])\n @tagline.destroy\n\n respond_to do |format|\n format.html { redirect_to(taglines_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lent = Lent.find(params[:id])\n @lent.destroy\n\n respond_to do |format|\n format.html { redirect_to lents_url }\n format.json { head :no_content }\n end\n end", "def delete(attribute); end", "def destroy\n @meant_it_rel = MeantItRel.find(params[:id])\n @meant_it_rel.destroy\n\n respond_to do |format|\n format.html { redirect_to(meant_it_rels_url) }\n format.xml { head :ok }\n end\n end", "def rm(*path)\n super; on_success{ nil }\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n client = Connection::MarkLogic.new.client\n client.send_corona_request(\"/v1/documents?uri=/amandments/amandment_#{@amandment.id}.xml\", :delete)\n @amandment.destroy\n respond_to do |format|\n format.html { redirect_to home_meeting_path, notice: 'Amandman was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @rute = Rute.find(params[:id])\n @rute.destroy\n\n respond_to do |format|\n format.html { redirect_to(rutes_url) }\n format.xml { head :ok }\n end\n end", "def delete_row(row_id); rest_delete(\"#{link('rows')}/#{row_id}\"); nil; end", "def destroy\n @leito = Leito.find(params[:id])\n @leito.destroy\n\n respond_to do |format|\n format.html { redirect_to leitos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @dossier = Dossier.find(params[:id])\n @dossier.destroy\n\n respond_to do |format|\n format.html { redirect_to(\"/\") }\n format.xml { head :ok }\n end\n end", "def destroy\n @journal_line = JournalLine.find(params[:id])\n @journal_line.destroy\n\n respond_to do |format|\n format.html { redirect_to(journal_lines_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lotto_type = LottoType.find(params[:id])\n @lotto_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(lotto_types_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @taxband = Taxband.find(params[:id])\n @taxband.destroy\n\n respond_to do |format|\n format.html { redirect_to(taxbands_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lector = Lector.find(params[:id])\n @lector.destroy\n\n respond_to do |format|\n format.html { redirect_to lectores_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @intelligence = Intelligence.find(params[:id])\n @intelligence.destroy\n\n respond_to do |format|\n format.html { redirect_to(intelligences_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @relatorio = Relatorio.find(params[:id])\n @relatorio.destroy\n\n respond_to do |format|\n format.html { redirect_to(home_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n chef_server_rest.delete(\"nodes/#{name}\")\n end", "def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end", "def remove\n valid = parse_valid(params)\n # puts valid\n choose = $db.search(\"//book[\"+valid+\"]\").remove\n size = 0\n for i in choose\n size += 1\n end\n $file = open PATH, \"w\"\n $file.write $db\n $file.close\n render :soap => \"<result>\"+size.to_s+\"</result>\"\n end", "def destroy\n @shelf = Shelf.find(params[:id])\n @shelf.destroy\n\n respond_to do |format|\n format.html { redirect_to(shelves_url) }\n format.xml { head :ok }\n end\n end", "def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end", "def delete()\n @ole.Delete()\n end", "def delete()\n @ole.Delete()\n end", "def delete()\n @ole.Delete()\n end", "def delete()\n @ole.Delete()\n end", "def rm path\n end", "def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end", "def destroy\n @sti = Sti.find(params[:id])\n @sti.destroy\n\n respond_to do |format|\n format.html { redirect_to(stis_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lede = Lede.find(params[:id])\n @lede.destroy\n\n respond_to do |format|\n format.html { redirect_to ledes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @litter = Litter.find(params[:id])\n @litter.destroy\n\n respond_to do |format|\n format.html { redirect_to litters_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @landlord = Landlord.find(params[:id])\n @landlord.destroy\n\n respond_to do |format|\n format.html { redirect_to(landlords_url) }\n format.xml { head :ok }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @lr40 = Lr40.find(params[:id])\n @lr40.destroy\n\n respond_to do |format|\n format.html { redirect_to(lr40s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @rig = Rig.find(params[:id])\n @rig.destroy\n\n respond_to do |format|\n format.html { redirect_to(rigs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @strelki = Strelki.find(params[:id])\n @strelki.destroy\n\n respond_to do |format|\n format.html { redirect_to(strelkis_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lactation = Lactation.find(params[:id])\n @lactation.destroy\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @helibasis = Helibase.find(params[:id])\n @helibasis.destroy\n\n respond_to do |format|\n format.html { redirect_to(helibases_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @relatorios = Relatorio.find(params[:id])\n @relatorios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @gene_ontology = GeneOntology.find(params[:id])\n @gene_ontology.destroy\n\n respond_to do |format|\n format.html { redirect_to(gene_ontologies_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @centricsteel = Centricsteel.find(params[:id])\n @centricsteel.destroy\n\n respond_to do |format|\n format.html { redirect_to(centricsteels_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @norma = Norma.find(params[:id])\n @norma.destroy\n\n respond_to do |format|\n format.html { redirect_to(normas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @settlement = @transaction.settlements.find(params[:id])\n @settlement.destroy\n\n respond_to do |format|\n format.html { redirect_to(client_transaction_settlements_url(@client, @transaction)) }\n format.xml { head :ok }\n end\n end", "def delete\n records = ReadLater.find_by_url(params[:url])\n records.destroy\n\n redirect_to read_laters_path\n end", "def destroy\n @etiquetage = Etiquetage.find(params[:id])\n @etiquetage.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_etiquetages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @attri = Attri.find(params[:id])\n @attri.destroy\n\n respond_to do |format|\n format.html { redirect_to attris_url }\n format.json { head :ok }\n end\n end", "def destroy\n @direccion = Direccion.find(params[:id])\n @direccion.destroy\n\n respond_to do |format|\n format.html { redirect_to(direccions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ingredience = Ingredience.find(params[:id])\n @ingredience.destroy\n\n respond_to do |format|\n format.html { redirect_to(ingrediences_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @modele = Modele.find(params[:id])\n @modele.destroy\n\n respond_to do |format|\n format.html { redirect_to(modeles_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.6557725", "0.6421214", "0.6326835", "0.6298232", "0.6298232", "0.6179706", "0.6138767", "0.61158025", "0.61097425", "0.61097425", "0.6107589", "0.6107589", "0.60609365", "0.6059919", "0.6053293", "0.6046545", "0.60423905", "0.6034084", "0.602292", "0.6008023", "0.59898084", "0.5983811", "0.59612334", "0.5958941", "0.59432584", "0.59404325", "0.5939956", "0.5938167", "0.593682", "0.593265", "0.59253997", "0.5923723", "0.5912396", "0.5895009", "0.58711356", "0.58635956", "0.5858613", "0.5852204", "0.58487", "0.58421546", "0.58362937", "0.5829032", "0.5818856", "0.5816996", "0.5813577", "0.5812357", "0.5805504", "0.5801816", "0.5795379", "0.57917684", "0.57877094", "0.5784526", "0.5780337", "0.5779264", "0.5775602", "0.5770402", "0.57686996", "0.576826", "0.5767204", "0.57656974", "0.5765415", "0.5762075", "0.5759061", "0.5758041", "0.5757749", "0.575416", "0.574669", "0.5743365", "0.57424915", "0.5738139", "0.57346606", "0.57308996", "0.57308406", "0.57308406", "0.57308406", "0.57308406", "0.57304794", "0.57287896", "0.57278097", "0.5725272", "0.5721135", "0.5712425", "0.57113004", "0.57089996", "0.57081205", "0.5707417", "0.5703072", "0.5697952", "0.5697368", "0.5695893", "0.56953484", "0.56925005", "0.5689502", "0.568787", "0.5686558", "0.56832856", "0.5682721", "0.56812954", "0.56812376", "0.56780547" ]
0.6564121
0
Provides us with a constant time lookup of the given facet's neighbours
def find_neighbours(face) if not @faces.member? face # There is no point doing anything if the face is not in the model return nil end neighbours = [] face.edges.each_value do |edge| if @edges.member? edge # this will match a pair of faces one of them will be this face matches = @edges[edge] matches.each do |matched_face| if matched_face != face neighbours.push(matched_face) end end end end return neighbours end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def live_neighbours_around_cell(cell)\n live_neighbours = []\n\n #check top cell\n if cell.x_axis > 0\n # puts \"Cell dimen1: #{cell.x_axis}:#{cell.y_axis}\"\n candidate = self.cell_grid[cell.x_axis - 1][cell.y_axis]\n # puts \"Candidate #{candidate.inspect}\"\n live_neighbours << candidate if candidate.alive?\n end\n #check right cell\n if cell.y_axis < (columns-1)\n # puts \"Cell dimen2: #{cell.x_axis}:#{cell.y_axis}\"\n candidate = self.cell_grid[cell.x_axis][cell.y_axis + 1]\n # puts \"Candidate #{candidate.inspect}\"\n live_neighbours << candidate if candidate.alive?\n end\n #check left cell\n if cell.y_axis > 0\n # puts \"Cell dimen3: #{cell.x_axis}:#{cell.y_axis}\"\n candidate = self.cell_grid[cell.x_axis][cell.y_axis - 1]\n # puts \"Candidate #{candidate.inspect}\"\n live_neighbours << candidate if candidate.alive?\n end\n # #check bottom cell\n if cell.x_axis < (rows-1)\n # puts \"Cell dimen4: #{cell.x_axis}:#{cell.y_axis}\"\n candidate = self.cell_grid[cell.x_axis + 1][cell.y_axis]\n # puts \"Candidate #{candidate.inspect}\"\n live_neighbours << candidate if candidate.alive?\n end\n # #check top left\n if cell.x_axis > 0 and cell.y_axis > 0\n # puts \"Cell dimen5: #{cell.x_axis}:#{cell.y_axis}\"\n candidate = self.cell_grid[cell.x_axis - 1][cell.y_axis - 1]\n # puts \"Candidate #{candidate.inspect}\"\n live_neighbours << candidate if candidate.alive?\n end\n # #check top right\n if cell.x_axis > 0 and cell.y_axis < (columns-1)\n # puts \"Cell dimen6: #{cell.x_axis}:#{cell.y_axis}\"\n candidate = self.cell_grid[cell.x_axis - 1][cell.y_axis + 1]\n # puts \"Candidate #{candidate.inspect}\"\n live_neighbours << candidate if candidate.alive?\n end\n # #check bottom left\n if cell.x_axis < (rows - 1) and cell.y_axis > 0\n # puts \"Cell dimen7: #{cell.x_axis}:#{cell.y_axis}\"\n candidate = self.cell_grid[cell.x_axis + 1][cell.y_axis - 1]\n # puts \"Candidate #{candidate.inspect}\"\n live_neighbours << candidate if candidate.alive?\n end\n # #check bottom right\n if cell.x_axis < (rows - 1) and cell.y_axis < (columns - 1)\n # puts \"Cell dimen8: #{cell.x_axis}:#{cell.y_axis}\"\n candidate = self.cell_grid[cell.x_axis + 1][cell.y_axis + 1]\n # puts \"Candidate #{candidate.inspect}\"\n live_neighbours << candidate if candidate.alive?\n end\n live_neighbours\n end", "def neighbours()\n @map.neighbours(@x, @y, true)\n end", "def live_neighbors(cell_row, cell_col)\n count = 0\n row = cell_row - 1\n col = cell_col - 1\n\n min_row = [row - 1, 0].max\n max_row = [row + 1, number_rows - 1].min\n min_col = [col - 1, 0].max\n max_col = [col + 1, number_columns - 1].min\n\n (min_row..max_row).each do |r|\n count += (min_col..max_col).inject(0) {|count,c| count + @state[r][c]}\n end\n count - @state[row][col]\n end", "def find_neighbours(x)\n x.x - 1 < 0 ? fx = 0 : fx = x.x - 1\n x.x + 1 > @world.length-1 ? tx = @world.length-1 : tx = x.x + 1\n x.y- 1 < 0 ? fy = 0 : fy = x.y - 1\n x.y + 1 > @world[0].length-1 ? ty = @world[0].length-1 : ty = x.y + 1\n n_state = 0\n v_arrays = @world[fx..tx]\n v_arrays.each { |arr|\n h_array = arr[fy..ty]\n h_array.each { |grub|\n if (!grub.equal?(x))\n grub.lives ? n_state +=1 : n_state +=0\n end\n }\n }\n return n_state\n end", "def neighbours point\n [\n [-1, 0],\n [1, 0],\n [0, 1],\n [0, -1]\n ].map do |(dx, dy)|\n [\n (point[0] + dx + @map.length) % @map.length,\n (point[1] + dy + @map.length) % @map.length\n ]\n end\n end", "def live_neighbours_around_cell(cell)\n live_neighbours = []\n # Neighbour to the North-East\n if cell.y > 0 and cell.x < (cols - 1)\n candidate = @cell_board[cell.y - 1][cell.x + 1]\n live_neighbours << candidate if candidate.alive?\n end\n # Neighbour to the South-East\n if cell.y < (rows - 1) and cell.x < (cols - 1)\n candidate = @cell_board[cell.y + 1][cell.x + 1]\n live_neighbours << candidate if candidate.alive?\n end\n # Neighbours to the South-West\n if cell.y < (rows - 1) and cell.x > 0\n candidate = @cell_board[cell.y + 1][cell.x - 1]\n live_neighbours << candidate if candidate.alive?\n end\n # Neighbours to the North-West\n if cell.y > 0 and cell.x > 0\n candidate = @cell_board[cell.y - 1][cell.x - 1]\n live_neighbours << candidate if candidate.alive?\n end\n # Neighbour to the North\n if cell.y > 0\n candidate = @cell_board[cell.y - 1][cell.x]\n live_neighbours << candidate if candidate.alive?\n end\n # Neighbour to the East\n if cell.x < (cols - 1)\n candidate = @cell_board[cell.y][cell.x + 1]\n live_neighbours << candidate if candidate.alive?\n end\n # Neighbour to the South\n if cell.y < (rows - 1)\n candidate = @cell_board[cell.y + 1][cell.x]\n live_neighbours << candidate if candidate.alive?\n end\n # Neighbours to the West\n if cell.x > 0\n candidate = @cell_board[cell.y][cell.x - 1]\n live_neighbours << candidate if candidate.alive?\n end\n live_neighbours\n end", "def neighbours(x, y)\n # If the x, y arguments are out of bounds we raise our custom `OutOfBoundError`.\n raise OutOfBoundsError if out_of_bounds x, y\n neighbours_found = 0\n # This method is compuationally expensive. As such, the performance degrades \n # as our cells count grows.\n @cells.each do |cx, cy|\n neighbours_found += 1 if neighbour? cx, cy, x, y\n end\n neighbours_found\n end", "def get_neighbours(x, y, state)\n count = 0\n for ix in x - 1..x + 1\n for iy in y - 1..y + 1\n count += 1 if state[[ix, iy]] and not (ix == x and iy == y)\n end\n end\n return count\nend", "def neighbours_in_use(row, col)\n neighbours = []\n\n neighbours << [row - 1, col] if row > 0 && used?(row - 1, col)\n neighbours << [row + 1, col] if row < @rows - 1 && used?(row + 1, col)\n neighbours << [row, col - 1] if col > 0 && used?(row, col - 1)\n neighbours << [row, col + 1] if col < @cols - 1 && used?(row, col + 1)\n\n neighbours\n end", "def neighbours(grid, coords)\n x, y = coords\n n = [\n [1, 0], [1, 1], [0, 1], [-1, 1],\n [-1,0], [-1, -1], [0, -1], [1, -1]\n ]\n \n n\n .map { |i|\n nx, ny = i\n grid.fetch([x + nx,y + ny], 0)\n }\n .sum\nend", "def know_neighbors\n bomb_neighbors = 0\n neighbor_coords = []\n rel_neighbor_coords = [[0, 1], [1, 1], [-1, 0], [-1, 1], [1, 0], [1, -1], [0, -1], [-1, -1]]\n rel_neighbor_coords.each do | coord |\n neighbor_coords << [@coords[0] + coord[0], @coords[1] + coord[1]]\n end\n neighbor_coords.select! {|pos| pos.all? { |coord| (0..8).cover? coord }}\n neighbor_coords\n end", "def live_neighbor_count(cell, live_cells)\n (neighborhood(cell) & live_cells).count\nend", "def neighbors(point, scr_height, scr_width)\n deltas = [ [0, 1], [0, -1],\n [1, 0], [-1, 0] ]\n neighbors = []\n deltas.each do |delta|\n neighbor = [point[0] + delta[0], point[1] + delta[1]]\n neighbors.push(neighbor) if in_bounds?(neighbor, scr_height, scr_width)\n end\n neighbors\nend", "def reachable_cells(x, y, world)\n visited = []\n queue = [[x, y]]\n\n while !queue.empty?\n start = queue.pop\n neighbors = DIRECTIONS.values.\n map {|d| [start[0] + d[:x], start[1] + d[:y]]}.\n select {|x,y| world[y][x] == '.' }\n new_cells = neighbors - visited\n queue = queue + new_cells\n visited.push(start)\n end\n\n visited\nend", "def neighbors\n @neighbors ||= [-1, 0, 1].repeated_permutation(2).map do |dx, dy|\n @grid[x + dx, y + dy] unless dx.zero? && dy.zero?\n end.compact\n end", "def find_live_neighbours(row, col)\n cell = grid[row, col]\n live_n = 0\n\n neighbours = [\n [row - 1, col], # up\n [row + 1, col], # down\n [row - 1, col - 1], # up-left\n [row, col - 1], # left\n [row + 1, col - 1], # down-left\n [row - 1, col + 1], # up-right\n [row, col + 1], # right\n [row + 1, col + 1] # down-right\n ]\n\n neighbours.each { |row, col| live_n += count_valid_cell(row, col) }\n toggle_cell_state(cell, live_n)\n end", "def neighbors\n neighbors = []\n for row in (x - 1)..(x + 1)\n for col in (y - 1)..(y + 1)\n if (0...FIELD_SIZE).cover?(row) && (0...FIELD_SIZE).cover?(col)\n if row != x || col != y\n neighbors.push(@battle_field[row, col])\n end\n end\n end\n end\n neighbors\n end", "def get_neighbors\n\t\t\t\tdbg.call unless @neighbors\n\t\t\t\treturn @neighbors.values\n\t\t\tend", "def get_neighbors(node)\n possible = []\n possible << @grid[[node.x, node.y - 1]] if @grid[[node.x, node.y - 1]].descriptor == TRAVERSABLE\n possible << @grid[[node.x, node.y + 1]] if @grid[[node.x, node.y + 1]].descriptor == TRAVERSABLE\n possible << @grid[[node.x - 1, node.y]] if @grid[[node.x - 1, node.y]].descriptor == TRAVERSABLE\n possible << @grid[[node.x + 1, node.y]] if @grid[[node.x + 1, node.y]].descriptor == TRAVERSABLE\n return possible\n end", "def get_neighbors(node)\n possible = []\n possible << @grid[[node.x, node.y - 1]] if @grid[[node.x, node.y - 1]].descriptor == TRAVERSABLE\n possible << @grid[[node.x, node.y + 1]] if @grid[[node.x, node.y + 1]].descriptor == TRAVERSABLE\n possible << @grid[[node.x - 1, node.y]] if @grid[[node.x - 1, node.y]].descriptor == TRAVERSABLE\n possible << @grid[[node.x + 1, node.y]] if @grid[[node.x + 1, node.y]].descriptor == TRAVERSABLE\n return possible\n end", "def neighbors_reader\n @neighbors\n end", "def neighbor(num)\n @neighbors[num]\n end", "def get_neighbors image\n coord = image.get_cell_coordinates(self)\n v_neighbors = [image.get_cell(coord[0], coord[1]-1), image.get_cell(coord[0], coord[1]+1)]\n h_neighbors = [image.get_cell(coord[0]-1, coord[1]), image.get_cell(coord[0]+1, coord[1])]\n neighbors = (v_neighbors + h_neighbors).compact\n end", "def neighbors1(x, y, b)\n ns = []\n if x-1 > -1\n ns << [b[x-1][y], b[x-1][y+1]]\n ns << b[x-1][y-1] if y-1 > -1\n end\n if y-1 > -1\n ns << b[x][y-1]\n ns << b[x+1][y-1] if b[x+1]\n end\n ns << b[x][y+1]\n ns << [b[x+1][y+1], b[x+1][y]] if b[x+1]\n ns.flatten.count('#')\nend", "def neighbors(p)\n if ce=@neighbors_cache[p]\n return ce\n end\n res = []\n bits = @structure[p]\n res << p-w if bits & UP > 0 # north\n res << p+w if bits & DOWN > 0 # south\n res << p-1 if p%w > 0 && bits & LEFT > 0 # west\n res << p+1 if p%w < w-1 && bits & RIGHT > 0 # east\n # select reachable neighbors\n @neighbors_cache[p] = res.find_all { |t| t>=0 && t<@wh }\n end", "def get_neighbors(x, y, array)\n \n # Ensures that no cell outside of the grid is called\n if x < 0 or x > @height - 1 or y < 0 or y > @width - 1\n return -1\n end\n \n num_neighbors = 0\n \n # Since not all cells can have 8 neighbors due to the bounds of \n # the grid, the cell given by x and y is tested to see which of \n # the 8 neighbors it can and cannot have\n if x > 0 and y > 0\n if array[x-1][y-1] == LIVE\n num_neighbors += 1\n end\n end\n if x > 0\n if array[x-1][y] == LIVE\n num_neighbors += 1;\n end\n end\n if x > 0 && y < @width - 1\n if array[x-1][y+1] == LIVE\n num_neighbors += 1;\n end\n end\n if y > 0\n if array[x][y-1] == LIVE\n num_neighbors += 1;\n end\n end\n if y < @width - 1\n if array[x][y+1] == LIVE\n num_neighbors += 1;\n end\n end\n if x < @height - 1 && y > 0\n if array[x+1][y-1] == LIVE\n num_neighbors += 1;\n end\n end\n if x < @height - 1\n if array[x+1][y] == LIVE\n num_neighbors += 1;\n end\n end\n if x < @height - 1 && y < @width - 1\n if array[x+1][y+1] == LIVE\n num_neighbors += 1;\n end\n end\n \n # Unneccessary, but here for readability purposes\n return num_neighbors\n end", "def nearby_dead_cells(live_cells)\n live_cells.map { |p| neighborhood(p) }.reduce(:|) - live_cells\nend", "def get_neighbors(tile)\n @tiles.flatten.select { |t|\n (t.x <= (tile.x + 1) && t.x >= (tile.x - 1)) &&\n (t.y <= (tile.y + 1) && t.y >= (tile.y - 1)) &&\n tile != t\n }\n end", "def immediate_neighbours(point)\n\t\t\tneighbours = []\n\t\t\t@new_points.each{|p|\n\t\t\t\tnext if p.items == point.items\n\t\t\t\td = distance(point.items,p.items)\n\t\t\t\tneighbours.push(p) if d < @epsilon\n\t\t\t}\n\t\t\tneighbours\n\t\tend", "def neighbors x, y\n dirs = [\n [-1, 0], [0, -1], [0, 1], [1, 0]\n ]\n ns = []\n dirs.each do |(i,j)|\n dx, dy = x+i, y+j\n if (0 <= dx && dx < @h) && (0 <= dy && dy < @w)\n ns << [dx, dy]\n end\n end\n ns\nend", "def neighbors(x, y)\n neighbors = []\n if @map[x - 1] && @map[x - 1][y]\n neighbors.push(@map[x - 1][y]) # left\n end\n if @map[x + 1] && @map[x + 1][y] \n neighbors.push(@map[x + 1][y]) # right\n end\n if @map[x][y - 1]\n neighbors.push(@map[x][y - 1]) # top\n end\n if @map[x][y + 1] \n neighbors.push(@map[x][y + 1]) # bottom\n end\n if @map[x - 1] && @map[x - 1][y - 1]\n neighbors.push(@map[x - 1][y - 1]) # top-left\n end\n if @map[x - 1] && @map[x - 1][y + 1] \n neighbors.push(@map[x - 1][y + 1]) # bottom-left\n end\n if @map[x + 1] && @map[x + 1][y + 1] \n neighbors.push(@map[x + 1][y + 1]) # top-right\n end\n if @map[x + 1] && @map[x + 1][y - 1] \n neighbors.push(@map[x + 1][y - 1]) # bottom-right\n end\n return neighbors\n end", "def get_num_neighbours(x, y)\n neighbours = 0\n (x-1..x+1).each do |col|\n (y-1..y+1).each do |row|\n if in_bounds?(col, row) && !(col == x && row == y) &&\n @grid[row][col] == 1\n neighbours += 1\n end\n end\n end\n neighbours\n end", "def neighbors(x, y)\n neighbors = []\n neighbors << [(x + 1), y] if (x + 1) < grid.count\n neighbors << [(x - 1), y] if x > 0\n neighbors << [x, (y + 1)] if (y + 1) < grid[0].count\n neighbors << [x, (y - 1)] if y > 0\n neighbors.select { |pos| self[*pos] != -1 }\n end", "def neighbours\n neighbours = []\n [@x-1, @x, @x+1].each do |x|\n [@y-1, @x, @y+1].each do |y|\n if x >= 0 && y >= 0 && x <= MAX_X && y <= MAX_Y && !(x == @x && y == @y)\n neighbours << [x,y]\n end\n end\n end\n return neighbours\n end", "def in_neighbors(vertex)\n\tend", "def neighbours_boundries(cell_cords, dimension)\n [0, cell_cords - 1].max..[cell_cords + 1, dimension - 1].min\n end", "def get_living_neighbours(cell)\n living_neighbours = []\n\n #Checking the status of neighbouring cells, with checks for cases where the cell resides on the edge of the grid.\n if cell.y < rows - 1\n neighbour = game_grid[cell.x][cell.y + 1]\n living_neighbours.push(neighbour) if neighbour.alive?\n end\n\n if cell.x < cols - 1 && cell.y < rows - 1\n neighbour = game_grid[cell.x + 1][cell.y + 1]\n living_neighbours.push(neighbour) if neighbour.alive?\n end\n\n if cell.x < cols - 1\n neighbour = game_grid[cell.x + 1][cell.y]\n living_neighbours.push(neighbour) if neighbour.alive?\n end\n\n if cell.x < rows - 1 && cell.y > 0\n neighbour = game_grid[cell.x + 1][cell.y - 1]\n living_neighbours.push(neighbour) if neighbour.alive?\n end\n\n if cell.y > 0\n neighbour = game_grid[cell.x][cell.y - 1]\n living_neighbours.push(neighbour) if neighbour.alive?\n end\n\n if cell.x > 0 && cell.y > 0\n neighbour = game_grid[cell.x - 1][cell.y - 1]\n living_neighbours.push(neighbour) if neighbour.alive?\n end\n\n if cell.x > 0\n neighbour = game_grid[cell.x - 1][cell.y]\n living_neighbours.push(neighbour) if neighbour.alive?\n end\n\n if cell.x > 0 && cell.y < rows - 1\n neighbour = game_grid[cell.x - 1][cell.y + 1]\n living_neighbours.push(neighbour) if neighbour.alive?\n end\n\n return living_neighbours\n\n end", "def live_neighbor_count(coords, cells=@cells)\n num_alive_neighbors = 0\n minmax = coords.map { |dim_coord| [dim_coord-1, dim_coord+1] }\n all_coords_in(minmax).each do |neighbor_coord|\n if coords != neighbor_coord && cells.include?(neighbor_coord)\n num_alive_neighbors += 1 \n end\n end\n num_alive_neighbors\n end", "def neighbours(radius = 1)\n (-radius..radius).each_with_object([]) do |x_diff, array|\n (-radius..radius).each do |y_diff|\n next if (x_diff.zero? && y_diff.zero?) ||\n x_diff + x < 0 ||\n y_diff + y < 0 ||\n x_diff + x > game.size ||\n y_diff + y > game.size\n array << game.find_square(x_diff + x, y_diff + y)\n end\n end\n end", "def interpolation_search_internal(value)\n return [false, 0] if @inner.size == 0\n left = 0\n right = @inner.size - 1\n return [false, 0] if value < @inner[left]\n return [false, right + 1] if value > @inner[right]\n while left <= right\n if left == right\n candidate = left\n else\n candidate = (left + (right - left) * (value - @inner[left]) / (@inner[right] - @inner[left]).to_f).round\n end\n return [false, left] if candidate < left\n return [false, right + 1] if candidate > right\n if @inner[candidate] == value\n return [true, candidate]\n elsif value < @inner[candidate]\n right = candidate - 1\n else\n left = candidate + 1\n end\n end\n return [false, left]\n end", "def neighbors(vertex)\n\tend", "def live_neighbours\n self.neighbours.select do |n|\n n && n.is_alive?\n end\n end", "def neighbour_count x,y\n @mat[x][y].count_neighbours\n end", "def count_neighbors(space, x_in, y_in, z_in, w_in, x_size, y_size, z_size, w_size)\n# count the number of active neighbors to (x, y, z, w)\ncount = 0\n[w_in-1, w_in, w_in+1].each do |w|\n\t[z_in-1, z_in, z_in+1].each do |z|\n\t\t[y_in-1, y_in, y_in+1].each do |y|\n\t\t\t[x_in-1, x_in, x_in+1].each do |x|\n\t\t\t\tif x==x_in and y==y_in and z==z_in and w==w_in\n\t\t\t\t\t# we do not consider ourself\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif x>=0 and x<x_size and y>=0 and y<y_size and z>=0 and z<z_size and w>=0 and w<w_size and space[x][y][z][w] == '#'\n\t\t\t\t\tcount+=1\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend\nreturn count\n#\nend", "def cell_neighbours(cell_x, cell_y)\n result = {}\n\n for curr_x in neighbours_boundries(cell_x, width)\n for curr_y in neighbours_boundries(cell_y, height)\n next if cell_x == curr_x && cell_y == curr_y\n\n cell_value = grid[curr_y][curr_x]\n if cell_value\n result[cell_value] ||= 0\n result[cell_value] += 1\n end\n end\n end\n\n neighbours_count = result.values.reduce(&:+) || 0\n dominant_color = result.max_by{ |_, count| count }.first unless result.empty?\n\n [neighbours_count, dominant_color]\n end", "def get_neighbors_alive (x,y)\n neighbors = []\n neighbors_alive = 0\n\n neighbors.push(cell_at(x-1,y-1)) #top left corner\n neighbors.push(cell_at(x, y-1)) #top\n neighbors.push(cell_at(x+1,y-1)) #top right corner\n neighbors.push(cell_at(x-1,y)) #left\n neighbors.push(cell_at(x+1,y)) #right\n neighbors.push(cell_at(x-1,y+1)) #bottom left corner\n neighbors.push(cell_at(x,y+1)) #down\n neighbors.push(cell_at(x+1,y+1)) #bottom right corner\n\n neighbors.each {|cell| neighbors_alive += cell.to_i}\n neighbors_alive\n end", "def neighbors cell\n [\n above_cell(cell),\n below_cell(cell),\n left_cell(cell),\n right_cell(cell),\n ]\n end", "def find_neighbors(tile_loc)\n neighbors = []\n possible_neighbors = [[-1,-1],[-1,0],[-1,1],[0,1],[1,1],[1,0],[1,-1],[0,-1]]\n\n\n possible_neighbors.each do |neighbor|\n possible_neighbor = [neighbor.first + tile_loc.first, neighbor.last + tile_loc.last]\n neighbors << possible_neighbor if valid?(possible_neighbor)\n end\n possible_neighbors\n end", "def out_neighbors(vertex)\n\tend", "def living_neighbors(cell)\n count = 0\n cell.neighborhood.each { |k, v|\n count += 1 if @community[v].state == true\n }\n count\n end", "def living_neighbors(cell)\n count = 0\n cell.neighborhood.each { |k, v|\n count += 1 if @community[v].state == true\n }\n count\n end", "def neighbor_cell_coordinates\n NEIGHBOR_OFFSETS.map { |coordinates| [row + coordinates[0], col + coordinates[1]] }\n end", "def neighbours(col, row)\n neigh = []\n\n [-1, +1].each do |inc|\n new_col = col + inc\n new_row = row + inc\n\n neigh << [new_col, row] if in_grid?(new_col, row)\n neigh << [col, new_row] if in_grid?(col, new_row)\n end\n\n neigh\n end", "def neighboors\n coordneighboors = [@x - 1, @x, @x + 1].product([@y - 1, @y, @y + 1])\n coordneighboors.delete([@x, @y])\n coordneighboors.select { |coord| coord[0] >= 0 && coord[0] < @matrix.rows && coord[1] >= 0 && coord[1] < @matrix.columns }\n end", "def get_neighbor(matrix)\r\n @live_neighbor=0\r\n get_next_state(matrix,0,1) #NORTH\r\n get_next_state(matrix,1,1) #NORTHEAST\r\n get_next_state(matrix,1,0) #EAST\r\n get_next_state(matrix,1,-1) #SOUTHEAST\r\n get_next_state(matrix,0,-1) #SOUTH\r\n get_next_state(matrix,-1,-1) #SOUTHWEST\r\n get_next_state(matrix,-1,0) #WEST\r\n get_next_state(matrix,-1,1) #NORTHWEST\r\n end", "def get_neighbours(n, m)\n [[n - 1, m],[n + 1, m],[n, m - 1],[n, m + 1]].select do |coords| \n coords.first.between?(0, rows - 1) && coords.last.between?(0, cols - 1)\n end\n end", "def identify_neighbours\n @x.times{ |r|\n @y.times{|c| \n #+1,+1 0,+1 +1,0\n @mat[r][c].add_neighbour @mat[r+1][c+1] unless @mat[r+1].nil? || @mat[r+1][c+1].nil?\n @mat[r][c].add_neighbour @mat[r][c+1] unless @mat[r].nil? || @mat[r][c+1].nil?\n @mat[r][c].add_neighbour @mat[r+1][c] unless @mat[r+1].nil? || @mat[r+1][c].nil?\n \n #-1,-1 0,-1 -1,0\n @mat[r][c].add_neighbour @mat[r-1][c-1] unless @mat[r-1].nil? || @mat[r-1][c-1].nil?\n @mat[r][c].add_neighbour @mat[r-1][c] unless @mat[r-1].nil? || @mat[r-1][c].nil?\n @mat[r][c].add_neighbour @mat[r][c-1] unless @mat[r].nil? || @mat[r][c-1].nil?\n \n #+1,-1 -1,+1\n @mat[r][c].add_neighbour @mat[r-1][c+1] unless @mat[r-1].nil? || @mat[r-1][c+1].nil?\n @mat[r][c].add_neighbour @mat[r+1][c-1] unless @mat[r+1].nil? || @mat[r+1][c-1].nil?\n \n }\n \n } \n end", "def neighbours(pos_x, pos_y)\n cells = neighbours_coords(pos_x, pos_y).flatten.each_slice(2).map do |c|\n next if invalid_cell? c\n cell(c[0], c[1])\n end\n\n cells.delete_if(&:nil?)\n\n cells.nil? ? 0 : cells.inject(0, :+)\n end", "def find_neighbors(node)\n nbrs = []\n self.edges.each do |e|\n nbrs.push(e.target) if e.source == node\n nbrs.push(e.source) if e.target == node\n end\n nbrs\n end", "def neighbor_named(name)\n @neighbors.find { |route| route.name == name }\n end", "def neighborhood(cell)\n Set.new((cell[0]-1..cell[0]+1).map{|x| (cell[1]-1..cell[1]+1).map{|y| [x,y]}}.\n flatten(1)) - Set.new([cell])\nend", "def neighbors(x,y)\n valid = 0..127\n [[x,y-1],[x,y+1],[x-1,y],[x+1,y]].select {|(h,v)| valid.cover?(h) && valid.cover?(v)}\nend", "def find_region\n count = 0\n GRID.each_with_index do |y_values, current_x|\n y_values.each do |current_y|\n distance = 0\n ALL_POINTS.each do |point|\n distance += ((point.y - current_y).abs + (point.x - current_x).abs)\n end\n p distance\n count += 1 if distance < 10_000\n end\n end\n p count\nend", "def find_face_neighbors(face)\n raise \"not a face\" unless face.is_a?(Face)\n neighbors = find_neighbors(face.vertices)\n neighbors - [face]\n end", "def neighbors_of(x,y)\r\n left = [x-1, y]\r\n right = [x+1, y]\r\n down = [x, y-1]\r\n up = [x, y+1]\r\n @neighbors << left << right << down << up\r\n end", "def neighbor\n neighbor_index = round_table.find_index(user) - 1\n round_table[neighbor_index]\n end", "def hex_neighbors(_entity, hex)\n other = hex.tile.cities.first.tokens.find { |t| t }.corporation\n @game.graph_for_entity(other).connected_hexes(other)[hex]\n end", "def neighbors(x, y)\n\t\tn = []\n\t\t\n\t\tn << [x-1, y] if x > 0 && @grid[y][x-1] & @@IN != 0\n\t\tn << [x+1, y] if x+1 < @grid[y].length && @grid[y][x+1] & @@IN != 0\n\t\tn << [x, y-1] if y > 0 && @grid[y-1][x] & @@IN != 0\n\t\tn << [x, y+1] if y+1 < @grid.length && @grid[y+1][x] & @@IN != 0\n\t\n\t\tn\n\tend", "def third_degree_neighbors(edges, start)\nend", "def possible_neighbors(y,x)\n # (-1..1).to_a.map do |row_offset|\n # (-1..1).to_a.map do |col_offset|\n # return y - row_offset, x - col_offset\n # end\n # end\n up = y-1\n down = y + 1\n my_row = y\n left = x - 1\n right = x + 1\n my_column = x\n\n [\n [my_row,x-1],[y,x+1], # sides\n [up,x-1], [y-1,x], [y-1,x+1], # top\n [down,x-1], [y+1,x], [y+1,x+1] # bottom\n ]\n end", "def neighbours(number)\n x, y = matrix.index(number)\n [ \n matrix[x, y-1],\n matrix[x, y+1],\n matrix[x-1, y],\n matrix[x+1, y],\n matrix[x+1, y+1],\n matrix[x+1, y-1],\n matrix[x-1, y-1],\n matrix[x-1, y+1]\n ].compact.uniq.delete_if { |cell|\n x2, y2 = matrix.index(cell)\n (x2 - x).abs > 1 || (y2 - y).abs > 1 || cell == number\n }\n end", "def neighbours_of(board, row, column)\r\n\r\n height = board.size\r\n width = board[0].size\r\n\r\n #generate co-ordinates for all the neighbours\r\n coordinates = [\r\n [row - 1, column - 1],\r\n [row - 1, column],\r\n [row - 1, column + 1],\r\n\r\n [row, column -1],\r\n [row, column +1],\r\n\r\n [row + 1, column - 1],\r\n [row + 1, column],\r\n [row + 1, column + 1],\r\n ]\r\n\r\n #filter out all the coordinates which are outside of the board boundary\r\n coordinates_in_board = coordinates.select do |coords|\r\n coords[0] >= 0 && coords[0] < height && coords[1] >= 0 && coords[1] < width\r\n end\r\n\r\n #get the values at the neighbouring coordinates\r\n coordinates_in_board.collect do |coords|\r\n board[coords[0]][coords[1]]\r\n end\r\n end", "def get_neighbors_from_cell(cell)\n coordinates = [\n [cell.coord_x + 1, cell.coord_y],\n [cell.coord_x - 1, cell.coord_y],\n [cell.coord_x, cell.coord_y - 1],\n [cell.coord_x, cell.coord_y + 1],\n [cell.coord_x - 1, cell.coord_y + 1],\n [cell.coord_x + 1, cell.coord_y + 1],\n [cell.coord_x - 1, cell.coord_y - 1],\n [cell.coord_x + 1, cell.coord_y - 1]\n ]\n\n neighbors = coordinates.map do |coordinate|\n find_cell(coordinate)\n end\n\n neighbors.select { |neighbor| neighbor && neighbor.empty? }\n end", "def neighbors(x, y)\n @space[y-1][x-1] + @space[y][x-1] + @space[y+1][x-1] +\n @space[y-1][x+1] + @space[y][x+1] + @space[y+1][x+1] +\n @space[y-1][x] + @space[y+1][x]\n end", "def neighbors(position)\n x,y = position\n [\n [x - 1, y + 1], [x , y + 1], [x + 1, y + 1],\n [x - 1, y ], [x + 1, y ],\n [x - 1, y - 1], [x , y - 1], [x + 1, y - 1],\n ]\nend", "def find_neighbours(snakes)\n x = @coords[0]\n y = @coords[1]\n neighbours = [[x, y + 1], [x + 1, y], [x, y - 1], [x - 1, y]]\n neighbours.keep_if do |e|\n coords_within_grid(e) && !snakes.include?(e)\n end\n end", "def inbounds_gep(ptr, indices, name = \"\")\n inbounds_gep2(nil, ptr, indices, name)\n end", "def neighbors\n mr_rogers = []\n\n (-1..1).each do |x_change|\n (-1..1).each do |y_change|\n new_indx = [x_change + index[0], y_change + index[1]]\n mr_rogers << new_indx if valid_index?(new_indx)\n end\n end\n\n mr_rogers.delete(index)\n mr_rogers.map{|arr| @board[arr[0]][arr[1]]}\n end", "def neighbors(actor, generator, neighbor)\n functor('nodal-neighbors', actor, generator, neighbor)\n end", "def get_neighbours_by_lambda(agent, lamb)\n\t\ttile = agent.tile\n\t\tmin_x = [0,tile.x-1].max\n\t\tmax_x = [@tiles.size-1, tile.x+1].min\n\t\tmin_y = [0,tile.y-1].max\n\t\tmax_y = [@tiles.size-1, tile.y+1].min\n\n\t\ttile_array = []\n\t\t(min_x..max_x).each do |x|\n\t\t\t(min_y..max_y).each do |y|\n\t\t\t if x != tile.x || y != tile.y \n\t\t\t\t if !@tiles[x][y].nil?\n\t\t\t\t\tt = lamb.call(@tiles[x][y], agent) \n\t\t\t\t\ttile_array << t if !t.nil?\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn tile_array\n\tend", "def count_neighbours(row_index, col_index)\n neighbours = 0\n neighbours += life_in_cell(row_index - 1, col_index - 1)\n neighbours += life_in_cell(row_index, col_index - 1)\n neighbours += life_in_cell(row_index + 1, col_index - 1)\n neighbours += life_in_cell(row_index - 1, col_index)\n neighbours += life_in_cell(row_index + 1, col_index)\n neighbours += life_in_cell(row_index - 1, col_index + 1)\n neighbours += life_in_cell(row_index, col_index + 1)\n neighbours += life_in_cell(row_index + 1, col_index + 1)\n return neighbours\n end", "def find_boundaries\n @fbuffer.ensure_uniqueness\n \n @boundaries = []\n boundary_edges = []\n @fbuffer.build_index\n \n @vbuffer.each_index do |i|\n # boundary vertices have identifiable as they have two or more neighboring vertices which are \n # only included in one face which includes this vertex.\n (@fbuffer.faces_with(i).flatten - [i]).inject(Hash.new(0)) { |hsh,id| hsh[id] += 1; hsh }.\n each { |n,count| boundary_edges << (i<n ? [i,n] : [n,i]) if count == 1 }\n end\n boundary_edges.uniq!\n boundary_edges.flatten!\n \n# partial_boundary = []\n \n # keep starting new boundaries until there are no boundary edges left to start with\n until boundary_edges.empty? do\n partial_boundary = [boundary_edges.shift, boundary_edges.shift]\n \n # until current partial boundary forms a closed loop\n until partial_boundary.first == partial_boundary.last\n # pick the first potential next edge and add it to the current partial boundary... should it choose an edge more systematically???\n next_e = boundary_edges.slice!( (boundary_edges.index(partial_boundary.last)/2)*2, 2 ) # this will error out (due to index returning nil) to avoid looping infinitely in case of funny data\n partial_boundary << ( partial_boundary.last == next_e.first ? next_e.last : next_e.first )\n end\n \n @boundaries << partial_boundary[0...-1]\n partial_boundary = []\n end\n @boundaries\n end", "def explore_neighbors(neighbors)\n neighbors.each do |pos|\n row, col = pos\n next_spot = board[[row, col]]\n\n next if next_spot.explored? || next_spot.bombed? || next_spot.flagged?\n next_spot.explored = true if next_spot.adjacent_bomb_count >= 0\n\n if next_spot.adjacent_bomb_count == 0\n next_spot.explore_neighbors(next_spot.neighbors)\n end\n end\n end", "def valid_neighbours(current)\n DIRECTION_VECTORS.values\n .map { |dir_vec| current + dir_vec }\n .select { |loc| OPEN_TILES.include?(@points[loc]) }\n end", "def neighbours nodeidentifier\n @edges[nodeidentifier]\n end", "def find_neighbors(movie_time)\n\n neighbors = []\n latest_movie = movie_time[-1]\n\n movie_names = []\n movie_time.each { |m| movie_names.push(m.name) }\n\n self.tmovies.each { |movie|\n\n if (!movie_names.include?(movie.mname))\n\n #get_next_time returns Movie_tuple or nil\n neighbor = get_next_time(latest_movie, movie)\n\n unless neighbor.nil?\n neighbors.push(neighbor)\n end\n\n end\n }\n\n return neighbors\n end", "def neighbors(id)\n # YOUR WORK HERE\n end", "def neighbors(row, col, arr)\n height = arr.size\n width = arr[0].size\n neighbors = []\n neighbors << [row, col + 1] if col + 1 < width && arr[row][col + 1] >= 1\n neighbors << [row, col - 1] if col - 1 >= 0 && arr[row][col - 1] >= 1\n neighbors << [row + 1, col] if row + 1 < height && arr[row + 1][col] >= 1\n neighbors << [row - 1, col] if row - 1 >= 0 && arr[row - 1][col] >= 1\n\n neighbors\nend", "def find_indexes_of_source_vertices\n # start with all vertices' indexes\n indexes = [*[email protected]]\n\n @vertices.each do |vertex|\n vertex.neighbours.each_with_index do |value, neighbour_index|\n if (value == true)\n indexes = indexes - [neighbour_index]\n end\n end\n end\n\n indexes\n end", "def neighbor_vertices\n @meeting_edges.map &:to\n end", "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 get_neighbor_squares(sq)\n row, column = sq[:row], sq[:column]\n result = []\n for dx in [-1,0,1]\n for dy in [-1,0,1]\n x, y = row + dx, column + dy\n if (dx != 0 || dy != 0) && (0..@board_size-1) === x && (0..@board_size-1) === y\n result << { :row => x, :column => y }\n end\n end\n end\n return result\n end", "def link_cells\n (0...rows).each do |r|\n (0...columns).each do |c|\n cell = @fields[r][c]\n cell.neighbors = find_neighbors(cell)\n end\n end\n end", "def neighbor_cells\n @neighbor_cells ||= neighbor_cell_coordinates.map do |coordinates|\n board.at(coordinates[0], coordinates[1]) if board.cell_exists?(coordinates[0], coordinates[1])\n end.compact\n end", "def find_neighbors(cell)\n min_r = [0, cell.row - 1].max\n max_r = [cell.row + 1, rows - 1].min\n min_c = [0, cell.column - 1].max\n max_c = [cell.column + 1, columns - 1].min\n\n get_cells(min_r..max_r, min_c..max_c).select { |x| x unless x == cell }\n end", "def neighbours(x, y)\n # With permutation() we can exclude diagonal cells in the square around a cell\n [-1, 0, 1].permutation(2).map { |(dx, dy)| [x + dx, y + dy]}\n .select { |(c, r)| c >= 0 && r >= 0 && !@board[r].nil? && @board[r][c] == @board[y][x] }\n end", "def neighbors(coord)\n color = self[coord]\n ADJACENCY\n .map { |direction| coord.add_elements(direction) }\n .select { |new_coord| self[new_coord] == color }\n end", "def neighbour_count row,col\n neighbours=0\n \n # iterate around the neighbours\n (-1..1).each do |i|\n (-1..1).each do |j|\n\t# Wrap lower right edge of matrix back to 0\n\tnrow=(row==@current_state.length-i) ? 0 : row+i\n\tncol=(col==@current_state[row].length-j) ? 0 : col+j\n\t# Do not count current cell\n\t# Treat illegal values as 0\n\tif (nrow!=row or ncol!=col) and @current_state[nrow][ncol]==1\n\t neighbours += 1\n\tend\n end\n end\n return neighbours\n end", "def neighbors_of(node)\n return nil unless nodes.include?(node)\n @structure[node] || []\n end", "def restrict_neighbours()\n\t# The grid starts out with values already. \n\t# Need to change the domain_grid to reflect the neighbours that can't \n\t# be certain values due to starting values\n\n\t$domain_grid.each_with_index do |row, index_r|\n\t\trow.each_with_index do |col, index_c|\n\t\t\tval = $value_grid[index_r][index_c]\n\t\t\t\n\t\t\tif val != 0 \n\t\t\t\tremove_from_neighbours(index_r,index_c,val)\n\t\t\tend\n\t\tend\n\tend\nend" ]
[ "0.6210027", "0.6119444", "0.59218603", "0.58929336", "0.5863465", "0.5861616", "0.58512187", "0.5848211", "0.58444685", "0.58275366", "0.5812767", "0.57992756", "0.57685834", "0.5745865", "0.5680776", "0.56559867", "0.56407666", "0.5609087", "0.55898356", "0.55898356", "0.55517966", "0.55363375", "0.5510859", "0.54904455", "0.548458", "0.54756796", "0.54739785", "0.54601437", "0.54539657", "0.54495466", "0.54460335", "0.54441655", "0.5439838", "0.5437605", "0.54130924", "0.5401642", "0.5401232", "0.53963107", "0.5388923", "0.53776354", "0.537281", "0.5359617", "0.53494877", "0.534532", "0.53386635", "0.5337384", "0.53361434", "0.53344995", "0.5332347", "0.5331548", "0.5331548", "0.53122187", "0.5297855", "0.5294915", "0.5290002", "0.52778614", "0.52659947", "0.5258163", "0.5256077", "0.525346", "0.52312493", "0.5227665", "0.5223849", "0.5210868", "0.5208506", "0.51995504", "0.51975864", "0.5190612", "0.51840425", "0.51794964", "0.5167958", "0.5164549", "0.51601624", "0.5149451", "0.513327", "0.5128554", "0.5127993", "0.5127771", "0.512605", "0.51205456", "0.5112359", "0.5108543", "0.50993407", "0.50987804", "0.50947654", "0.50871736", "0.5081435", "0.5076416", "0.5056134", "0.5053262", "0.5012334", "0.5009074", "0.5007438", "0.50048846", "0.5003296", "0.50009453", "0.4997179", "0.49957198", "0.4993228", "0.49838203" ]
0.5832027
9
Returns a titleized version of the filename my_file.pdf returns My File
def title resource_title.presence || CGI.unescape(file_name.to_s).gsub(/\.\w+$/, '').titleize end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def title\n CGI::unescape(file_name.to_s).gsub(/\\.\\w+$/, '').titleize\n end", "def title\n CGI::unescape(file_name.to_s).gsub(/\\.\\w+$/, '').titleize\n end", "def title\n CGI::unescape(self.file_name).gsub(/\\.\\w+$/, '').titleize\n end", "def discover_file_title(page = current_page)\n\n if page.data.title\n return page.data.title # Frontmatter title\n else\n filename = page.url.split(/\\//).last.gsub('%20', ' ').titleize\n\n return filename.chomp(File.extname(filename))\n end\n end", "def title\n #CGI::unescape(file_name.to_s).gsub(/\\.\\w+$/, '').titleize\n self[:file_name].gsub(/\\.\\w+$/, '').titleize rescue ''\n end", "def file_to_pagename(filename)\n\t\tfilename.chomp(\".md\").gsub('_', ' ').capitalize\n\tend", "def file_to_pagename(filename)\n\t\tfilename.chomp(\".md\").gsub('_', ' ').capitalize\n\tend", "def file_title(path)\n filename_from_path(path).split(\".\")[0]\n end", "def human_pdf_filename\n \"Rechnung-#{self.short_number}.pdf\"\n end", "def pdf_name(name = nil)\n name ||= self.name\n Pathname(name).sub_ext(\".pdf\")\n end", "def filename\n @basename + PAGE_FILE_EXT\n end", "def title\n #Flip off the part after the last dot, including that dot: find the filename without extensions\n fragments = @filename.split('.')\n fragments.pop\n title = fragments.join('.')\n\n return title.gsub(/[_]/, ' ').capitalize\n end", "def title\n filename.nil? ? nil : File.basename(filename)\n end", "def to_title(file)\n # Strip .md if it exists\n title = file.gsub(/.md$/, '')\n\n title = title.gsub(/-/, ' ')\n title = title.gsub(/([A-Z][a-z])/, ' \\1').strip\n title = title.split.map { |word| word[0].upcase+word[1..99999] }.join(' ')\n return title\n end", "def title\n if file =~ /README.md/\n result = File.basename File.dirname(file)\n else\n result = File.basename(file,'.md')\n end\n result.tr '-', ' '\n end", "def get_title\n r = %r{((\\d+\\.)+\\s*)(?<title>(.)*)\\.html\\.erb}\n match = r.match(file_name)\n raise BadFilenameException, \"Can't match the file: #{file_name}\" unless match\n t = match[:title].strip\n end", "def full_filename(filename)\n if filename.include? '.pdf'\n filename.gsub! '.pdf' '.jpg' \n end\n \"thumb_#{filename}\"\n end", "def file_name(title)\n name = title.gsub(/[\\r\\n]/, \" \")\n .gsub(/[^a-zA-Z\\d\\s]/, \"\")\n .gsub(/ /, \"_\")\n\n name.length > 31 ? name[0..30] : name\n end", "def file_name(title)\n name = title.gsub(/[\\r\\n]/, ' ')\n .gsub(/[^a-zA-Z\\d\\s]/, '')\n .tr(' ', '_')\n\n name.length > 31 ? name[0..30] : name\n end", "def file_title(title)\n title.downcase.gsub(/\\s+/, '-').gsub(/-{2,}/, '-').gsub(':', '')\nend", "def filename\n \"#{mounted_as}_#{Time.zone.now.to_s :number}.pdf\" if original_filename\n end", "def page_file_name(name, format)\n ext = @page_class.format_to_ext(format)\n @page_class.cname(name) + '.' + ext\n end", "def filename identifier\n raise \"An identifier is required\" if identifier.to_s == ''\n \"./#{application}_#{customer}_#{identifier}.pdf\"\n end", "def title_folded_to_filename\n self[:title].gsub(/[^a-z0-9-]/) do |c|\n case c\n when /\\s+|\\./ then '-'\n when /[A-Z]+/ then c.downcase\n else ''\n end\n end.gsub(/\\-+/,'-')\n end", "def untitled_file_name()\n return \"ללא שם\"\n end", "def display_filename\n filename = self._internal_display_filename\n\n # Sometimes filenames have e.g. %20 in - no point butchering that\n # (without unescaping it, this would remove the % and leave 20s in there)\n filename = CGI.unescape(filename)\n\n # Remove weird spaces\n filename = filename.gsub(/\\s+/, \" \")\n # Remove non-alphabetic characters\n filename = filename.gsub(/[^A-Za-z0-9.]/, \" \")\n # Remove spaces near dots\n filename = filename.gsub(/\\s*\\.\\s*/, \".\")\n # Compress adjacent spaces down to a single one\n filename = filename.gsub(/\\s+/, \" \")\n filename = filename.strip\n\n return filename\n end", "def generate_filename(title)\n \"#{formatted_current_timestamp}-#{slug_for(title)}.md\"\nend", "def full_filename (for_file = model.document.file)\n for_file\n end", "def get_filename (file)\n\t\tif file.is_a? File\n\t\t\tfile = file.path\n\t\tend\n\t\treturn file\n\tend", "def filename\n return @filename if @filename\n name.downcase.gsub(/\\W/, '_').squeeze('_')\n end", "def filename\n \"#{directory}/MCF-Invoice-#{@order.order_number}.pdf\"\n end", "def public_filename(record, file)\n filename = [application_for_offering.id.to_s] \n filename << application_for_offering.person.fullname\n filename << title\n ext = file.suffix.nil? || file.suffix == :original ? file.extension : file.suffix\n filename.join(' ').gsub(/[^a-z0-9 \\(\\)]+/i,'') + \".#{ext}\"\n end", "def pretty_filename_for_download\n student_name = \"#{student.last_name} #{student.first_name}\"\n escaped_student_name = student_name.gsub(/[^a-zA-Z0-9]+/, '')\n date_text = self.created_at.strftime('%Y%m%d')\n \"IEP_#{escaped_student_name}_#{date_text}_#{student.id}_#{self.id}.pdf\"\n end", "def to_title(file_slug)\n file_slug.gsub(/[^\\p{Word}+]/u, ' ').gsub(/\\b\\w/){$&.upcase}\n end", "def to_title(file_slug)\n if file_slug == 'index' && !@pointer['id'].index('/').nil?\n file_slug = @pointer['id'].split('/')[-2]\n end\n\n Ruhoh::StringFormat.titleize(file_slug)\n end", "def filename(record, file)\n original = \"#{file.basename}.#{file.extension}\"\n write_attribute(:original_filename, original)\n ext = file.suffix.nil? || file.suffix == :original ? file.extension : file.suffix\n \"#{application_for_offering.id.to_s}-#{title.gsub(/[\\s,\\.\\\\\\/\\*\\?\\%\\:\\|\\\"\\'\\<\\>]?/,'')}.#{ext}\"\n end", "def file_name\n # file = full_name\n # file = file.gsub('::', '/')\n # file = file.gsub('#' , '/')\n # file = file.gsub('.' , '-')\n # #file = File.join(output, file + '.html')\n # file\n WebRI.entry_to_path(full_name)\n end", "def default_pdf_file_name\n \"#{self.number}.pdf\" if self.number\n end", "def filename(name)\n @filename = name.downcase.strip.gsub(' ', '-')\n end", "def populate_title\n if self.title.blank?\n self.title = self.file_file_name.blank? ? \"\" : self.file_file_name.gsub(/_/, \" \").capitalize\n end\n\tend", "def filename\n @file.basename.to_s\n end", "def file_name\n name.underscore\n end", "def page_file_name(name, format)\n format.nil? ? name : \"#{name}.#{::Gollum::Page.format_to_ext(format)}\"\n end", "def file_name\n \"#{@file_name}.#{extension}\"\n end", "def get_filename(pagename)\n\t\tget_permalink(pagename) + \".md\"\n\tend", "def get_filename(pagename)\n\t\tget_permalink(pagename) + \".md\"\n\tend", "def to_title(file_slug)\n if file_slug == 'index' && !@pointer['id'].index('/').nil?\n file_slug = @pointer['id'].split('/')[-2]\n end\n\n file_slug.gsub(/[^\\p{Word}+]/u, ' ').gsub(/\\b\\w/){$&.upcase}\n end", "def image_pdf\r\n directory = File.expand_path File.dirname(__FILE__)\r\n specific_filename = directory + \"/\" + \"Media/file1.pdf\"\r\nend", "def name() @filename end", "def file_name(name)\n name.to_s.gsub(/-/, \"_\").underscore\n end", "def display_deriv_fname\n tokens = @filename.split('.')\n if tokens.length > 1\n return \"#{tokens[0]}.htm\"\n else\n return \"#{@filename}.htm\"\n end\n end", "def full_filename( for_file )\n super.downcase\n # super.chomp( File.extname( super ) ) + '.jpg'\n end", "def filename(post)\n date = DateTime.parse(post.date)\n rendered_title = post.title.rendered\n slug =\n if rendered_title.empty?\n date.strftime('%s').to_i % (24 * 60 * 60)\n else\n # TODO: Should slugify the first 5 words of the content instead\n rendered_title.downcase.gsub('/[\\s.\\/_]/', ' ').gsub(/[^\\w\\s-]/, '').squeeze(' ').tr(' ', '-').chomp('-')\n end\n\n \"#{date.strftime('%F')}-#{slug}.md\"\n end", "def report_filename(extension = \"pdf\")\n basename = \"ProceedingsTex.\" + extension.to_s\n File.join(RAILS_ROOT, \"files\", \"proceedings_report\", @offering.id.to_s, basename)\n end", "def get_filename(file)\n File.basename(file)\n end", "def proper_filename(file)\n file.gsub(/[^\\w]/,'_')\n end", "def file_name\n\t\treturn 'st' + student_id.to_s + 'pr' + problem_id.to_s + 'so' + id.to_s\n\tend", "def set_file_name\n update(name: (file.filename rescue \"Untitled File\"))\n end", "def set_file_name\n update(name: (file.filename rescue \"Untitled File\"))\n end", "def getPageKey\n if @formatted_name.nil?\n @formatted_name = @humanly_name.split(/\\./)[0].gsub(%r{\\s},WHITE_SPACE).gsub(%r{[/<>+]}, WHITE_SPACE).downcase + '.' + @file_extension\n end\n return @formatted_name\n end", "def basename_to_title(basename)\n basename.gsub(/[\\-_]/, \" \").capitalize\n end", "def file_name\n File.basename(file_path)\n end", "def filename\n \"#{secure_token(10)}.#{file.extension}\" if original_filename.present?\n end", "def filename(title, now)\n File.join('_posts', format('%d-%02d-%02d-%s.md', now.year, now.month, now.day, file_title(title)))\nend", "def name\n filename\n end", "def name\n filename\n end", "def file_name\n return unless @file\n\n @file.absolute_name\n end", "def name\n file.partition(base).last.gsub(/[_\\/]/, \" \").strip\n end", "def export_file_name(extension)\n \"CompSage Report on #{@survey.job_title.gsub(/[\\\\\\/:\\*\\?\"<>\\|]/,' ')}.#{extension}\"\n end", "def old_display_filename\n filename = self._internal_display_filename\n\n # Convert weird spaces (e.g. \\n) to normal ones\n filename = filename.gsub(/\\s/, \" \")\n # Remove slashes, they mess with URLs\n filename = filename.gsub(/\\//, \"-\")\n\n return filename\n end", "def title\n return @title if @title\n return @filename if @filename\n return @type if @type\n return \"Unknown file name\"\n end", "def filename(name)\n # Reemplaza letras con acentos y ñ\n filename = name.gsub('á','a').gsub('é','e').gsub('í','i').gsub('ó','o').gsub('ú','u').gsub('ñ','n').downcase\n return filename\nend", "def file_name name\n File.basename(name).sub(/\\.[^\\.]*/, '')\n end", "def file_name name\n File.basename(name).sub(/\\.[^\\.]*/, '')\n end", "def filename\n @name ||= \"#{timestamp}-#{secure_token(8)}.#{file.extension}\" if original_filename.present?\n end", "def fileset_title(filename)\n case parent\n when Numismatics::Coin\n coin_image_title(filename)\n else\n filename\n end\n end", "def filename\n original_filename\n end", "def title\n @blob.basename.split(\".\").first.capitalize\n end", "def pdf_file_name\n \"#{Payment.model_name.human}_#{I18n.l(object.created_at, format: '%Y%m%d%-k%M')}\"\n end", "def filename\n unless @filename\n @filename = @path.basename.to_s\n end\n\n @filename\n end", "def filename\n @filename = \"#{secure_token}_#{split_extension(original_filename)}.#{file.extension}\" if original_filename.present?\n end", "def file_name\n \"#{name.downcase.gsub(/\\s/, '')}.jpg\"\n end", "def pdf_filename\n invoice_number.present? ? invoice_number : number\n end", "def filename\n if original_filename\n \"#{model.name.parameterize}-#{secure_token(8)}.#{file.extension}\"\n end\n end", "def file name\n \n end", "def get_filename(url)\n parts = url.split('/')\n dirname = parts[-2]\n filename = parts[-1].split('.')[0] + \"_ocr.pdf\"\n '990s/' + dirname + '/' + filename\nend", "def quick_title(song)\n File.basename(song, File.extname(song)).gsub(/^[^A-Za-z]+\\s+(\\w)/, \"\\\\1\")\n end", "def draft_filename(title)\n File.join('_drafts', file_title(title) + '.md')\nend", "def generate_file_name\n file_name = attachment.instance_read(:file_name).slugged_filename\n attachment.instance_write :file_name, file_name\n end", "def filename\n \"#{secure_token(10)+File.extname(original_filename)}\" if original_filename.present?\n end", "def filename(file)\n name = if file.respond_to?(:original_filename)\n file.original_filename\n else\n File.basename(file)\n end\n Pathname.normalize_filename(name)\n end", "def bundle_resouce_file_name\n self.title.gsub(/\\s/,\"_\")\n end", "def filename\n unless @filename\n load_file_params\n end\n @filename\n end", "def filename\n original_filename.try(:gsub, '+', '-')\n end", "def get_file_name(manual, version)\n\n fn = ''\n\n case manual\n when 'audio_2.json'\n fn = 'audio'\n when 'checking_1.json'\n fn = 'checking-vol1'\n when 'checking_2.json'\n fn = 'checking-vol2'\n when 'translate_1.json'\n fn = 'translate-vol1'\n when 'translate_2.json'\n fn = 'translate-vol2'\n when 'gateway_3.json'\n fn = 'gl'\n when 'intro_1.json'\n fn = 'intro'\n when 'process_1.json'\n fn = 'process'\n else\n 'en-ta-v%s' % [version]\n end\n\n '%sen-ta-%s-v%s.pdf' % [@context.registers[:site].config['ta_pdf_cdn'], fn, version]\n end", "def original_filename\n File.basename(@file_path)\n end", "def page_name\n basename = File.basename @relative_name\n basename =~ /\\.(rb|rdoc|txt|md)$/i\n\n $` || basename\n end", "def set_title\n @title = File.basename(@absolute_path)\n @title.sub!(/^[0-9][0-9]-/, '')\n @title.gsub!(/_/, ' ')\n @title.gsub!(/-/, ', ')\n end", "def _output_filename(file)\n sub_strings = File.basename(file).split('.')\n base_name, extensions = sub_strings.first, sub_strings[1..-1]\n\n if extensions.last == 'haml'\n extensions.pop\n if extensions.empty?\n [base_name, options[:default_ext]].join('.')\n else\n [base_name, extensions].flatten.join('.')\n end\n else\n [base_name, extensions, options[:default_ext]].flatten.compact.join('.')\n end\n end", "def filename\n if original_filename.present?\n \"#{model.story.slug}-#{secure_token}.#{file.extension}\"\n end\n end" ]
[ "0.78236794", "0.78226596", "0.77352", "0.77024174", "0.7669881", "0.7618735", "0.7618735", "0.7448031", "0.74270076", "0.7380212", "0.7324282", "0.72479856", "0.72242177", "0.72040194", "0.71369725", "0.71276784", "0.7101518", "0.7097445", "0.70804125", "0.7001001", "0.6975368", "0.696097", "0.6933274", "0.69232666", "0.6920059", "0.6883397", "0.68788654", "0.68646085", "0.6863646", "0.68317235", "0.680666", "0.6801238", "0.6796198", "0.6750509", "0.67429453", "0.6716076", "0.6712908", "0.6703549", "0.67005986", "0.66909325", "0.66890484", "0.66850656", "0.6674796", "0.66580015", "0.6622569", "0.6622569", "0.66057616", "0.65925956", "0.65841305", "0.6580178", "0.6577415", "0.6573858", "0.6555732", "0.6555096", "0.65452516", "0.65419483", "0.6536869", "0.6526295", "0.6526295", "0.6484097", "0.6481286", "0.6473701", "0.64685154", "0.6464973", "0.64626634", "0.64626634", "0.6456751", "0.6451979", "0.64473933", "0.64352155", "0.6429109", "0.642813", "0.64270055", "0.64270055", "0.64215773", "0.6421174", "0.64173245", "0.64117604", "0.6400787", "0.63999575", "0.6388148", "0.63878715", "0.6376275", "0.636807", "0.6366455", "0.63608557", "0.63560504", "0.6352271", "0.63445264", "0.63431436", "0.6342002", "0.6333618", "0.6326657", "0.6321219", "0.6319571", "0.6316604", "0.63155144", "0.6302566", "0.6295475", "0.62849575" ]
0.7514949
7
puts "Happy Mother's Day, Mom!" end
def mothers_day(name) "Happy Mother's Day, #{name}!" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hail_the_king\n\tputs \"hail king mark\"\nend", "def hail_the_king\n\tputs \"hail king mark\"\nend", "def greetings\n\tputs \"Greetings friend!\"\nend", "def exiter\n puts \"\"\n puts \"*****************************************************************************\"\n puts \"I can't believe you're leaving, I GUESS MY JUKES WEREN'T GOOD ENOUGH FOR YOU!\"\n puts \"*****************************************************************************\"\n puts \"\"\nend", "def tie_my_shoes\n puts \"grab shoe laces\"\n puts \"twist and tie around\"\n puts \"end\"\nend", "def sayMessage\r\n puts \"Hey Programmers!\"\r\n puts \"What's for lunch?\"\r\nend", "def me_happy\n puts \"ain't I happy\"\nend", "def mothers_day\n puts \"Happy Mother's Day, Mom!\"\nend", "def another_greetings\n puts 'Hello'; puts 'Motherfucker'\nend", "def greet\n puts \"# Welcome to Mastermind!\"\n puts \"# Good luck!\"\n end", "def hello\n puts \"Hello Dude!!!\"\n puts \"Hellod Douchebag!!!\"\nend", "def saymessage\n puts \"hi programers\"\n puts \"I am hungy\"\nend", "def hello_world \n puts \"This is a crazy part of the world\"\n end", "def welcome\n puts <<-END\nWelcome to the voting simulator!\nHave fun!\n END\nend", "def greeting \r\n puts \"Hi, Ruby programmer!\"\r\nend", "def introduceMyself\n puts \"I am handsome\"\n puts \"I am talented\"\n puts \"I am brilliant\"\nend", "def code_like_crazy\r\n puts \"I'm crushing some code!\"\r\n end", "def speak\r\n puts \"Ho, ho, ho! Haaaappy holidays!\"\r\n puts \"\"\r\n end", "def introduce_myself\n puts \"My name is Anndony Quemag\"\n puts \"My age is 23\"\n puts \"Im work at kommit\"\nend", "def test\r\nputs \"Hodor! Hodor!\"\r\nend", "def joke1\n puts \"A peanut was walking down the street. He was a-salt-ed.\"\nend", "def greeting\nputs \"HELLO, BONJOUR, HOLA, GUTENTAG, HALLO, HOWDY, NAMASKAR, MERHABA\"\nend", "def sayMoo\n puts 'mooooooo...'\nend", "def sayHello\n # output some text\n puts(\"hello, world\")\nend", "def introduce_myself\n puts \"I am handsome\"\n puts \"I am talented\"\n puts \"I am brilliant\"\nend", "def introduce_myself\n puts 'am handsome'\n puts 'i am talented'\n puts 'i am brilliant'\nend", "def say_hi\n\t\tputs \"Hello!\"\n\tend", "def print_out_start_of_game\n\n puts \"Welcome to a new version of the 2 Player Game.\"\n puts \"\"\n\nend", "def goodbye\n puts \"Come back when you get hungry!!!\"\nend", "def speak\n print \"Ho, ho, ho! Haaaappy holidays!\"\nend", "def introduce_myself\n puts \"I am a world ruler\"\n puts \"I am filty rich\"\n puts \"I own a library\"\nend", "def meow #teaching the cat how to meow\n puts \"meow!\" \n end", "def welcome\n puts \"\\nWelcome user! We have created a guessing game for you.\"\n puts \"Try your best to guess the word or else the bouquet of \"\n puts \"roses will die.\"\n puts \"Hint: colors make things happy\\n\\n\"\nend", "def does\n puts \"ALL THE THINGESSSS!!!eleventy\"\nend", "def say_hello(anything)\n # write code\n puts anything\n puts \"Hello World!\"\nend", "def goodbye \nputs \"see you tomorrow for more Makeup :)\"\nend", "def greet_me\n puts \"Hello\"\nend", "def say_moo\n puts 'mooooooo...'\nend", "def meow\n puts \"meow!\"\n end", "def meow\n puts \"meow!\"\n end", "def greeting\n puts\n puts \"Welcome to Tic Tac Toe\"\n puts \"Lets Play\"\n #puts \"Player X your up first\"\n puts\nend", "def greet\n puts \"Hello! My name is #{name}!\"\n end", "def greeting(name)\n print \"hello \" + name + \" what the fuck is your problem?\"\nend", "def osteen\r\n\r\nputs \" You can change yout world by changing your words\"\r\nend", "def meal\n 'Dinner'\n puts 'Dinner'\nend", "def meal\n 'Dinner'\n puts 'Dinner'\nend", "def meal\n 'Dinner'\n puts 'Dinner'\nend", "def meal\n 'Dinner'\n puts 'Dinner'\nend", "def meal\n 'Dinner'\n puts 'Dinner'\nend", "def meal\n 'Dinner'\n puts 'Dinner'\nend", "def meal\n 'Dinner'\n puts 'Dinner'\nend", "def meal\n 'Dinner'\n puts 'Dinner'\nend", "def meal\n 'Dinner'\n puts 'Dinner'\nend", "def meal\n 'Dinner'\n puts 'Dinner'\nend", "def meal\n 'Dinner'\n puts 'Dinner'\nend", "def meal\n 'Dinner'\n puts 'Dinner'\nend", "def say_hi\n\t\tputs 'saying hi'\n\tend", "def saysomething\n puts \"Hello\"\nend", "def hello\n puts 'Hello! Im Caz the calculator. I can help you do simple calculations. Lets begin.'\nend", "def say_hello\n puts \"HELLOOOOO!\"\nend", "def hola\n puts \"Hola\"\n end", "def say_hi\n puts \"hi\"\nend", "def display_string\r\n puts \"Welcome to Ruby Fundamentals\" \r\nend", "def start_greetings\n puts \"This is the castle of the Ice King. At the end of the corridor there are two doors\"\n puts \"Thau shall choose to go through one door, the Fire Door or the Snow Door\"\n puts \"Press 1 for Fire Door. Press 2 for Snow Door\"\nend", "def meow\n puts \"meow!\"\nend", "def meal \n 'dinner'\n puts 'dinner'\nend", "def say_hi\n puts \"Hi!\"\n end", "def greet\n puts '------------------------'\n puts \"Greetings to you #{@name}\"\n end", "def speak\n \tputs \"Ho, Ho, Ho! Haaaaaappy holidays!\"\n end", "def hello(name, age)\n\tputs \"Welcome #{name}, #{age} is definitely not too old to learn how to code\" \nend", "def greeting(name)\r\n print \"Hello there, #{name}!\"\r\nend", "def saludar\n\tputs \"Hello there\"\nend", "def say_hello_to(name)\n puts \"Hello, #{name}. It's good to see you.\"\n puts \" \"\n end", "def say\n puts \"Hi\"\nend", "def say\n puts \"Hi\"\nend", "def main()\n puts(\"Hello, Ruby.\")\n\nend", "def introduction # def opens a function/ method\n\tputs \"This is an introduction program to ruby.\" # puts includes \\n newline before displaying a string\n\tputs \"If you entered this from the command line it would have looked something like this...\"\n\tputs \"\\n\\t$\\t#{$0}\" # \"#{$0}\"\" displays the script ran from the command line. \nend", "def greeting\n puts 'Greetings, honorable gentleman.'\nend", "def grab_food\n\tputs 'grabbing some food'\n\tputs 'and it’s good!'\nend", "def greet2\n puts \"\\n\n We've looked up some interesting\\n\n facts about characters from the films,\\n\n and we invite you to learn some \\n\n more about them.\\n\"\n sleep 4\n end", "def say_hello\n\tputs \"Bonjour!\"\nend", "def hammer\n\t\tputs \"A nice gentle bangabang\"\n\tend", "def say_hi\n puts \"hi\"\nend", "def say_hi\n puts \"hi\"\n end", "def welcome\n puts \"Welcome to Ruby!\"\nend", "def sayHi\n\t\tputs(greet)\n\tend", "def intro\n\tputs \"\\nHello, welcome to Secret Number, created by Jonathan Wang.\"\nend", "def greeting\n puts \"Welcome to the world of practical effects\"\n end", "def greet(name)\n print \"Hello, #{name} how are you doing today?\"\nend", "def goodbye\n puts \"\", \"Thank you! Goodbye :)\"\n end", "def meow\n puts \"meow!\"\n end", "def meow\n puts \"meow!\"\n end", "def greeting\n new_break\n puts \" Hello! Welcome back to your Chore Org \\u00A9 !\"\n puts \" What would you like to do today?\"\n new_break\nend", "def say_hello\n puts \"Hello Ruby!\"\nend", "def intro\n\tputs \"\\nHey, this is Grandma. HOW ARE YOU DEARY?\"\nend", "def hola\n puts \"Hello\"\n end", "def say_hi\n puts \"Hello\"\nend", "def printing\n \n # \"print\" print data in console without linebrean by default\n print \"HELLO WORLD! \"\n # \"puts\" print data in console with linebreak\n puts \"Hello World!\"\n puts 2+2\n\n#\"end\" finalize the function \nend", "def introduce_myself\n #method body\n puts \"'I am handsome'\"\n puts \"i am talented\"\n puts \"i am briliant\"\n puts \"i am amazing\"\n puts 'is talented'\n puts \"is charming\"\n\n #method body\n end", "def greet\n hello + \" \" + world # this format allows us to use puts on line 31\nend", "def compliment_machine(name)\nputs \"Hey there, #{name}! Lookin' good today!\"\nputs \"Is that a new face? It looks nice!\"\nend" ]
[ "0.8188794", "0.8188794", "0.7960303", "0.7948425", "0.7938684", "0.787992", "0.78758764", "0.7859918", "0.7748546", "0.77404517", "0.76921546", "0.76326466", "0.76160777", "0.76115644", "0.76111144", "0.7604432", "0.7591334", "0.7581989", "0.7578423", "0.7572359", "0.7571666", "0.7558313", "0.75466704", "0.75300276", "0.7514413", "0.75113827", "0.74931675", "0.74925774", "0.7477241", "0.74733996", "0.74657804", "0.7459374", "0.74587375", "0.74584043", "0.7449583", "0.74315816", "0.7422755", "0.7407783", "0.7394584", "0.7394584", "0.7379315", "0.73787206", "0.7376886", "0.73582673", "0.73553365", "0.73553365", "0.73553365", "0.73553365", "0.73553365", "0.73553365", "0.73553365", "0.73553365", "0.73553365", "0.73553365", "0.73553365", "0.73553365", "0.7350931", "0.7341637", "0.73393726", "0.7337791", "0.7335812", "0.7331017", "0.7329823", "0.73295516", "0.7321762", "0.7312041", "0.73079735", "0.7302166", "0.7295923", "0.72958827", "0.7295403", "0.7286487", "0.7282032", "0.72786367", "0.72786367", "0.7270186", "0.726906", "0.7260295", "0.7253692", "0.7252755", "0.72497207", "0.72479147", "0.72462624", "0.72407943", "0.72318435", "0.723037", "0.7219945", "0.7216003", "0.7209572", "0.7209571", "0.72049665", "0.72049665", "0.7198999", "0.7194331", "0.71902615", "0.7185361", "0.7183438", "0.71814615", "0.71781695", "0.7169083", "0.71618927" ]
0.0
-1
the block must return a Cps
def test_with_mercury_cps(sources, queues, **kws, &block) em do seql do let(:m) { Mercury::Monadic.open(**kws) } and_then { delete_sources_and_queues_cps(sources, queues) } and_then { block.call(m) } and_then { delete_sources_and_queues_cps(sources, queues) } and_then { m.close } and_lift { done } end.run end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def return(&block); end", "def blocks() end", "def getc() end", "def getc() end", "def getc() end", "def blocks; end", "def blocks; end", "def blocks; end", "def block?; end", "def block_node; end", "def block_node; end", "def cp_c\n end", "def block_class() Block; end", "def pcc(*args)\n return\n end", "def captured_by_block; end", "def captured_by_block?; end", "def c\n end", "def getblockcount\n coind.getblockcount\n end", "def process(&block); end", "def callBlock\n yield\n yield\nend", "def return!(&block); end", "def block_to_proc(&p)\n\tp.call\nend", "def context(&block); end", "def context(&block); end", "def getc\n end", "def getc\n end", "def callBlock\n yield ,\n end", "def Cape(&block)\n Cape.module_eval do\n @outer_self = block.binding.eval('self', __FILE__, __LINE__)\n begin\n if 0 < block.arity\n block.call self\n else\n module_eval(&block)\n end\n ensure\n rake.expire_cache!\n end\n end\n Cape\nend", "def run(&block); end", "def block_reference_count; end", "def block\n true\n end", "def ccf\n end", "def return_values(block_body_node); end", "def block=(_arg0); end", "def block=(_arg0); end", "def cp_b\n end", "def perform(&block); end", "def multi(&block); end", "def value\n @value ||= @block.call\n end", "def cstime=(*) end", "def run(&block)\n end", "def block_reference_count=(_arg0); end", "def run_block\n p = Proc.new\n p.call\nend", "def list_block()\n\nend", "def method &block \r\n\t1\r\nend", "def getblocknumber\n coind.getblocknumber\n end", "def cpl\n end", "def getc\n raise NotImplementedError\n end", "def getc()\n #This is a stub, used for indexing\n end", "def procasaurus( &block )\n\tputs \"I am a procasaurus.\"\n\tputs block.class\n\t# note the proc must be the last parameter and must start with ampersand\nend", "def runblock\r\n\t\t\[email protected]\r\n\t\tend", "def runblock\r\n\t\t\[email protected]\r\n\t\tend", "def meth5\n p = lambda { return 99 } \n result = p.call \n \"The block returned #{result}\"\nend", "def method &block\r\n\t1\r\nend", "def method &block\r\n\t1\r\nend", "def be_proc(&block)\n block.call\n puts block.class\nend", "def ca; end", "def body\n Node::Block.new([return_operation])\n end", "def run_block\n p = Proc.new # <1>\n p.call\nend", "def parfait_block(compiler)\n return @parfait_block if @parfait_block\n @parfait_block = compiler.create_block( make_arg_type , make_frame(compiler))\n end", "def observe(&block)\n start = Time.now\n\n begin\n value = block.call\n rescue => ex\n raised = ex\n end\n\n duration = (Time.now - start) * 1000\n Science::Result.new self, value, duration, raised\n end", "def process_blocks(blocks); end", "def get_block(*params); raise('Stub or mock required.') end", "def cret(cond, val=nil, blk=nil)\n return if @finished\n pret val\n cont = blk ? blk : @function.add_block(\"block\")\n @builder.cond(Convert(cond, Types::BOOL), @function.return_block, cont.to_ptr)\n if blk\n self.finish\n else\n @builder.position_at_end(cont)\n @basic_block = cont\n end\n end", "def get_block_value\r\n if block_given?\r\n value = yield\r\n pp \"The block returned #{value}\"\r\n end\r\nend", "def my_each_with_proc(prc)\n #self.my_each_with_block(prc)\n #expection a block but passing in a prc\n self.my_each_with_block(&prc) # the & conver the prc back in to a block\n\n end", "def getc; nil; end", "def return_block\n yield\nend", "def return_block\n return @function.return_block\n end", "def times\n if block_given? # metodo de kernel para verificar si viene un bloque\n p yield(1, 100) # yield ejecuta el bloque que se paso por parametros\n end\nend", "def content\n call_block\n end", "def ret_block\n x = 1\n y = 2\n z = 3\n yield(x,y,z)\n yield(x)\n yield(x,x,x,x)\n yield([x,y,z])\nend", "def run\n block.call\n end", "def enable_pending_cops; end", "def block_node=(_); end", "def codepoints\n return to_enum :codepoints unless block_given?\n while c = getc\n c.codepoints.each do |cp|\n yield cp\n end\n end\n end", "def cops; end", "def cops; end", "def cops; end", "def fetch_result(&block)\n if block_given?\n return @cue_list.select(&block)\n else\n return @cue_list\n end\n end", "def map_cp(options={}, &block)\n map_send(:cp, options={}, &block)\n end" ]
[ "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.65260804", "0.6403458", "0.63061607", "0.61848027", "0.61848027", "0.61848027", "0.61356074", "0.61356074", "0.61356074", "0.6045155", "0.60335314", "0.60335314", "0.60230154", "0.5988558", "0.5959548", "0.59293103", "0.59213734", "0.58313245", "0.5811822", "0.5781083", "0.5776855", "0.56988823", "0.56793934", "0.5648209", "0.5648209", "0.5626307", "0.5626307", "0.56141907", "0.56000173", "0.55665374", "0.5563357", "0.55593926", "0.55495733", "0.55466276", "0.5513848", "0.5513848", "0.5500467", "0.54692006", "0.546813", "0.5467562", "0.54622763", "0.54565686", "0.5445464", "0.5432363", "0.5432324", "0.5430344", "0.54302245", "0.54256105", "0.54214364", "0.54169273", "0.540537", "0.54038924", "0.54038924", "0.5401683", "0.5391478", "0.5391478", "0.5366284", "0.5363915", "0.53585786", "0.53539354", "0.5347579", "0.53430015", "0.53387314", "0.5330915", "0.5327586", "0.53259563", "0.5319811", "0.5295406", "0.5280144", "0.52789646", "0.52687377", "0.52630043", "0.52568465", "0.5247862", "0.52423346", "0.52307683", "0.5227378", "0.5218146", "0.5218146", "0.5218146", "0.52145237", "0.5207498" ]
0.0
-1
of the correct number of each fruit.
def buy_fruit(list) list.map { |fruit, quantity| [fruit] * quantity }.flatten end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def buy_fruit(fruits_wih_quantity)\n fruits = []\n \n fruits_wih_quantity.each do |fruit, quantity|\n quantity.times do\n fruits << fruit\n end\n end\n\n fruits\nend", "def buy_fruit(fruit_list)\n fruit_array = []\n fruit_list.each do |fruit, quantity|\n quantity.times { fruit_array << fruit }\n end\n fruit_array\nend", "def buy_fruit(fruits)\n result = []\n fruits.each do |pair|\n pair.last.times { |i| result << pair.first}\n end\n result\nend", "def buy_fruit(fruit_quantity)\n fruit = []\n\n fruit_quantity.each do |sub_array|\n count = sub_array[1]\n\n until count <= 0\n fruit << sub_array[0]\n count -= 1\n end\n end\n fruit\nend", "def countTheOranges\n\t\treturn @fruit_num\n\tend", "def buy_fruit(fruits)\n fruits.each_with_object([]) do |fruit, result|\n fruit.last.times { result << fruit.first }\n end\nend", "def buy_fruit3(array)\n #array.each_with_object([]) {|obj, result| obj.last.times {result<< obj.first}}\n array.each_with_object([]) {|(fruit, count), result| count.times {result<< fruit}}\nend", "def buy_fruit(grocery_list)\n result = []\n grocery_list.each do |fruit|\n fruit[1].times do\n result << fruit[0]\n end\n end\n result\nend", "def buy_fruit(grocery_list)\n array_of_fruits = []\n\n grocery_list.each do |fruit|\n fruit[1].times { array_of_fruits << fruit[0]}\n end\n array_of_fruits\nend", "def buy_fruit(array)\n new_list = []\n number = 0\n array.each do |fruit|\n number = fruit.pop\n number.times { new_list << fruit }\n end\n new_list.flatten\nend", "def buy_fruit(array)\n fruits = []\n array.each do |subarray|\n subarray[1].times do\n fruits << subarray[0]\n end\n end\n fruits\nend", "def buy_fruit(list)\n quantities = []\n list.each { |item| item[1].times { quantities << item[0] } }\n quantities\nend", "def buy_fruit(array) \n results = []\n array.each do |fruit, number|\n number.times { results << fruit }\n end\n results\nend", "def buy_fruit(array)\n expanded_list = []\n\n array.each do |item|\n fruit, quantity = item[0], item[1]\n quantity.times { expanded_list << fruit }\n end\n expanded_list\nend", "def buy_fruit_2(arr)\n arr.map { |fruit, quantity| [fruit] * quantity }.flatten # => [\"apples\", \"apples\", \"apples\", \"orange\", \"bananas\", \"bananas\"]\nend", "def buy_fruit(list)\n expanded_list = []\n\n list.each do |item|\n fruit, quantity = item[0], item[1]\n quantity.times { expanded_list << fruit }\n end\n\n expanded_list\nend", "def buy_fruit(fruit_array)\n fruit_array.map { |fruit, how_many| [fruit] * how_many }.flatten\nend", "def buy_fruit(array)\n results = []\n\n array.each do |fruit, num|\n num.times do\n results << fruit\n end\n end\n\n results\nend", "def buy_fruit(ary)\n ary.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def buy_fruit(list)\n list.each_with_object([]) do |(fruit, quantity), new_arr|\n quantity.times { new_arr << fruit }\n end\nend", "def buy_fruit(array)\n returner = []\n array.each{|subarray| subarray[1].times{returner << subarray[0]}}\n returner\nend", "def buy_fruit(list)\n list.to_h.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def buy_fruit(list)\n new_list = []\n list.each { |arr| arr[1].times { new_list << arr[0] } }\n new_list\nend", "def buy_fruit(groceries)\n things_to_buy = []\n groceries.each do |items|\n items[1].times { things_to_buy << items[0] }\n end\n things_to_buy \nend", "def buy_fruit(arr)\n output = []\n arr.each { |fruit, count| output += [fruit] * count }\n output\nend", "def buy_fruit(list)\n list.each_with_object([]) do |fruit_info, shopping_list|\n fruit, quantity = fruit_info[0], fruit_info[1]\n quantity.times {shopping_list << fruit}\n end \nend", "def buy_fruit2(arr)\n arr.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def buy_fruit(arr)\n arr.each_with_object([]) do |pair, all_fruit|\n pair.last.times { |fruit| all_fruit << pair.first }\n end\nend", "def buy_fruit(deep_list)\n list = []\n deep_list.each do |fruits|\n fruits[1].times do\n list << fruits[0]\n end\n end\n list\nend", "def grows_fruits\n return @orange_count = @tree_years * 100\n end", "def buy_fruit2(array)\n array.map {|fruit, quantity| [fruit] * quantity}.flatten\nend", "def buy_fruit(array)\n final_array = []\n array.each do |subarray|\n subarray[1].times do |_|\n final_array << subarray[0]\n end\n end\n final_array\nend", "def countApplesAndOranges(s, t, a, b, apples, oranges)\n sam_apples_count = 0\n sam_oranges_count = 0\n apples.each do |apple|\n apple_position = apple + a\n if (apple_position >= s && apple_position <= t) then\n sam_apples_count += 1\n end\n end\n \n oranges.each do |orange|\n orange_position = orange + b\n if (orange_position >= s && orange_position <= t) then\n sam_oranges_count += 1\n end\n end\n \n puts sam_apples_count\n puts sam_oranges_count\nend", "def bakery_num(num_of_people, fav_food)\n # Hash to show the serving zise of each food item \n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1}\n # Raise an error if fav_food is not one of my_list\n raise ArgumentError.new(\"You can't make that food\") if my_list[fav_food].nil?\n # Initialize each quantity at zero\n supplies = { \"pie\" => 0,\n \t\t\t \"cake\" => 0,\n \t\t\t \"cookie\" => 0 }\n \n left_over = num_of_people % my_list[fav_food]\n supplies[fav_food] = num_of_people/my_list[fav_food]\n if left_over == 0\n \"You need to make #{supplies[fav_food]} #{fav_food}(s).\"\n else \n my_list.each do |k, v|\n if left_over >= v \n supplies[k] = left_over / v\n left_over = left_over % v\n end\n end\n return \"You need to make #{supplies['pie']} pie(s), #{supplies['cake']} cake(s), and #{supplies['cookie']} cookie(s).\"\n end\nend", "def bakery_num(num_of_people, fav_food)\n # Hash to show the serving zise of each food item \n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1}\n # Raise an error if fav_food is not one of my_list\n raise ArgumentError.new(\"You can't make that food\") if my_list[fav_food].nil?\n # Initialize each quantity at zero\n supplies = { \"pie\" => 0,\n \"cake\" => 0,\n \"cookie\" => 0}\n \n left_over = num_of_people % my_list[fav_food]\n supplies[fav_food] = num_of_people/my_list[fav_food]\n if left_over == 0\n \"You need to make #{supplies[fav_food]} #{fav_food}(s).\"\n else \n my_list.each do |k, v|\n if left_over >= v \n supplies[k] = left_over / v\n left_over = left_over % v\n end\n end\n return \"You need to make #{supplies['pie']} pie(s), #{supplies['cake']} cake(s), and #{supplies['cookie']} cookie(s).\"\n end\nend", "def apples_and_oranges(s, t, a, b, apples, oranges)\n n_apples = 0\n n_oranges = 0\n\n apples.each do |apple| \n if apple + a >= s && apple + a <= t\n n_apples += 1 \n end\n end \n\n oranges.each do |orange| \n if orange + b <= t && orange + b >= s\n n_oranges += 1 \n end\n end\n \n puts n_apples\n puts n_oranges\nend", "def bakery_num(num_of_people, fav_food)\n food_servings = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} # Initialize the food and the quantity \n fav_food_qty = food_servings[fav_food] \n \n raise ArgumentError.new(\"You can't make that food\") if !food_servings.has_key?(fav_food)\n \n if num_of_people % fav_food_qty == 0\n num_of_food = num_of_people / fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n else \n food_qty = food_servings.clone\n # First make favorite food\n food_qty[fav_food] = num_of_people / food_servings[fav_food]\n num_of_people %= food_servings[fav_food]\n \tfood_servings.delete(fav_food)\t\t\n \t# Now servings for the rest\n food_servings.each_key do |key| \n break if num_of_people == 0 # this isn't really necessary with 3 keys, but with more it would be.\n food_qty[key] = num_of_people / food_servings[key]\n num_of_people %= food_servings[key]\n end\n return \"You need to make #{food_qty[\"pie\"]} pie(s), #{food_qty[\"cake\"]} cake(s), and #{food_qty[\"cookie\"]} cookie(s).\" # This prints the needed quantities\n end\nend", "def buy_fruit(grocery_list)\n grocery_list.each_with_object([]) do |sub_arr, arr|\n sub_arr[1].times { arr << sub_arr[0] }\n end\nend", "def buy_fruit(array_of_arrays)\n result = []\n array_of_arrays.each { |array| array[1].times{ |i| result << array[0] } }\n result\nend", "def growFruit age\n\t\t@fruit_num += Random.rand(@age)\n\tend", "def produce_fruit\n\t\t# Start producing fruit after age 7.\n\t\t# Ramp up the fruit production as the tree ages.\n\t\tcase @current_age\n\t\twhen 0...7\n\t\t\tputs \"The tree is too young to have any fruit yet\"\n\t\twhen 7...20\n\t\t \tputs \"Producing some fruit!\"\n\t\t \t@orange_count += 10\n\t\twhen 20...40\n\t\t \tputs \"Producing some fruit!\"\n\t\t \t@orange_count += 25\n\t\twhen 40...60\n\t\t\tputs \"Producing some fruit!\"\n\t\t\t@orange_count += 40\n\t\twhen 60..DEATH_AGE\n\t\t\tputs \"Producing some fruit!\"\n\t\t\t@orange_count += 50\n\t\telse\n\t\t \tputs \"You gave me #{@current_age} -- I have no idea what to do with that.\"\n\t\tend\n\tend", "def bakery_num(num_of_people, fav_food)\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1}\n food_array = []\n has_fave = false\n\n my_list.each_key do |k|\n if k == fav_food\n has_fave = true\n end\n end\n raise ArgumentError.new(\"You can't make that food\") if has_fave == false\n fav_food_qty = my_list[fav_food]\n if num_of_people % fav_food_qty == 0\n num_of_food = num_of_people / fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n else num_of_people % fav_food_qty != 0\n while num_of_people > 0\n my_list.each do |k, v|\n food_qty = num_of_people / v\n num_of_people = num_of_people % v\n food_array << food_qty\n end\n end\n return \"You need to make #{food_array[0]} pie(s), #{food_array[1]} cake(s), and #{food_array[2]} cookie(s).\"\n end\nend", "def buy_fruit(list)\n list.each_with_object([]) do |item, arr|\n item[1].times { |_| arr << item[0] }\n end\nend", "def bakery_num(num_of_people, fav_food)\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1}\n pie_qty = 0\n cake_qty = 0\n cookie_qty = 0\n \n has_fave = false\n\n my_list.each_key do |k|\n if k == fav_food\n has_fave = true\n fav_food = k\n end\n end\n if has_fave == false\n raise ArgumentError.new(\"You can't make that food\")\n else\n fav_food_qty = my_list.values_at(fav_food)[0]\n if num_of_people % fav_food_qty == 0\n num_of_food = num_of_people / fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n else num_of_people % fav_food_qty != 0\n while num_of_people > 0\n if num_of_people / my_list[\"pie\"] > 0\n pie_qty = num_of_people / my_list[\"pie\"]\n num_of_people = num_of_people % my_list[\"pie\"]\n elsif num_of_people / my_list[\"cake\"] > 0\n cake_qty = num_of_people / my_list[\"cake\"]\n num_of_people = num_of_people % my_list[\"cake\"]\n else\n cookie_qty = num_of_people\n num_of_people = 0\n end\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n end\n end\nend", "def bakery_num( num_of_people, fav_food ) # defines a method called bakery_num that takes two parameters, num_of_peope, fav_food\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} # Hash of avaialble foods and associated counts\n \n pie_qty = 0\n cake_qty = 0 # quantity of the foods equals to 0 \n cookie_qty = 0\n \n has_fave = false # Initializes our has_fave tood to false\n\n my_list.each_key do |key| # iterating over my_list keys to do a comparison \n if key == fav_food # Favorite food comparison\n has_fave = true # confirms fav_food is in the list \n end\n # has_fave = true if key == fav_food\n end\n \n if has_fave == false # my_list does not contain fav_food \n raise ArgumentError.new(\"You can't make that food\") # Raise error if fav_food was not found\n else # Fav_food was in the list\n fav_food_qty = my_list[fav_food] #.values_at(fav_food)[0] # if in the list, return the quantity on hand *** refactor\n if num_of_people % fav_food_qty == 0 # Checks if num_of_people is evenly divisable by the fav_food_qty\n num_of_food = num_of_people / fav_food_qty # returns num_of_food eq to number of people / fav foods \n return \"You need to make #{num_of_food} #{fav_food}(s).\" # Return favorite food along with quantity\n else #num_of_people % fav_food_qty != 0 # num_of_people was not evenly divisable by fav_food_qty\n while num_of_people > 0 # while num_of_people is greater than zero \n if num_of_people / my_list[\"pie\"] > 0 # At least more people than the quantity of pie will feed \n pie_qty = num_of_people / my_list[\"pie\"] # quantity of pie is equal the number of people divided by my_list of pie \n num_of_people = num_of_people % my_list[\"pie\"] # number of people ramaining after distributing pies\n elsif num_of_people / my_list[\"cake\"] > 0 # At least more people than the quantity of cake \n cake_qty = num_of_people / my_list[\"cake\"] # quantity of cake is equal to the number of people divided by qty of people cake will feed\n num_of_people = num_of_people % my_list[\"cake\"] # number of people remaining after distributing cakes \n else # num_of_people is less than both qty that pie and cake will feed\n cookie_qty = num_of_people # cookie quantity is equal to the number of people \n num_of_people = 0 # Set num_of_people to 0 in order to end the loop\n end # Ending if-else conditions\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n end\n end\nend", "def bakery_num(num_of_people, fav_food) # this is defining bakery_num and takes 2 inputs\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} # creates hash, keys are baked goods, values are how many you can feed\n pie_qty = 0 # sets pie_qty to zero\n cake_qty = 0\n cookie_qty = 0\n \n has_fav = false # rename?\n\n my_list.each_key do |k| # iterates through each key in my_list\n if k == fav_food # if they key matches fav_food input\n has_fav = true # change has_fav to true\n end\n end\n \n if has_fav == false # If food isn't in stock/ isn't found\n raise ArgumentError.new(\"You can't make that food\")\n \n else\n fav_food_qty = my_list.values_at(fav_food)[0] # quantity of people favorite food can feed\n \n if num_of_people % fav_food_qty == 0 # if num_of_people can be divided evenly by fav_food_qty\n num_of_food = num_of_people / fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n \n else\n num_of_fav_food = num_of_people / fav_food_qty\n num_of_people = num_of_people % fav_food_qty\n \n while num_of_people > 0\n cake_qty = num_of_people / my_list[\"cake\"]\n if num_of_people % my_list[\"cake\"] > 0\n cookie_qty = num_of_people\n num_of_people = 0\n end \n end\n \n if fav_food == \"pie\"\n pie_qty = num_of_fav_food\n elsif fav_food == \"cake\"\n cake_qty = num_of_fav_food\n else\n cookie_qty = num_of_fav_food\n end\n\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n \n \n end \n end\nend", "def bakery_num( num_of_people, fav_food ) # defines a method called bakery_num that takes two parameters, num_of_peope, fav_food\n serving_sizes = { \"pie\" => 8, \"cake\" => 6, \"cookie\" => 1 } # Hash of available foods and associated counts\n food_quantities = { \"fav_food\" => 0, \"pie\" => 0, \"cake\" => 0, \"cookie\" => 0 } # Hash of food quantities\n\n # Raise error if serving sizes doesn't contain food\n raise ArgumentError.new(\"You can't make that food\") if !serving_sizes.has_key? (fav_food)\n\n # Returns the necessary number of food items needed to satisfy each serving if the \n # number of people attending is evenly divisible by the quantity of the passed favorite food.\n return \"You need to make #{num_of_people / serving_sizes[fav_food]} #{fav_food}(s).\" if num_of_people % serving_sizes[fav_food] == 0\n\n # Loop through each key in food_quantities to determine how many of each food item is needed.\n food_quantities.each do |key, value|\n if key == \"fav_food\" \n food_quantities[key] = num_of_people / serving_sizes[fav_food] # Setting \"fav_food\" property for future use in food_quantities\n food_quantities[fav_food] = food_quantities[key]\n num_of_people = num_of_people % serving_sizes[fav_food] # Setting remaining amount of people left after fav_food is determined.\n elsif num_of_people / serving_sizes[key] > 0 # key is not fav_food and number of remaining people divided by the next food item serving size is greater than zero\n food_quantities[key] = num_of_people / serving_sizes[key] # Setting count for additional food items needed for remaining people\n num_of_people = num_of_people % serving_sizes[key] # Setting number of remaining people after the additional food item\n end # Ending conditional\n end # Ending .each loop\n\n return \"You need to make #{food_quantities[\"pie\"]} pie(s), #{food_quantities[\"cake\"]} cake(s), and #{food_quantities[\"cookie\"]} cookie(s).\"\nend", "def bakery_num(servings, favorite_food)\n raise ArgumentError, \"You can't make that food\" unless TREAT_SERVINGS.key?(favorite_food)\n\n #instead of initializing them individually, we cna put it into a hash and easily associate with the servings hash\n order_quantity = {\"pie\" => 0, \"cake\" => 0, \"cookie\" => 0}\n fave_food_servings = TREAT_SERVINGS[favorite_food]\n\n if servings % fave_food_servings == 0\n return \"You need to make #{servings/fave_food_servings} #{favorite_food}(s).\"\n end\n\n # we know that we'll only have to fill the order with foods that have serving sizes of \n # equal to or less than favorite_food. so, if the constant TREAT_SERVINGS is always in \n # order by most servings : least_servings, this should return\n # an array of the treats that will potentially be part of the order\n foods = TREAT_SERVINGS.keys.drop_while {|food| food != favorite_food}\n\n # take_while will continue iterating until it evaluates to false or nil\n # so the last line in the block is asking if servings still have to be allocated\n foods.take_while do |food|\n order_quantity[food] = servings / TREAT_SERVINGS[food]\n servings %= TREAT_SERVINGS[food]\n end\n\n \"You need to make #{order_quantity[\"pie\"]} pie(s), #{order_quantity[\"cake\"]} cake(s), and #{order_quantity[\"cookie\"]} cookie(s).\"\nend", "def buy_fruit(arr)\n new_arr = []\n\n arr.each { |element| element[1].times { |_| new_arr << element[0] } }\n p new_arr\nend", "def orangeCount\n return @oranges\n end", "def buy_fruit(types)\n fruits = []\n\n types.each do |subarray|\n subarray[1].times do |time|\n fruits << subarray[0]\n end\n end\n fruits\nend", "def bakery_num(num_of_people, fav_food)\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} # create hash\n pie_qty = 0\n cake_qty = 0\n cookie_qty = 0\n\n raise ArgumentError.new(\"You can't make that food\") unless my_list.has_key?(fav_food)\n\n fav_food_qty = my_list.values_at(fav_food)[0] #create variable and set it to the my_list hash's value as an array\n\n if num_of_people % fav_food_qty == 0 #if num of people divides evenly by fav food quantity\n num_of_food = num_of_people / fav_food_qty #create new variable that is set to num of people divided by fav food qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n else num_of_people % fav_food_qty != 0 # if not evenly divided\n case fav_food\n when \"pie\"\n pie_qty = num_of_people / my_list[\"pie\"] # pie qty = 5\n num_of_people = num_of_people % my_list[\"pie\"] # num of people = 1\n cake_qty = num_of_people / my_list[\"cake\"]\n num_of_people = num_of_people % my_list[\"cake\"]\n cookie_qty = num_of_people\n when \"cake\"\n cake_qty = num_of_people / my_list[\"cake\"]\n num_of_people = num_of_people % my_list[\"cake\"]\n cookie_qty = num_of_people\n when \"cookie\"\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n end\nend", "def bakery_num(num_of_people, fav_food)\n \n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1}\n pie_qty = 0\n cake_qty = 0\n cookie_qty = 0\n \n unless my_list.has_key?(fav_food)\n raise ArgumentError.new(\"You can't make that food\")\n else\n\treturn \"You need to make #{num_of_people / my_list[fav_food]} #{fav_food}(s).\" if num_of_people % my_list[fav_food] == 0\n \n if fav_food == \"pie\"\n \tpie_qty = num_of_people/my_list[\"pie\"]\n \tnum_of_people = num_of_people % my_list[\"pie\"]\n \tcake_qty = num_of_people / my_list[\"cake\"]\n \tnum_of_people = num_of_people % my_list[\"cake\"]\n else \n \tcake_qty = num_of_people/my_list[\"cake\"]\n \tnum_of_people = num_of_people % my_list[\"cake\"]\n \tpie_qty = num_of_people / my_list[\"pie\"]\n \tnum_of_people = num_of_people % my_list[\"pie\"]\n end\n \n cookie_qty = num_of_people\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n \n end\nend", "def bakery_num(num_of_people, fav_food) \n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} \n pie_qty = 0\n cake_qty = 0\n cookie_qty = 0\n \n raise ArgumentError.new(\"You can't make that food\") unless my_list.has_key?(fav_food)\n\n fav_food_qty = my_list[fav_food] \n if num_of_people % fav_food_qty == 0 \n num_of_food = num_of_people / fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n else \n while num_of_people > 0\t\n pie_qty = num_of_people / my_list[\"pie\"] unless fav_food == \"cake\"\n num_of_people = num_of_people % my_list[\"pie\"] unless fav_food == \"cake\"\n cake_qty = num_of_people / my_list[\"cake\"]\n num_of_people = num_of_people % my_list[\"cake\"]\n cookie_qty = num_of_people\n num_of_people = 0\n end\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\nend", "def favorite_food_frequency\n all_favorite_foods.each_with_object(Hash.new(0)) do |food, object|\n object[food] += 1\n end\n end", "def count_items\n @baskets.rows.each do |basket|\n count_basket(basket)\n end\n end", "def bakery_num(num_of_people, fav_food)\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1}\n quantity = {\"pie\" => 0, \"cake\" => 0, \"cookie\" => 0}\n raise ArgumentError.new(\"You can't make that food\") unless my_list.include?(fav_food)\n\n quantity[fav_food] = num_of_people / my_list[fav_food]\n remainder = num_of_people % my_list[fav_food]\n return \"You need to make #{quantity[fav_food]} #{fav_food}(s).\" if num_of_people % my_list[fav_food] == 0\n \n my_list.each do |k,v|\n next if remainder < v\n quantity[k] = (remainder / v)\n remainder = remainder % v\n end \n\n \"You need to make #{quantity[\"pie\"]} pie(s), #{quantity[\"cake\"]} cake(s), and #{quantity[\"cookie\"]} cookie(s).\"\nend", "def showPiles\n 3.times { |i| puts i.to_s + \" : \" + $piles[i].count().to_s}\nend", "def countApplesAndOranges(start_point, ending_point, apple_tree,\n orange_tree, apples, oranges)\n fallen_a = Array.new(0)\n fallen_o = Array.new(0)\n v = start_point..ending_point\n apples.each do |a|\n fallen_a << a if v.include?(apple_tree + a)\n end\n oranges.each do |o|\n fallen_o << o if v.include?(orange_tree + o)\n end\n p fallen_a.size\n p fallen_o.size\nend", "def buy_fruit(list)\n cart = []\n \n list.map do |fruit, quantity|\n quantity.times do\n cart << fruit\n end\n end\n \n cart\nend", "def buy_fruit(array)\n array.each_with_object([]) do |arr, result|\n arr[1].times{|i| result << arr[0]}\n end\nend", "def bakery_num(num_of_people, fav_food) # creating method bakery_num\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} #creating hash. value of keys equals servings per person\n pie_qty = 0\n cake_qty = 0\n cookie_qty = 0\n dessert_array = Array.new\n has_fave = false \n\n my_list.each_key do |k| #iterates each key in the hash my_list\n if k == fav_food # making a comparison of each key in hash\n has_fave = true # gives a true value to fave_food\n #fav_food = k #fav_food is set to the value of the key ***** Redundant assignment, line deleted.\n end\n end\n\n if has_fave == false #if has_fave is false\n raise ArgumentError.new(\"You can't make that food\") #makes a new error to say that we cannot make that food because we have the incorrect arguements\n else\n fav_food_qty = my_list[fav_food] #creating a variable that, through the values method, returns an array made up by the value of the key established at fav_food \n if num_of_people % fav_food_qty == 0 #if theres no remainder in num_of_people divided fav_food_quantity\n num_of_food = num_of_people / fav_food_qty #creating num_of_food variable that gives us how many food items we should make\n return \"You need to make #{num_of_food} #{fav_food}(s).\" # returns string \n else #if there is a remainder \n while num_of_people > 0\n #\n my_list.each do |k,v|\n dessert_qty = num_of_people / v\n num_of_people = num_of_people % v\n dessert_array << dessert_qty \n end\n \n #\n # if num_of_people / my_list[\"pie\"] > 0 # if num_of_people divided by number of servings of pie is greather than zero\n # pie_qty = num_of_people / my_list[\"pie\"] # pie_qty equals num_of_people divided by servings of pie\n # num_of_people = num_of_people % my_list[\"pie\"] # num_of_people equals the remainder of num_of_people and servings of pie\n # elsif num_of_people / my_list[\"cake\"] > 0 #repetition of first set of conditions of pie\n # cake_qty = num_of_people / my_list[\"cake\"]\n # num_of_people = num_of_people % my_list[\"cake\"]\n # else\n # cookie_qty = num_of_people / my_list[\"cookie\"] \n # num_of_people = num_of_people % my_list[\"cookie\"] # so we don't have an infinite loop\n # end\n end\n return \"You need to make #{dessert_array[0]} pie(s), #{dessert_array[1]} cake(s), and #{dessert_array[2]} cookie(s).\"\n end\n end\nend", "def bakery_num(num_of_people, fav_food) #defining method bakery_num, which takes 2 arguments\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1, \"pudding\" => 2, \"bunt cake\" => 4, \"mega-cupcakes\" => 3} #creates hash my_list, key is food, value is number\n pie_qty = cake_qty = cookie_qty = has_fave = 0 \n \n\n my_list.each_key do |k| #iterating through array my_list\n if k == fav_food #tests if each item in array my_list = fav_food\n has_fave = 1 #if test above passes, set has_fave to true\n # fav_food = k #if test above passes, set fav_food to k\n end\n end\n \n if has_fave == 0 #if fav_food is not a key, end program\n raise ArgumentError.new(\"You can't make that food\")\n else #if fav_food is a key\n fav_food_qty = my_list.values_at(fav_food)[0] #set fav_food_qty equal to the value of fav_food\n if num_of_people % fav_food_qty == 0 \n num_of_food = num_of_people / fav_food_qty #if num_of_people is evenly divisible by fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n \n #num_of_food = num_of_people / fav_food_qty #then perform division by integer\n #return \"You need to make #{num_of_food} #{fav_food}(s).\" #return \"You need to make (num_of_food) (fav_food)s\"\n else num_of_people % fav_food_qty != 0 #redundant else\n while num_of_people > 0 #while num_of_people is greater than 0\n if num_of_people / my_list[\"pie\"] > 0 #if num_of_people divided by value of pie is greater than 0\n pie_qty = num_of_people / my_list[\"pie\"] #set pie_qty equal to num_of_people divided by value of pie in hash\n num_of_people = num_of_people % my_list[\"pie\"] #set num_of_people equal to the remainder of num_of_people divided by value of pie in hash\n elsif num_of_people / my_list[\"cake\"] > 0 #if num_of_people divided by hash value of cake is greater than 0\n cake_qty = num_of_people / my_list[\"cake\"] #set cake_qty equal to num_of_people divided by hash value of cake\n num_of_people = num_of_people % my_list[\"cake\"] #set num_of_people equal to the remainder of num_of_people divided by value of cake in hash\n else\n cookie_qty = num_of_people #set cookie_qty equal to num_of_people\n num_of_people = 0 #set num_of_people equal to 0\n end\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\" #print out\n end\n end\n \nend", "def buy_fruit(pair_array)\n flat_list = []\n pair_array.each do |pair|\n pair.last.times { flat_list << pair.first }\n end\n flat_list\nend", "def bakery_num(num_of_people, fav_food) #defines the method and accepts arguments num_of_people and fav_food\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} \n pie_qty = 0 #declaring variables at 0\n cake_qty = 0 #declaring variables at 0\n cookie_qty = 0 #declaring variables at 0\n \n has_fave = false\n\n my_list.each_key do |k| #iterates through the keys in my_list\n if k == fav_food #checks if passed argument fav_food is in the hash as a key\n has_fave = true #sets boolean has_fave to true\n fav_food = k #re-assigns fav_food to the key in the hash\n end\n end\n \n if has_fave == false #if fav_food is not found in the list\n raise ArgumentError.new(\"You can't make that food\") #raise an error\n else\n fav_food_qty = my_list.values_at(fav_food)[0] #declares a variable that is the quantity of fav food argument and sets it equal to first element in the value\n \n if num_of_people % fav_food_qty == 0 #if number of people is divisable by quantity of fav food\n num_of_food = num_of_people / fav_food_qty #number of food is set to number of people divided by fav food quantity\n return \"You need to make #{num_of_food} #{fav_food}(s).\" #returns string concatenated declaring how much of the food to make\n \n else num_of_people % fav_food_qty != 0 #if num of people is not divisable by fav food qty\n while num_of_people > 0 \n if num_of_people / my_list[\"pie\"] > 0 #if number of people divided by number of pies floor is greater than 0 \n pie_qty = num_of_people / my_list[\"pie\"] #sets pie quantity to multiples of number of servings\n num_of_people = num_of_people % my_list[\"pie\"] #num of people reassigned to remainder \n elsif num_of_people / my_list[\"cake\"] > 0 #if number of people divided by number of cakes floor is greater than 0\n cake_qty = num_of_people / my_list[\"cake\"] #sets cake quantity to multiples of number of servings\n num_of_people = num_of_people % my_list[\"cake\"] #num of people reassigned to remainder \n else\n cookie_qty = num_of_people #sets cookie qty to number of people remaining\n num_of_people = 0 #ends the loop if \"cookie else\" is reached\n end\n end\n \n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\" #returns the string, whole combination\n end\n end\nend", "def flour_quantity\n weight / (1 + percentages_except_flour) * pizzas\n end", "def get_ingredient_counts\n otc = 0\n legend = 0\n self.ingredients.each do |ingredient|\n if ingredient.get_base_item.drug_class == 'legend'\n legend += 1\n elsif ingredient.get_base_item.drug_class == 'over_the_counter'\n otc += 1\n end\n end\n self.number_legend_ingredients = legend\n self.number_otc_ingredients = otc\n end", "def fruit_plural(fruits)\n fruits_arr = []\n counter = 0\n \n loop do \n break if counter == fruits.size\n \n current_value = fruits[counter]\n fruits_arr << current_value.concat(\"s\")\n \n counter += 1\n end\n \n fruits_arr\nend", "def count_difficulties\n hash = {}\n i = 0\n while i < 20\n hash[i] = 0\n i += 1\n end\n Drink.all.each do |drink|\n hash[drink.ingredient_cards.count] += 1\n end\n puts hash\nend", "def count_basket(basket)\n basket.each do |item_id|\n increase_item_count(item_id)\n end\n end", "def popularity \n array = []\n Meal.all.select do |meal|\n if meal.recipe == self\n array << meal\n end\n end\n puts \"#{self.title} has been made #{array.length} times!\"\n end", "def buy_fruit(array)\n array.map { |fruit, value| [fruit] * value }.flatten\nend", "def total_sugars\n food.sugars * quantity\n end", "def bakery_num(num_of_people, fav_food)\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1}\n food_quantity = {\"pie\" => 0, \"cake\" => 0, \"cookie\" => 0}\n \n#Determine whether fav_food is a key in my_list\n# if you type in a food that isn't on the list, it raises an argument error\n\nunless my_list.has_key?(fav_food)\n raise ArgumentError.new(\"You can't make that food\")\nend\n\n# takes the value of the favorite food\n fav_food_qty = my_list[fav_food]\n#checks whether the number of people is divisible by that value \n if num_of_people % fav_food_qty == 0\n \n num_of_food = num_of_people / fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n#if there is a remainder...\n else num_of_people % fav_food_qty != 0\n food_quantity[fav_food] = num_of_people / fav_food_qty\n remaining_people=num_of_people%fav_food_qty\n my_list.each do |k,v|\n if remaining_people / my_list[k] > 0\n food_quantity[k] += remaining_people / my_list[k]\n remaining_people = remaining_people % my_list[k]\n end\n end\n # returns the number of pies, cakes, and cookie that can be made\n return \"You need to make #{food_quantity['pie']} pie(s), #{food_quantity['cake']} cake(s), and #{food_quantity['cookie']} cookie(s).\"\n end\n end", "def bakery_num(num_of_people, fav_food) #defining a method bakery_number. Takes number of people and favorite food as parameters \n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} #hash- my_list that has type of food as a key and amount of food as a value\n pie_qty = 0 # set default quantity to zero \n cake_qty = 0 # set default quantity to zero \n cookie_qty = 0 # set default quantity to zero \n \n ##has_fave = false # setting has_fave to false ##\n\n #my_list.each_key do |k| # we are iterating over my_list key values \n #if k == fav_food # if one of the keys matches fav_food, then...\n #has_fave = true # has_fave is set to true \n ##fav_food = k ##not necessary \n #closed out if statement \n if my_list.has_key?(fav_food) \n fav_food_qty = my_list.values_at(fav_food)[0] \n if num_of_people % fav_food_qty == 0 \n num_of_food = num_of_people / fav_food_qty \n return \"You need to make #{num_of_food} #{fav_food}(s).\" \n else \n case fav_food\n when \"pie\"\n if num_of_people / my_list[\"pie\"] > 0 \n pie_qty = num_of_people / my_list[\"pie\"] \n num_of_people = num_of_people % my_list[\"pie\"] \n elsif num_of_people / my_list[\"cake\"] > 0 \n cake_qty = num_of_people / my_list[\"cake\"] \n num_of_people = num_of_people % my_list[\"cake\"]\n else\n cookie_qty = num_of_people\n num_of_people = 0\n when \"cake\"\n if num_of_people / my_list[\"cake\"] > 0 \n cake_qty = num_of_people / my_list[\"cake\"] \n num_of_people = num_of_people % my_list[\"cake\"]\n else\n cookie_qty = num_of_people\n num_of_people = 0\n when \"cookie\"\n cookie_qty = num_of_people\n num_of_people = 0\n else\n \"You need to pick pie, cake, or cookie\"\n end \n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n end \n end \n else \n raise ArgumentError.new(\"You can't make that food\") # raise argument using a string \n end", "def number_ingredients(perfect_10_recipe)\n return perfect_10_recipe.size\nend", "def countApplesAndOranges(s, t, a, b, apples, oranges)\n result_a = 0\n apples.each do |d|\n cord = a + d\n if s <= cord && cord <= t\n result_a += 1\n end\n end\n puts result_a\n\n result_o = 0\n oranges.each do |d|\n cord = b + d\n if s <= cord && cord <= t\n result_o += 1\n end\n end\n puts result_o\nend", "def counting_recommendation\n count = @shoe.count\n if count <= 1\n @cold\n elsif count <= 10\n @warm\n else\n @hot\n end\n end", "def score(combo)\n @ingredients.map { |arr| arr[0..arr.size-2] } # skip last element\n .map.with_index do |set, i|\n set.map { |val| val * combo[i] } # multiply ingredient values by # of teaspoons\n end.transpose.map { |x| x.reduce(:+) } # multiply elementwise: https://stackoverflow.com/a/2682983/\n .map { |num| [num, 0].max }.reduce(:*) # min of zero, multiply result\n end", "def carbohidratos\n food = @ingredientes.head\n carbos = 0.0\n while food != nil do\n carbos += food[:value].carbohidratos * (food[:value].gramos / 1000.0)\n food = food[:next]\n end\n carbos * (100.0 / @total_nutricional)\n end", "def countApplesAndOranges(s, t, a, b, apples, oranges)\n # apple_tree = a\n # orange_tree = b\n # house = [s, t]\n apple_count = 0\n orange_count = 0\n\n apples.collect do |distance|\n if ((a + distance) >= s) && ((a + distance) <= t)\n apple_count += 1\n end\n end\n\n oranges.collect do |distance|\n if ((b + distance) >= s) && ((b + distance) <= t)\n orange_count += 1\n end\n end\n\n puts apple_count\n puts orange_count\n\nend", "def pizza_size \n\tsize = [\"small\", \"medium\", \"large\", \"super\", \"giganto\"].sample # .sample randomizing all the sizes\nend", "def cupcake_solver(cupcake_counts, number_of_students_in_class)\n # number of cupcakes for each flavor\n cake_set = cupcake_counts\n n = number_of_students_in_class\n cakes_per_student = 0\n\n cake_set.each do |count|\n # cakes per student for this flavor\n c = count / n\n # running total\n cakes_per_student += c\n end\n cakes_per_student\nend", "def buy_fruit(array)\n array.map {|value, index| [value] * index}.flatten # by placing value in [brackets] it makes it an array.\nend", "def ways_to_fill_a_fridge(amount, available = [5, 5, 10, 15, 20])\r\n containers = 1\r\n ways = []\r\n until containers > available.length\r\n schemes = available.combination(containers)\r\n schemes.each {|scheme| ways << scheme if scheme.inject(:+) == amount}\r\n containers += 1\r\n end\r\n ways\r\nend", "def buy_fruit(list)\n expanded_list = []\n list = list.flatten\n i = 0\n while i < list.size\n expanded_list << [list[i]] * list[i + 1]\n i += 2\n end\n expanded_list.flatten\nend", "def product_count\n self.items.inject(0) {|sum, item| sum + item.quantity}\n end", "def buy_fruit(list)\n list.map { |sub_arr| [sub_arr[0]] * sub_arr[1] }.flatten\nend", "def count_eggs(chicken_array)\n total_eggs = 0\n for chicken in chicken_array\n total_eggs += chicken[:eggs]\n end\n return total_eggs\nend", "def test_bear_food_count\n @river.add_fish(@fish1)\n @river.add_fish(@fish2)\n @bear.fishes_for_fish(@river)\n @bear.bear_food_count\n assert_equal(1, @bear.stomach.count)\n end", "def total_birds\n birds.count\n end", "def buy_fruit(list)\n list.each_with_object([]) do |(fruit, quantity), explanded list|\n explanded list.concat(Array.new(quantity, fruit))\n end\nend", "def bakery_num(num_of_people, fav_food)\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1}\n\n raise ArgumentError.new(\"You can't make that food\") unless my_list.has_key?(fav_food)\n \n return \"You need to make #{num_of_people / my_list[fav_food]} #{fav_food}(s).\" if num_of_people % my_list[fav_food] == 0\n return \"You need to make 0 pie(s), 0 cake(s), and #{num_of_people} cookie(s).\" if fav_food == \"cookie\"\n return \"You need to make #{num_of_people / my_list[fav_food]} pie(s), 0 cake(s), and #{num_of_people % my_list[fav_food]} cookie(s).\" if fav_food == \"pie\"\n return \"You need to make 0 pie(s), #{num_of_people / my_list[fav_food]} cake(s), and #{num_of_people % my_list[fav_food]} cookie(s).\" if fav_food == \"cake\"\n \nend", "def animal_number\n animals.size\n #binding.pry\n end", "def pickAnOrange\n\t\tif @fruit_num == 0 and @age < 5\n\t\t\tputs 'No oranges have grown yet!'\n\n\t\telsif @fruit_num > 0\n\t\t\t@fruit_num -= 1\n\t\t\tputs 'Hmmm, a delicious orange!'\n\n\t\telse\n\t\t\tputs 'The tree has no more oranges!'\n\t\tend\n\tend", "def bakery_num(num_of_people, fav_food) #Defining a function that takes two parameters\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} #Declaring a my_list hash\n pie_qty = 0 # Assigning three other variables \n cake_qty = 0\n cookie_qty = 0\n \n has_fave = false #setting a default value of false \n\n my_list.each_key do |k| #looping through the keys of my_list\n if k == fav_food #An if statement, where the condition is comapred to one of the parameters\n has_fave = true #If true, declaring a has_fave to true \n fav_food = k #Assigning fav_food to that key\n end\n end\n if has_fave == false #If no matec ==> error\n raise ArgumentError.new(\"You can't make that food\")\n else\n fav_food_qty = my_list.values_at(fav_food)[0] #If match ==> find value from Hash \n if num_of_people % fav_food_qty == 0 #Module of the first function parameter, number of people by fav food quantity\n num_of_food = num_of_people / fav_food_qty #If true, get portions \n return \"You need to make #{num_of_food} #{fav_food}(s).\" #return an order \n else num_of_people % fav_food_qty != 0 #redundant but if not \n while num_of_people > 0 \n if num_of_people / my_list[\"pie\"] > 0 #if there are more people than pies\n pie_qty = num_of_people / my_list[\"pie\"] #This gets portions\n num_of_people = num_of_people % my_list[\"pie\"] #this gets amount of people for leftovers \n elsif num_of_people / my_list[\"cake\"] > 0 #If the number of people is not rgeater than pies, we go into cakes\n cake_qty = num_of_people / my_list[\"cake\"]\n num_of_people = num_of_people % my_list[\"cake\"]\n else\n cookie_qty = num_of_people\n num_of_people = 0\n end\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n end\n end\nend", "def calorie_count\n @sugar_amount * CALORIES_PER_SUGAR_GRAM +\n @flour_amount * CALORIES_PER_FLOUR_GRAM\n end", "def students_with_brown_eyes(eye_colors)\n\tbrown_eyes = 0\n\n\teye_colors.each do |eye_color|\n \t\tif eye_color == \"Brown\"\n\t\t\tbrown_eyes += 1\n\t\tend\n\tend\n\n\treturn brown_eyes\n\nend" ]
[ "0.7027516", "0.6904498", "0.6857692", "0.68079233", "0.67924154", "0.67397386", "0.66914696", "0.6690356", "0.66797477", "0.66751146", "0.6659053", "0.6655904", "0.6583897", "0.6581272", "0.65171206", "0.64914966", "0.64782274", "0.6432688", "0.6427226", "0.64071953", "0.63755935", "0.63681567", "0.63474035", "0.63431543", "0.6339139", "0.6314937", "0.6308298", "0.6304885", "0.6303929", "0.62408185", "0.6233319", "0.62216043", "0.61796856", "0.61765385", "0.61656624", "0.6151915", "0.6142581", "0.6109103", "0.6106688", "0.61025697", "0.609477", "0.609393", "0.6084413", "0.60842", "0.6074774", "0.60300213", "0.599557", "0.5982096", "0.5974298", "0.59661204", "0.5939882", "0.59328115", "0.5923884", "0.5920048", "0.5910718", "0.5890501", "0.5887465", "0.5866575", "0.5863044", "0.58581483", "0.5844669", "0.5841016", "0.58259714", "0.5788729", "0.57860553", "0.5738763", "0.57203823", "0.57001734", "0.5678642", "0.56765246", "0.56720245", "0.5670487", "0.566884", "0.56617236", "0.56580037", "0.56545496", "0.5650991", "0.5634156", "0.5633085", "0.5624447", "0.561432", "0.56050783", "0.5602978", "0.55892766", "0.55803686", "0.5564663", "0.55646515", "0.5563576", "0.55562615", "0.5547194", "0.5545917", "0.5538586", "0.5521117", "0.55163276", "0.55082405", "0.5505816", "0.55022275", "0.55015534" ]
0.6528751
15
=begin take list and transform each fruit and quantity to fruit quantity and flatten the array =end
def buy_fruit(types) fruits = [] types.each do |subarray| subarray[1].times do |time| fruits << subarray[0] end end fruits end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def buy_fruit_2(arr)\n arr.map { |fruit, quantity| [fruit] * quantity }.flatten # => [\"apples\", \"apples\", \"apples\", \"orange\", \"bananas\", \"bananas\"]\nend", "def buy_fruit2(arr)\n arr.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def buy_fruit(ary)\n ary.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def buy_fruit(list)\n list.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def buy_fruit(list)\n list.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def buy_fruit(list)\n list.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def buy_fruit2(array)\n array.map {|fruit, quantity| [fruit] * quantity}.flatten\nend", "def buy_fruit(fruit_array)\n fruit_array.map { |fruit, how_many| [fruit] * how_many }.flatten\nend", "def buy_fruit(list)\n list.each_with_object([]) do |(fruit, quantity), explanded list|\n explanded list.concat(Array.new(quantity, fruit))\n end\nend", "def buy_fruit(array)\n expanded_list = []\n\n array.each do |item|\n fruit, quantity = item[0], item[1]\n quantity.times { expanded_list << fruit }\n end\n expanded_list\nend", "def buy_fruit(list)\n list.to_h.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def buy_fruit(array)\n result = []\n array.each do |value|\n result << [value[0]] * value[1] # again need to place brackets around value[idx] to return an array.\n end\n result.flatten\nend", "def buy_fruit(list)\n list.map { |sub_arr| [sub_arr[0]] * sub_arr[1] }.flatten\nend", "def buy_fruit(array)\n array.map { |fruit, value| [fruit] * value }.flatten\nend", "def buy_fruit(grocery_list)\n grocery_list.each_with_object([]) do |sub_arr, arr|\n sub_arr[1].times { arr << sub_arr[0] }\n end\nend", "def buy_fruit(list)\n list.each_with_object([]) do |(fruit, quantity), new_arr|\n quantity.times { new_arr << fruit }\n end\nend", "def buy_fruit(list)\n expanded_list = []\n list = list.flatten\n i = 0\n while i < list.size\n expanded_list << [list[i]] * list[i + 1]\n i += 2\n end\n expanded_list.flatten\nend", "def buy_fruit(list)\n list.each_with_object([]) do |item, arr|\n item[1].times { |_| arr << item[0] }\n end\nend", "def buy_fruit(list)\n expanded_list = []\n\n list.each do |item|\n fruit, quantity = item[0], item[1]\n quantity.times { expanded_list << fruit }\n end\n\n expanded_list\nend", "def buy_fruit(array)\n array.map { |sub_array| [sub_array[0]] * sub_array[1] }.flatten\nend", "def buy_fruit(array)\n array.map do |sub_arr|\n [sub_arr[0]] * sub_arr[1]\n end.flatten\nend", "def buy_fruit(list)\n quantities = []\n list.each { |item| item[1].times { quantities << item[0] } }\n quantities\nend", "def buy_fruit(grocery_list)\n array_of_fruits = []\n\n grocery_list.each do |fruit|\n fruit[1].times { array_of_fruits << fruit[0]}\n end\n array_of_fruits\nend", "def buy_fruit(array)\n new_list = []\n number = 0\n array.each do |fruit|\n number = fruit.pop\n number.times { new_list << fruit }\n end\n new_list.flatten\nend", "def buy_fruit(array)\n array.map {|value, index| [value] * index}.flatten # by placing value in [brackets] it makes it an array.\nend", "def buy_fruit(array_of_arrays)\n result = []\n array_of_arrays.each { |array| array[1].times{ |i| result << array[0] } }\n result\nend", "def buy_fruit(fruits)\n fruits.each_with_object([]) do |fruit, result|\n fruit.last.times { result << fruit.first }\n end\nend", "def flatten_sequence(list); end", "def buy_fruit(list)\n list.each_with_object([]) do |fruit_info, shopping_list|\n fruit, quantity = fruit_info[0], fruit_info[1]\n quantity.times {shopping_list << fruit}\n end \nend", "def buy_fruit(grocery_list)\n result = []\n grocery_list.each do |fruit|\n fruit[1].times do\n result << fruit[0]\n end\n end\n result\nend", "def buy_fruit(fruit_list)\n fruit_array = []\n fruit_list.each do |fruit, quantity|\n quantity.times { fruit_array << fruit }\n end\n fruit_array\nend", "def buy_fruit(list)\n new_list = []\n list.each { |arr| arr[1].times { new_list << arr[0] } }\n new_list\nend", "def buy_fruit(array)\n array.each_with_object([]) do |arr, result|\n arr[1].times{|i| result << arr[0]}\n end\nend", "def buy_fruit(arr)\n arr.each_with_object([]) do |pair, all_fruit|\n pair.last.times { |fruit| all_fruit << pair.first }\n end\nend", "def buy_fruit(array)\n final_array = []\n array.each do |subarray|\n subarray[1].times do |_|\n final_array << subarray[0]\n end\n end\n final_array\nend", "def buy_fruit(deep_list)\n list = []\n deep_list.each do |fruits|\n fruits[1].times do\n list << fruits[0]\n end\n end\n list\nend", "def buy_fruit(pair_array)\n flat_list = []\n pair_array.each do |pair|\n pair.last.times { flat_list << pair.first }\n end\n flat_list\nend", "def products\n @products.map{|prouduct, num| (1..num).map{|i| prouduct}}.flatten\n end", "def flatten_repetition(list, named); end", "def buy_fruit(arr)\n output = []\n arr.each { |fruit, count| output += [fruit] * count }\n output\nend", "def buy_fruit(fruit_quantity)\n fruit = []\n\n fruit_quantity.each do |sub_array|\n count = sub_array[1]\n\n until count <= 0\n fruit << sub_array[0]\n count -= 1\n end\n end\n fruit\nend", "def buy_fruit(array)\n fruits = []\n array.each do |subarray|\n subarray[1].times do\n fruits << subarray[0]\n end\n end\n fruits\nend", "def buy_fruit3(array)\n #array.each_with_object([]) {|obj, result| obj.last.times {result<< obj.first}}\n array.each_with_object([]) {|(fruit, count), result| count.times {result<< fruit}}\nend", "def buy_fruit(list)\n cart = []\n \n list.map do |fruit, quantity|\n quantity.times do\n cart << fruit\n end\n end\n \n cart\nend", "def applying_flatten array_value\n return array_value.flatten!\n end", "def buy_fruit(array)\n returner = []\n array.each{|subarray| subarray[1].times{returner << subarray[0]}}\n returner\nend", "def buy_fruit(arr)\n new_arr = []\n\n arr.each { |element| element[1].times { |_| new_arr << element[0] } }\n p new_arr\nend", "def buy_fruit(groceries)\n things_to_buy = []\n groceries.each do |items|\n items[1].times { things_to_buy << items[0] }\n end\n things_to_buy \nend", "def buy_fruit(fruits_wih_quantity)\n fruits = []\n \n fruits_wih_quantity.each do |fruit, quantity|\n quantity.times do\n fruits << fruit\n end\n end\n\n fruits\nend", "def using_flatten(array)\n array.flatten\n end", "def buy_fruit(fruits)\n result = []\n fruits.each do |pair|\n pair.last.times { |i| result << pair.first}\n end\n result\nend", "def flatten() end", "def using_flatten(array)\n \n array.flatten\n \nend", "def cartProd\n @items = []\n @arr1.each{ |a|\n @arr2.each{ |b|\n item = [] << a << b\n @items << item\n }\n }\n end", "def flatten_array(arr)\n arr.each_with_object([]) do |item, flat|\n if item.is_a? Integer\n flat << item\n else\n flatten_array(item).each do |num|\n flat << num\n end\n end\n end\nend", "def using_flatten(array)\n array.flatten\n \nend", "def flatten\n\t\tmake_flat(@array)\n\tend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten()\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def flatten(array)\n container = []\n\n array.each do |element|\n if element.is_a?(Array)\n container += element\n else\n container << element\n end\n end\n\n container\nend", "def flatten(list)\n list.flatten\nend", "def using_flatten (array)\n return array.flatten!\nend", "def flatten_sequence(list) # :nodoc:\n foldl(list.compact) { |r, e| # and then merge flat elements\n merge_fold(r, e)\n }\n end", "def quantified_items\n products.map { |product| [product.variant, product.quantity] }\n end", "def flatten\n # if any item is a Set or Java Collection, then convert those into arrays before recursively flattening the list\n if any? { |item| Set === item or Java::JavaUtil::Collection === item } then\n return map { |item| (Set === item or Java::JavaUtil::Collection === item) ? item.to_a : item }.flatten\n end\n base__flatten\n end", "def flatten(nested_array, result = [])\n nested_array.each do |integer|\n if integer.class == Array\n flatten(integer, result)\n else\n result << integer\n end\n end\n result\nend", "def flatten!() end", "def flatten_repetition(list, named) # :nodoc:\n if list.any? { |e| e.instance_of?(Hash) }\n # If keyed subtrees are in the array, we'll want to discard all \n # strings inbetween. To keep them, name them. \n return list.select { |e| e.instance_of?(Hash) }\n end\n\n if list.any? { |e| e.instance_of?(Array) }\n # If any arrays are nested in this array, flatten all arrays to this\n # level. \n return list.\n select { |e| e.instance_of?(Array) }.\n flatten(1)\n end\n \n # Consistent handling of empty lists, when we act on a named result \n return [] if named && list.empty?\n \n # If there are only strings, concatenate them and return that. \n foldl(list) { |s,e| s+e }\n end", "def using_flatten(arr)\n arr.flatten\nend", "def buy_fruit(array) \n results = []\n array.each do |fruit, number|\n number.times { results << fruit }\n end\n results\nend", "def flat(a)\n\tnew_arr = []\n\ta.each do |el|\n\t\tif el.is_a? Array\n\t\t\tel.each do |n|\n\t\t\t\tif el.is_a? Array\n\t\t\t\t\ta << n\n\t\t\t\telse\n\t\t\t\t\tnew_arr << n\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tnew_arr << el\t\n\t\tend\n\tend\n\tp new_arr\nend", "def my_flatten\n arr = []\n i = 0\n while i < self.length\n if self[i].is_a? Array\n arr += self[i].my_flatten\n else\n arr << self[i]\n end\n i += 1\n end\n return arr\n end", "def productify(array)\n\nend", "def flatten(array)\n new_array = []\n array.each do |x|\n if x.class == Array\n x.each {|y| new_array.push(y)}\n else\n new_array.push(x)\n end\n end\n new_array\nend", "def expand\n map { |p| p&.flatten || p }.flatten\n end", "def flatten\n map {|item| item.respond_to?(:flatten) ? item.flatten : item }.flatten\n end", "def join_ingredients(src)\n \n new_array = []\n \n new_array.push(\"I love #{src[0][0]} and #{src[0][1]} on my pizza\")\n new_array.push(\"I love #{src[1][0]} and #{src[1][1]} on my pizza\")\n new_array.push(\"I love #{src[2][0]} and #{src[2][1]} on my pizza\")\n \n\n new_array\nend", "def my_flatten\n flattened_array = []\n each do |item|\n if item.class != Array\n flattened_array << item\n else\n #recursevly call my flatten\n item.my_flatten.each { |sub_item| flattened_array << sub_item }\n end\n end\n flattened_array\n end", "def my_flatten\n flattened = []\n self.my_each do |el|\n el.is_a?(Array) ? flattened += el.my_flatten : flattened << el\n end\n flattened\n end", "def flatten(*args)\n new_array = []\n self.each do |v|\n if v.is_a?(Array)\n new_array.push( *(v.flatten(*args)) )\n else\n new_array << v\n end\n end\n new_array\n end", "def gracify(data)\n data.map{|i| Belt.new(i[0], i[1])}\n end", "def my_flatten\n flattened = []\n self.my_each do |el|\n if el.is_a? Array\n flattened += el.my_flatten\n else\n flattened << el\n end\n end\n flattened\n end", "def unflatten(flat_array)\n result = []\n x = 0\n\n while x < flat_array.length do \n if flat_array[x] < 3 \n result.push flat_array[x]\n x += 1\n else\n temp = [*flat_array[x...x + flat_array[x]]]\n result.push temp \n x += flat_array[x]\n end\n end\n result \nend", "def buy_fruit(array)\n results = []\n\n array.each do |fruit, num|\n num.times do\n results << fruit\n end\n end\n\n results\nend", "def multi_dimensional_sum(array)\n array.flatten\nend", "def make_quantity_list(item_list)\n index = 0\n while index < item_list.length\n item_list[index] = 1\n index = index+1\n end\n return item_list\nend", "def flatten!\n\t\t@array = make_flat(@array)\n\tend", "def apple_picker_collect(array)\n apples = array.collect do |item|\n item if item == \"apple\"\n end\n apples.compact\nend", "def populate\n (0...@quantity).each do |i|\n @result[i] = sequence(i)\n end\n end", "def my_flatten(array)\n print array.flatten\n end", "def my_flatten\n # return self unless self.is_a?(Array)\n new_arr = []\n self.each do |el|\n if el.is_a?(Array)\n new_arr += el.my_flatten\n else\n new_arr << el\n end\n end\n new_arr\n end", "def flattenDeck(deck)\n arr = []\n for card in deck.cards\n arr.push(card.value)\n end\n arr\nend", "def my_flatten\n flattened = []\n self.my_each do |el|\n el.is_a?(Array) ? flattened.concat(el.my_flatten) : flattened << el\n end\n flattened\n end" ]
[ "0.73612505", "0.73401815", "0.72806686", "0.7242852", "0.7242852", "0.7242852", "0.72266173", "0.7210359", "0.71545136", "0.70066273", "0.69635695", "0.6954689", "0.69305956", "0.691524", "0.68855387", "0.67886496", "0.67487717", "0.6726757", "0.6676413", "0.6631249", "0.65425295", "0.65057826", "0.6504618", "0.6454091", "0.64448935", "0.6413531", "0.6403155", "0.6388962", "0.6367335", "0.6322752", "0.6314154", "0.6304998", "0.6292593", "0.628475", "0.6275425", "0.6181562", "0.6165351", "0.61317617", "0.6106011", "0.61006266", "0.60960644", "0.60950047", "0.6060054", "0.60040927", "0.5966472", "0.5964404", "0.59605545", "0.5906295", "0.58963203", "0.5875468", "0.5862263", "0.58347654", "0.58205986", "0.5779314", "0.5753459", "0.5747555", "0.5742968", "0.5724215", "0.5724215", "0.57159317", "0.5698367", "0.5698367", "0.5698367", "0.5698367", "0.5698367", "0.5698367", "0.5647824", "0.56382424", "0.56279254", "0.5623481", "0.56163794", "0.55989236", "0.5579147", "0.55653113", "0.5564774", "0.5540966", "0.5518277", "0.5499722", "0.549243", "0.5487829", "0.5475674", "0.54731107", "0.5471299", "0.5433365", "0.5421846", "0.54198074", "0.5419", "0.5410496", "0.5402632", "0.53982687", "0.5397775", "0.538802", "0.5385821", "0.5371127", "0.53646666", "0.53566456", "0.53506196", "0.5348856", "0.5348528", "0.5345719" ]
0.5761109
54
["apples", "apples", "apples", "orange", "bananas","bananas"] =begin Input:array of subarrays that each have string and number create empty array iterate through types and for each subarray call times method on number (subarray[1]) and for each time take the item (subarray[0]) and append to fruits array return fruits array Output: one array with the strings the number of times that was given in the original array =end
def buy_fruit(array) fruits = [] array.each do |subarray| subarray[1].times do fruits << subarray[0] end end fruits end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def buy_fruit(types)\n fruits = []\n\n types.each do |subarray|\n subarray[1].times do |time|\n fruits << subarray[0]\n end\n end\n fruits\nend", "def buy_fruit3(array)\n #array.each_with_object([]) {|obj, result| obj.last.times {result<< obj.first}}\n array.each_with_object([]) {|(fruit, count), result| count.times {result<< fruit}}\nend", "def buy_fruit(array_of_arrays)\n result = []\n array_of_arrays.each { |array| array[1].times{ |i| result << array[0] } }\n result\nend", "def buy_fruit(array)\n returner = []\n array.each{|subarray| subarray[1].times{returner << subarray[0]}}\n returner\nend", "def buy_fruit_2(arr)\n arr.map { |fruit, quantity| [fruit] * quantity }.flatten # => [\"apples\", \"apples\", \"apples\", \"orange\", \"bananas\", \"bananas\"]\nend", "def buy_fruit(array)\n final_array = []\n array.each do |subarray|\n subarray[1].times do |_|\n final_array << subarray[0]\n end\n end\n final_array\nend", "def buy_fruit(arr)\n output = []\n arr.each { |fruit, count| output += [fruit] * count }\n output\nend", "def buy_fruit(fruit_array)\n fruit_array.map { |fruit, how_many| [fruit] * how_many }.flatten\nend", "def buy_fruit(arr)\n new_arr = []\n\n arr.each { |element| element[1].times { |_| new_arr << element[0] } }\n p new_arr\nend", "def buy_fruit2(arr)\n arr.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def buy_fruit(array)\n new_list = []\n number = 0\n array.each do |fruit|\n number = fruit.pop\n number.times { new_list << fruit }\n end\n new_list.flatten\nend", "def buy_fruit2(array)\n array.map {|fruit, quantity| [fruit] * quantity}.flatten\nend", "def buy_fruit(array) \n results = []\n array.each do |fruit, number|\n number.times { results << fruit }\n end\n results\nend", "def buy_fruit(ary)\n ary.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def count_eggs(chicken_array)\n total_eggs = 0\n for chicken in chicken_array\n total_eggs += chicken[:eggs]\n end\n return total_eggs\nend", "def buy_fruit(grocery_list)\n grocery_list.each_with_object([]) do |sub_arr, arr|\n sub_arr[1].times { arr << sub_arr[0] }\n end\nend", "def num_repeater(array = [])\n raise 'incorrect array' unless array.is_a? Array\n\n array_with_repeated_num = []\n array.each do |e|\n unless e.is_a? Integer\n array_with_repeated_num << e\n next\n end\n (1..e).each { array_with_repeated_num << e }\n end\n array_with_repeated_num\nend", "def buy_fruit(array)\n array.map {|value, index| [value] * index}.flatten # by placing value in [brackets] it makes it an array.\nend", "def actor_list(array)\n #the variable actors is equal to a new array that only has the key actors in each of the movies\n actor_in_bond = array.map {|movie| movie[:actor]}\n #list variable gives me the array of unique people out of the list of array\n list = actor_in_bond.uniq\n #variable movies per actor is equal to a iterator that will give me a new array of the movie actor from the list and\n #check the number of times the actor's name shows up in the array actor in bond then it will\n #give me an array of the actors name with the number of movie it is in\n movies_per_actor = list.map {|movie| \"#{movie} => #{actor_in_bond.count(movie)}\"}\n #outputs the list of actors with number of movies they are in\n puts movies_per_actor\nend", "def freq_calc(mult_arr)\n\tresult_arr = []\n\tsubarrs_by_index = reorder_on_index(mult_arr)\n\tsubarrs_by_index.uniq.each do |arr|\n\t\tarr.uniq.each do |letter|\n\t\t\tresult_arr << {letter => (count(arr, letter))}\n\t\tend\n\t\tp arr.uniq\n\tend\n\treturn result_arr\nend", "def count_elements(array)\n new_array = []\n for person in array.uniq\n new_array.push{:name => person[:name], :count => array.count(name)}\n end\nend", "def buy_fruit(array)\n array.each_with_object([]) do |arr, result|\n arr[1].times{|i| result << arr[0]}\n end\nend", "def customer_pet_count(customer_array)\n customer_array[:pets].count\nend", "def buy_fruit(array)\n array.map { |sub_array| [sub_array[0]] * sub_array[1] }.flatten\nend", "def buy_fruit(grocery_list)\n array_of_fruits = []\n\n grocery_list.each do |fruit|\n fruit[1].times { array_of_fruits << fruit[0]}\n end\n array_of_fruits\nend", "def count_elements(array)\n array.uniq.collect do |word|\n word[:count] = array.count(word)\n word\n end\nend", "def buy_fruit(array)\n results = []\n\n array.each do |fruit, num|\n num.times do\n results << fruit\n end\n end\n\n results\nend", "def buy_fruit(array)\n array.map do |sub_arr|\n [sub_arr[0]] * sub_arr[1]\n end.flatten\nend", "def star_counter(arr_of_arrys)\n counter_arr = []\n arr_of_arrys.each do |array|\n num_of_stars = 0\n array.each do |value|\n num_of_stars += 1 if value == \"*\"\n end\n counter_arr << num_of_stars\n end\n return counter_arr\nend", "def count_elements (array)\n result_array = []\n\n array.each do |data|\n flag =0\n result_array.each do |k|\n if k[:name] == data[:name]\n k[:count] +=1\n flag =1\n end\n end\n if(flag == 0)\n data[:count] = 1\n result_array << data\n end\n end\n result_array\nend", "def count_elements(array)\n counted = []\n array.each do |item|\n item[:count] = array.count(item)\n counted << item\n end\n return counted.uniq{ |item|\n item[:name]\n }\nend", "def count_elements(array)\n #Build hash where key = name and val = count\n counts = Hash.new(0)\n array.each do |element|\n counts[element[:name]] += 1\n end\n\n #Turn this into array of hashes\n ret = []\n counts.map do |key, val|\n h = {}\n h[:name] = key\n h[:count] = val\n ret << h\n end\n ret\nend", "def buy_fruit(array)\n array.map { |fruit, value| [fruit] * value }.flatten\nend", "def count_elements(array)\n array.group_by(&:itself).map { |key, value| key.merge(count: value.length)} # counts number of times occur\nend", "def buy_fruit(array)\n result = []\n array.each do |value|\n result << [value[0]] * value[1] # again need to place brackets around value[idx] to return an array.\n end\n result.flatten\nend", "def count_elements(array)\n new_array = array.uniq\n new_array.each do |hash|\n hash[:count] = array.count(hash)\n end\n new_array\nend", "def buy_fruit(array)\n expanded_list = []\n\n array.each do |item|\n fruit, quantity = item[0], item[1]\n quantity.times { expanded_list << fruit }\n end\n expanded_list\nend", "def buy_fruit(arr)\n arr.each_with_object([]) do |pair, all_fruit|\n pair.last.times { |fruit| all_fruit << pair.first }\n end\nend", "def count_elements(array)\n new_array = []\n\n array.each do |original_array_element|\n\n #now inside the array looking at each indv hash\n \tif new_array.empty?\n\n \t\tfirst_new_element = {name: original_array_element[:name], count: 1}\n \t\tnew_array.push(first_new_element)\n\n \telse\n name_found = false\n \t\tnew_array.each do |new_hash_item|\n \t\t\t#binding.pry\n \t\t\tif new_hash_item.has_value?(original_array_element[:name])\n \t\t\t\tnew_hash_item[:count] += 1\n name_found = true\n \t\t\tend\n end\n if name_found == false\n new_element = {name: original_array_element[:name], count: 1}\n new_array.push(new_element)\n end\n \tend\n end\n return new_array\nend", "def lengths(inputArray)\n newArr = []\n #could do p array.map{|word|word.length}\n newArr.push(inputArray.map{|words| words.length})\n p newArr\nend", "def gem_element arr\n freq = Hash.new(0)\n count = 0\n\n combo = arr.map(&:chars).map(&:uniq).flatten\n combo.each{ |key| freq[key]+=1 }\n freq.each{ |k,v| count +=1 if v == arr.size }\n count\n \nend", "def count_elements(array)\n array.each_with_object(Hash.new(0)){|arr, hash| hash[arr[:name]] += 1}.map{|key, value|{:name=>key, :count=>value}}\nend", "def count_elements(array)\n\t# My attempt:\n\t# hash = {}\n\t# array.each do |e|\n\t# \thash[e] = 1\n\t# end\n\t# new_array = []\n\t# hash.each do |animal, count|\n\t# \tnew_array = hash.select{|animal2, count2| animal2 == animal}\n\t# end\n\t# new_array\n\n\t# Stack Overflow:\n\tcounts = Hash.new(0) # sets default value (the value that is returned when trying to access key that does not exist) to 0 instead of nil\n\tarray.each { |e| counts[e] += 1 }\n\tcounts\nend", "def buy_fruit(list)\n list.each_with_object([]) do |item, arr|\n item[1].times { |_| arr << item[0] }\n end\nend", "def buy_fruit(grocery_list)\n result = []\n grocery_list.each do |fruit|\n fruit[1].times do\n result << fruit[0]\n end\n end\n result\nend", "def count_occurence(array)\n counts = Hash.new(0)\n array.each { |name| counts[name] += 1 }\n puts counts\n\n price_calculator=PriceCalculator.new\n price_calculator.sepitem_quantity(counts)\n\n end", "def count_elements(array)\n counts = Hash.new 0\n unique_elements = array.uniq\n\n unique_elements.each do |item|\n item[:count] = array.count(item)\n end\n\n unique_elements\nend", "def buy_fruit(list)\n new_list = []\n list.each { |arr| arr[1].times { new_list << arr[0] } }\n new_list\nend", "def count(array)\n hash = {}\n array.each do |item|\n hash[item] = array.count(item)\n end\n hash\nend", "def buy_fruit(fruit_quantity)\n fruit = []\n\n fruit_quantity.each do |sub_array|\n count = sub_array[1]\n\n until count <= 0\n fruit << sub_array[0]\n count -= 1\n end\n end\n fruit\nend", "def count_occurrences1(array)\n occurrences = {}\n\n array.map(&:downcase).each do |element|\n occurrences[element] = array.count(element)\n end\n\n occurrences.each do |element, count|\n puts \"#{element} => #{count}\"\n end\nend", "def count_items(elective_array)\n return elective_array.length\nend", "def buy_fruit(list)\n list.each_with_object([]) do |(fruit, quantity), new_arr|\n quantity.times { new_arr << fruit }\n end\nend", "def count_elements(array)\n newArray = []\n array.each do |obj|\n newArray.push(obj)\n obj[:count] = 0\n #if newArray.length > 0\n newArray.each do |obj|\n if obj.include?(:count)\n obj[:count] += 1\n else\n obj[:count] = 1\n end\n #binding.pry\n end\n #end\n end\n newArray.shift\n return newArray\nend", "def buy_fruit(groceries)\n things_to_buy = []\n groceries.each do |items|\n items[1].times { things_to_buy << items[0] }\n end\n things_to_buy \nend", "def frequency(a)\r\n a.group_by do |e|\r\n e\r\n end.map do |key, values|\r\n [values.size]\r\n end\r\nend", "def stock_count(stock_count_array)\n stock_count_array[:pets].count\nend", "def count_elements(arr)\n counter = Array.new\n counter_helper = Array.new\n arr.each do |element|\n if counter_helper.include?(element)\n counter[counter_helper.find_index(element)][:count] += 1\n else\n counter_helper.push(element.clone)\n element[:count] = 1\n counter.push(element)\n end\n end\n counter\nend", "def buy_fruit(fruits)\n fruits.each_with_object([]) do |fruit, result|\n fruit.last.times { result << fruit.first }\n end\nend", "def length_finder(input_array)\n input_array.map {|word| word.size}\nend", "def calcuate_frequencies(sequences)\n freq_array = Array.new(4) {|i|Array.new(10){|i| 0}} #2-dimensional array, second dimension initialised to 0's\n sequences.each do |seq|\n for position in 0..3\n freq_array[position][seq[position].to_i] += 1 #increment frequency value by 1\n end\n end\n freq_array\nend", "def count_occurrences(array)\n return puts('Invalid Array') unless array.is_a?(Array)\n return puts('There is nothing to count') if array.empty?\n\n counts = array.each_with_object(Hash.new(0)) do |word, hash|\n hash[word] += 1\n end\n\n counts.each do |word, count|\n puts \"#{word} => #{count}\"\n end\nend", "def count_freq(array)\n array.each_with_object(Hash.new(0)) { |obj, counts| counts[obj] += 1 }\n end", "def count_occurrences(array)\n count = ''\n output = { }\n\n array.each do |item|\n count = array.count(item)\n output[item] = count\n end\n output.each do |key, value|\n puts \"#{key} => #{value}\"\n end\nend", "def buy_fruit(list)\n quantities = []\n list.each { |item| item[1].times { quantities << item[0] } }\n quantities\nend", "def count_occurrences(array)\n array.uniq.each { |word| puts \"#{word} => #{array.count(word)}\"}\nend", "def length_finder(input_array)\n #input_array.map { |s| s.length }\n input_array.map(&:length)\nend", "def buy_fruit(deep_list)\n list = []\n deep_list.each do |fruits|\n fruits[1].times do\n list << fruits[0]\n end\n end\n list\nend", "def buy_fruit(list)\n list.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def buy_fruit(list)\n list.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def buy_fruit(list)\n list.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def count_list(array)\n counter = 0\n array.each do |num|\n counter +=1\n end\ncounter\nend", "def element_count(array)\n\nend", "def length_finder(input_array)\n input_array.map { |elem| elem.size }\nend", "def gem_stones array\n\n gem_list = []\n\n array.map! do |x|\n x.chars.uniq.sort\n end\n\n sum_of_array = array.flatten\n freq = Hash.new(0)\n sum_of_array.each do |key|\n freq.store(key, freq[key]+1)\n end\n freq.each do |key, value|\n if value == array.size\n gem_list << key\n end\n end\n gem_list \nend", "def count_elements(array)\n\nend", "def count_items(electives)\n electives.length #counts number of items in the array\nend", "def length_finder(input_array)\n\toutput_array = input_array.map{ |string| string.length}\nend", "def Occurrence_count(arr)\n\th1={}\n\tarr.each do |element|\n\t\th1[\"#{element}\"].nil? ? h1[\"#{element}\"]=1 : h1[\"#{element}\"]+=1\n\tend\n\th1.each do |key,value|\n\t\tputs \"\tOccurrence of #{ key } in the array is #{value} times \"\n\tend\t\nend", "def buy_fruit(fruits)\n result = []\n fruits.each do |pair|\n pair.last.times { |i| result << pair.first}\n end\n result\nend", "def deep_count(arr)\n count = 0\n arr.each do |el|\n if el.class != Array\n count += 1\n else\n count += 1 + deep_count(el)\n end\n end\n count\nend", "def subarray_count(subarray)\n\t\t\t\t\teach_cons(subarray.length).count(subarray)\n\t\t\t end", "def length_finder(input_array)\n total = []\n input_array.each { |word| total << word.length }\n return total\nend", "def add_item_counts(cart:[])\n cart.each do |item|\n item.map { |food_item, info| info[:count] = count_item(food_item, cart) }\n end\nend", "def tally(hand)\n arr = hand.map{|e| e[0]} #gets the second element of the nested array (cos arrays are zero indexed)\n running_total = 0 #initialise this at the beginning & then iterate through each value to get the total from our new hand_total array\n \n arr.each do |value|\n if value == 'A'\n running_total += 11\n elsif value == 'J' || value == 'Q' || value == 'K' #could also say value.to_i ==0 because it would fail and return a 0\n running_total += 10\n else\n running_total += value.to_i\n end\n end\n\n # correct for Aces\n arr.select{|e| e == \"A\"}.count.times do\n running_total -= 10 if running_total > 21\n end\n \n running_total\nend", "def count(array)\n count = 0\n array.each do |x|\n count += 1\n end\n\n return count\nend", "def buy_fruit(fruit_list)\n fruit_array = []\n fruit_list.each do |fruit, quantity|\n quantity.times { fruit_array << fruit }\n end\n fruit_array\nend", "def mix_names(girls_array, boys_array)\n b_i = 0 \n boys_array.length.times do \n girls_array << boys_array[b_i]\n b_i += 1 \n end \n output = girls_array\n return output\nend", "def dimension_finder(array)\n if array.any? { |nested_array| nested_array.is_a?(Array) }\n dim = array.group_by { |nested_array| nested_array.is_a?(Array) && dimension_finder(nested_array) }.keys\n [array.size] + dim.first if dim.size == 1 && dim.first\n else\n [array.size]\n end\n end", "def length_finder(input_array)\n result=Array.new\n input_array.each do |string|\n result << string.length\n end\n return result\nend", "def count_occurrences(array)\n\toccurences = {}\n\n\tarray.each do |element|\n\t\toccurences[element] = array.count(element)\n\tend\n\n\toccurences.each do |element, count|\n\t\tputs \"#{element} => #{count}\"\n\tend\t\nend", "def count_occurrences(arr)\n unique_elements = arr.uniq\n unique_elements.each { |element| puts \"#{element} => #{arr.count(element)}\"}\nend", "def look_and_say(array)\n return [] if array.empty?\n\n output = [[1, array[0]]]\n\n (1...array.length).each do |idx|\n el = array[idx]\n if el == output.last[1]\n output.last[0] += 1\n else\n output << [1, el]\n end\n end\n\n output\nend", "def PowerSetCount(arr)\n combinations = []\n (0..arr.size).each { |combo| combinations += arr.combination(combo).to_a }\n combinations.size\nend", "def look_and_say(array)\n output = []\n count = 1\n current = array[0]\n (1...array.length).each do |index|\n if array[index] == current\n count += 1\n else\n output << [count, current]\n current = array[index]\n count = 1\n end\n end\n output << [count, current]\nend", "def my_uniq(arr)\n #make hash with each item in teh array as a key, and the value will be its frequency\n new_arr = []\n freqhash = Hash.new(0)\n arr.each do |ele| \n freqhash[ele] += 1\n end\n \n freqhash.each do |k, v| \n new_arr << k\n end\n \n new_arr\nend", "def pets_by_breed(pet_shop, type)\n\n counter = []\n\n for pet in pet_shop[:pets]\n if pet[:breed] == type\n counter.push(pet)\n end\n end\n return counter\nend", "def fruit_plural(fruits)\n fruits_arr = []\n counter = 0\n \n loop do \n break if counter == fruits.size\n \n current_value = fruits[counter]\n fruits_arr << current_value.concat(\"s\")\n \n counter += 1\n end\n \n fruits_arr\nend", "def count_elements(array_of_hashes)\n array_of_hashes.each do |hashes|\n hashes[:count] = 0\n # this creates a new key-value in our hash, count: 0\n name = hashes[:name]\n # this creates a new variable 'name' and assigns it the name from each hash\n array_of_hashes.each do |hash|\n # repeats the loop of iteration through array_of_hashes\n if name == hash[:name]\n # tests our variable 'name' == the :name key\n hashes[:count] += 1\n #if so, adds +1 to our count key.\n end\n end\n end.uniq\n # This removes any duplicates\n # We can apply this to the end of our loop by adding it to 'end'\nend", "def words_longer_than(array,num)\n new_array = []\n array.map{ |w|\n new_array.push(w.count(\"e\"))\n }\n letter_per_word(new_array, new_array.length)\nend" ]
[ "0.7587965", "0.71324956", "0.70461273", "0.6976981", "0.6890353", "0.68251824", "0.6657469", "0.66036433", "0.6483378", "0.643137", "0.6420295", "0.6403345", "0.6367472", "0.63482946", "0.6333552", "0.6330763", "0.6317521", "0.625491", "0.62327856", "0.6191003", "0.61901855", "0.61750895", "0.6174906", "0.6163688", "0.6137887", "0.6126603", "0.61249006", "0.6099931", "0.6092991", "0.60900867", "0.60741204", "0.6073607", "0.606848", "0.6042148", "0.60276294", "0.60174334", "0.6008954", "0.60067254", "0.5992554", "0.5990968", "0.59892774", "0.5975355", "0.5964222", "0.5957174", "0.59509903", "0.59460485", "0.5913811", "0.5913397", "0.5893168", "0.5882075", "0.58802056", "0.5874952", "0.58732367", "0.58660185", "0.5837616", "0.5831731", "0.5802721", "0.57998437", "0.57960427", "0.57791066", "0.5758636", "0.57510865", "0.5737532", "0.5736714", "0.57326996", "0.5719869", "0.57183653", "0.57061404", "0.56894207", "0.56894207", "0.56894207", "0.5680985", "0.5678536", "0.5677067", "0.5675717", "0.5675074", "0.5670963", "0.5669507", "0.56685615", "0.5637115", "0.5631987", "0.56203", "0.5614494", "0.5614444", "0.5601527", "0.5588319", "0.55843276", "0.55567914", "0.5547731", "0.5547168", "0.5541805", "0.5530829", "0.5526621", "0.5526487", "0.55250394", "0.55242664", "0.5520404", "0.5519893", "0.5511672", "0.55048156" ]
0.70899475
2
associated with the PUT action so when we hit this url with a PUT request, this will run
def update # find our post id = params[:id] @post = Post.find(id) # increment the number of votes if params[:tweet] == "true" @post.votes = @post.votes + 1 @post.save elsif params[:flagged] == "true" @post.flagged = @post.flagged + 1 @post.save end # TODO: ask Tom what this does again render :json => @post end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put!\n request! :put\n end", "def put(request)\n request.method = :put\n request.call\n end", "def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def put(*args)\n request :put, *args\n end", "def update\n put :update\n end", "def put(url, body = {})\n call(url: url, action: :put, body: body)\n end", "def put(action, **args); end", "def put url, object = nil\n request url, HTTP::Put, object\n end", "def update(request)\n end", "def update(request)\n end", "def put(*args)\n request(:put, *args)\n end", "def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end", "def put(uri, params = {}, env = {}, &block)\n super(uri, params, env, &block).tap do |response|\n record_request_response_pair!('put')\n end\n end", "def poteti_put(action, parameters = nil, session = nil, flash = nil)\n process_action(action, parameters, session, flash, 'PUT')\n end", "def put(url, vars={})\n send_request url, vars, 'PUT'\n end", "def put?\r\nHTTP_METHOD_LOOKUP[request_method] == :put\r\nend", "def put(request)\n _request(request) { |client, options| client.put options }\n end", "def put_update\n response = self.class.put(\"/service/#{$service_id}/version/#{$service_version}/logging/sftp/#{$name}\", \n headers: { \"Fastly-Key\" => $key }, \n body: $put_form_data )\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def put url, payload\n RestClient::Request.execute(:method => :put, :url => url, :payload => payload, :headers => lbaas_headers, :timeout => @timeout, :open_timeout => @open_timeout)\n end", "def perform_put(path, options = {})\n perform_request(:put, path, options)\n end", "def update!(**args)\n @action = args[:action] if args.key?(:action)\n @uri = args[:uri] if args.key?(:uri)\n end", "def update!(**args)\n @action_type = args[:action_type] if args.key?(:action_type)\n @url = args[:url] if args.key?(:url)\n end", "def update!(**args)\n @action_type = args[:action_type] if args.key?(:action_type)\n @url = args[:url] if args.key?(:url)\n end", "def put endpoint, data\n do_request :put, endpoint, data\n end", "def put(action, params={}, options={})\n request(:put, action, params, options)\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 put(path, &block)\n route 'PUT', path, &block\n end", "def create_method\n :http_put\n end", "def create_method\n :http_put\n end", "def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def update\n unless @action.nil?\n log_action( action.name, @environment[:api_key] )\n\n @success.call( action ) if @success && @action\n @action = nil;\n end\n end", "def fire_put(url_or_path, entity, options = {}, &block)\n url = absolute_url(url_or_path)\n headers = {:Accept => MEDIA_TYPE_JSON, :'Content-type' => ENCODED_MEDIA_TYPE_JSON}.\n merge(options.fetch(:headers, {}))\n headers = merge_log_weasel_header(headers)\n timeout = options.fetch(:timeout, Ladon.default_request_timeout)\n body = encode_entity(entity)\n response = Typhoeus::Request.put(url, headers: headers, timeout: timeout, body: body)\n handle_response(response, method: :put, url: url, default_data: options[:default_data],\n raise_on_error: options[:raise_on_error], &block)\n end", "def run\n\t\treq = Net::HTTP::Put.new(uri.path)\n\t\treq.body = query_string\n\t\tres = Net::HTTP.start(url.host, url.port) { |http|\n\t\t http.request(req)\n\t\t}\n\t\tres.body\n\tend", "def put(url, options = {}, &block)\n run! Request.new(url, :put, options.slice(:headers, :params, :payload), &block)\n end", "def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end", "def put(object, url, headers={})\n do_request(\"put\", url, object, headers)\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def api_put_request(url_prefix, data, raw_response = false)\n to_put = URI.escape(url_prefix)\n request = Net::HTTP::Put.new(to_put)\n request.body = data\n @logger.info \"PUT #{to_put}\"\n exec_request(request, raw_response, data)\n end", "def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend", "def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend", "def put(request)\n do_request(request) { |client| client.http_put request.body }\n end", "def update(*args)\n put(*args)\n end", "def update(*args)\n put(*args)\n end", "def put(*args, &block)\n self.client.put *args\n end", "def update\n head :ok\n end", "def put(payload = {})\n request! do\n api[url.path].put(to_payload(payload), API_HEADERS)\n end\n end", "def do_PUT(req, res)\n perform_proxy_request(req, res) do |http, path, header|\n http.put(path, req.body || '', header)\n end\n end", "def do_put(uri = '', body = '')\n build_request(:put, uri, body)\n end", "def put(data = \"\")\n submit :Put, data\n end", "def update\n head :unauthorized\n end", "def cfa_update\n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : Entered in cfa titles cfa_update method\"\n \n begin\n params.permit!\n data=params[\"cfas\"]\n cfa={:cfa_title=>{\"job_name\": params[:job_name]}}\n cfa=RestClient.put $api_service+'/cfa_titles/'+data[:id],cfa \n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : cfa_updated successfully\"\n rescue =>e\n Rails.logger.custom_log.error { \"#{e}cfas_controller cfa_update method\" }\n end\n redirect_to :action => \"index\"\n # redirect_to :action => \"show\" ,:id=>data[:id]\n end", "def put(url, options = {}, &block)\n request HttpPut, url, options, &block\n end", "def update #saves and redirects, saves changes\n end", "def update(params={})\n self.request(__method__, params)\n end", "def put(uri, params = {})\n send_request(uri, :put, params)\n end", "def put options\n rest_request({ method: :put }.merge(options))\n end", "def put options\n rest_request({ method: :put }.merge(options))\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def on_put(resource_uri, opts)\n debug \"on_put: #{resource_uri}\"\n resource = update_resource(resource_uri, true, opts)\n show_resource(resource, opts)\n end", "def put(path, payload)\n req = Net::HTTP::Put.new(path)\n action(req, payload)\n end", "def http_put(url, params, &request_modifier)\n uri = URI.parse url\n req = Net::HTTP::Put.new uri.path\n req.set_form_data(params)\n request_modifier && (request_modifier.call req)\n\n session = (Net::HTTP.new uri.host, uri.port)\n case res = session.start { |http| http.request req }\n when Net::HTTPSuccess, Net::HTTPRedirection\n # OK\n else\n res.error!\n end\n end", "def update(params)\n self.class.new reinit_endpoint(params).do_put\n end", "def put url, body, headers = {}\n http_request(url, Net::HTTP::Put, body, headers)\n end", "def put(url, payload, headers={})\n RestClient.put url, payload, headers\n end", "def update\n\n\tend", "def update\n\n\tend", "def alchemy_put(action, parameters = nil, session = nil, flash = nil)\n process_alchemy_action(action, parameters, session, flash, \"PUT\")\n end" ]
[ "0.73253626", "0.6931096", "0.6782932", "0.6775214", "0.67483354", "0.660166", "0.6557152", "0.654198", "0.65378946", "0.65378946", "0.65154064", "0.64241236", "0.6372714", "0.63434434", "0.63321036", "0.6321409", "0.6302976", "0.6284745", "0.6266784", "0.62501836", "0.62467384", "0.623432", "0.62014675", "0.62014675", "0.6199513", "0.6194385", "0.61795676", "0.6172721", "0.6143566", "0.6143566", "0.6141267", "0.6135051", "0.61219984", "0.6096402", "0.60950935", "0.60681844", "0.6053469", "0.604971", "0.6036517", "0.6033923", "0.60331523", "0.6028782", "0.6027856", "0.6027856", "0.60207856", "0.601972", "0.6016247", "0.60039884", "0.59953", "0.59938306", "0.59736603", "0.5956109", "0.5945984", "0.5944728", "0.5939239", "0.59035486", "0.5902273", "0.5902273", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5901914", "0.5900992", "0.5898482", "0.589829", "0.5895103", "0.5893616", "0.58892107", "0.5886859", "0.5886859", "0.5884944" ]
0.0
-1
Creates a new MList::Message and delivers it to the subscribers of this list.
def post(email_or_attributes) email = email_or_attributes email = MList::EmailPost.new(email_or_attributes) unless email.is_a?(MList::EmailPost) process_message messages.build( :parent => email.reply_to_message, :parent_identifier => email.parent_identifier, :mail_list => self, :subscriber => email.subscriber, :recipients => list.recipients(email.subscriber), :email => MList::Email.new(:source => email.to_s) ), :search_parent => false, :copy_sender => email.copy_sender end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @message = Mailboxer::Message.new\n p User.get_recipient_list(@user.id)\n p 'hola world'\n @recipients = User.get_recipient_list(@user.id)\n end", "def message_create(originator, recipients, body, params={})\n # Convert an array of recipients to a comma-separated string.\n recipients = recipients.join(',') if recipients.kind_of?(Array)\n\n Message.new(request(\n :post,\n 'messages',\n params.merge({\n :originator => originator.to_s,\n :body => body.to_s,\n :recipients => recipients })))\n end", "def create\n @message = Message.new(params[:message])\n if params[:recipient_ids]\n recipients = User.find(params[:recipient_ids])\n for rec in recipients\n @message.recipients << MessageRecipient.new({:user_id => rec.id, :message_id => @message.id, :read => :false, :parent_id => current_user.id})\n end\n end\n\n respond_to do |format|\n if current_user.messages << @message\n if params[:sendmethod] == \"Instant\"\n if @message.send_message!\n flash[:notice] = \"Successfully sent...\"\n format.html { redirect_to sent_account_messages_url }\n else\n flash[:error] = \"An error has been raised...\"\n end\n else\n flash[:notice] = 'Message was successfully created.'\n format.html { redirect_to outbox_account_messages_url }\n end\n \n \n format.xml { render :xml => @message, :status => :created, :location => @message }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @message.errors, :status => :unprocessable_entity }\n end\n end\n end", "def message_create(originator, recipients, body, params = {})\n # Convert an array of recipients to a comma-separated string.\n recipients = recipients.join(',') if recipients.is_a?(Array)\n\n Message.new(request(\n :post,\n 'messages',\n params.merge(originator: originator.to_s,\n body: body.to_s,\n recipients: recipients)\n ))\n end", "def newMessage\n message = Message.last\n\n MagicMailer.newMessage(message)\n end", "def create_message(options = {})\n post(\"inbox/messages\", messages: [options]).pop\n end", "def create\n message = Message.new(message_params)\n message.user = current_user\n if message.save\n # 'messages' is name of channel we are broadcasting to\n ActionCable.server.broadcast 'messages',\n # Set message and user\n message: message.content,\n user: message.user.first_name\n head :ok\n end\n end", "def create\n @message = Message.new(params[:message])\n if @message.save\n MessageMailer.notify_private_message_sent(@message.sender, @message.receiver).deliver\n puts \"FOI\"\n end\n respond_with(@message)\n end", "def rx_message(data)\n\t\t# Get the current user from connection.rb and then create the Message\n\t\tcurrent_user.messages.create(content: data['message'], to_id: nil) # Nil means the global chatroom\n\tend", "def reply\n message = self.message.class.new(:subject => subject, :body => body)\n message.sender = receiver\n message.to(sender)\n message\n end", "def new_message(from, to, subject, message)\r\n rec = to.clone\r\n subs = to.concat([from])\r\n conv = Conversation.create(subs)\r\n time = Time.new\r\n message = Message.create(from, rec, subject, time, message, nil)\r\n\r\n subs.each{ |s| self.message_boxes[s.to_s].add_conversation(conv)}\r\n conv.add_message(message)\r\n\r\n self.conversations.store(conv.conversation_id.to_s, conv)\r\n conv\r\n end", "def receive_message(params={}, *attrs)\n self.class.receive_message(queue_url, params, *attrs).map do |val|\n Message.new self, val\n end\n end", "def send_new_message_notification\n message = self.message\n # Don't notify the message sender themselves\n return if message.sender_id == self.user_id\n data = {\n category: 'message',\n message: message.body.truncate(150, separator: ' '),\n is_private: message.is_private,\n offer_id: message.offer_id,\n order_id: message.order_id,\n item_id: message.item_id,\n author_id: message.sender_id,\n message_id: message.id\n }\n channel = Channel.private_channels_for(self.user_id, app_name)\n PushService.new.send_notification(channel, app_name, data)\n end", "def newMessage\n @message = Message.new\n end", "def create\n message = msg_params\n @msg = Msg.new(msg_params)\n thesender = @msg.sender\n thesentdate = @msg.sent\n theservertime = DateTime.now\n unless @msg.content.empty? || @msg.sender.empty?\n ActionCable.server.broadcast 'room_channel',\n content: @msg.content,\n sender: thesender,\n servertime: theservertime\n end\n end", "def create\n @message = Message.new params[:message]\n @message.save\n respond_with @message, location: after_send_path, notice: t('hyalin.messages.sent_success')\n end", "def publish( message )\n subscribers.each do |name, subscriber|\n subscriber.produce( message )\n end\n end", "def recevoirMessage(message)\r\n\t\t@lstMessages[message.id] = message\r\n\tend", "def create\n @message = Message.new(message_param)\n @message_thread = MessageThread.find(@message.message_thread_id)\n\n @message.receiver = current_user.equal_user?(@message_thread.started_user) ? @message_thread.to_user : @message_thread.started_user\n @message.sender = current_user\n @message.is_sender_read = true\n @message.is_receiver_read = false\n\n if @message.save\n flash[:success] = \"Message has been sent!\"\n redirect_to @message_thread\n end\n end", "def create\n @mailing_list = MailingList.new(mailing_list_params)\n if @mailing_list.save\n redirect_to new_message_path, notice: 'You have subscribed to our Mailing List'\n else\n @message = Message.new\n render template: \"messages/new\"\n end\n end", "def create_message(user_id, recipient_id, token , subject, message)\n response = self.class.post('/messages', body: { \"user_id\": user_id, \"recipient_id\": recipient_id,\"token\": token , \"subject\": subject, \"stripped-text\": message }, headers: { \"authorization\" => @auth_token })\n puts response\n\n end", "def deliver(message, _options = {})\n raise ArgumentError, \"too many recipients, max. is #{MAX_RECIPIENT}\" if message.to.length > MAX_RECIPIENT\n\n from = message.from.present? ? message.from.to_s : from_number.to_s\n\n raise ArgumentError, 'no from number given on new message or the transport given' if from.empty?\n\n client = Twilio::REST::Client.new(account_sid, auth_token)\n messages = prepare_numbers(message.to).map do |n|\n client.messages.create(\n from: from,\n to: n,\n body: message.body\n )\n end\n numbers = messages.map do |result|\n result.try(:to)\n end\n NumberList.new.push numbers.compact\n end", "def forward\n message = self.message.class.new(:subject => subject, :body => body)\n message.sender = receiver\n message\n end", "def create\n chatroommessage = ChatroomMessage.new(permitted_params)\n chatroom = Chatroom.find(permitted_params[:chatroom_id])\n if chatroommessage.save\n serialized_data = ActiveModelSerializers::Adapter::Json.new(\n ChatroomMessageSerializer.new(chatroommessage)\n ).serializable_hash\n ChatroomMessagesChannel.broadcast_to chatroom, serialized_data\n head :ok\n end\n end", "def reply\n message = self.class.new(:subject => subject, :body => body)\n message.sender = sender\n message.to(to)\n message\n end", "def create\n @message = Message.new(message_params.merge(read: false))\n\n if @message.sender == @message.message_thread.seller\n @message.receiver = @message.message_thread.buyer\n else\n @message.receiver = @message.message_thread.seller\n end\n\n respond_to do |format|\n if @message.save\n MessageBroadcastController.publish('/messages', @message.detailed_attributes)\n format.json { render json: @message.attributes, status: :created }\n else\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_message(message)\n @message = message\n mail(\n :from => message.email,\n :to => '[email protected]',\n :subject => 'New Message From ' + message.email\n )\n end", "def create\n @message = Message.new(message_params)\n\n if @message.save\n @user = User.find(@message.user_id)\n @user.messages << @message\n render json: @message, status: :created\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end", "def deliver(message) \n @channel.send(:add_message, message)\n end", "def create\n # @message = Message.new(message_params)\n # @message is built by CanCanCan\n respond_to do |format|\n if @message.save\n @message.notify(:commoners, group: @message.conversation) if @message.in_conversation?\n @message.notify(:commoners, group: @message.discussion) if @message.in_discussion?\n format.html { redirect_to success_path, notice: _('Message sent') }\n else\n @new_message = @message\n @messages = Message.where(messageable: messageable)\n format.html { render \"#{messageable.class.class_name.downcase.pluralize}/show\" }\n end\n end\n end", "def send_message(msg)\n\t\t\tdb_update({}, {'$push' => { 'messages' => msg.id.to_db } })\n\t\t\tmessages.add(msg)\n\t\tend", "def create_message(options={})\n author = options[:author]\n messageable = options[:messageable]\n params = options[:params]\n subject = RecipientsFor::Subject.new(params)\n subject.messageable_type = messageable.class.name\n subject.messageable_id = messageable.id\n if subject.save\n set_author_on_subject(author, subject)\n create_reader_infos(\n messageble: messageable,\n subject: subject\n )\n ActiveSupport::Notifications.instrument('message_created', subject_id: subject.id)\n end\n subject\n end", "def new_message(message)\n @message = message\n mail_ids = @message.batch.students.pluck(:email)*\",\"\n mail to: \"#{mail_ids}\", subject: \"A message from your trainer\"\n end", "def create\n @message = Message.new(message_params)\n # require authentication + channel membership\n @message.author_id = @current_user.id;\n @message.channel_id = @channel.id;\n\n if @message.save\n # later we can require only broadcasting to 'live' users\n @channel.users.each do |user|\n UserChannel.broadcast_to(user, {message: @message})\n end\n render json: {ok: true}, status: :created\n else\n errors = {}\n @message.errors.each { |err| errors[err] = @message.errors.full_messages_for(err) }\n render json: errors, status: :unprocessable_entity\n end\n end", "def new_message(msg,opts={})\n opts = default_opts.merge(opts)\n msg_uri = RDF::URI.new(\"http://cogi.strinz.me/messages/#{opts[:id]}\")\n mem = repo\n rdf_msg = Cogibara::Message.for(msg_uri)\n\n mem.insert([msg_uri, RDF.type, onto_class.Message])\n rdf_msg.message = msg\n rdf_msg.message_id = opts[:id] if opts[:id]\n # mem.insert([msg_uri, onto_prop.message_string, msg])\n # mem.insert([msg_uri, onto_prop.message_id, opts[:id]]) if opts[:id]\n\n if opts[:to]\n u_to = Cogibara::User.new(opts[:to])\n u_to.received_messages << rdf_msg.subject\n rdf_msg.to = u_to.subject\n u_to.save\n # mem.insert([msg_uri, onto_prop.to_user, opts[:to]]) if opts[:to]\n end\n\n if opts[:from]\n u_from = Cogibara::User.new(opts[:from])\n u_from.sent_messages << rdf_msg.subject\n rdf_msg.from = u_from.subject\n u_from.save\n # mem.insert([msg_uri, onto_prop.from_user, opts[:from]])\n end\n\n rdf_msg.save\n\n rdf_msg\n end", "def create\n @message = Message.new(message_params)\n create_q(@message)\n end", "def create\n @message = Message.new(message_params)\n @message.sender_id = current_user.id\n @message.recipient_id = params[:recipient_id]\n\n respond_to do |format|\n if @message.save\n flash[:notice] = \"Mesaj gönderildi.\"\n format.json { render json: {success: true} } \n # Pusher.trigger('private-'+params[:recipient_id],'new_message', {:from => current_user.name, \n # :subject => @message.subject})\n else\n flash[:error] = \"Mesaj gönderilemedi.\"\n redirect_to '/'\n end\n end\n end", "def reply\n message = self.message.class.new(:subject => \"Re: #{subject}\",\n :body => body.gsub(/^/, '> '))\n message.sender = receiver\n message.to(sender)\n message\n end", "def create\n @recipients = \n if params[:_recipients].present?\n @recipients = params[:_recipients].split(',').map{ |r| Actor.find(r) }\n else\n []\n end\n\n @receipt = @actor.send_message(@recipients, params[:body], params[:subject], sanitize_text = false, attachment = nil)\n if (@receipt.errors.blank?)\n @conversation = @receipt.conversation\n flash[:success]= t('mailboxer.sent')\n redirect_to conversation_path(@conversation, :box => :sentbox)\n else\n render :action => :new\n end\n end", "def create\r\n @message = Message.new(message_params).tap do |m|\r\n m.user = current_user\r\n m.channel = @channel\r\n end\r\n\r\n if @message.save\r\n push_notification :add\r\n @message.mark_as_read! for: current_user\r\n end\r\n\r\n render inline: \"{}\"\r\n end", "def new_message(obj)\n @obj = obj\n @admin_recipients = User.role_users(:admin).map(&:email)\n @author_recipients = User.role_users(:author).map(&:email)\n @recipients = @admin_recipients\n emails = @recipients.join(\",\")\n m = [\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\"].join(\",\")\n mail to: m\n end", "def persist_message(params)\n message = params[:subscribable].messages.create(content: params[:message])\n params[:message_object] = message\n continue(params)\n end", "def create\n @message = current_owner.messages_as_sender.new(message_params)\n respond_to do |format|\n if @message.save\n format.html { redirect_to messages_path, notice: 'Message was successfully created.' }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_message(message)\n @message = message\n\n mail to: @message.user.email\n end", "def receives_messages\n Messenger.resolve(@@default_messenger).add_message_handler do |message|\n new.received(message)\n end\n end", "def message(msg, options={})\n (@messages ||= []) << options.merge({:message => msg})\n proc_with_message(messages.last, &@message_proc) if @message_proc\n end", "def message_list(filters = {})\n params = { limit: 10, offset: 0 }.merge(filters).compact\n query = \"messages?#{URI.encode_www_form(params)}\"\n\n List.new(Message, request(:get, query))\n end", "def add(msg)\n attributes = {:message => msg, :conversation => msg.conversation}\n attributes[:mailbox] = @type.to_s unless @type == :all\n attributes[:read] = msg.sender.id == @user.id\n mail_msg = MailItem.new(attributes)\n @user.mail_items << mail_msg\n return mail_msg\n end", "def create\n\t\tchannel_sid = params[:channel_sid]\n\t\t@client = Twilio::REST::Client.new(ENV['account_sid'], ENV['auth_token'])\n\t\t# Add the member\n\t\tservice = @client.chat.v2.services(ENV['service_sid'])\n\t\tchannel = service.channels(channel_sid)\n\t\tmessage = channel.messages.create(body: params[:body])\n\t\tputs message\n\t\tresponse = \"{\\n\\\"message\\\": \\\"Message sent\\\"\\n}\"\n\t\tjson_response(response)\n\tend", "def create\n message = Message.new(message_params)\n conversation = Conversation.find(message_params[:conversation_id])\n message.username = message.user.username\n if message.save\n serialized_data = ActiveModelSerializers::Adapter::Json.new(\n MessageSerializer.new(message)).serializable_hash\n MessagesChannel.broadcast_to(conversation, serialized_data)\n # ActionCable.server.broadcast 'conversations_channel', serialized_data\n head :ok\n # binding.pry\n end\n end", "def new_message(message)\n @message = message\n mail\n end", "def create\n \n @message = current_user.messages.build(params[:message])\n\n \n if @message.save\n \n flash[:notice] = \"Message Sent\"\n else \n flash[:notice] = \"Opps.\"\n end\n \n end", "def create\n user = User.find_by(token: params[:token])\n new_message_params = {\n text: message_params[:text],\n conversation_id: message_params[:conversation_id],\n user_id: user.id,\n username: user.username\n }\n @message = Message.new(new_message_params)\n conversation = Conversation.find(message_params[:conversation_id])\n\n if @message.save\n # render json: @message, status: :created, location: @message\n serialized_data = ActiveModelSerializers::Adapter::Json.new(\n MessageSerializer.new(@message)\n ).serializable_hash\n MessagesChannel.broadcast_to conversation, serialized_data\n head :ok\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end", "def deliver\n response = Curl::Easy.http_post(\n BASE_URL + 'messages',\n Curl::PostField.content('to', @to),\n Curl::PostField.content('from', @from),\n Curl::PostField.content('subject', @subject),\n Curl::PostField.content('text', @text)\n )\n @response = JSON.parse(response.body)\n end", "def add_message(client_id, data, ttl)\n id = @id_counter.to_s(16)\n @id_counter += 1\n message = MockMessage.new(id, self, client_id, data, ttl)\n @messages << message\n message\n end", "def build_message\n @subject = RecipientsFor::Subject.new\n @content = RecipientsFor::Content.new\n end", "def new_message(*phrases) Message.new(*phrases); end", "def create\n # if params[:user_id].to_i == current_user[:id]\n # return\n # end\n @message = Message.new(message_params)\n @message.user = current_user\n @message.room_id = params[:room_id]\n @messages = Message.all\n ActionCable.server.broadcast \"room_channel_#{@message.room_id}\", message: @message\n\n if @message.save\n render json: @message\n else\n render plain: \"Failed to create a message\", status: :unprocessable_entity\n end\n end", "def new_message_admin(from_user, to_user, message)\n @from_user = from_user\n @to_user = to_user\n @message = message\n\n mail(:subject => \"#{@to_user.full_name} has a new message!\")\n end", "def initialize\n @messages = []\n end", "def produce( message )\n @client.set( @name, message )\n return ::Qup::Message.new( message.object_id, message )\n end", "def voice_message_create(recipients, body, params={})\n # Convert an array of recipients to a comma-separated string.\n recipients = recipients.join(',') if recipients.kind_of?(Array)\n\n VoiceMessage.new(request(\n :post,\n 'voicemessages',\n params.merge({ :recipients => recipients, :body => body.to_s })))\n end", "def create\n @receiver = User.find(message_params[:receiver])\n @message = Message.create(sender: current_user, receiver: @receiver, status: 0, message: message_params[:message])\n if @message.save\n flash[:success] = 'Message was successfully sent.'\n redirect_to new_message_path\n else\n flash[:error] = 'Something wrong!'\n render :new\n end\n end", "def create\n recipient_ids = params[:recipients]\n recipients = User.where(id: recipient_ids)\n\n @receipt = @user.send_message(recipients, params[:message][:body], params[:message][:subject])\n if (@receipt.errors.blank?)\n if params[:confirm_message]\n @receipt.mark_as_unread\n end\n redirect_to messages_path(box: \"outbox\")\n else\n render :action => :new\n end\n end", "def send_message(receiver, message)\r\n Message.create!(:sender => self, :receiver => receiver, :subject => message.subject, :body => message.body)\r\n end", "def send_message(receiver, message)\r\n Message.create!(:sender => self, :receiver => receiver, :subject => message.subject, :body => message.body)\r\n end", "def new\n message = params[:message]\n image_url = params[:image_url]\n\n begin\n Subscriber.where(:subscribed => true).each do |s|\n s.send_message message, image_url\n end\n flash[:success] = \"Messages on their way!\"\n rescue Exception => e\n flash[:alert] = \"Something when wrong: #{e.message}\"\n end\n redirect_to '/'\n end", "def voice_message_create(recipients, body, params = {})\n # Convert an array of recipients to a comma-separated string.\n recipients = recipients.join(',') if recipients.is_a?(Array)\n\n VoiceMessage.new(request(\n :post,\n 'voicemessages',\n params.merge(recipients: recipients, body: body.to_s)\n ))\n end", "def new_message(user, message)\n @user = user\n @message = message\n @service = @message.service\n mail(to: @user.email, subject: 'New message sent through SocialPresence')\n end", "def new_message_email(message,receiver)\n @message = message\n @receiver = receiver\n @conversation = @message.conversation\n\n if @conversation.reservation.present?\n @reservation = @conversation.reservation\n end\n\n set_subject(message)\n mail :to => receiver.send(Mailboxer.email_method, message),\n :subject => t('mailboxer.message_mailer.subject_new', :subject => @subject),\n :template_name => 'new_message_email'\n end", "def create\n\n @message = Message.new(message_params)\n @message.sender = current_user\n @message.recipients << current_user\n to = params[:to]\n if to.nil?\n group = Group.find_by(id: params[:group_id])\n @message.groups << group\n to = []\n unless group.nil?\n group.users.each do |user|\n to << user.username\n end\n end\n else\n to = to.split(/\\s*,\\s*/)\n end\n to.each do |user_str|\n user = User.find_by(username: user_str)\n if user.nil?\n user = User.find_by(email: user_str)\n end\n unless user.nil?\n unless @message.recipients.include?(user)\n @message.recipients << user\n end\n end\n end\n\n respond_to do |format|\n if @message.save\n if group.nil?\n format.html { redirect_to messages_url, notice: 'Message was successfully created.' }\n else\n format.html { redirect_to group, notice: 'Message was successfully created.' }\n end\n format.json { render :show, status: :created, location: @message }\n else\n format.html { redirect_to messages_url }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_message(params = {})\n response = post('secret_mails/new.json', params)\n Croudia::Object::SecretMail.new(response)\n end", "def new_messageble(options={})\n messageble = options[:messageble],\n readers = options[:readers]\n find_or_create_receipients(\n messageble: options[:messageble],\n personas: options[:readers],\n notifications: options[:notifications]\n )\n @subject = RecipientsFor::Subject.new\n @content = RecipientsFor::Content.new\n end", "def message(body: nil, to: nil, from: nil, method: nil, action: nil, status_callback: nil, **keyword_args)\n message = Message.new(\n body: body,\n to: to,\n from: from,\n method: method,\n action: action,\n status_callback: status_callback,\n **keyword_args\n )\n\n yield(message) if block_given?\n append(message)\n end", "def forward\n message = self.class.new(:subject => subject, :body => body)\n message.sender = sender\n message\n end", "def create\n \n @message = current_user.messages.build(params[:message])\n if @message.save\n \n \n @account_sid = 'ACdb43c99b5deb7d4ed12083140f41bab3'\n @auth_token = '11dbb8cbba9b004652469aa77e51183c'\n\n # set up a client to talk to the Twilio REST API\n @client = Twilio::REST::Client.new(@account_sid, @auth_token)\n ha = HashWithIndifferentAccess.new(params[:message])\n mssg = ha['content']\n\n friends = {\n \"+14159006499\" => \"Jered\",\n \"+11111111111\" => \"Chris\",\n \"+11111111111\" => \"Kathryn\"}\n\n @account = @client.account\n @message = @account.sms.messages.create({:to => '+14159006499', :from => '+18319204556', :body => mssg})\n puts @message\n flash[:success] = \"Message created!\"\n redirect_to 'http://www.bugl.co/acknowledge.html'\n\n else\n @feed_items = []\n render 'static_pages/home'\n end\n \n @message = Message.new(params[:message])\n\n respond_to do |format|\n if @message.save\n \n format.json { render json: @message, status: :created, location: @message }\n else\n \n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @message = Message.new(message_params)\n\n if @message.save\n ActionCable.server.broadcast 'room_channel', content: @message.content, user_name: @message.user.name\n # head :ok\n end\n end", "def message(body: nil, to: nil, from: nil, action: nil, method: nil, status_callback: nil, **keyword_args)\n message = Message.new(body: body, to: to, from: from, action: action, method: method, status_callback: status_callback, **keyword_args)\n\n yield(message) if block_given?\n append(message)\n end", "def create\n\t\t@recipients = Array.new\n\t\tif params[:_recipients].present?\n\t\t\tparams[:_recipients].each do |recp_id|\n\t\t\t\trecp = Actor.find_by_id(recp_id)\n\t\t\t\tnext if recp.nil?\n\t\t\t\t@recipients << recp\n\t\t\tend\n\t\tend\n\t\t@receipt = @actor.send_message(@recipients, params[:body], params[:subject])\n\t\tif (@receipt.errors.blank?)\n\t\t\t@conversation = @receipt.conversation\n flash[:success]=\"Your message was sent\"\n\t\t\tredirect_to conversation_path(@conversation, :box => :sentbox)\n\t\telse\n\t\t\trender :action => :new\n\t\tend\n\tend", "def create_message(data); end", "def create_message(data); end", "def notify(msg)\n @room_queue.push(msg)\n end", "def deliver\n xml = Clockwork::XML::SMS.build_multiple( self.messages )\n http_response = Clockwork::HTTP.post( Clockwork::API::SMS_URL, xml, @use_ssl )\n responses = Clockwork::XML::SMS.parse_multiple( self.messages, http_response )\n end", "def create\n @message = Message.new(params[:message])\n respond_to do |format|\n if @message.save\n \t@messageMail = Message.last()\n \ttopic = @messageMail.topic\n \tname = @messageMail.name\n \temail = @messageMail.email\n \tmessage = @messageMail.message\n \tMessageMailer.newMessage(topic, name, email, message).deliver \n format.html { redirect_to \"/contact\", notice: 'Your message has been sent. Thank you for contacting us.' }\n format.json { render json: @message, status: :created, location: @message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_message_to_members(message)\n response = ''\n to_list = @members.map do |member|\n '[To:' + member.to_s + ']'\n end.join()\n uri = URI.encode(\"/v1/rooms/#{@user_info['room_id']}/messages?body=#{to_list}\\n#{message}\")\n\n @api_https_.start do\n response = @api_https_.post(uri, '', @api_header_)\n end\n end", "def send_message message\n payload = { \"text\" => message }.to_json\n data = client.post \"#{api_prefix}/rooms/#{id}/chatMessages\", payload\n\n Message.new client, id, data\n end", "def messages\n @messages ||= @message_list.map.with_index do |payload, index|\n Message.new(payload, @starting_channel_sequence + index)\n end\n end", "def create\n recipients = User.where(id: params['recipients']) || [User.find_by_id(params[:uid].keys.first)]\n conversation = current_user.send_message(recipients, params[:message][:body], params[:message][:subject]).conversation\n flash[:success] = (I18n.locale == :sw ? \"Ujumbe wako umetumwa\" : \"Your message has been sent\")\n redirect_to conversation_path(conversation)\n end", "def send_message (*params)\n send_line Message.new(*params)\n end", "def create\n\n @message = current_user.messages.build\n @message.subject = params[:message][:subject]\n @message.body = params[:message][:body]\n# @message.to User.find_by_username(params[:message][:to])\n @message.to User.find(:all, :conditions=>[\"username IN (\\\"#{params[:message][:to].split(',').join(\"\\\",\\\"\")}\\\")\" ]) unless params[:message][:to].nil?\n\n\n respond_to do |format|\n if @message.save\n @message.deliver\n\n flash[:notice] = 'Message was successfully created.'\n format.html { redirect_to(@message) }\n format.xml { render :xml => @message, :status => :created, :location => @message }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @message.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @message = Message.new\n respond_with @message\n end", "def add_to_message_queue(msg_type, socket_send_message)\n #message = [\"#{msg_type}|#{socket_send_message}|\\n\"] # Cria o array de mensagens\n # Verifica todos os objetos em comum e partilha entre os jogadores\n # [:uuid, :x, :y, :direction].each do |instance|\n # # Pega cada instancia do objeto e adiciona na mensagem \n # end\n @messages.push << \"#{msg_type}|#{socket_send_message}\"\n p \"CLIENT: Added to queue: #{@messages}\"\n end", "def listen_for_messages\n @queue.subscribe do |_delivery_info, _metad5ata, payload|\n data = JSON.parse(payload)\n display_message(data['user'], data['message'])\n end\n end", "def index\n collect_messages\n @message = Message.new\n #Stalker.enqueue('email.send', :to => '[email protected]')\n end", "def create\n @to = User.find(params[:message][:to])\n current_user.send_message(@to, params[:message][:topic], params[:message][:body])\n redirect_to outbox_url\n end", "def create\n @message = current_user.send_message params[:message]\n if @message.new_record?\n render :action => \"new\"\n else\n flash[:notice] = \"The message was saved successfully.\"\n redirect_to messages_path\n end\n end", "def new\n @message = current_user.messages.build\n end", "def new_message_email(message,receiver)\n @message = message\n @receiver = receiver\n set_subject(message)\n mail :to => receiver.send(Mailboxer.email_method, message),\n :from => \"Panel KW Kraków <reply+#{message.conversation.code}@panel.kw.krakow.pl>\",\n :subject => @subject,\n :template_name => 'new_message_email'\n end", "def create\n @message = Message.new(message_params)\n @message.sender = current_user\n @message.receiver = @user\n @message.read = false\n respond_to do |format|\n if @message.save\n format.html { redirect_to messages_user_path(@user.id, 1), flash: { :success => 'Message was successfully sent.' } }\n format.json { render :index, status: :created, location: @message }\n else\n set_messages\n format.html { render :show }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def process_email(email, subscriber)\n recipients = list.recipients(subscriber)\n process_message messages.build(\n :mail_list => self,\n :subscriber => subscriber,\n :recipients => recipients,\n :email => email\n ), :copy_sender => list.copy_sender?(subscriber)\n end", "def add_message(type, text)\n @messages ||= []\n @messages.push({type: type, text: text})\n end" ]
[ "0.6398173", "0.62860376", "0.62821066", "0.6262946", "0.6243486", "0.6243401", "0.6191331", "0.61237687", "0.61068827", "0.60916877", "0.6033017", "0.6032903", "0.60327256", "0.59819627", "0.59638673", "0.59467804", "0.5908018", "0.5872774", "0.5853226", "0.58456683", "0.5839617", "0.58392024", "0.58261096", "0.5822039", "0.5815898", "0.5815673", "0.5813941", "0.5808208", "0.5800448", "0.5783697", "0.57747936", "0.57659984", "0.5762538", "0.5749324", "0.5746889", "0.5744102", "0.5729534", "0.5727822", "0.5705229", "0.57042533", "0.5690542", "0.568859", "0.56878006", "0.56867075", "0.5682184", "0.56811535", "0.56728995", "0.56695503", "0.56692", "0.5667153", "0.56663275", "0.5658487", "0.5651358", "0.5651023", "0.5650598", "0.56398314", "0.5638108", "0.5628642", "0.56265604", "0.5622241", "0.5620496", "0.5616893", "0.56138635", "0.5612568", "0.560944", "0.560944", "0.56032544", "0.56031996", "0.56010485", "0.55980456", "0.5593686", "0.5593686", "0.55914146", "0.5588168", "0.5582731", "0.55799526", "0.5579674", "0.5577676", "0.5570639", "0.5569705", "0.5569705", "0.55678767", "0.5549426", "0.5549232", "0.55459243", "0.55445904", "0.5540763", "0.5539219", "0.55356085", "0.5534395", "0.5533375", "0.55328196", "0.5514167", "0.551416", "0.55087054", "0.5500152", "0.5499641", "0.5496668", "0.5496182", "0.54950804", "0.54921824" ]
0.0
-1
Processes the email received by the MList::Server.
def process_email(email, subscriber) recipients = list.recipients(subscriber) process_message messages.build( :mail_list => self, :subscriber => subscriber, :recipients => recipients, :email => email ), :copy_sender => list.copy_sender?(subscriber) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_mail(mail, config)\n end", "def receive_inbound_email_from_mail(**kwargs, &block); end", "def process_mail(mail, config)\n end", "def process\n parsed = {}\n parsed[:contents] = \"#{@email.subject} ::: #{@email.body}\"\n parsed[:from] = \"#{@email.from[:email]}\"\n #[:to] is an array of hashes, since possible multiple to's\n parsed[:to] = \"#{@email.to[0][:email]}\"\n\n email_of_interest = parsed[:to]\n if !(/@/.match(parsed[:to]))\n Rails.logger.warn \"Poorly formatted email! parsed: #{parsed}\"\n end\n\n object = Person.react_to_email(email_of_interest)\n if object.class.to_s == \"Person\"\n Communication.create(person_id: object.id,\n contents: parsed[:contents],\n medium: \"email\",\n when: Date.today)\n end\n end", "def scan(mhead, mbody)\n return nil unless mhead['from'].start_with?('\"Mail Delivery System\"')\n return nil unless mhead['subject'] == 'Mail delivery failed: returning message to sender'\n\n dscontents = [Sisimai::Bite.DELIVERYSTATUS]\n hasdivided = mbody.split(\"\\n\")\n rfc822list = [] # (Array) Each line in message/rfc822 part string\n blanklines = 0 # (Integer) The number of blank lines\n readcursor = 0 # (Integer) Points the current cursor position\n recipients = 0 # (Integer) The number of 'Final-Recipient' header\n v = nil\n\n while e = hasdivided.shift do\n if readcursor == 0\n # Beginning of the bounce message or delivery status part\n if e.start_with?(StartingOf[:message][0])\n readcursor |= Indicators[:deliverystatus]\n next\n end\n end\n\n if (readcursor & Indicators[:'message-rfc822']) == 0\n # Beginning of the original message part\n if e.start_with?(StartingOf[:rfc822][0])\n readcursor |= Indicators[:'message-rfc822']\n next\n end\n end\n\n if readcursor & Indicators[:'message-rfc822'] > 0\n # After \"message/rfc822\"\n if e.empty?\n blanklines += 1\n break if blanklines > 1\n next\n end\n rfc822list << e\n else\n # Before \"message/rfc822\"\n next if (readcursor & Indicators[:deliverystatus]) == 0\n next if e.empty?\n\n # The following address failed:\n #\n # [email protected]\n #\n # For the following reason:\n #\n # Mail size limit exceeded. For explanation visit\n # http://postmaster.1and1.com/en/error-messages?ip=%1s\n v = dscontents[-1]\n\n if cv = e.match(/\\A([^ ]+[@][^ ]+)\\z/)\n # [email protected]\n if v['recipient']\n # There are multiple recipient addresses in the message body.\n dscontents << Sisimai::Bite.DELIVERYSTATUS\n v = dscontents[-1]\n end\n v['recipient'] = cv[1]\n recipients += 1\n\n elsif e.start_with?(StartingOf[:error][0])\n # For the following reason:\n v['diagnosis'] = e\n else\n # Get error message and append error message strings\n v['diagnosis'] << ' ' << e if v['diagnosis']\n end\n end\n end\n return nil unless recipients > 0\n\n dscontents.each do |e|\n e['agent'] = self.smtpagent\n e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'].to_s.gsub(/\\A#{StartingOf[:error][0]}/, ''))\n\n MessagesOf.each_key do |r|\n # Verify each regular expression of session errors\n next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }\n e['reason'] = r.to_s\n break\n end\n end\n\n rfc822part = Sisimai::RFC5322.weedout(rfc822list)\n return { 'ds' => dscontents, 'rfc822' => rfc822part }\n end", "def process_message_response\n # Is this email confirming receipt of a previous message? \n msg_id = find_message_id_tag(:subject=>@subject, :body=>@body)\n#puts \"**** body=#{@body}, msg_id=#{msg_id}\"\n if msg_id \n # Does the \"confirmed message\" id actually match a message?\n message = Message.find_by_id(msg_id)\n if message\n msg_tag = message_id_tag(:id => msg_id, :action => :confirm_tag) # e.g. !2104\n search_target = Regexp.new('[\\'\\s\\(\\[]*' + \"#{Regexp.escape(msg_tag)}\" + '[\\'\\s\\.,\\)\\]]*')\n # The main reason to strip out the tag (like !2104) from the message is that it may be the\n # first part of the response, if there is one; e.g. \"!2104 Kafanchan\" replying to a message\n # requesting location. \n user_reply = first_nonblank_line(@body)\n#puts \"**** user_reply='#{user_reply}'\"\n user_reply = user_reply.sub(search_target, ' ').strip if user_reply\n # Mark all members with this email address as having responded to this message\n @possible_senders.each do |a_member|\n message.process_response(:member => a_member, :text => user_reply, :mode => 'email')\n end\n else\n msg_tag = message_id_tag(:id => msg_id, :action => :create, :location => :body)\n Notifier.send_generic(@from_address, I18n.t('error_msg.invalid_confirmation')).deliver\n end\n end\n end", "def scan(mhead, mbody)\n return nil unless mhead['x-mlserver']\n return nil unless mhead['from'] =~ /.+[-]admin[@].+/\n return nil unless mhead['message-id'] =~ /\\A[<]\\d+[.]FML.+[@].+[>]\\z/\n\n dscontents = [Sisimai::Bite.DELIVERYSTATUS]\n hasdivided = mbody.split(\"\\n\")\n rfc822list = [] # (Array) Each line in message/rfc822 part string\n blanklines = 0 # (Integer) The number of blank lines\n readcursor = 0 # (Integer) Points the current cursor position\n recipients = 0 # (Integer) The number of 'Final-Recipient' header\n v = nil\n\n readcursor |= Indicators[:deliverystatus]\n while e = hasdivided.shift do\n if (readcursor & Indicators[:'message-rfc822']) == 0\n # Beginning of the original message part\n if e == StartingOf[:rfc822][0]\n readcursor |= Indicators[:'message-rfc822']\n next\n end\n end\n\n if readcursor & Indicators[:'message-rfc822'] > 0\n # After \"Original mail as follows:\" line\n #\n # From [email protected] Mon Nov 20 18:10:11 2017\n # Return-Path: <[email protected]>\n # ...\n #\n if e.empty?\n blanklines += 1\n break if blanklines > 1\n next\n end\n rfc822list << e.lstrip\n else\n # Before \"message/rfc822\"\n next if (readcursor & Indicators[:deliverystatus]) == 0\n next if e.empty?\n\n # Duplicated Message-ID in <[email protected]>.\n # Original mail as follows:\n v = dscontents[-1]\n\n if cv = e.match(/[<]([^ ]+?[@][^ ]+?)[>][.]\\z/)\n # Duplicated Message-ID in <[email protected]>.\n if v['recipient']\n # There are multiple recipient addresses in the message body.\n dscontents << Sisimai::Bite.DELIVERYSTATUS\n v = dscontents[-1]\n end\n v['recipient'] = cv[1]\n v['diagnosis'] = e\n recipients += 1\n else\n # If you know the general guide of this list, please send mail with\n # the mail body \n v['diagnosis'] ||= ''\n v['diagnosis'] << e\n end\n end\n end\n return nil unless recipients > 0\n\n dscontents.each do |e|\n e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])\n e['agent'] = self.smtpagent\n e.each_key { |a| e[a] ||= '' }\n\n ErrorTable.each_key do |f|\n # Try to match with error messages defined in ErrorTable\n next unless e['diagnosis'] =~ ErrorTable[f]\n e['reason'] = f.to_s\n break\n end\n\n unless e['reason']\n # Error messages in the message body did not matched\n ErrorTitle.each_key do |f|\n # Try to match with the Subject string\n next unless mhead['subject'] =~ ErrorTitle[f]\n e['reason'] = f.to_s\n break\n end\n end\n end\n\n rfc822part = Sisimai::RFC5322.weedout(rfc822list)\n return { 'ds' => dscontents, 'rfc822' => rfc822part }\n end", "def process_emails(reader_info)\n notifications = reader_info.notifications\n notifications.each do |notification|\n case notification[:notification_type]\n when \"email\"\n send_email(reader_info) if notification[:checked]\n when \"internal\"\n send_internal(reader_info) if notification[:checked]\n when \"sms\"\n send_sms(reader_info) if notification[:checked]\n when \"e-boks\"\n send_e_boks(reader_info) if notification[:checked]\n end\n end\n end", "def process_mailbox\n handler.process\n end", "def process\n return 'OK' if @email.to.first[:token] == 'example'\n return process_image if @email.to.first[:token] == 'flyers'\n\n token = ReplyToken.find(@email.to.first[:token])\n\n case token.reply_type\n when 'participation_request'\n process_participation_request(token)\n when 'conversation'\n process_conversation(token)\n when 'comment'\n process_comment(token)\n when 'community'\n process_community_reply(token)\n end\n\n track_reply(token)\n\n token.use!\n end", "def scan(mhead, mbody)\n match = 0\n match += 1 if mhead['subject'] =~ /\\AUndeliverable Mail[ ]*\\z/\n match += 1 if mhead['x-mailer'].to_s.start_with?('<SMTP32 v')\n return nil unless match > 0\n\n dscontents = [Sisimai::Bite.DELIVERYSTATUS]\n hasdivided = mbody.split(\"\\n\")\n rfc822list = [] # (Array) Each line in message/rfc822 part string\n blanklines = 0 # (Integer) The number of blank lines\n readcursor = 0 # (Integer) Points the current cursor position\n recipients = 0 # (Integer) The number of 'Final-Recipient' header\n v = nil\n\n while e = hasdivided.shift do\n if readcursor == 0\n # Beginning of the bounce message or delivery status part\n if e == StartingOf[:message][0]\n readcursor |= Indicators[:deliverystatus]\n next\n end\n end\n\n if (readcursor & Indicators[:'message-rfc822']) == 0\n # Beginning of the original message part\n if e == StartingOf[:rfc822][0]\n readcursor |= Indicators[:'message-rfc822']\n next\n end\n end\n\n if readcursor & Indicators[:'message-rfc822'] > 0\n # After \"message/rfc822\"\n if e.empty?\n blanklines += 1\n break if blanklines > 1\n next\n end\n rfc822list << e\n else\n # Before \"message/rfc822\"\n break if readcursor & Indicators[:'message-rfc822'] > 0\n\n # Unknown user: [email protected]\n #\n # Original message follows.\n v = dscontents[-1]\n\n if cv = e.match(/\\A([^ ]+)[ ](.+)[:][ \\t]*([^ ]+[@][^ ]+)/)\n # Unknown user: [email protected]\n if v['recipient']\n # There are multiple recipient addresses in the message body.\n dscontents << Sisimai::Bite.DELIVERYSTATUS\n v = dscontents[-1]\n end\n v['diagnosis'] = cv[1] + ' ' + cv[2]\n v['recipient'] = cv[3]\n recipients += 1\n\n elsif cv = e.match(/\\Aundeliverable[ ]+to[ ]+(.+)\\z/)\n # undeliverable to [email protected]\n if v['recipient']\n # There are multiple recipient addresses in the message body.\n dscontents << Sisimai::Bite.DELIVERYSTATUS\n v = dscontents[-1]\n end\n v['recipient'] = cv[1]\n recipients += 1\n else\n # Other error message text\n v['alterrors'] << ' ' << e if v['alterrors']\n v['alterrors'] = e if e.include?(StartingOf[:error][0])\n end\n end\n end\n return nil unless recipients > 0\n\n dscontents.each do |e|\n e['agent'] = self.smtpagent\n\n unless e['alterrors'].to_s.empty?\n # Copy alternative error message\n e['diagnosis'] = if e['diagnosis']\n e['alterrors'] + ' ' + e['diagnosis']\n else\n e['alterrors']\n end\n e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])\n e.delete('alterrors')\n end\n e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])\n\n ReSMTP.each_key do |r|\n # Detect SMTP command from the message\n next unless e['diagnosis'] =~ ReSMTP[r]\n e['command'] = r.to_s.upcase\n break\n end\n\n ReFailures.each_key do |r|\n # Verify each regular expression of session errors\n next unless e['diagnosis'] =~ ReFailures[r]\n e['reason'] = r.to_s\n break\n end\n e.each_key { |a| e[a] ||= '' }\n end\n\n rfc822part = Sisimai::RFC5322.weedout(rfc822list)\n return { 'ds' => dscontents, 'rfc822' => rfc822part }\n end", "def process_msgs\n end", "def on_mail_from_event(ctx, mail_from_data); end", "def handle_message( from, to_list, message )\n # Strip SMTP commands from To: and From:\n from.gsub!( /MAIL FROM:\\s*/, \"\" )\n to_list = to_list.map { |to| to.gsub( /RCPT TO:\\s*/, \"\" ) }\n\n puts \"* Message begins\"\n puts \" From: #{from}\"\n puts \" To: #{to_list.join(\", \")}\"\n puts \" Body:\"\n puts message\n puts \"\\n* Message ends\"\n\n end", "def receive(email, raw_email)\n # Find which info requests the email is for\n # We deliberately don't use Envelope-to here, so ones that are BCC\n # drop into the holding pen for checking.\n reply_info_requests = [] # XXX should be set?\n for address in (email.to || []) + (email.cc || [])\n reply_info_request = InfoRequest.find_by_incoming_email(address)\n reply_info_requests.push(reply_info_request) if reply_info_request\n end\n\n # Nothing found, so save in holding pen\n if reply_info_requests.size == 0 \n InfoRequest.holding_pen_request.receive(email, raw_email)\n return\n end\n\n # Send the message to each request, to be archived with it\n for reply_info_request in reply_info_requests\n reply_info_request.receive(email, raw_email)\n end\n end", "def receive(email)\n if email && email.from && email.from.first\n @dest_address=email.to.first.to_s\n logger.info @dest_address\n if @dest_address.include?(\"#{APP_CONFIG[:project_email]}\")\n new_post_create_via_mail(email)\n elsif @dest_address.include?(\"#{APP_CONFIG[:message_email]}\")\n new_message_create_via_mail(email)\n elsif @dest_address.downcase.include?(\"ctzm\")\n comment_for_message_via_mail(email)\n end\n end\n end", "def process(event)\n debug do\n mailer = event.payload[:mailer]\n action = event.payload[:action]\n \"#{mailer}##{action}: processed outbound mail in #{event.duration.round(1)}ms\"\n end\n end", "def receive_email\n \n \n #if one of the to addresses matches us, use that one. todo - correctly handle mulitple emails, or correctly fail\n if params[:to].match(/group\\+(\\d+)@/) && @group = Group.find($1)\n from = params[:from]\n body = params[:plain].gsub(/^On .* wrote:$\\s*(^>.*$\\s*)+/,'') #strip out replies and whatnot\n\n if @sender = @group.students.find_by_email(from)\n @group.send_message(@sender.name+\": \"+body,@sender,[@group.user])\n elsif @group.user.email==from\n @group.send_message(@group.user.display_name+\": \"+body,@group.user)\n end\n end\n render :text => 'success', :status => 200\n end", "def on_mail_from_event(ctx, mail_from_data) end", "def process_message_body\n @attachments = []\n if @mail.multipart?\n @body, @html = [], []\n scan_parts(@mail)\n @body = @body.join(\"\\n\")\n @html = @html.join(\"\\n\")\n else\n if @mail.content_type =~ /text\\/html/\n @html = @mail.body.to_s\n @body = ''\n else\n @body = @mail.body.to_s\n @html = ''\n end\n end\n\n @body = convert_to_utf8(@body)\n @html = convert_to_utf8(@html)\n end", "def check\n # if the server doesn't support us, we just do nothing.\n return unless Config.server.respond_to?(:broadcast_message)\n\n info \"starting email checker loop\"\n\n Thread.new do\n loop do\n debug \"checking email\"\n\n begin\n with_imap do |imap|\n imap.search(['NOT', 'DELETED']).each do |message_id|\n info \"mail found, handling\"\n handle_message_id(imap, message_id)\n end\n end\n\n rescue Exception => ex\n error \"checking email: #{ex}\"\n end\n\n break unless poll_email?\n\n sleep (Config.email['interval'] || 30)\n end\n end\n end", "def receive(email)\n # debugger\n @email = email\n sender_email = email.from.to_a.first.to_s.strip\n # Ignore emails received from the application emission address to avoid hell cycles\n if sender_email.downcase == Setting.mail_from.to_s.strip.downcase\n logger.info \"ContactsMailHandler: ignoring email from Redmine emission address [#{sender_email}]\" if logger && logger.info\n return false\n end\n @user = User.find_by_mail(sender_email) if sender_email.present?\n if @user.nil? || (@user && [email protected]?)\n logger.info \"ContactsMailHandler: user not found [#{sender_email}]\" if logger && logger.info\n end\n dispatch\n end", "def handle(uids)\n each_message uids, 'text/plain' do |uid, mail|\n @mail = mail\n @url = nil\n @description = nil\n\n case mail.from.first\n when '[email protected]' then\n next false unless handle_a2atransfer\n when '[email protected]' then\n next false unless handle_alert\n when '[email protected]' then\n next false unless handle_hsbc\n else\n log \"Unknown From: #{mail.from.join ', '}\"\n next false\n end\n\n add_item mail.subject, @description, mail.from, mail.date, @url,\n mail.message_id, 'HSBC'\n end\n end", "def receive(email)\n post = Post.new\n\n # Will fail if no matches. Rely on validation\n list_post_header = email.header_string(\"List-Post\")\n matches = list_post_header.match(/<mailto:(\\S+)@/) if list_post_header\n if matches\n mailing_list_name = matches[1]\n else\n mailing_list_name = email.to.first.to_s\n end\n post.mailing_list = MailingList.find_by_name(mailing_list_name)\n\n post.subject = email.subject\n \n if email.multipart?\n plain_text_part = nil\n\n # Outlook\n related_part = email.parts.find { |part| \n part.content_type == \"multipart/related\"\n }\n if related_part\n alt_part = related_part.parts.find { |part| \n part.content_type == \"multipart/alternative\"\n }\n else\n alt_part = email.parts.find { |part| \n part.content_type == \"multipart/alternative\"\n }\n end\n \n # OS X rich text email\n if alt_part \n plain_text_part = alt_part.parts.find { |part| \n part.content_type == \"text/plain\"\n }\n end\n\n plain_text_part = email.parts.find { |part| \n part.content_type == \"text/plain\"\n } unless plain_text_part\n \n plain_text_part = email.parts.find { |part| \n part.content_type == \"text/html\"\n } unless plain_text_part\n \n post.body = plain_text_part.body\n end\n \n if post.body.blank?\n post.body = email.body\n end\n \n post.from_name = email.friendly_from\n post.from_email_address = email.from\n post.date = email.date\n begin\n post.save!\n rescue => save_error\n RACING_ON_RAILS_DEFAULT_LOGGER.error(\"Could not save post: #{save_error}\")\n if post and !post.errors.empty?\n RACING_ON_RAILS_DEFAULT_LOGGER.error(post.errors.full_messages)\n end\n raise\n end\n end", "def tick \n mailer.messages.each do |request| \n response = mailer.new_message(:to => request.from, \n :from => settings.service.default_sender)\n\n process_request(request, response) && response.deliver\n end\n rescue StandardError => e\n logger.fatal(\"SERVER ERROR\") { \"#{e.inspect}\\n\" + e.backtrace.join(\"\\n \") }\n raise\n end", "def receive(local_port, local_hostname, remote_port, remote_hostname, remote_ip)\n # Start a hash to collect the information gathered from the receive process\n @contact = Contact::new(remote_ip)\n @mail = ItemOfMail::new\n @mail[:contact_id] = @contact[:id]\n @mail[:local_port] = local_port\n @mail[:local_hostname] = local_hostname\n @mail[:remote_port] = remote_port\n @mail[:remote_hostname] = remote_hostname\n @mail[:remote_ip] = remote_ip\n @mail[:saved] = true # prevent saving until we have at least a MAIL FROM\n LOG.info(@mail[:mail_id]) {\"New item of mail opened with id '#{@mail[:mail_id]}'\"}\n\n # start the main receiving process here\n @done = false\n @encrypted = false\n @authenticated = false\n @warning_given = false\n @mail[:encrypted] = false\n @mail[:authenticated] = nil\n send_text(connect_base)\n @level = 1\n response = \"252 2.5.1 Administrative prohibition\"\n begin\n begin\n break if @done\n text = recv_text\n # the client closed the channel abruptly or we're forcing QUIT\n if (text.nil?) || @warning_given\n text = \"QUIT\"\n @contact.violation\n end\n # this handles an attempt to connect with HTTP\n if text.start_with?(\"GET\")\n LOG.error(@mail[:mail_id]) {\"An attempt was made to connect with a web browser\"}\n @mail[:saved] = true # prevent saving\n raise Quit\n end\n # main command detect loop\n unrecognized = true\n Patterns.each do |pattern|\n break if pattern[0]>@level\n m = text.match(/^#{pattern[1].upcase}$/i)\n if m\n case\n when pattern[2]==:quit\n send_text(quit(m[1]))\n when pattern[0]>@level\n send_text(\"500 5.5.1 Command out of sequence\")\n else\n response = send(pattern[2], m[1])\n @contact.violation if send_text(response)=='5'\n end\n unrecognized = false\n break\n end\n end\n if unrecognized\n response = \"500 5.5.1 Unrecognized command #{text.inspect}, incorrectly formatted command, or command out of sequence\"\n @contact.violation\n send_text(response)\n end\n end until @done\n\n rescue => e\n LOG.fatal(@mail[:mail_id]) {e.inspect}\n exit(1)\n end\n\n # print the intermediate structure into the log (for debugging)\n (LOG.info(@mail[:mail_id]) { \"Received Mail:\\n#{@mail.pretty_inspect}\" }) if DumpMailIntoLog\n\n ensure\n # run the mail queue queue runner now, if it's not running already\n ok = nil\n File.open(LockFilePath,\"w\") do |f|\n ok = f.flock( File::LOCK_NB | File::LOCK_EX )\n f.flock(File::LOCK_UN) if ok\n end\n if ok\n pid = Process::spawn(\"#{$app[:path]}/run_queue.rb\")\n Process::detach(pid)\n LOG.info(@mail[:mail_id]) {\"Spawned run_queue.rb, pwd=#{`pwd`.chomp}, path=>#{$app[:path]}, pid=>#{pid.inspect}\"}\n end\n end", "def deliver_email\n#puts \"**** deliver_email: emails=#{emails}\"\n emails = @contact_info.map {|c| c[:email]}.compact.uniq\n self.subject ||= 'Message from SIM Nigeria'\n id_for_reply = self.following_up || id # a follow-up message uses id of the original msg\n#puts \"**** Messages#deliver_email response_time_limit=#{response_time_limit}\"\n outgoing = Notifier.send_group_message(:recipients=>emails, :content=>self.body, \n :subject => subject, :id => id_for_reply , :response_time_limit => response_time_limit, \n :bcc => true, :following_up => following_up) # send using bcc:, not to:\nraise \"send_email with nil email produced\" if outgoing.nil?\n outgoing.deliver\n # Mark all as being sent, but only if they have an email address\n # This is terribly inefficient ... need to find a way to use a single SQL statement\n sent_messages.each do |sm| \n sm.update_attributes(:msg_status => MsgSentToGateway) if sm.member.primary_email\n end\n end", "def scan(mhead, mbody)\n return nil unless mhead['from'] =~ /postmaster[@](?:biglobe|inacatv|tmtv|ttv)[.]ne[.]jp/\n return nil unless mhead['subject'].start_with?('Returned mail:')\n\n dscontents = [Sisimai::Bite.DELIVERYSTATUS]\n hasdivided = mbody.split(\"\\n\")\n rfc822list = [] # (Array) Each line in message/rfc822 part string\n blanklines = 0 # (Integer) The number of blank lines\n readcursor = 0 # (Integer) Points the current cursor position\n recipients = 0 # (Integer) The number of 'Final-Recipient' header\n v = nil\n\n while e = hasdivided.shift do\n if readcursor == 0\n # Beginning of the bounce message or delivery status part\n if e == StartingOf[:message][0]\n readcursor |= Indicators[:deliverystatus]\n next\n end\n end\n\n if (readcursor & Indicators[:'message-rfc822']) == 0\n # Beginning of the original message part\n if e == StartingOf[:rfc822][0]\n readcursor |= Indicators[:'message-rfc822']\n next\n end\n end\n\n if readcursor & Indicators[:'message-rfc822'] > 0\n # After \"message/rfc822\"\n if e.empty?\n blanklines += 1\n break if blanklines > 1\n next\n end\n rfc822list << e\n else\n # Before \"message/rfc822\"\n next if (readcursor & Indicators[:deliverystatus]) == 0\n next if e.empty?\n\n # This is a MIME-encapsulated message.\n #\n # ----_Biglobe000000/00000.biglobe.ne.jp\n # Content-Type: text/plain; charset=\"iso-2022-jp\"\n #\n # ----- The following addresses had delivery problems -----\n # ********@***.biglobe.ne.jp\n #\n # ----- Non-delivered information -----\n # The number of messages in recipient's mailbox exceeded the local limit.\n #\n # ----_Biglobe000000/00000.biglobe.ne.jp\n # Content-Type: message/rfc822\n #\n v = dscontents[-1]\n\n if cv = e.match(/\\A([^ ]+[@][^ ]+)\\z/)\n # ----- The following addresses had delivery problems -----\n # ********@***.biglobe.ne.jp\n if v['recipient']\n # There are multiple recipient addresses in the message body.\n dscontents << Sisimai::Bite.DELIVERYSTATUS\n v = dscontents[-1]\n end\n\n r = Sisimai::Address.s3s4(cv[1])\n if Sisimai::RFC5322.is_emailaddress(r)\n v['recipient'] = r\n recipients += 1\n end\n else\n next if e =~ /\\A[^\\w]/\n v['diagnosis'] ||= ''\n v['diagnosis'] << e + ' '\n end\n end\n end\n return nil unless recipients > 0\n\n dscontents.each do |e|\n e['agent'] = self.smtpagent\n e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])\n\n MessagesOf.each_key do |r|\n # Verify each regular expression of session errors\n next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }\n e['reason'] = r.to_s\n break\n end\n end\n\n rfc822part = Sisimai::RFC5322.weedout(rfc822list)\n return { 'ds' => dscontents, 'rfc822' => rfc822part }\n end", "def each_message(uids, type) # :yields: TMail::Mail\n parts = mime_parts uids, type\n\n uids = []\n\n each_part parts, true do |uid, message|\n mail = TMail::Mail.parse message\n\n begin\n success = yield uid, mail\n\n uids << uid if success\n rescue => e\n log e.message\n puts \"\\t#{e.backtrace.join \"\\n\\t\"}\" unless $DEBUG # backtrace at bottom\n log \"Subject: #{mail.subject}\"\n log \"Message-Id: #{mail.message_id}\"\n p mail.body if verbose?\n\n raise if $DEBUG\n end\n end\n\n uids\n end", "def scan(mhead, mbody)\n # :from => %r/\\AMAILER-DAEMON[@]/,\n # :subject => %r/\\AMail delivery failed: returning message to sender\\z/,\n return nil unless mhead['x-gmx-antispam']\n\n dscontents = [Sisimai::Bite.DELIVERYSTATUS]\n hasdivided = mbody.split(\"\\n\")\n rfc822list = [] # (Array) Each line in message/rfc822 part string\n blanklines = 0 # (Integer) The number of blank lines\n readcursor = 0 # (Integer) Points the current cursor position\n recipients = 0 # (Integer) The number of 'Final-Recipient' header\n v = nil\n\n while e = hasdivided.shift do\n if readcursor == 0\n # Beginning of the bounce message or delivery status part\n if e.start_with?(StartingOf[:message][0])\n readcursor |= Indicators[:deliverystatus]\n next\n end\n end\n\n if (readcursor & Indicators[:'message-rfc822']) == 0\n # Beginning of the original message part\n if e.start_with?(StartingOf[:rfc822][0])\n readcursor |= Indicators[:'message-rfc822']\n next\n end\n end\n\n if readcursor & Indicators[:'message-rfc822'] > 0\n # After \"message/rfc822\"\n if e.empty?\n blanklines += 1\n break if blanklines > 1\n next\n end\n rfc822list << e\n else\n # Before \"message/rfc822\"\n next if (readcursor & Indicators[:deliverystatus]) == 0\n next if e.empty?\n\n # This message was created automatically by mail delivery software.\n #\n # A message that you sent could not be delivered to one or more of\n # its recipients. This is a permanent error. The following address\n # failed:\n #\n # \"[email protected]\":\n # SMTP error from remote server after RCPT command:\n # host: mx.example.jp\n # 5.1.1 <[email protected]>... User Unknown\n v = dscontents[-1]\n\n if cv = e.match(/\\A[\"]([^ ]+[@][^ ]+)[\"]:\\z/) || e.match(/\\A[<]([^ ]+[@][^ ]+)[>]\\z/)\n # \"[email protected]\":\n # ---- OR ----\n # <[email protected]>\n #\n # Reason:\n # delivery retry timeout exceeded\n if v['recipient']\n # There are multiple recipient addresses in the message body.\n dscontents << Sisimai::Bite.DELIVERYSTATUS\n v = dscontents[-1]\n end\n v['recipient'] = cv[1]\n recipients += 1\n\n elsif cv = e.match(/\\ASMTP error .+ ([A-Z]{4}) command:\\z/)\n # SMTP error from remote server after RCPT command:\n v['command'] = cv[1]\n\n elsif cv = e.match(/\\Ahost:[ \\t]*(.+)\\z/)\n # host: mx.example.jp\n v['rhost'] = cv[1]\n else\n # Get error message\n if e =~ /\\b[45][.]\\d[.]\\d\\b/ || e =~ /[<][^ ]+[@][^ ]+[>]/ || e =~ /\\b[45]\\d{2}\\b/\n v['diagnosis'] ||= e\n else\n next if e.empty?\n if e.start_with?('Reason:')\n # Reason:\n # delivery retry timeout exceeded\n v['diagnosis'] = e\n\n elsif v['diagnosis'] == 'Reason:'\n v['diagnosis'] = e\n end\n end\n end\n end\n end\n return nil unless recipients > 0\n\n dscontents.each do |e|\n e['agent'] = self.smtpagent\n e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'].gsub(/\\\\n/, ' '))\n\n MessagesOf.each_key do |r|\n # Verify each regular expression of session errors\n next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }\n e['reason'] = r.to_s\n break\n end\n end\n\n rfc822part = Sisimai::RFC5322.weedout(rfc822list)\n return { 'ds' => dscontents, 'rfc822' => rfc822part }\n end", "def getEmailList()\n emailListFile = File.dirname(File.dirname(__FILE__)) + \"/config/\" +\n \"email_recepients.txt\"\n lines = IO.readlines(emailListFile)\n\n lines.each do |line|\n if line.match(/^EMAIL_RESULTS/)\n temp = line.gsub(/EMAIL_RESULTS=/, \"\")\n temp.strip!\n @resultRecepients = temp.split(\",\")\n elsif line.match(/^EMAIL_ERRORS/)\n temp = line.gsub(/EMAIL_ERRORS=/, \"\")\n temp.strip!\n @errorRecepients = temp.split(\",\") \n elsif line.match(/^EMAIL_CAPTURE/)\n temp = line.gsub(/EMAIL_CAPTURE=/, \"\")\n temp.strip!\n @captureRecepients = temp.split(\",\") \n end\n end\n end", "def process_mail_from sender\n if @state.include? :mail_from\n @state -= [:mail_from, :rcpt, :data]\n receive_reset\n end\n\n super\n end", "def process(event)\n mailer = event.payload[:mailer]\n action = event.payload[:action]\n duration = event.duration.round(1)\n log_with_formatter event: event do |fmt|\n { message: \"#{mailer}##{action}: processed outbound mail in #{duration}ms\" }\n end\n end", "def scan(mhead, mbody)\n match = 0\n match += 1 if mhead['from'].include?('[email protected]')\n match += 1 if mhead['from'].include?('[email protected]')\n match += 1 if mhead['subject'] == 'Mail System Error - Returned Mail'\n match += 1 if mhead['received'].any? { |a| a.include?('ezweb.ne.jp (EZweb Mail) with') }\n match += 1 if mhead['received'].any? { |a| a.include?('.au.com (') }\n if mhead['message-id']\n match += 1 if mhead['message-id'].end_with?('.ezweb.ne.jp>', '.au.com>')\n end\n return nil if match < 2\n\n dscontents = [Sisimai::Bite.DELIVERYSTATUS]\n hasdivided = mbody.split(\"\\n\")\n rfc822list = [] # (Array) Each line in message/rfc822 part string\n blanklines = 0 # (Integer) The number of blank lines\n readcursor = 0 # (Integer) Points the current cursor position\n recipients = 0 # (Integer) The number of 'Final-Recipient' header\n rxboundary = %r/\\A__SISIMAI_PSEUDO_BOUNDARY__\\z/\n v = nil\n\n if mhead['content-type']\n # Get the boundary string and set regular expression for matching with\n # the boundary string.\n b0 = Sisimai::MIME.boundary(mhead['content-type'], 1)\n rxboundary = Regexp.new('\\A' << Regexp.escape(b0) << '\\z') unless b0.empty?\n end\n rxmessages = []\n ReFailures.each_value { |a| rxmessages << a }\n\n while e = hasdivided.shift do\n if readcursor == 0\n # Beginning of the bounce message or delivery status part\n readcursor |= Indicators[:deliverystatus] if e =~ MarkingsOf[:message]\n end\n\n if (readcursor & Indicators[:'message-rfc822']) == 0\n # Beginning of the original message part\n if e =~ MarkingsOf[:rfc822] || e =~ rxboundary\n readcursor |= Indicators[:'message-rfc822']\n next\n end\n end\n\n if readcursor & Indicators[:'message-rfc822'] > 0\n # After \"message/rfc822\"\n if e.empty?\n blanklines += 1\n break if blanklines > 1\n next\n end\n rfc822list << e\n else\n # Before \"message/rfc822\"\n next if (readcursor & Indicators[:deliverystatus]) == 0\n next if e.empty?\n\n # The user(s) account is disabled.\n #\n # <***@ezweb.ne.jp>: 550 user unknown (in reply to RCPT TO command)\n #\n # -- OR --\n # Each of the following recipients was rejected by a remote\n # mail server.\n #\n # Recipient: <******@ezweb.ne.jp>\n # >>> RCPT TO:<******@ezweb.ne.jp>\n # <<< 550 <******@ezweb.ne.jp>: User unknown\n v = dscontents[-1]\n\n if cv = e.match(/\\A[<]([^ ]+[@][^ ]+)[>]\\z/) ||\n e.match(/\\A[<]([^ ]+[@][^ ]+)[>]:?(.*)\\z/) ||\n e.match(/\\A[ \\t]+Recipient: [<]([^ ]+[@][^ ]+)[>]/)\n\n if v['recipient']\n # There are multiple recipient addresses in the message body.\n dscontents << Sisimai::Bite.DELIVERYSTATUS\n v = dscontents[-1]\n end\n\n r = Sisimai::Address.s3s4(cv[1])\n if Sisimai::RFC5322.is_emailaddress(r)\n v['recipient'] = r\n recipients += 1\n end\n\n elsif cv = e.match(/\\AStatus:[ ]*(\\d[.]\\d+[.]\\d+)/)\n # Status: 5.1.1\n # Status:5.2.0\n # Status: 5.1.0 (permanent failure)\n v['status'] = cv[1]\n\n elsif cv = e.match(/\\AAction:[ ]*(.+)\\z/)\n # Action: failed\n v['action'] = cv[1].downcase\n\n elsif cv = e.match(/\\ARemote-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\\z/)\n # Remote-MTA: DNS; mx.example.jp\n v['rhost'] = cv[1].downcase\n\n elsif cv = e.match(/\\ALast-Attempt-Date:[ ]*(.+)\\z/)\n # Last-Attempt-Date: Fri, 14 Feb 2014 12:30:08 -0500\n v['date'] = cv[1]\n else\n next if Sisimai::String.is_8bit(e)\n if cv = e.match(/\\A[ \\t]+[>]{3}[ \\t]+([A-Z]{4})/)\n # >>> RCPT TO:<******@ezweb.ne.jp>\n v['command'] = cv[1]\n else\n # Check error message\n if rxmessages.any? { |a| e =~ a }\n # Check with regular expressions of each error\n v['diagnosis'] ||= ''\n v['diagnosis'] << ' ' << e\n else\n # >>> 550\n v['alterrors'] ||= ''\n v['alterrors'] << ' ' << e\n end\n end\n end\n end\n end\n return nil unless recipients > 0\n\n dscontents.each do |e|\n unless e['alterrors'].to_s.empty?\n # Copy alternative error message\n e['diagnosis'] ||= e['alterrors']\n if e['diagnosis'].start_with?('-') || e['diagnosis'].end_with?('__')\n # Override the value of diagnostic code message\n e['diagnosis'] = e['alterrors'] unless e['alterrors'].empty?\n end\n e.delete('alterrors')\n end\n e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])\n\n if mhead['x-spasign'].to_s == 'NG'\n # Content-Type: text/plain; ..., X-SPASIGN: NG (spamghetti, au by EZweb)\n # Filtered recipient returns message that include 'X-SPASIGN' header\n e['reason'] = 'filtered'\n else\n if e['command'] == 'RCPT'\n # set \"userunknown\" when the remote server rejected after RCPT\n # command.\n e['reason'] = 'userunknown'\n else\n # SMTP command is not RCPT\n catch :SESSION do\n ReFailures.each_key do |r|\n # Verify each regular expression of session errors\n ReFailures[r].each do |rr|\n # Check each regular expression\n next unless e['diagnosis'] =~ rr\n e['reason'] = r.to_s\n throw :SESSION\n end\n end\n end\n\n end\n end\n\n unless e['reason']\n # The value of \"reason\" is not set yet.\n # Deal as \"userunknown\" when the domain part of the recipient\n # is \"ezweb.ne.jp\".\n e['reason'] = 'userunknown' unless e['recipient'].end_with?('@ezweb.ne.jp', '@au.com')\n end\n e['agent'] = self.smtpagent\n end\n\n rfc822part = Sisimai::RFC5322.weedout(rfc822list)\n return { 'ds' => dscontents, 'rfc822' => rfc822part }\n end", "def new_message_event(message_hash)\n\t\tputs \"Processing new message...\"\n\t\tmessage_hash[:to].each do |rcpt|\n\t\t\tto = strip_brackets(rcpt)\n\t\t\tfrom = strip_brackets(message_hash[:from])\n\t\t\tsubj = message_hash[:subject]\n\t\t\tmsg = build_message(from, to, subj, message_hash[:data])\n\t\t\tdomain = to.split('@')[1]\n\t\t\tmx = get_MX_server(domain)\n\t\t\tNet::SMTP.start(mx) do |smtp|\n if $debug then puts \"Sending message to \" + to end\n\t\t\t\tsmtp.send_message(msg, from, to)\n\t\t\tend\n\t\tend\n\tend", "def execute\n @imap = Net::IMAP.new(@imap_setting[:server], @imap_setting[:port])\n @imap.login(@imap_setting[:user], @imap_setting[:password])\n @imap.select(@imap_setting[:folder])\n \n #process all mail read email with test in subject for testing purpose. In reality it will process all emails\n query = imap_setting[:mode] == \"prod\" ? ['NOT', 'SEEN'] : ['SUBJECT', 'test']\n @imap.uid_search(query).each do |uid|\n catch(:continue) do\n mail = TMail::Mail.parse( imap.uid_fetch(uid, 'RFC822').first.attr['RFC822'] )\n from = mail.from\n to = mail.to\n bcc = mail.bcc\n cc = mail.cc\n subject = mail.subject\n msgid = mail.message_id \n date = mail.date\n ref_msgid = [mail.in_reply_to, mail.references].flatten.compact.join(\" \") \n \n #normalize all email addresses\n from.map! {|address| normalize_address(address) }\n to.map! {|address| normalize_address(address) }\n cc.map! {|address| normalize_address(address) } unless cc.is_nil?\n bcc.map! {|address| normalize_address(address) } unless bcc.is_nil?\n\n #find matching user\n user = nil\n user_email = from.find do |f|\n user = User.find_by_email(f.downcase)\n end\n \n if user\n logger.info \"processing email for #{user.username}\"\n if bcc.include?(@imap_setting[:email])\n #if from as user or asignee to as contact and we are in bcc it's outbound\n contacts = to.map do |t|\n #find contact by user or assigned to\n contact = Contact.find_by_email_and_user(t, user)\n if contact.nil?\n contact = Contact.find_by_email_and_assignee(t, user)\n end\n \n if contact.nil?\n #create contact, user is emailing a contact that's not in FFC\n logger.info \"new contact #{t}\"\n contact = Contact.new\n contact.user = user\n contact.email = t\n unless contact.save \n logger.warn \"could not save contact #{t}\"\n contact = nil\n end\n end\n contact\n end\n contacts.compact!\n \n #save mail\n from_list = from.join(\" \")\n to_list = to.join(\" \")\n cc_list = cc.join(\" \")\n bcc_list = bcc.join(\" \")\n body = mail.quoted_body\n save_email(from_list, to_list, subject, cc_list, bcc_list, body, msgid, ref_msgid, date, user, contacts)\n else\n #TODO if fowarded msg has from as user and to as contact it's inbound\n \n end\n \n else\n #unknown sender,this email is not supposed to be in drop box\n logger.warn \"mail from unknown user from: #{from} to: #{to} subject: #{subject}\"\n handle_processed_mail(uid) if @imap_setting[:mode] == \"prod\"\n end\n \n end\n \n end\n @imap.logout\n @imap.disconnect\n \n rescue Net::IMAP::NoResponseError => e\n logger.error \"IMAP server error\"\n rescue Net::IMAP::ByeResponseError => e\n logger.error \"IMAP server error\"\n rescue => e\n logger.error \"IMAP server error\"\n \n end", "def scan(mhead, mbody)\n # :'from' => %r/mailer-daemon[@]mail[.]zoho[.]com\\z/,\n # :'subject' => %r{\\A(?:\n # Undelivered[ ]Mail[ ]Returned[ ]to[ ]Sender\n # |Mail[ ]Delivery[ ]Status[ ]Notification\n # )\n # }x,\n # :'x-mailer' => %r/\\AZoho Mail\\z/,\n return nil unless mhead['x-zohomail']\n\n dscontents = [Sisimai::Bite.DELIVERYSTATUS]\n hasdivided = mbody.split(\"\\n\")\n rfc822list = [] # (Array) Each line in message/rfc822 part string\n blanklines = 0 # (Integer) The number of blank lines\n readcursor = 0 # (Integer) Points the current cursor position\n recipients = 0 # (Integer) The number of 'Final-Recipient' header\n qprintable = false\n v = nil\n\n while e = hasdivided.shift do\n if readcursor == 0\n # Beginning of the bounce message or delivery status part\n if e.start_with?(StartingOf[:message][0])\n readcursor |= Indicators[:deliverystatus]\n next\n end\n end\n\n if (readcursor & Indicators[:'message-rfc822']) == 0\n # Beginning of the original message part\n if e.include?(StartingOf[:rfc822][0])\n readcursor |= Indicators[:'message-rfc822']\n next\n end\n end\n\n if readcursor & Indicators[:'message-rfc822'] > 0\n # After \"message/rfc822\"\n if e.empty?\n blanklines += 1\n break if blanklines > 1\n next\n end\n rfc822list << e\n else\n # Before \"message/rfc822\"\n next if (readcursor & Indicators[:deliverystatus]) == 0\n next if e.empty?\n\n # This message was created automatically by mail delivery software.\n # A message that you sent could not be delivered to one or more of its recip=\n # ients. This is a permanent error.=20\n #\n # [email protected] Invalid Address, ERROR_CODE :550, ERROR_CODE :5.1.=\n # 1 <[email protected]>... User Unknown\n\n # This message was created automatically by mail delivery software.\n # A message that you sent could not be delivered to one or more of its recipients. This is a permanent error.\n #\n # [email protected] Invalid Address, ERROR_CODE :550, ERROR_CODE :Requested action not taken: mailbox unavailable\n v = dscontents[-1]\n\n if cv = e.match(/\\A([^ ]+[@][^ ]+)[ \\t]+(.+)\\z/)\n # [email protected] Invalid Address, ERROR_CODE :550, ERROR_CODE :5.1.=\n if v['recipient']\n # There are multiple recipient addresses in the message body.\n dscontents << Sisimai::Bite.DELIVERYSTATUS\n v = dscontents[-1]\n end\n v['recipient'] = cv[1]\n v['diagnosis'] = cv[2]\n\n if v['diagnosis'].end_with?('=')\n # Quoted printable\n v['diagnosis'] = v['diagnosis'].chomp('=')\n qprintable = true\n end\n recipients += 1\n\n elsif cv = e.match(/\\A\\[Status: .+[<]([^ ]+[@][^ ]+)[>],/)\n # Expired\n # [Status: Error, Address: <[email protected]>, ResponseCode 421, , Host not reachable.]\n if v['recipient']\n # There are multiple recipient addresses in the message body.\n dscontents << Sisimai::Bite.DELIVERYSTATUS\n v = dscontents[-1]\n end\n v['recipient'] = cv[1]\n v['diagnosis'] = e\n recipients += 1\n else\n # Continued line\n next unless qprintable\n v['diagnosis'] << e\n end\n end\n end\n return nil unless recipients > 0\n\n dscontents.each do |e|\n e['agent'] = self.smtpagent\n e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'].gsub(/\\\\n/, ' '))\n\n MessagesOf.each_key do |r|\n # Verify each regular expression of session errors\n next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }\n e['reason'] = r.to_s\n break\n end\n end\n\n rfc822part = Sisimai::RFC5322.weedout(rfc822list)\n return { 'ds' => dscontents, 'rfc822' => rfc822part }\n end", "def maillist_prod\n maillist_parse(maillist_prod_file)\n end", "def perform\n current_time = Time.now\n packages = find_packages(city_db_id)\n emails = find_emails(city_db_id)\n\n ## Create list of recipients as array of strings\n recipients = []\n emails.each do |email|\n recipients << email.email_value\n end\n\n Emailer.packages_notification(current_time,packages,recipients).deliver\n end", "def extract_message(item)\n # message = item[\"message\"]\n # timestamp = DateTime.parse(item[\"@timestamp\"]).strftime(\"%Y-%m-%d %H:%M:%S\") rescue nil\n # from = REGEX_EMAIL.match(REGEX_FROM_EMAIL.match(message)[0])[0] rescue nil\n # to = REGEX_EMAIL.match(REGEX_TO_EMAIL.match(message)[0])[0] rescue nil\n # status = REGEX_STATUS.match(message)[0].split(\"=\")[1] rescue nil\n # subject = REGEX_SUBJECT.match(message)[0].split(\" \")[1..-2].join(\" \") rescue nil\n # error_message = ( status == \"deferred\" || status == \"bounced\" ) ? ( REGEX_ERROR_MESSAGE.match(message)[0] rescue nil ) : nil\n { :timestamp => item[:timestamp],\n :status => item[:status],\n :from => item[:from] ,\n :to => item[:to] ,\n :subject => item[:subject],\n }.merge( item[:error_message] ? { error_message: item[:error_message].split(\" \")[1..-1].join(\" \") } : {})\n end", "def receive(mail)\n mail\n end", "def fetch_mail\n# \tp \"Fetching mail...\"\n \tconfig = { :host => 'imap.gmail.com', :port => 993, :username => 'CrowdAssistant', :password => 'CrowdAss'}\n \timap = Net::IMAP.new(config[:host], config[:port], true)\n \timap.login(config[:username], config[:password])\n \timap.select(\"INBOX\")\n \tmessages_to_archive = []\n \timap.search([\"NOT\", \"DELETED\"]).each do |message_id|\n \t\ttask = imap.fetch(message_id, 'BODY[TEXT]')[0].attr['BODY[TEXT]']\n \t\tmessage = imap.fetch(message_id, 'ENVELOPE')[0].attr['ENVELOPE']\n \t\tfrom = \"#{message.sender[0].mailbox}@#{message.sender[0].host}\"\n# p from\n \t\tu = User.find_by_email(from)\n# p u\n \t\tif u\n\t \t\t#Why does an empty resource and resourcetype fail?\n task = task.gsub(\"=\\r\\n\", \"\")\n\t \t\tt = Task.create(:user_id => u.id, :instructions => task, :fields => \"[{\\\"Reply\\\":\\\"t\\\"}]\", :priority => 2, :workflow => \"p\", :redundancy => 2, :resource => \"www.google.com\", :resourcetype => \"l\", :status=>\"Not Started\")\n\t \t\tAssistant.handle(t)\n\t \telse\n#\t \t\tp \"Whoops, some dude who hasn't signed up sent us an email\"\n\t \tend\n \t\tmessages_to_archive << message_id\n \tend\n \timap.store(messages_to_archive, \"+FLAGS\", [:Deleted]) unless messages_to_archive.empty?\n end", "def receive_inbound_email_from_source(*args); end", "def receive_inbound_email_from_source(*args); end", "def get_mails\n if params[:action] == 'get_mails'\n Log.add_info(request, params.inspect)\n end\n\n if !params[:pop].nil? and params[:pop] == 'true'\n\n mail_account_id = params[:mail_account_id]\n SqlHelper.validate_token([mail_account_id])\n\n begin\n new_arrivals_h = {}\n\n if mail_account_id.blank?\n mail_accounts = MailAccount.find_all(\"user_id=#{@login_user.id}\")\n mail_accounts.each do |mail_account|\n emails = Email.do_pop(mail_account)\n unless emails.empty?\n new_arrivals_h[mail_account.id] ||= []\n new_arrivals_h[mail_account.id] |= emails\n end\n end\n else\n mail_account = MailAccount.find(mail_account_id)\n emails = Email.do_pop(mail_account)\n unless emails.empty?\n new_arrivals_h[mail_account.id] ||= []\n new_arrivals_h[mail_account.id] |= emails\n end\n end\n\n unless new_arrivals_h.empty?\n flash[:notice] = t('mail.received', :count => new_arrivals_h.values.flatten.length)\n\n # FEATURE_MAIL_FILTERS >>>\n new_arrivals_h.each do |mail_account_id, emails|\n mail_filters = MailFilter.get_for(mail_account_id, true, MailFilter::TRIGGER_CHECKING)\n filter_next = true\n\n emails.each do |email|\n mail_filters.each do |filter|\n filter_next = filter.execute(email)\n break unless filter_next\n end\n break unless filter_next\n end\n end\n # FEATURE_MAIL_FILTERS <<<\n end\n rescue => evar\n if evar.to_s.starts_with?('ERROR:')\n flash[:notice] = evar.to_s\n else\n flash[:notice] = 'ERROR:' + t('mail.receive_error') + '<br/>' + evar.to_s\n end\n Log.add_error(nil, evar)\n end\n end\n\n @folder_id = params[:id]\n SqlHelper.validate_token([@folder_id])\n\n if @folder_id == TreeElement::ROOT_ID.to_s\n @emails = nil\n else\n=begin\n# @emails = MailFolder.get_mails_to_show(@folder_id, @login_user)\n=end\n# FEATURE_PAGING_IN_TREE >>>\n @sort_col = (params[:sort_col] || 'sent_at')\n @sort_type = (params[:sort_type] || 'DESC')\n SqlHelper.validate_token([@sort_col, @sort_type], ['.'])\n\n sql = EmailsHelper.get_list_sql(@login_user, params[:keyword], [@folder_id], @sort_col, @sort_type, 0, nil)\n @email_pages, @emails, @total_num = paginate_by_sql(Email, sql, 10)\n# FEATURE_PAGING_IN_TREE <<<\n end\n\n session[:mailfolder_id] = @folder_id\n\n render(:partial => 'ajax_folder_mails', :layout => false)\n end", "def post(email_or_attributes)\n email = email_or_attributes\n email = MList::EmailPost.new(email_or_attributes) unless email.is_a?(MList::EmailPost)\n process_message messages.build(\n :parent => email.reply_to_message,\n :parent_identifier => email.parent_identifier,\n :mail_list => self,\n :subscriber => email.subscriber,\n :recipients => list.recipients(email.subscriber),\n :email => MList::Email.new(:source => email.to_s)\n ), :search_parent => false, :copy_sender => email.copy_sender\n end", "def importing_update( email_list )\n @failed_registrations = FailedRegistration.all \n # email_list.each do | email | \n mail( :to => email_list, \n :subject => \"potoSchool | Tarumanegara Failed Registration #{Time.now}\" )\n # end\n end", "def proc_msg(m)\r\n message = nil\r\n\t\tbegin\r\n #TODO: spawn new thread here when through put needs to be higher\r\n\t\t\tMessage.transaction do\r\n\t\t\t\tmessage = @pop.process_email(m)\r\n\r\n\t\t\t\t@msg_proc.process(message) unless message.nil?\r\n\t\t\t\[email protected](m)\r\n\t\t\tend\r\n\t\trescue Exception => e\r\n\t\t\tif !message.nil? && !message.id.nil?\r\n\t\t\t\tlog.error(\"Exception processing message: #{message.id}\")\r\n\t\t\tend\r\n\t\t\tlog.error(\"#{e.class}: #{e.message}\")\r\n\t\t\tlog.error(e.backtrace.join(\"\\n\\t\"))\r\n\t\tend\r\n\tend", "def sync\n imap = imap_login\n imap.search([\"NOT\", \"SEEN\"]).each do |message_id|\n envelope = imap.fetch(message_id, \"ENVELOPE\")[0].attr[\"ENVELOPE\"]\n puts \"#{envelope.from[0].name}: \\t#{envelope.subject}\"\n\n # TODO right now we are hardcoding the regex's which are used in matching\n # and extracting data out of the incoming mail, at some point this\n # should be customizable by the end user\n\n # TODO we are assuming that all messages matching the criteria retrieved\n # from this imap account belong to this mailing list\n\n # handle subscription confirmation\n if envelope.subject =~ /^\\s*confirm\\s*([a-f0-9]*)\\s*$/\n puts \"confirm subscription #{$1}\"\n smtp = smtp_login\n message = message_for :address => request_address, :subject => \"confirm #{$1}\", :body => \"confirm #{$1}\"\n smtp.send_message message, @smtp_username, request_address\n smtp.finish\n\n # handle received patches\n elsif envelope.subject =~ /^\\s*\\[PATCH[^\\]]*\\]\\s*#([0-9]*).*$/i\n puts \"Received patch #{$2}\"\n puts \" Associating w/ issue ##{$1}\"\n\n issue = Issue.find $1\n patch = Patch.new :issue_id => issue.id,\n :mailing_list_id => self.id,\n :message_id => envelope.headers['Message-Id'],\n :subject => $2,\n :content => envelope.body\n patch.save!\n\n issue.status = IssueStatus.find_by_name(\"In Progress\")\n issue.save!\n\n # handle chained patches (first one may be the only one w/ the issue id)\n elsif envelope.subject =~ /^\\s*\\[PATCH[^\\]]*\\].*$/i\n # TODO handle multiple levels of patch replies\n parent_message_id = envelope.headers['In-Reply-To']\n parent_patch = Patch.find_by_message_id(parent_message_id)\n\n puts \"Received chained patch #{$2}\"\n puts \" Associating w/ issue ##{parent_patch.issue_id} (parent patch ##{parent_patch.id})\"\n\n patch = Patch.new :issue_id => parent_patch.issue_id,\n :mailing_list_id => self.id,\n :patch_id => parent_patch.id,\n :message_id => envelope.headers['Message-Id'],\n :subject => $2,\n :content => envelope.body\n\n patch.save!\n\n issue.status = IssueStatus.find_by_name(\"In Progress\")\n issue.save!\n\n # handle received patch comments\n elsif envelope.subject =~ /^\\s*RE:\\s*\\[PATCH[^\\]]*\\]\\s*#([0-9]*).*$/i\n # TODO handle multiple levels of replies\n parent_message_id = envelope.headers['In-Reply-To']\n parent_patch = Patch.find_by_message_id(parent_message_id)\n\n puts \"Received response to patch #{$2}\"\n puts \" Associating w/ patch ##{parent_patch.id}\"\n\n patch_comment = PatchComment.new :patch_id => parent_patch.id,\n :message_id => envelope.headers['Message-Id'],\n :content => envelope.body\n\n status = if envelope.body =~ /.*NACK.*/i\n IssueStatus.find_by_name(\"Rejected\")\n elsif envelope.body =~ /.*ACK.*/i\n IssueStatus.find_by_name(\"Resolved\")\n else\n IssueStatus.find_by_name(\"Feedback\")\n end\n\n issue.status = status\n issue.save!\n end\n\n\n end\n end", "def work(raw_post)\n email_params = JSON.parse(raw_post).with_indifferent_access\n send_simple_message(params)\n ack! # we need to let queue know that message was received\n end", "def parse_mail(mail)\n\n @mail = mail\n\n unless mail.date.nil?\n self.sent_at = mail.date.strftime('%Y-%m-%d %H:%M:%S')\n end\n\n unless mail.from.nil?\n begin\n addrs = mail[:from].to_s\n addrs = EmailsHelper.split_preserving_quot(addrs, '\"', ',')\n self.from_address = addrs.join(Email::ADDRESS_SEPARATOR)\n rescue\n self.from_address = mail.from.join(Email::ADDRESS_SEPARATOR)\n end\n end\n\n unless mail.to.nil?\n begin\n addrs = mail[:to].to_s\n addrs = EmailsHelper.split_preserving_quot(addrs, '\"', ',')\n self.to_addresses = addrs.join(Email::ADDRESS_SEPARATOR)\n rescue\n self.to_addresses = mail.to.join(Email::ADDRESS_SEPARATOR)\n end\n end\n\n unless mail.cc.nil?\n begin\n addrs = mail[:cc].to_s\n addrs = EmailsHelper.split_preserving_quot(addrs, '\"', ',')\n self.cc_addresses = addrs.join(Email::ADDRESS_SEPARATOR)\n rescue\n self.cc_addresses = mail.cc.join(Email::ADDRESS_SEPARATOR)\n end\n end\n\n unless mail.bcc.nil?\n begin\n addrs = mail[:bcc].to_s\n addrs = EmailsHelper.split_preserving_quot(addrs, '\"', ',')\n self.bcc_addresses = addrs.join(Email::ADDRESS_SEPARATOR)\n rescue\n self.bcc_addresses = mail.bcc.join(Email::ADDRESS_SEPARATOR)\n end\n end\n\n unless mail.reply_to.nil?\n begin\n addrs = mail[:reply_to].to_s\n addrs = EmailsHelper.split_preserving_quot(addrs, '\"', ',')\n self.reply_to = addrs.join(Email::ADDRESS_SEPARATOR)\n rescue\n self.reply_to = mail.reply_to.join(Email::ADDRESS_SEPARATOR)\n end\n end\n\n self.subject = mail.subject\n\n # Email Body ###\n plain_part = (@mail.multipart?) ? ((@mail.text_part) ? @mail.text_part : nil) : nil\n html_part = (@mail.html_part) ? @mail.html_part : nil\n message_part = (plain_part || html_part)\n message_part ||= @mail unless @mail.multipart?\n\n if message_part.nil?\n self.message = ''\n else\n charset = @mail.header.charset\n charset = nil if !charset.nil? and (charset.casecmp('US-ASCII') == 0)\n\n charset ||= message_part.header.charset\n charset = nil if !charset.nil? and (charset.casecmp('US-ASCII') == 0)\n\n message = message_part.body.decoded\n unless charset.nil? or charset.empty?\n message.encode!(Encoding::UTF_8, charset, {:invalid => :replace, :undef => :replace, :replace => ' '})\n end\n self.message = message\n end\n end", "def deliver_email\n\t\treturn not_validated_error unless EmailValidator.new(content: content).validated?\n\t\tformatted_content = EmailFormatter.new(content: content, service: service).format\n\n\t\tif service == \"mandrill\"\n\t\t\tself.class.base_uri \"https://mandrillapp.com/api/1.0\"\n\t\t\tresponse = self.class.post(\"/messages/send.json\", body: {\"key\" => ENV.fetch(\"MANDRILL_API_KEY\"), \"message\" => formatted_content})\n\t\t\tif response[\"status\"] == \"sent\"\n\t\t\t\t\"Yay! Your email is on it's way!!\"\n\t\t\telse\n\t\t\t\t\"Oh no. That email couldn't be delivered\"\n\t\t\tend\n\n\t\telsif service == \"mailgun\"\n\t\t\tself.class.base_uri \"https://api.mailgun.net/v3/sandboxaebea391c02a4a0494ab285e2adf8170.mailgun.org\"\n\t\t\tself.class.basic_auth 'api', ENV.fetch(\"MAILGUN_API_KEY\")\n\t\t\tresponse = self.class.post(\"/messages\", body: formatted_content)\n\t\t\tif response[\"message\"] == \"Queued. Thank you.\"\n\t\t\t\t\"Yay! Your email is on it's way!!\"\n\t\t\telse\n\t\t\t\t\"Oh no. That email couldn't be delivered\"\n\t\t\tend\n\t\tend\n\tend", "def scan(mhead, mbody)\n return nil unless mhead\n return nil unless mbody\n\n # :'message-id' => %r/\\A[<]mxl[~][0-9a-f]+/,\n match = 0\n match += 1 if mhead['x-mx-bounce']\n match += 1 if mhead['x-mxl-hash']\n match += 1 if mhead['x-mxl-notehash']\n match += 1 if mhead['from'].start_with?('Mail Delivery System')\n match += 1 if mhead['subject'] =~ %r{(?:\n Mail[ ]delivery[ ]failed(:[ ]returning[ ]message[ ]to[ ]sender)?\n |Warning:[ ]message[ ].+[ ]delayed[ ]+\n |Delivery[ ]Status[ ]Notification\n )\n }x\n return nil if match.zero?\n\n dscontents = [Sisimai::Bite.DELIVERYSTATUS]\n hasdivided = mbody.split(\"\\n\")\n rfc822list = [] # (Array) Each line in message/rfc822 part string\n blanklines = 0 # (Integer) The number of blank lines\n readcursor = 0 # (Integer) Points the current cursor position\n recipients = 0 # (Integer) The number of 'Final-Recipient' header\n localhost0 = '' # (String) Local MTA\n v = nil\n\n hasdivided.each do |e|\n if readcursor.zero?\n # Beginning of the bounce message or delivery status part\n if e == StartingOf[:message][0]\n readcursor |= Indicators[:deliverystatus]\n next\n end\n end\n\n if (readcursor & Indicators[:'message-rfc822']).zero?\n # Beginning of the original message part\n if e == StartingOf[:rfc822][0]\n readcursor |= Indicators[:'message-rfc822']\n next\n end\n end\n\n if readcursor & Indicators[:'message-rfc822'] > 0\n # After \"message/rfc822\"\n if e.empty?\n blanklines += 1\n break if blanklines > 1\n next\n end\n rfc822list << e\n else\n # Before \"message/rfc822\"\n next if (readcursor & Indicators[:deliverystatus]).zero?\n next if e.empty?\n\n # This message was created automatically by mail delivery software.\n #\n # A message that you sent could not be delivered to one or more of its\n # recipients. This is a permanent error. The following address(es) failed:\n #\n # [email protected]\n # SMTP error from remote mail server after RCPT TO:<[email protected]>:\n # host neko.example.jp [192.0.2.222]: 550 5.1.1 <[email protected]>... User Unknown\n v = dscontents[-1]\n\n if cv = e.match(/\\A[ \\t]*[<]([^ ]+[@][^ ]+)[>]:(.+)\\z/)\n # A message that you have sent could not be delivered to one or more\n # recipients. This is a permanent error. The following address failed:\n #\n # <[email protected]>: 550 5.1.1 ...\n if v['recipient']\n # There are multiple recipient addresses in the message body.\n dscontents << Sisimai::Bite.DELIVERYSTATUS\n v = dscontents[-1]\n end\n v['recipient'] = cv[1]\n v['diagnosis'] = cv[2]\n recipients += 1\n\n elsif dscontents.size == recipients\n # Error message\n next if e.empty?\n v['diagnosis'] << e + ' '\n end\n end\n end\n return nil if recipients.zero?\n\n if mhead['received'].size > 0\n # Get the name of local MTA\n # Received: from marutamachi.example.org (c192128.example.net [192.0.2.128])\n if cv = mhead['received'][-1].match(/from[ ]([^ ]+) /)\n localhost0 = cv[1]\n end\n end\n\n require 'sisimai/string'\n dscontents.map do |e|\n e['agent'] = self.smtpagent\n e['lhost'] = localhost0\n\n e['diagnosis'] = e['diagnosis'].gsub(/[-]{2}.*\\z/, '')\n e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])\n\n unless e['rhost']\n # Get the remote host name\n if cv = e['diagnosis'].match(/host[ ]+([^ \\t]+)[ ]\\[.+\\]:[ ]/)\n # host neko.example.jp [192.0.2.222]: 550 5.1.1 <[email protected]>... User Unknown\n e['rhost'] = cv[1]\n end\n\n unless e['rhost']\n # Get localhost and remote host name from Received header.\n e['rhost'] = Sisimai::RFC5322.received(mhead['received'][-1]).pop if mhead['received'].size > 0\n end\n end\n\n unless e['command']\n # Get the SMTP command name for the session\n ReCommands.each do |r|\n # Verify each regular expression of SMTP commands\n if cv = e['diagnosis'].match(r)\n e['command'] = cv[1].upcase\n break\n end\n end\n\n # Detect the reason of bounce\n if e['command'] == 'MAIL'\n # MAIL | Connected to 192.0.2.135 but sender was rejected.\n e['reason'] = 'rejected'\n\n elsif %w[HELO EHLO].index(e['command'])\n # HELO | Connected to 192.0.2.135 but my name was rejected.\n e['reason'] = 'blocked'\n else\n # Verify each regular expression of session errors\n ReFailures.each_key do |r|\n # Check each regular expression\n next unless e['diagnosis'] =~ ReFailures[r]\n e['reason'] = r.to_s\n break\n end\n\n unless e['reason']\n # The reason \"expired\"\n e['reason'] = 'expired' if e['diagnosis'] =~ ReDelaying\n end\n end\n end\n e.each_key { |a| e[a] ||= '' }\n end\n\n rfc822part = Sisimai::RFC5322.weedout(rfc822list)\n return { 'ds' => dscontents, 'rfc822' => rfc822part }\n end", "def receive_emails_pop\n self.config_emails.each do |config_email|\n case (config_email.server_email)\n when 'pop.gmail.com'\n Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE)\n else\n \"\"\n end\n Net::POP3.start(config_email.server_email, config_email.port, config_email.username, ConfigEmail.decryption(config_email.password_encrypted)) do |pop|\n if pop.mails.empty?\n puts 'No mails.'\n else\n pop.each_mail do |mail|\n UserMailer.current_vendor_config_email(config_email)\n UserMailer.receive(mail.pop)\n mail.delete\n end\n pop.finish\n end\n end\n end\n end", "def received(morder)\n @morder = morder\n mail to: morder.email, subject: \"Pragmatic Store Order Confirmation\"\n end", "def scan(mhead, mbody)\n match = 0\n match += 1 if mhead['subject'] == '[BOUNCE]'\n match += 1 if mhead['message-id'].to_s.include?('.JavaMail.')\n match += 1 if mhead['received'].any? { |a| a.include?('JAMES SMTP Server') }\n return nil unless match > 0\n\n dscontents = [Sisimai::Bite.DELIVERYSTATUS]\n hasdivided = mbody.split(\"\\n\")\n rfc822list = [] # (Array) Each line in message/rfc822 part string\n blanklines = 0 # (Integer) The number of blank lines\n readcursor = 0 # (Integer) Points the current cursor position\n recipients = 0 # (Integer) The number of 'Final-Recipient' header\n diagnostic = '' # (String) Alternative diagnostic message\n subjecttxt = nil # (String) Alternative Subject text\n gotmessage = -1 # (Integer) Flag for error message\n v = nil\n\n while e = hasdivided.shift do\n if readcursor == 0\n # Beginning of the bounce message or delivery status part\n if e.start_with?(StartingOf[:message][0])\n readcursor |= Indicators[:deliverystatus]\n next\n end\n end\n\n if (readcursor & Indicators[:'message-rfc822']) == 0\n # Beginning of the original message part\n if e.start_with?(StartingOf[:rfc822][0])\n readcursor |= Indicators[:'message-rfc822']\n next\n end\n end\n\n if readcursor & Indicators[:'message-rfc822'] > 0\n # After \"message/rfc822\"\n if e.empty?\n blanklines += 1\n break if blanklines > 1\n next\n end\n rfc822list << e\n else\n # Before \"message/rfc822\"\n next if (readcursor & Indicators[:deliverystatus]) == 0\n next if e.empty?\n\n # Message details:\n # Subject: Nyaaan\n # Sent date: Thu Apr 29 01:20:50 JST 2015\n # MAIL FROM: [email protected]\n # RCPT TO: [email protected]\n # From: Neko <[email protected]>\n # To: [email protected]\n # Size (in bytes): 1024\n # Number of lines: 64\n v = dscontents[-1]\n\n if cv = e.match(/\\A[ ][ ]RCPT[ ]TO:[ ]([^ ]+[@][^ ]+)\\z/)\n # RCPT TO: [email protected]\n if v['recipient']\n # There are multiple recipient addresses in the message body.\n dscontents << Sisimai::Bite.DELIVERYSTATUS\n v = dscontents[-1]\n end\n v['recipient'] = cv[1]\n recipients += 1\n\n elsif cv = e.match(/\\A[ ][ ]Sent[ ]date:[ ](.+)\\z/)\n # Sent date: Thu Apr 29 01:20:50 JST 2015\n v['date'] = cv[1]\n\n elsif cv = e.match(/\\A[ ][ ]Subject:[ ](.+)\\z/)\n # Subject: Nyaaan\n subjecttxt = cv[1]\n else\n next if gotmessage == 1\n if v['diagnosis']\n # Get an error message text\n if e.start_with?('Message details:')\n # Message details:\n # Subject: nyaan\n # ...\n gotmessage = 1\n else\n # Append error message text like the followng:\n # Error message below:\n # 550 - Requested action not taken: no such user here\n v['diagnosis'] << ' ' << e\n end\n else\n # Error message below:\n # 550 - Requested action not taken: no such user here\n v['diagnosis'] = e if e == StartingOf[:error][0]\n end\n end\n end\n end\n return nil unless recipients > 0\n\n unless rfc822list.any? { |a| a.start_with?('Subject:') }\n # Set the value of subjecttxt as a Subject if there is no original\n # message in the bounce mail.\n rfc822list << ('Subject: ' << subjecttxt)\n end\n\n dscontents.each do |e|\n e['agent'] = self.smtpagent\n e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'] || diagnostic)\n e.each_key { |a| e[a] ||= '' }\n end\n\n rfc822part = Sisimai::RFC5322.weedout(rfc822list)\n return { 'ds' => dscontents, 'rfc822' => rfc822part }\n end", "def get_messages\n @connection.search(@filter).each do |message|\n body = @connection.fetch(message, \"RFC822\")[0].attr[\"RFC822\"]\n begin\n @processor.process(body)\n rescue StandardError => error\n Mailman.logger.error \"Error encountered processing message: #{message.inspect}\\n #{error.class.to_s}: #{error.message}\\n #{error.backtrace.join(\"\\n\")}\"\n next\n end\n @connection.store(message, \"+FLAGS\", @done_flags)\n end\n # Clears messages that have the Deleted flag set\n @connection.expunge\n end", "def process_message(message)\n end", "def process_mail_from params\n # Requiring TLS is touchy, cf RFC2784.\n # Requiring AUTH seems to be much more reasonable.\n #if (options[:starttls] == :required and [email protected]?(:starttls))\n # reply 550, \"This server requires STARTTLS before MAIL FROM\"\n #elsif (options[:auth] == :required and [email protected]?(:auth))\n # reply 550, \"This server requires authentication before MAIL FROM\"\n if @state.include?(:mail_from)\n reply 503, \"Sender already given\"\n return\n end\n \n if params.nil?\n reply 501, \"Syntax: MAIL FROM:<address>\"\n return\n end\n \n reverse_path, mail_parameters = params.split(' ', 2)\n if reverse_path !~ /@|<>/ # valid email or empty sender (<>)\n reply 501, \"Syntax: MAIL FROM:<address>\"\n # RET=[FULL|HDRS], ENVID=, BODY=[8BITMIME|7BIT]\n elsif !receive_sender(unbracket(reverse_path))\n reply 550, \"sender is unacceptable\"\n else\n reply 250, \"Ok\"\n @state << :mail_from\n end\n end", "def process_mail_from sender\n if (@@parms[:starttls]==:required and [email protected]?(:starttls))\n send_data \"550 This server requires STARTTLS before MAIL FROM\\r\\n\"\n elsif (@@parms[:auth]==:required and [email protected]?(:auth))\n send_data \"550 This server requires authentication before MAIL FROM\\r\\n\"\n elsif @state.include?(:mail_from)\n send_data \"503 MAIL already given\\r\\n\"\n else\n unless receive_sender sender\n send_data \"550 sender is unacceptable\\r\\n\"\n else\n send_data \"250 Ok\\r\\n\"\n @state << :mail_from\n end\n end\n end", "def get_messages\n unless @connection.mails.empty?\n @connection.each_mail do |msg|\n begin\n process_message(msg.pop)\n rescue\n handle_bogus_message(msg.pop)\n end\n # Delete message from server\n msg.delete\n end\n end\n end", "def receive(email, options={})\n @email = email\n @handler_options = options\n sender_email = email.from.to_a.first.to_s.strip\n # Ignore emails received from the application emission address to avoid hell cycles\n if sender_email.casecmp(Setting.mail_from.to_s.strip) == 0\n if logger\n logger.info \"MailHandler: ignoring email from Redmine emission address [#{sender_email}]\"\n end\n return false\n end\n # Ignore auto generated emails\n self.class.ignored_emails_headers.each do |key, ignored_value|\n value = email.header[key]\n if value\n value = value.to_s.downcase\n if (ignored_value.is_a?(Regexp) && value.match(ignored_value)) || value == ignored_value\n if logger\n logger.info \"MailHandler: ignoring email with #{key}:#{value} header\"\n end\n return false\n end\n end\n end\n @user = User.find_by_mail(sender_email) if sender_email.present?\n if @user && [email protected]?\n if logger\n logger.info \"MailHandler: ignoring email from non-active user [#{@user.login}]\"\n end\n return false\n end\n if @user.nil?\n # Email was submitted by an unknown user\n case handler_options[:unknown_user]\n when 'accept'\n @user = User.anonymous\n when 'create'\n @user = create_user_from_email\n if @user\n if logger\n logger.info \"MailHandler: [#{@user.login}] account created\"\n end\n add_user_to_group(handler_options[:default_group])\n unless handler_options[:no_account_notice]\n Mailer.account_information(@user, @user.password).deliver\n end\n else\n if logger\n logger.error \"MailHandler: could not create account for [#{sender_email}]\"\n end\n return false\n end\n else\n # Default behaviour, emails from unknown users are ignored\n if logger\n logger.info \"MailHandler: ignoring email from unknown user [#{sender_email}]\"\n end\n return false\n end\n end\n User.current = @user\n dispatch\n end", "def jobs_notifier(email_list)\n @listed_jobs = JobPosting.where(created_at: (Time.now.midnight-5.days)..(Time.now))\n @greeting = \"Hi\"\n headers['X-SMTPAPI'] = { :to => email_list.to_a }.to_json\n mail(\n :to => \"[email protected]\",\n :subject => \"New Job Posted!\"\n )\n \n end", "def run()\r\n\t\twhile 0\r\n\t\t\tbegin \r\n\t\t\t\tlog.info 'Connecting to email server...'\r\n\t\t\t\tif @pop.connect() \r\n\t\t\t\t\t#make the db connection\r\n log.info \"Processing #{@pop.message_count} messages...\"\r\n\r\n\t\t\t\t\tActiveRecord::Base.establish_connection(@config[@db_env])\r\n @pop.each_mail do |m| \r\n proc_msg(m)\t\t\t\t\t\t\t\r\n end\r\n\t\t\t\t\tActiveRecord::Base.connection.disconnect!\r\n\r\n\t\t\t\t\[email protected]()\r\n\t\t\t\t\tlog.info \"Processing complete.\"\r\n\t\t\t\t\tlog.info(\"\")\r\n\t\t\t\telse\r\n\t\t\t\t\tlog.error \"Could not connect to mail server!\\n\"\r\n\t\t\t\t\tlog.info(\"\")\r\n\t\t\t\tend\r\n\t\t\trescue Exception => e\r\n\t\t\t\tlog_exception(e)\r\n\t\t\t\tMessage.send_error_email(\"Error processing an SMS message.\", e)\r\n\t\t\t\[email protected]()\r\n\t\t\t\tsleep(30)\r\n\t\t\tend\r\n\t\t\tsleep(15)\r\n\t\tend\t\r\n\t\tlog.close\r\n\tend", "def message_received(message)\n @message = message\n mail to: message.email, subject: 'Message to JOT confirmation'\n end", "def index\n options = params.dup\n email = options.delete(:email)\n if MailHandler.receive(email, options)\n head :created\n else\n head :unprocessable_entity\n end\n end", "def received\n EnquiryMailer.received\n end", "def email_cleaned\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :campaign_id => data['campaign_id'],\n :email => data['email'],\n :reason => data['reason'],\n :human => \"#{data['email']} was cleaned from Mailchimp list with ID #{data['list_id']}. Reason: '#{data['reason']}'\"\n }\n end", "def decode_workitem( email )\n ldebug { \"decoding workitem from: #{email}\" }\n analysis_error_response( email )\n arwi_id = get_arwi_id_for_decode( email )\n puts \"listener got arwi:#{arwi_id}\"\n return unless arwi_id && arwi_id.to_s.size > 0\n workitem = MailItem.get_workitem( arwi_id, 'delete', \"listener\" )\n puts \"listener can not got workitem for arwi:#{arwi_id}\" unless workitem\n return unless workitem\n puts \"listener got wi:#{workitem.class}, #{workitem}\"\n workitem[\"attachment\"] = email[:attachment]\n workitem[\"email_from\"] = email[:from].join(',')\n begin\n SMOperation.build( email, workitem )\n email[:subject] = Kconv.toutf8(email[:subject])\n # _ps_type = $1 if /\\+([a-z]+)?_?([\\d]+)@/ =~ email[:to]\n # step = SMSpreadsheet.get_stepname_from_spreadsheet( workitem.fei.wfname, _ps_type )\n event = Hash.new\n event[:title] = \"#{email[:subject]}\"\n event[:desc] = \"#{email[:body]}\"\n calendar_name = workitem.fields['user_name'] || 'default'\n SMGoogleCalendar.create_event( event, calendar_name )\n rescue Exception => e\n puts \"decode_workitem error: #{e.message}\"\n end\n print \"#{@blue_underline}3.listener processed workitem:#{@normal} #{workitem}\\n\"\n workitem\n end", "def create\n @email_update = EmailUpdate.new(params[:email_update])\n\n respond_to do |format|\n if @email_update.save\n @emailList = Email.pluck(:email)\n @emailList.each do |recipient|\n UserMailer.info_email(@email_update.subject, @email_update.message, recipient).deliver \n end\n format.html { redirect_to @email_update, notice: 'Email update was successfully created.' }\n format.json { render json: @email_update, status: :created, location: @email_update }\n else\n format.html { render action: \"new\" }\n format.json { render json: @email_update.errors, status: :unprocessable_entity }\n end\n end\n end", "def email\n\t\temail_response = EmailHandler.new(email_content).deliver_email\n\t\t\trender text: email_response + \"\\n\"\n\tend", "def mail; end", "def parser_email(line)\n if line.include? MailHeader.from\n fields=line.split(MailHeader.key_separator)\n if fields.length>1\n\t\t\t\tvalue=fields[1].split(\" \")\n if value.length>1\n firstname_lastname=value[0];\n email_address=value[1].gsub(/[<>]/,'')\n company_url=\"www.\"+email_address.split('@')[1];\n # if the email address is not contains the '@',the address is not correct\n unless email_address.include? \"@\"\n mail_header_output.firstname_lastname=MailHeader.unknown\n mail_header_output.flastname=MailHeader.unknown\n end\n mail_header_output.company_url=company_url\n check_firstname_lastname(email_address)\n check_flastname(email_address)\n check_email_name_conflict()\n end #end value.length\n end #end fields.length\n end #end line include\n end", "def mails\n\n begin\n @imap = WmailImapUtils.current_imap\n \n if not @imap.blank?\n @mailbox = params['mailbox']\n @min = params['min'].to_i\n @max = params['max'].to_i\n @total = params['total'].to_i\n\n @imap.select(@mailbox)\n @mails = @imap.fetch(@total-@max..@total-@min, 'ENVELOPE')\n @unseen_flags = @imap.search(['NOT','SEEN'])\n end\n rescue\n redirect_to authenticate_wmail_accounts_path(:redirect => messages_mailbox_path(:label => selected_label)),\n :alert => 'Connection Lost. Please login to your account'\n end\n end", "def process_entities(items_to_check, log)\n @items_list = []\n\n # Get all of the items that will be put into the contents of the alert sent.\n @items_list = gather_content_items(items_to_check)\n\n # send email to admins with the items of interest\n if !items_list.empty? && send_alert_this_day?(@timing, @config, nil)\n recipients.each do |admin|\n send_email(admin, log, [items_list])\n end\n end\n end", "def deliver\n response = Curl.post(BASE_URL + 'messages/send.json', email_json)\n response = JSON.parse(response.body)\n @response = response.is_a?(Array) ? response.first : response\n end", "def sendMail(body)\n options = { :address => $advanced['mail']['address'],\n :port => $port,\n :domain => ENV['HOSTNAME'],\n :user_name => $advanced['mail']['username'],\n :password => $advanced['mail']['password'],\n :authentication => nil,\n :enable_starttls_auto => true }\n Mail.defaults do\n delivery_method :smtp, options\n end\n\n users = Array.new\n\n # Logic for pulling the email accounts from Plex.tv and/or the\n\t# config file\n\tplexTv = PlexTv.new($advanced)\n\n\tif !$testEmail\n \t if $plexEmails\n plex_users = plexTv.get('/pms/friends/all')\n\n if plex_users.nil? || plex_users.empty?\n $logger.info(\"No Plex friends found.\") \n else \n plex_users['MediaContainer']['User'].each do | user |\n\t\t\tif !user['email'].empty?\n users.push(user['email'])\n\t\t\tend\n end\n end\n\t end\n\t if !$advanced['mail']['recipients'].nil? || !$advanced['mail']['recipients_email'].nil?\n\t if !$advanced['mail']['recipients_email'].nil?\n\t $advanced['mail']['recipients_email'].each do | recipient |\n\t\t users.push(recipient)\n\t end\n\t end\n\t if !$advanced['mail']['recipients'].nil?\n\t\t $advanced['mail']['recipients'].each do | recipient |\n\t\t plex_users = plexTv.get('/pms/friends/all')\n plex_users['MediaContainer']['User'].each do | user |\n\t\t if user['username'] == recipient\n users.push(user['email'])\n\t\t\t end\n end\n\t\t end\n\t end\n\t end\n\tend\n\n #Get owner's email as well and add it to the list of recpients\n users.push(plexTv.get('/users/account')['user']['email'][0])\n \n\t#used to send individual email. Now it bcc's one email\n #users.each do | user |\n mail = Mail.new do\n from \"#{$advanced['mail']['from']} <#{$advanced['mail']['username']}>\"\n bcc users\n subject $advanced['mail']['subject'] + \" \" + (I18n.l Time.now.to_date)\n content_type 'text/html; charset=UTF-8'\n body body\n end\n begin\n mail.deliver!\n\t\t\trescue => e\n\t\t\t $logger.info(\"SMTP mailing failed!\\n#{e.message}#{e.backtrace}\")\n\t\t\tend\n #end\n end", "def get_messages\n @connection.uid_search(@filter).each do |message|\n puts \"PROCESSING MESSAGE #{message}\"\n [email protected]_fetch(message,\"RFC822\")[0].attr[\"RFC822\"]\n @processor.process(body, @options)\n @connection.uid_copy(message, 'Processed')\n\n @connection.uid_store(message,\"+FLAGS\",[:Deleted])\n end\n @connection.expunge\n #@connection.delete_all\n end", "def process(&after_each_message)\n Mail.all(read_only: false, delete_after_find: true) do |message|\n message.skip_deletion unless process_message(message)\n after_each_message.call(message) if after_each_message\n end\n end", "def email_list\n end", "def received\n AcademyApplicationMailer.received\n end", "def parseMessageFile(filename) \n \n mFile = File.open(filename)\n\n def mFile.nextContentLine\n line = nil\n loop do\n line = self.readline.chomp\n break unless line[0] == '#'\n end\n\n line\n end\n \n #from = mFile.readline.chomp\n from = mFile.nextContentLine\n \n #to = mFile.readline.chomp\n to = mFile.nextContentLine\n \n #cc = mFile.readline.chomp\n cc = mFile.nextContentLine\n cc = cc == '' ? nil : cc\n \n #subject = mFile.readline.chomp\n subject = mFile.nextContentLine\n \n \n body = ''\n \n mFile.each_line do |l|\n body << l\n \n \n \n \n end\n \n \n [from, to, cc, subject, body]\n \n \n \n \n end", "def tick \n mailer.messages.each do |request| \n response = mailer.new_message(:to => request.from, \n :from => settings.service.default_sender)\n \n begin\n apps.each do |app|\n app.call(:request => request, \n :response => response, \n :settings => settings,\n :logger => logger)\n end\n rescue StandardError => e\n logger.info(\"FAIL\") { e.to_s }\n logger.debug(\"FAIL\") { \"#{e.inspect}\\n\"+e.backtrace.join(\"\\n \") }\n\n if settings.service.raise_exceptions\n raise\n else\n next\n end\n end\n\n response.deliver\n end\n rescue Exception => e\n logger.fatal(\"Caught exception: #{e}\\n\\n#{e.backtrace.join(\"\\n\")}\")\n raise\n end", "def launch_email_client(event)\n mail_list = @@item.mail_list\n mail_list = \"private@#{mail_list}.apache.org\" unless mail_list.include? '@'\n\n to = @@item.chair_email\n cc = \"#{mail_list},#{@@item.cc}\"\n\n if @@item.missing\n subject = \"Missing #{@@item.title} Board Report\"\n if @@item.attach =~ /^\\d/\n body = %{\n Dear #{@@item.owner},\n\n The board report for #{@@item.title} has not yet been submitted for\n this month's board meeting. Please try to submit these reports by the\n Friday before the meeting.\n\n Thanks,\n\n #{User.username}\n }\n else\n body = %{\n Dear #{@@item.owner},\n\n The board report for #{@@item.title} has not yet been submitted for\n this month's board meeting. If you or another member of the PMC are\n unable to get it in by twenty-four hours before meeting time, please\n let the board know, and plan to report next month.\n\n https://www.apache.org/foundation/board/reporting#how\n\n Thanks,\n\n #{User.username}\n\n (on behalf of the ASF Board)\n }\n end\n\n # strip indentation; concatenate lines within a paragraph\n indent = body[/^\\s*/]\n body = body.strip().gsub(/#{indent}/, \"\\n\").gsub(/(\\S)\\n(\\S)/, \"$1 $2\")\n else\n subject = \"#{@@item.title} Board Report\"\n body = @@item.comments.join(\"\\n\\n\")\n\n if not body and @@item.text\n monthNames = %w(January February March April May June July August\n September October November December)\n year = Agenda.date.split('-')[0].to_i\n month = Agenda.date.split('-')[1].to_i\n\n subject = \"[REPORT] #{@@item.title} - #{monthNames[month-1]} #{year}\"\n to = @@item.cc\n cc = mail_list\n body = @@item.text\n end\n end\n\n if event.ctrlKey or event.shiftKey or event.metaKey\n @email = {\n to: to,\n cc: cc,\n subject: subject,\n body: body\n }\n\n jQuery('#email-' + @@item.mail_list).modal(:show)\n else\n window.location = \"mailto:#{to}?cc=#{cc}\" +\n \"&subject=#{encodeURIComponent(subject)}\" +\n \"&body=#{encodeURIComponent(body)}\"\n end\n end", "def email_job_result(jlh)\n return unless email_result?(jlh)\n email_expression = Regexp.new('EMAIL_RESULT_BELOW:(.*)EMAIL_RESULT_ABOVE',Regexp::MULTILINE)\n match = email_expression.match(jlh[:job_result])\n jmd = jlh[:jmd]\n jle = jlh[:jle]\n if (match.nil?)\n $logger.debug(\"The output for job_code #{jmd.job_code} does not have valid e-mail output!\")\n return\n end\n $logger.debug(\"The output for job_code #{jmd.job_code} does have valid e-mail output! See the rails log for details\")\n body = match[1]\n #get the subject from the body\n match = Regexp.new('SUBJECT:(.*)').match(body)\n subject = match[1] unless match.nil?\n body.sub!(\"SUBJECT:#{subject}\",'')#append on subject\n subject = $application_properties['service_subject'] + \" \" + subject if jlh.has_key?(:service)\n subject = subject + ' -- REMINDER ' + @reminder_hash[jmd.job_code].to_s if (jlh[:reminder_email])\n body.chomp!.reverse!.chomp!.reverse! unless jmd.email_content_type.eql?('text/html')\n from = $application_properties['PST_Team']\n content_type = jmd.email_content_type\n recipients = []\n cc = []# or should it be ''?\n #banana slug\n #integrate with escalation levels to get additional e-mails out of the escalation\n recipients = jlh[:email_to] if jlh.has_key?(:email_to)\n cc = jlh[:email_cc] if jlh.has_key?(:email_cc)\n\n if (jmd.track_status_change && jmd.email_on_status_change_only)\n esc = jle.get_escalation\n esc = JobLogEntry.before(jle).status_not(\"UNKNOWN\").limit(1).first.get_escalation if esc.nil? #if this is nil this jle is green\n\n if ! esc.nil? #this is added in the event that the alert has never been red and we are in this method because we are executing as a service\n esc_emails = esc.get_escalation_based_emails\n recipients = recipients | esc_emails[0]\n cc = cc | esc_emails[1]\n end\n end\n\n recipients = recipients.uniq.join(',')\n cc = cc.uniq.join(',')\n\n email_hash = {:request => jmd.job_code, :content_type => content_type, :subject=>subject,\n :recipients=>recipients, :from=>from, :cc=>cc,:body=>body,\n :incl_attachment=>jmd.incl_attachment,:attachment_path=>jmd.attachment_path,\n :jmd => jmd, :jle => jle}\n\n JobMailer.job_result(email_hash).deliver\n end", "def in_process\n to = params[:patron_email] + ', ' + params[:staff_email]\n from = \"Request Services <#{params[:staff_email]}>\"\n title = params[:bib_record].title\n subject = \"On Order / In Process Request [#{title}]\"\n mail(to: to, from: from, subject: subject)\n end", "def reply(fields)\n mail = Mail.new\n\n # fill in the from address\n mail.from = fields[:from]\n\n # fill in the reply to headers\n mail.in_reply_to = self.id\n mail.references = self.id\n\n # fill in the subject from the original email\n if self.subject =~ /^re:\\s/i\n mail.subject = self.subject\n elsif self.subject\n mail.subject = 'Re: ' + self.subject\n elsif fields[:subject]\n mail.subject = fields[:subject]\n end\n\n # fill in the subject from the original email\n mail.body = fields[:body]\n\n # gather up the to, cc, and bcc addresses\n to = []\n cc = []\n bcc = []\n\n # process 'bcc' addresses on method call\n # Do this first so can suppress such addresses in To: and Cc: fields\n if fields[:bcc]\n Array(fields[:bcc]).compact.each do |addr|\n addr = Message.liberal_email_parser(addr) if addr.is_a? String\n next if bcc.any? {|a| a.address == addr.address}\n bcc << addr\n end\n end\n\n # process 'to' addresses on method call\n if fields[:to]\n Array(fields[:to]).compact.each do |addr|\n addr = Message.liberal_email_parser(addr) if addr.is_a? String\n next if to.any? {|a| a.address = addr.address}\n to << addr\n end\n end\n\n # process 'from' addresses from original email\n self.from.addrs.each do |addr|\n next if to.any? {|a| a.address == addr.address}\n if fields[:to]\n next if cc.any? {|a| a.address == addr.address}\n next if bcc.any? {|a| a.address == addr.address} # skip if already in Bcc\n cc << addr\n else\n to << addr\n end\n end\n\n # process 'to' addresses from original email\n if self.to\n self.to.addrs.each do |addr|\n next if to.any? {|a| a.address == addr.address}\n next if cc.any? {|a| a.address == addr.address}\n next if bcc.any? {|a| a.address == addr.address} # skip if already in Bcc\n cc << addr\n end\n end\n\n # process 'cc' addresses from original email\n if self.cc\n self.cc.each do |addr|\n addr = Message.liberal_email_parser(addr) if addr.is_a? String\n next if to.any? {|a| a.address == addr.address}\n next if cc.any? {|a| a.address == addr.address}\n next if bcc.any? {|a| a.address == addr.address} # skip if already in Bcc\n cc << addr\n end\n end\n\n # process 'cc' addresses on method call\n if fields[:cc]\n Array(fields[:cc]).compact.each do |addr|\n addr = Message.liberal_email_parser(addr) if addr.is_a? String\n next if to.any? {|a| a.address == addr.address}\n next if cc.any? {|a| a.address == addr.address}\n next if bcc.any? {|a| a.address == addr.address} # skip if already in Bcc\n cc << addr\n end\n end\n\n # reformat email addresses\n mail[:to] = to.map(&:format)\n mail[:cc] = cc.map(&:format) unless cc.empty?\n mail[:bcc] = bcc.map(&:format) unless bcc.empty?\n\n # return the resulting email\n mail\n end", "def processMessage\n\n loop do\n\n input = @processMessageQueue.pop\n\n Log::debug \"#{__method__}: #{input}\"\n\n case input[:type]\n when :send\n\n id = input[:id]\n to = input[:to]\n from = input[:from]\n\n output = packMessage(to, input[:message])\n\n if output\n \n @processJobQueue.push({\n :type=>:notifyPacked,\n :id=>id,\n :time => Time.now,\n :counter => output[:counter],\n :message => {\n :to => to,\n :from => from,\n :message => output[:data],\n :ip => input[:ip],\n :port => input[:port]\n } \n })\n\n else\n\n @processJobQueue.push({\n :type=>:notifyNotSent,\n :id=>id,\n :time => Time.now\n })\n\n end\n\n when :receive\n\n id = input[:id]\n \n result = unpackMessage(input[:data])\n\n if result\n\n case result[:recipient]\n when :PR6_RECIPIENT_CLIENT\n\n @processJobQueue.push({\n :type => :processMessage,\n :from => result[:from],\n :to => result[:to],\n :message => result[:data] \n })\n\n when :PR6_RECIPIENT_SERVER\n\n association = AssociationRecord.read(result[:to], result[:to], result[:from])\n\n if association\n\n output = packMessage(result[:from], Server.new(association, @objects).input(result[:counter], result[:data]))\n \n if output.size > 0\n\n @outputQueue.push({\n :to => result[:from],\n :from => result[:to],\n :ip => input[:ip],\n :port => input[:port],\n :message => output[:data]\n })\n\n end\n\n else\n\n Log::warning \"#{__method__}: assocation record removed since last read\"\n \n end\n\n else\n raise\n end\n\n end\n\n else\n raise \"unknown message type\"\n end\n\n end\n\n end", "def fetch\n capture_errors(MessageError) do\n if defined?(@message) && [email protected]?\n @message\n else\n Mail.new(conn.fetch(@uid).ok![0])\n end\n end\n end", "def scan(&block)\n @processor = block if block\n incoming_config = config.incoming\n if incoming_config.nil?\n logger.error(\"Not scanning for incoming mail, since environment is '#{Kernel.environment}'\")\n return\n end\n\n say \"Starting scan at #{Time.now}\"\n c,e,n = nil,nil\n\n begin\n imap = Net::IMAP.new(incoming_config.server, incoming_config.port, true)\n imap.login(incoming_config.user, incoming_config.secret)\n imap.select('INBOX')\n messages = imap.search([\"NOT\", \"DELETED\"])\n n = messages.size\n c = e = 0\n messages.each do |message_id|\n received_message = nil\n rfc822 = imap.fetch(message_id, \"RFC822\")[0].attr[\"RFC822\"]\n begin\n received_message = receive(rfc822)\n say \"Processed message #{received_message.mail.subject}\"\n c += 1\n rescue Exception => exception\n # todo: move message into an \"error\" folder so it doesn't get reprocessed, but don't delete it\n report_exception(exception)\n say \"Error processing message #{message_id}: #{exception.class.name}: #{exception.message}\"\n e += 1\n ensure\n if received_message && received_message.delete?\n say \"Deleting message #{message_id}\"\n imap.store(message_id, \"+FLAGS\", [:Deleted])\n end\n end\n end\n\n imap.close # Sends a CLOSE command to close the currently selected mailbox. The CLOSE command permanently removes from the mailbox all messages that have the \\Deleted flag set.\n imap.logout\n imap.disconnect\n # NoResponseError and ByeResponseError happen often when imap'ing\n rescue Net::IMAP::NoResponseError, Net::IMAP::ByeResponseError, Errno::ENOTCONN\n # ignore\n rescue Exception => e\n report_exception(e)\n end\n say \"Processed #{c.inspect} of #{n.inspect} emails received (#{e} errors).\"\n end", "def deliver\n xml = Clockwork::XML::SMS.build_multiple( self.messages )\n http_response = Clockwork::HTTP.post( Clockwork::API::SMS_URL, xml, @use_ssl )\n responses = Clockwork::XML::SMS.parse_multiple( self.messages, http_response )\n end", "def reminder_received(event)\n @event = event\n\n mail :to => event.email, :subject => 'Reminder alert'\n end", "def index\n @inbox = Email.to(@user.name)\n process_incoming(@inbox)\n @sent = Email.from(@user.name)\n end", "def email(cdn, e)\n data = JSON.load REDIS[cdn]\n link = \"http://logserver.flocasts.com/#{cdn.to_sym.object_id}\"\n\n tox = data['server_admins']\n from = '[email protected]'\n subj = '[ERROR] ' + cdn\n text = [link, \"\\n\", e.message, e.class, e.backtrace].join \"\\n\"\n\n Gmail.new from, 'flocastayo' do |gmail|\n gmail.deliver do\n to tox\n subject subj\n text_part { body text }\n end\n end\nend", "def process(message)\n end", "def process(msg)\n headers = msg[\"headers\"]\n federation = headers[\"federation\"]\n\n Log.info(\"Federation received %s from %s\" % [federation[\"req\"], headers[\"mc_sender\"]])\n\n federation[\"reply-to\"] = headers.delete(\"reply-to\")\n headers[\"reply-to\"] = collective_source_name\n\n record_seen(headers)\n\n Log.debug(\"federation => collective: %s\" % [headers])\n\n @outbox << {\n :targets => federation.delete(\"target\"),\n :req => federation[\"req\"],\n :data => JSON.dump(msg)\n }\n end", "def received(order)\n @order = order\n order.line_items.each do |line_item|\n image_url = line_item.product.image_url\n attachments[image_url] = File.read(image_url)\n end\n I18n.with_locale(@order.user.language) do\n mail to: order.email, subject: I18n.t('order_mailer.recieved.subject')\n end\n end", "def goThroughUserEmails(user_id, username, password, server, port, tls, last_uid, virtual_device_name)\n begin\n new_uid = last_uid\n \n user = User.find_by_id(user_id)\n if user == nil\n return\n end\n \n # Connect to gmail server\n if tls\n imap = Net::IMAP.new(server,port,false)\n else\n imap = Net::IMAP.new(server,port,true)\n end\n \n # Login\n imap.login(username, password)\n \n # Select inbox\n imap.select('INBOX')\n \n # get all new mails\n tmp_last_uid = (last_uid+1).to_s+\":\"+(last_uid+101).to_s\n #puts tmp_last_uid\n imap.uid_search([\"NOT\", \"DELETED\", \"UID\", tmp_last_uid]).each do |uid|\n puts \"Checking mail with uid: #{uid}\"\n #notSeen = false\n #if imap.search([\"NOT\", \"DELETED\", \"NOT\", \"SEEN\", \"UID\", uid]) != nil\n # notSeen = true\n #end\n \n # fetches the source of the email for tmail to parse\n source = imap.uid_fetch(uid, 'RFC822')\n \n if source == nil\n puts \"Couldn't find mail with uid: #{uid}\"\n next\n end\n \n source = source.first.attr['RFC822']\n \n email = TMail::Mail.parse(source) \n \n if user == nil\n next\n end\n \n device = nil\n \n # If has attachments, save them\n if email.has_attachments?\n email.parts.each_with_index do |part, index|\n puts part.content_type\n \n # Text files are ignored. If mail has attachments, body was considerede as attachment.\n if part.content_type == \"text/plain\" or part.content_type == \"multipart/alternative\"\n next\n end\n \n # Create device if doesn't already exist\n if device == nil\n # Try to find virtual device or create it\n device = findOrCreateVirtualDevice(user.id, virtual_device_name)\n \n # If device name is already in use for other type of device, \n if device == nil\n puts \"Couldn't create virtual_container with name #{virtual_device_name}\"\n next\n end\n end \n \n filename = part_filename(part)\n content_type = part.content_type\n filename ||= \"#{index}.#{ext(part)}\"\n file = filename\n fname = file.split(\".\")\n \n # If prefix given in topic, add it to filename\n if email.subject.to_s.include?(\"[p]\") \n # Adds email topic as a prefix for the file\n filename = email.subject.to_s.gsub('[p]', '').strip.gsub(/\\r/, '_') + \"_\" + filename\n end\n \n # Use virtualContainerManager to add the file\n # Create the manager \n @virtualContainerManager = VirtualContainerManager.new(user, device.dev_name)\n \n # Add file with the manager\n @virtualContainerManager.addFile('/' + filename, part.body)\n \n # Add metadata\n @virtualContainerManager.addMetadata('/' + filename, \"mail_topic\", email.subject)\n @virtualContainerManager.addMetadata('/' + filename, \"mail_from\", email.from.to_s.strip)\n \n # Make the commit\n @virtualContainerManager.commit\n \n puts \"File #{filename} was saved to visualrest\"\n end\n end\n # If mail was not seen, mark it again as not seen\n #puts \"merkitään lukemattomaksi\"\n #if notSeen\n # imap.store(uid, \"-FLAGS\", [:seen])\n #end\n if uid > new_uid\n new_uid = uid\n end\n end\n \n \n imap.logout\n imap.disconnect\n \n rescue => e\n puts \"Problem fetching users mails\"\n puts e\n return new_uid\n end\n return new_uid\n end", "def notify(data)\n puts data[:email]\n @body = data[:body]\n mail to: data[:email], subject: data[:subject]\n end", "def receive_inbound_email_from_mail(**kwargs, &block)\n create_inbound_email_from_mail(**kwargs, &block).tap(&:route)\n end" ]
[ "0.67105305", "0.6704208", "0.6631321", "0.62802464", "0.6206252", "0.61915076", "0.61255157", "0.61229783", "0.6115969", "0.6062662", "0.60546124", "0.60490656", "0.6038545", "0.6026178", "0.60095584", "0.5999877", "0.5971041", "0.5955457", "0.59428436", "0.5917347", "0.59145635", "0.58995175", "0.5880326", "0.5869732", "0.5869455", "0.586395", "0.58558595", "0.58371526", "0.5831067", "0.5829968", "0.582936", "0.5780931", "0.5777769", "0.57742274", "0.5759779", "0.5754426", "0.57474923", "0.5715521", "0.56949264", "0.5668317", "0.56641173", "0.5662154", "0.5638882", "0.5638882", "0.5633683", "0.56130403", "0.5612617", "0.5605681", "0.5575969", "0.55741566", "0.55712175", "0.55646265", "0.5558215", "0.55543697", "0.55521345", "0.55447775", "0.55216604", "0.5520281", "0.5515556", "0.5512004", "0.549426", "0.5483434", "0.54811746", "0.5465722", "0.54499567", "0.5446788", "0.5441362", "0.54182416", "0.5406282", "0.54049176", "0.54031014", "0.53893673", "0.5381026", "0.5376736", "0.5361118", "0.5360499", "0.53516996", "0.53463894", "0.53447664", "0.534112", "0.53386647", "0.5334845", "0.5323982", "0.5322155", "0.531499", "0.5314463", "0.53076255", "0.53025824", "0.5288902", "0.5286802", "0.52855986", "0.5269519", "0.5260896", "0.52442735", "0.52438843", "0.52350503", "0.52326053", "0.5225837", "0.5225347", "0.52218705" ]
0.6466807
3
Answers the provided subject with superfluous 're:' and this list's labels removed. clean_subject('[List Label] Re: The new Chrome Browser from Google') => 'Re: The new Chrome Browser from Google' clean_subject('Re: [List Label] Re: The new Chrome Browser from Google') => 'Re: The new Chrome Browser from Google'
def clean_subject(string) without_label = string.gsub(subject_prefix_regex, '') if without_label =~ REGARD_RE "Re: #{remove_regard(without_label)}" else without_label end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subject_clean(subject)\n return '' if subject.blank?\n\n ticket_hook = SygiopsSupport::Setting.get('ticket_hook')\n ticket_hook_divider = SygiopsSupport::Setting.get('ticket_hook_divider')\n ticket_subject_size = SygiopsSupport::Setting.get('ticket_subject_size')\n\n # remove all possible ticket hook formats with []\n subject = subject.gsub(/\\[#{ticket_hook}: #{number}\\](\\s+?|)/, '')\n subject = subject.gsub(/\\[#{ticket_hook}:#{number}\\](\\s+?|)/, '')\n subject = subject.gsub(/\\[#{ticket_hook}#{ticket_hook_divider}#{number}\\](\\s+?|)/, '')\n\n # remove all possible ticket hook formats without []\n subject = subject.gsub(/#{ticket_hook}: #{number}(\\s+?|)/, '')\n subject = subject.gsub(/#{ticket_hook}:#{number}(\\s+?|)/, '')\n subject = subject.gsub(/#{ticket_hook}#{ticket_hook_divider}#{number}(\\s+?|)/, '')\n\n # remove leading \"..:\\s\" and \"..[\\d+]:\\s\" e. g. \"Re: \" or \"Re[5]: \"\n subject = subject.gsub(/^(..(\\[\\d+\\])?:\\s)+/, '')\n\n # resize subject based on config\n if subject.length > ticket_subject_size.to_i\n subject = subject[ 0, ticket_subject_size.to_i ] + '[...]'\n end\n\n subject.strip!\n subject\n end", "def clean_related(subject)\n \tsubject.gsub!(/\\n/, \"\")\n \tsubject.gsub!(/<[^<>]*>/, \"\")\n \tsubject.to_s\n \tsubject.split('&gt;')\n end", "def clean\n self.subject = sanitize subject\n end", "def clean\n self.subject = sanitize self.subject\n end", "def parse_subject (str, record)\n # lines = str.split /\\r?\\n/\n # str = ''\n # lines.each do |line|\n # if line.lstrip =~ /^Subject:/\n # colour_puts(:cyan, line, out_file)\n\n # puts \"str = #{str}\"\n start_idx = subject_start_idx(str)\n end_idx = subject_end_idx(str)\n\n # if start_idx\n\n if start_idx && end_idx\n str = str[subject_start_idx(str) .. subject_end_idx(str)]\n # elsif start_idx\n # str = str[subject_start_idx(str) .. -1]\n # str = line\n # end\n end\n if str == ''\n str = \"ERROR - CAN'T PARSE HEADING!!!'\"\n end\n\n str = strip_ruby_core str, record\n str = strip_issue_type str, record\n strip_completion(str).strip.gsub(\"\\n\",'').gsub(\"\\t\",' ')\n end", "def subject\n\t\tlink = self.links.find {|link| link.llabel[0] == ?S } or return nil\n\t\treturn link.lword.sub( /\\.[np]$/, '' )\n\tend", "def subject\n map_field(:subject)&.map { |a| a.gsub(/ \\$[a-z] /, '--') }\n end", "def communication_subject_for_solr\n return FinderHelper.strip(communication_subject)\n end", "def clean_subject_string(old_subject_string)\n return if old_subject_string.blank?\n\n # There's a max of 30 characters in the database\n new_subject_string = old_subject_string.strip[0..29]\n\n # strip leading and trailing whitespace\n new_subject_string = new_subject_string.strip()\n\n # if the subject ends in a period (something metadata rules can require), strip the period\n new_subject_string = new_subject_string.gsub(/\\.$/, '').titleize\n\n # If new_subject_string is empty, return nil, else return new_subject_string.\n return unless new_subject_string.present?\n\n return new_subject_string \n end", "def subject_topic\n map_field(:subject_topic)&.map { |a| a.gsub(/ \\$[a-z] /, '--') }\n end", "def normalize_subject_name\n self.subject = subject.downcase.titleize\n end", "def get_subject_name\n subject_name = subject_header.text.sub! 'Subject:', ''\n subject_name = subject_name.strip!\n subject_name\n end", "def clean_terms\n submission_keys = redis.lrange(SUBMISSIONS_KEY, 0, -1)\n submission_keys.each do |submission_key|\n redis.hdel(submission_key, \"terms\")\n end\n end", "def subject_with_formatting\n (self.subject.blank?) ? 'N/A' : self.subject\n end", "def validate_subject\n if @subject.nil?\n puts \"No subject, skipping\"\n raise StandardError, \"No subject\"\n else\n @title.strip\n end\n end", "def extract_subjects_from_table(subject_list)\n subject_list\n .split(',')\n .map(&:strip)\n .reject { |subject| subject == 'None' }\n .compact\nend", "def keywords_subject\n key = @strip['keywords']\n if key.nil?\n @null\n else\n [@strip['subject'], key].join(',')\n end\n end", "def check_subject\n return true if subject.blank?\n\n subject.gsub!(/\\s|\\t|\\r/, ' ')\n true\n end", "def clean_title(title)\n title.gsub(/[\\#=>\\d]|Papers We Love|PWL/, '').sub(/[-{1}]/, '').sub(/\\(part \\d?( of \\d?)?\\)/i, '').strip\nend", "def clean_primary_subject()\n self.area_of_study = self.clean_subject_string(self.area_of_study)\n self.save\n end", "def format_final_subject(subjects)\n if subjects.size == 1\n subjects[0]\n elsif subjects.size == 2\n subjects[0] + ' and ' + subjects[1]\n else\n last_subject = subjects.pop()\n subjects.join(', ') + ' and ' + last_subject\n end\n end", "def named_subject\n map_field(:named_subject)&.map { |a| a.gsub(/ \\$[a-z] /, ' ') }\n end", "def subject\n subject = self.read_attribute(:subject)\n begin\n Rfc2047.decode subject if subject\n rescue Rfc2047::Unparseable\n return subject\n end\n end", "def formatted_subject(text)\n name = PersonMailer.global_prefs.app_name\n label = name.blank? ? \"\" : \"[#{name}] \"\n \"#{label}#{text}\"\n end", "def get_subject(lyric)\n arr = lyric.gsub(' and ', 'and').split('and')\n subjects = []\n for item in arr\n item = item.split(' ')\n subjects.push(item[0..1].join(' ')) if item[0].downcase == 'the'\n end\n return subjects\n end", "def subject_name\n subject_full_name\n end", "def parse_lists_from_subject(subject)\n # extract part between '[...]'\n subject.to_s.match(/\\[(.*)\\]/)\n if $1\n # and create array by valid separators: \\s , |\n subject_array = $1.split(/[\\s,|]/)\n else\n return []\n end\n lists = []\n List.all.each do |list|\n subject_array.each do |pot_list|\n if pot_list.casecmp(list.name) == 0\n lists << list\n end\n end\n end\n return lists\n end", "def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end", "def without_instruction(text)\n text.gsub(/^you (should|must)/i, '').gsub(/\\.$/, '')\n end", "def get_subject\n out = ''\n if aggregate_count > 1 #multiple records of any type\n if type_count > 1 #multiple types of records\n if distinct_aggregate_count > 1 #multiple profiles\n others = (distinct_aggregate_count-1)\n out << \"and #{pluralize(others, 'other')} \"\n out << subject_aggregate.sub('was ','were ')\n out << \" #{type_count} times\"\n else\n out << subject_aggregate\n out << \" #{type_count} times\"\n end\n else\n if distinct_aggregate_count > 1 #multiple profiles\n others = (distinct_aggregate_count-1)\n out << \"and #{pluralize(others, 'other')} \"\n out << subject.sub('was ','were ')\n else\n out << subject\n end\n end\n else\n out << subject\n end\n return out.html_safe\n end", "def remove_prefix(msg)\n msg.sub(PREFIX_REGEX, \"|\")\n end", "def solrize\n return [rdf_subject.to_s] unless label_present\n [rdf_subject.to_s, { label: \"#{preferred_label}$#{rdf_subject}\" }]\n end", "def fix_unselectable_shortest(terms, prefix, original, subject)\n list = original.list.dup\n shortest = list.min{|one, two| one.length <=> two.length}\n return if shortest.nil?\n list.delete(shortest)\n\n check_pattern = completion_matcher(terms, shortest, nil, subject)\n filter = restricted_pattern(prefix)\n if list.all?{|item| check_pattern =~ item and filter !~ item }\n original.list.replace [shortest]\n end\n end", "def subject(*extra)\n subject = \"\"\n subject << \"#{@project.name} | \" if @project\n subject << extra.join(' | ') if extra.present?\n subject\n end", "def subject_alternative_names\n @_subject_alternative_names ||= begin\n if attribute = read_attributes_by_oid('extReq', 'msExtReq')\n set = OpenSSL::ASN1.decode(attribute.value)\n seq = set.value.first\n if sans = seq.value.collect { |asn1ext| OpenSSL::X509::Extension.new(asn1ext).to_a }.detect { |e| e.first == 'subjectAltName' }\n sans[1].gsub(/DNS:/,'').split(', ')\n else\n []\n end\n else\n []\n end\n end\n end", "def subject\n @subject ||= \"(sans sujet)\"\n if @no_header_subject.nil?\n \"#{header_subject}#{@subject}\"\n else\n @subject\n end\n end", "def original_email(email)\n if email.match(/\\[\\w+-\\d+\\]/)\n email.sub(/\\[\\w+-\\d+\\]/, '')\n else\n email\n end\n end", "def sanitize_label(label)\n label.gsub(%r![^a-z0-9_\\-.]!i, \"\")\n end", "def remove_listlibrary_headers str\n # Lots of messages have Message-Id headers added;\n # Date headers were added to 3 in ruby-list, 2 in chipy\n # 3 messages in ruby-list have Date headers added\n # 2 messages in chipy have Date headers added\n while str =~ /^X-ListLibrary-Added-Header: (.*)$/\n header = $1 # Thanks, Perl\n header.sub!('\\n','') # yes, remove a literal \\n that yaml didn't parse\n str.sub!(/^#{header}: .*\\n/, '')\n str.sub!(/^X-ListLibrary-Added-Header: .*\\n/, '')\n end\n str\nend", "def remove_stop_words(question, vectorStopWords)\n vectorStopWords.each do |stopWord|\n if question.match(/\\b#{stopWord}\\b/)\n question.gsub! (/\\b#{stopWord}\\b/), ''\n end\n end\n question\n end", "def cleanup_title(single_line)\n\tif single_line =~ /[^>]*$/ #Starts at the end and finds the first > symbol and matches everything before it (the song title), credit goes to Jonah for reminding me that #{$&} exists\n title = \"#{$&}\"\n end\n\t#Thank you Isaac for telling me to use gsub instead of what I did above\n\ttitle.gsub!(/[\\(|\\[|\\{|\\\\|\\/|_|\\-|\\:|\\\"|\\`|\\+|\\{|\\*].*$/,\"\") #Replaces everything after the first instance of ( [ { \\ / _ - : \" ` + = *\n\ttitle.gsub!(/feat\\..*/) #removes everything after feat.\n\ttitle.gsub!(/[\\?|\\¿|\\!|\\¡|\\.|\\;|\\&|\\@|\\%|\\#|\\|]/,\"\") #removes all punctuation\n\tif title =~ /[^\\w\\s']/ #ignores songs that contain non-Eng\n\t\ttitle = nil\n\tend\n\tif title != nil\n\t\ttitle.downcase!\n\t\t#Stop words implementation\n\t\ttitle.gsub!(/is\\s|a\\s|ab\\s|and\\s|by\\s|for\\s|from\\s|in\\s|of\\s|on\\s|or\\s|out\\s|the\\s|to\\s|with\\s/,\"\")\n\t\treturn title\n\tend\nend", "def subject_names\n @subject_names ||= sw_subject_names\n end", "def parse(subject, term)\n return term\n end", "def sw_subject_titles(sep = ' ')\n result = []\n mods_ng_xml.subject.titleInfo.each { |ti_el|\n parts = ti_el.element_children.map(&:text).reject(&:empty?)\n result << parts.join(sep).strip unless parts.empty?\n }\n result\n end", "def to_s\n if (subject.nil? || subject.blank?)\n truncate(self.description, :length => 100, :omission => '...')\n else\n self.subject\n end\n end", "def subject_list_for_autocomplete\n subject_list = \"[\"\n all_subjects do |subject|\n subject_list+=\"{label:\\\"#{subject.to_s}\\\",title:\\\"#{subject.title}\\\",value:\\\"#{subject.code}\\\"},\\n\"\n subject_list << { :label => \"#{subject.to_s}\",\n :title => \"#{subject.title}\",\n :value => \"#{subject.code}\" }\n end\n subject_list += \"]\"\n end", "def subject(*extra)\n subject = \"GitLab\"\n subject << (@project ? \" | #{@project.name_with_namespace}\" : \"\")\n subject << \" | \" + extra.join(' | ') if extra.present?\n subject\n end", "def clean_title(title)\n title.\n # Take the part of the title before Bill, Act or -\n split(/Bill|Act|-/, 2)[0].\n # Remove any brackets\n gsub(/\\([a-zA-Z.\\d\\s'\",]*\\)/, '').\n # Strip any trailing whitespace\n rstrip\nend", "def trim_title(ttl)\n if ttl\n unless @site.ttlcut.blank?\n re = /#{@site.ttlcut}/\n if md = re.match(ttl)\n ttl = md[1] || ttl.sub(re, '')\n end\n end\n ttl.gsub(/\\s+/, ' ').strip\n end\n end", "def alternate_clean_title(title)\n title.\n # Take the part of the title before Bill or Act\n split(/Bill|Act/, 2)[0].\n # Remove any brackets\n gsub(/\\([a-zA-Z.\\s\\d'\",-]*\\)/, '').\n # Strip any trailing whitespace\n rstrip\nend", "def cleansed_title\n self.title.gsub(/[\\t\\r\\n\\f:@]/, '')\n end", "def remove_duplicate_errors\n if errors[\"mailboxer_notification.conversation.subject\"].present? and errors[\"mailboxer_notification.subject\"].present?\n errors[\"mailboxer_notification.conversation.subject\"].each do |msg|\n errors[\"mailboxer_notification.conversation.subject\"].delete(msg)\n end\n end\n end", "def strip_text_unique(passage)\n strip_text(passage).uniq#unique\nend", "def removed_panel(interview, resume)\n subject \"Interview cancelled\"\n recipients [ interview.employee.email ]\n from [ \"[email protected]\" ]\n sent_on Time.now\n content_type 'text/html'\n body :emp_to => interview.employee,\n :interview => interview,\n :uniqid => resume.uniqid,\n :resume => resume,\n :requirement => interview.req_match.requirement\n end", "def cleanMsgText(txt)\r\n clean = txt.gsub(/[\"]/,\"'\")\r\n\r\n clean\r\n end", "def sanitize_label(label); end", "def subject_name\n return @subject_name\n end", "def subjects(list=[], [email protected]_css('article-meta article-categories'), prefix = nil)\n return unless root\n subj_node = root.at_css('> subject')\n\n subj_text = subj_node && subj_node.text\n\n if subj_text.present?\n prefix = [prefix, subj_text].compact.join(\" - \")\n list << prefix\n end\n\n root.css('> subj-group').each do |node|\n subjects(list, node, prefix)\n end\n\n list.presence\n end", "def subject\n self['subject'] || msg['subject']\n end", "def subjectify(options = {})\n result = []\n all_subjects = []\n sub_array = []\n options[:value].each_with_index do |subject, i|\n spl_sub = subject.split(QUERYSEP)\n sub_array << []\n subject_accum = ''\n spl_sub.each_with_index do |subsubject, j|\n spl_sub[j] = subject_accum + subsubject\n subject_accum = spl_sub[j] + QUERYSEP\n sub_array[i] << spl_sub[j]\n end\n all_subjects[i] = subject.split(QUERYSEP)\n end\n options[:value].each_with_index do |_subject, i|\n lnk = ''\n lnk_accum = ''\n all_subjects[i].each_with_index do |subsubject, j|\n lnk = lnk_accum + link_to(subsubject,\n \"/?f[subject_facet][]=#{CGI.escape sub_array[i][j]}\",\n class: 'search-subject', title: \"Search: #{sub_array[i][j]}\")\n lnk_accum = lnk + content_tag(:span, SEPARATOR, class: 'subject-level')\n end\n result << sanitize(lnk)\n end\n result\n end", "def subject_list\n list = []\n subjects.each { |subject| list << subject.name }\n list.to_sentence\n end", "def body_clean\n text = \"\"\n\n # Iterate through each line\n body.split(/\\n/).each do |line|\n # Included replies \"> some text\"\n next if line.match(/^>+/) \n next if line.match(/On.*wrote:/)\n # Outlook reply style\n break if line.match(/-{4,}Original Message-{4,}/)\n # Signature break \"--\"\n break if line.match(/^\\s*\\-{2,}\\s*$/)\n # Lines with only whitespace - blank them\n line.gsub(/^\\s+$/, \"\")\n\n text += line + \"\\n\"\n end\n\n # Clean out multiple line breaks throughout (longer than one blank line)\n text.gsub!(/\\n{3,}/, \"\\n\\n\") \n # Clean up multiple line breaks at end (none)\n text.gsub!(/\\n{2,}$/, \"\\n\")\n\n return text\n end", "def create_cleared_text(s)\n s.gsub(/[RMQ]T @[a-zA-Z0-9_]+:.*/, '')\n .gsub(/\\. ?(@[a-zA-Z0-9_]+ )+/, '')\n .gsub(/@[a-zA-Z0-9_]+/, '')\n .gsub(%r[(https?|ftp)(:\\/\\/[-_.!~*\\'()a-zA-Z0-9;\\/?:\\@&=+\\$,%#]+)], '')\n .gsub(/#.+([  、。]|$)/, '')\n .strip\n end", "def subject() self.headers[\"Subject\"] || \"[NO SUBJECT]\" end", "def labels_to_remove\n if params[:remove_labels].nil? || !params[:remove_labels].is_a?(Array) || params[:remove_labels].uniq.compact.empty?\n @labels_to_remove ||= []\n end\n\n @labels_to_remove ||= params[:remove_labels].uniq.compact\n end", "def remove_stop_words(song)\n\ttitle = song\n\ttitle.gsub!(/\\b(a|an|and|by|for|from|in|of|on|out|the|to|with)\\b+/, \"\")\n\treturn title\nend", "def clean_message(message); end", "def strip_citations_potentially_inefficient(summary)\n summary_stripped = ''\n str_len = summary.length\n idx = 0\n while idx < str_len\n summary_stripped += summary[idx]\n idx+=1\n while summary[idx] == '['\n while idx + 1 < str_len && summary[idx] != ']'\n idx+=1\n end\n idx+=1\n end\n end\n return summary_stripped\n end", "def admin_remove_member_request_list\n %w( [email protected] )\n end", "def get_text_for_indexing\n text = self.body.strip\n text.sub!(/Dear .+,/, \"\")\n text.sub!(/[^\\n]+1049\\/2001[^:\\n]+:? ?/, \"\") # XXX: can't be more specific without locale\n self.remove_privacy_sensitive_things!(text)\n return text\n end", "def remove_subject_topic(index)\n self.descMetadata.remove_subject_topic(index)\n end", "def title_brief\n return '' unless @marc_record && @marc_record['245']\n subfieldA = @marc_record['245']['a'] || ''\n title = subfieldA.strip\n # return the cleaned up title\n trim_punctuation(title)\n end", "def cleaned(txt)\n\t\ttxt.gsub(/[(,\\'.#)]/, '')\n\tend", "def cleaned(txt)\n\t\ttxt.gsub(/[(,\\'.#)]/, '')\n\tend", "def cleanup_title(line)\n\ttitle = line.gsub(/.*>/, '') #strip everything in front of song title\n\ttitle.gsub!(/\\(.*|\\[.*|\\{.*|\\\\.*|\\/.*|\\_.*|\\-.*|\\:.*|\\\".*|\\`.*|\\+.*|\\=.*|\\*.*|feat\\..*/, \"\") #Remove rest of title following given characters\n\ttitle.gsub!(/(\\?|\\¿|\\!|\\¡|\\.|\\;|\\&|\\@|\\%|\\#|\\|)*/, '') #remove special characters\n\ttitle = title.downcase\n\ttitle.gsub!(/\\b(and|an|a|by|for|from|in|of|on|or|out|the|to|with)*\\b/, '') #remove stop words\n\ttitle.gsub!(/\\s\\s+/, ' ') #add whitespace between words\n\treturn title\nend", "def subject_names\n ret = []\n if cn = self.subject_component('CN')\n ret << cn\n end\n # Merge in san_names if we got anything.\n if sn = self.san_names\n ret.concat(sn)\n end\n\n return ret.sort.uniq\n end", "def subject\n title \n end", "def subject_name\n subject&.name\n end", "def prefix\n if self.answers.first && self.answers.first.text.include?('|')\n self.answers.first.text.split('|')[0]\n end\n end", "def remove_duplicates_recursivly (phrase, important, string)\n\ttype = [\"\"]\n\tremovables = [\"CC\", \",\"]\n\tphrase.each do |sub|\n\t\tif sub.exact_tag?(type)\n\t\t\t# it is a repetition\n\t\t\tif delete.empty?\n\t\t\t# If it is the first repetition, check the first\n\t\t\t# done to avoid checking every entity if in important\n\t\t\t\tdelete[!arr_in_phrase(important, sub.to_s)]\n\t\t\tend\n\t\t\t# save it\n\t\t\tsame << sub.to_s\n\t\t\tdelete << !arr_in_phrase(important, sub.to_s)\n\n\t\telsif sub.exact_tag?(removables)\n\t\t\t# it is not a repetition, but it is a connector of some sort (\",\" \"or\" \"and\" maybe something else?)\n\t\t\tto_remove = sub.to_s\n\t\telsif !sub.exact_tag?(removables)\n\t\t\t# not a repetition\n\t\t\tif !same.empty? && delete.any?{|boolean|boolean}\n\t\t\t\t# delete unnecessary information\n\t\t\t\t# need to implement: sub! every true and its left removable (from to_remove) and spaces by a space\n\t\t\t\t# if there is only one true, delete all removables\n\t\t\t\t# elsif the last one is false put its left removable (from to_remove)\n\t\t\t\t# before the last undeleted string, and delete the other removable so there wont be 2 of them. (example: one, two and three -> delete three -> one and two)\n\t\t\tend\n\t\t\tsame = [sub.to_s]\n\t\t\tdelete = []\n\t\t\tif sub.has? :tag\n\t\t\t\ttype = sub.tag\n\t\t\tend\n\t\tend\n\t\tstring = remove_duplicates_recursivly(sub, important, string)\n\tend\nend", "def unfinished_subjects(param = nil)\n @unfinished_subjects ||= plan_subjects - self.finished_subjects\n\n if param == :subjects\n return @unfinished_subjects.map {|p| p.subject}\n else\n return @unfinished_subjects\n end\n end", "def doc2dc_subject(doc)\n # # ALL subjects?\n # doc.xpath(\"//idinfo/keywords/theme/themekey\").map { |node|\n # node.text.strip\n # }\n\n # filter by vocabulary - anything labeled ISO 19115\n subjects = []\n if iso_theme = doc.at_css('theme:has(themekt[text() *= \"ISO 19115\"])')\n iso_theme.xpath(\".//themekey\").each { |node|\n subjects << node.text.sub(/^./, &:upcase)\n }\n end\n subjects.flatten.sort\n end", "def clean\n self.short_msg = sanitize(short_msg)\n self.long_msg = sanitize(long_msg)\n end", "def clean_phrase\n clean_phrase = @phrase.dup\n clean_phrase.downcase!\n clean_phrase.squeeze!\n clean_phrase.gsub!(/[[:space:]]/, '')\n clean_phrase = clean_phrase.split(//)\n end", "def sanitize_mods_name_label(label)\n label.sub(/:$/, '')\n end", "def label(contents, attrs = {})\n if contents\n contents.sub!(/\\*/, '<span class=\"req\">*</span>')\n contents.sub!(/\\((.*)\\)/, '<span class=\"note\">\\1</span>')\n end\n\n super\n end", "def normalize_reviewers(list)\n list.split(',').map { |reviewer|\n name, domain = reviewer.strip.split('@', 2)\n domain ||= Config.data['domain']\n [name, domain].join('@')\n }.compact.uniq\n end", "def subject_titles\n @subject_titles ||= sw_subject_titles\n end", "def subjects\n links = frm.table(:class=>\"listHier\").links.find_all { |link| link.title=~/View announcement/ }\n subjects = []\n links.each { |link| subjects << link.text }\n return subjects\n end", "def remove(tags)\n Array(tags).each { |t| @message.remove_label(t) }\n return @message.labels\n end", "def transform_control_title (title)\n title.gsub(/^\\(L1\\) /, '').gsub(/[()',.&:]/, '').gsub(/.scr/, '').gsub(/\\s+/, '_').gsub(/[\\\\%-]/, '_').gsub(/_+/,'_').downcase\nend", "def rezm_subject_and_status(message)\n if message.receiver_deleted?\n message.subject + \" (Deleted)\" \n elsif message.read_at.nil?\n message.subject + \" (Unread)\" \n else \n message.subject\n end\n end", "def dedup_tags\n title = dup\n tags = title.scan(/(?<=\\A| )(@(\\S+?)(\\([^)]+\\))?)(?= |\\Z)/).uniq\n tags.each do |tag|\n found = false\n title.gsub!(/( |^)#{Regexp.escape(tag[1])}(\\([^)]+\\))?(?= |$)/) do |m|\n if found\n ''\n else\n found = true\n m\n end\n end\n end\n title\n end", "def normalize_query_result_subject(subject)\n subject.kind_of?(Array) && !subject.empty? && is_well_formed_query_result?(subject[0]) ? subject[0] : subject\n end", "def weed_nils\n subject.reject! { |s| s == \"\" } if subject.present?\n end", "def tstrip(term)\n ['au:','ti:','abs:','feed:'].each do |prefix|\n term = term.split(':', 2)[1] if term.start_with?(prefix)\n end\n term#.gsub(\"'\", \"''\").gsub('\"', \"'\")\n end", "def subjects\r\n subjects = []\r\n range =\"#{group[:first_message]}-\"\r\n connection.query(:xhdr, \"Subject\", range) do |status, data|\r\n if status[:code] == 221\r\n data.each do |line|\r\n message = Message.new\r\n message.num, message.subject = line.split(' ', 2)\r\n subjects << message\r\n end\r\n end\r\n end\r\n subjects\r\n end", "def subject_and_status(message)\n tag = ''\n if message.receiver_deleted?\n tag = \" (Deleted)\"\n elsif message.read_at.nil? and params[:action] != \"outbox\"\n \"&middot; <strong>#{message.subject}</strong>\".html_safe\n else\n message.subject\n end\n end", "def remove_discard_supernatant(items)\n show do\n title 'Remove Supernatant'\n note 'Remove and discard supernatant from:'\n items.each do |item|\n bullet item.to_s\n end\n end\n end", "def remove_text_label\n\t\t$tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.p.className(create_ats_regex_string(\"ats-removetxtlbl\")), format_method(__method__))\n\tend" ]
[ "0.7135233", "0.66608185", "0.6257178", "0.6223467", "0.58771783", "0.5775358", "0.5763737", "0.57335246", "0.5665581", "0.5626435", "0.55718213", "0.5447046", "0.5358902", "0.5334072", "0.53285927", "0.532299", "0.5317979", "0.5314128", "0.5236104", "0.5221052", "0.51900154", "0.5168227", "0.51602185", "0.51522017", "0.51512104", "0.5142652", "0.5141527", "0.5103519", "0.50934017", "0.5079738", "0.50756806", "0.50741863", "0.5049786", "0.5026688", "0.502068", "0.50138927", "0.50096214", "0.500469", "0.49955764", "0.49902922", "0.49770162", "0.49679023", "0.4967223", "0.49564755", "0.4936025", "0.49256116", "0.49243125", "0.49149677", "0.4913423", "0.49081308", "0.48826516", "0.4869153", "0.48614085", "0.48552868", "0.4853868", "0.48530874", "0.48513684", "0.4849175", "0.4845149", "0.4839541", "0.4811958", "0.48000216", "0.4796318", "0.47896567", "0.47847447", "0.47752684", "0.47730124", "0.47688562", "0.47618476", "0.47558436", "0.4750863", "0.47501585", "0.4742167", "0.4742167", "0.47404122", "0.4723003", "0.47155133", "0.47122335", "0.4711119", "0.47098505", "0.47041845", "0.46946284", "0.46932858", "0.46894825", "0.4681271", "0.4673322", "0.46700072", "0.46684983", "0.46650985", "0.4663629", "0.46589217", "0.4647605", "0.46459517", "0.46457726", "0.46449235", "0.46358973", "0.46327713", "0.4629712", "0.46174315", "0.46026117" ]
0.7636132
0
The MList::List instance of the list manager.
def list @list ||= manager_list end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list\n @list_helper ||= ListWrapper.new(self)\n end", "def list\n @list.nil? ? List.new : @list\n end", "def new\n @list = List.new\n end", "def define_list(&block)\n @list = List::Base.new(model, &block)\n end", "def new\n @list = List.new\n end", "def list\n @List\n end", "def lists\n Resources::Lists.new(self)\n end", "def list\n return @lists\n end", "def list\n @list\n end", "def list alist=nil\n return @list if alist.nil?\n #@list = Canis::ListDataModel.new(alist)\n @list = alist\n end", "def list\n @@list\n end", "def list\n @list ||= []\n end", "def list\n @list ||= []\n end", "def list\n @list ||= []\n end", "def set_list\n @list = List.find(params[:id])\n end", "def current_list\n List.find(session[:list_id])\n end", "def index\n @list_items = @list.list_items\n end", "def list\n return @list\n end", "def set_list\n @list = List.find(params[:list_id])\n end", "def list alist=nil\n return @list if alist.nil?\n @list = RubyCurses::ListDataModel.new(alist)\n end", "def new\n @list = List.new\nend", "def list\n session[:list_type_id] = ListType.find(:first).id if session[:list_type_id] == nil\n @list_items = ListItem.find_all_by_user_id_and_list_type_id(\n session[:user_id], \n session[:list_type_id],\n :order => \"position\") \n if @list_items.size > 0\n @list_item = @list_items.first\n session[:list_item_id] = @list_items.first.id\n else\n session[:list_item_id] = nil\n end\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def list=(value)\n @list = value\n end", "def lists\n @lib.lists\n end", "def set_list\n @list = List.find(params[:list_id])\n end", "def set_list\n @list = List.find(params[:list_id])\n end", "def set_list\n @list = List.find(params[:list_id])\n end", "def find_list\n @list = List.find(params[:id])\n end", "def lists\n @lists ||= begin\n item_ids_by_list_id = web_menu_lists_attributes.index_by { |attrs| attrs[:list_id] }\n attrs = 'lists.*, 0 as position, true as show_price_on_menu, true as show_description_on_menu, true as show_notes_on_menu, \\'{}\\'::json as list_item_metadata'\n lists = List.where(id: item_ids_by_list_id.keys).accessible_by(@ability).select(attrs)\n lists.each do |list|\n metadata = item_ids_by_list_id[list.id.to_s][:list_item_metadata] || {}\n list.list_item_metadata = metadata\n end\n lists\n end\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def set_list\n @list = List.find(params[:id])\n end", "def list\n self.class.list\n end", "def initialize\n self.list = []\n self.refresh\n end", "def list\n @list.dup\n end", "def get_list(list_name)\n @lib.get_list(list_name)\n end", "def lists\n client.get_lists\n end", "def set_ml_list\n @ml_list = Ml::List.find_by(id: params[:id]) || Ml::List.find_by(id: params[:list_id])\n end", "def set_list\n @list = @lists.find(params[:id])\n end", "def new\n\t\t@list = List.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml\t{ render :xml => @list }\n\t\tend\n\tend", "def set_list\n @list = current_user.lists.find(params[:id])\n end", "def show\n @list = List.find(params[:id])\n end", "def get_items\n\t\treturn @list\n\tend", "def set_list\n @list = current_customer.lists.find(params[:list_id])\n end", "def set_list\n @list = current_user.lists.find(params[:list_id])\n end", "def find_list\n @list = current_user.lists.find params[:id]\n end", "def initialize\n self.list = []\n end", "def get_items\r\n @list\r\n end", "def create\n @ml_list = Ml::List.new(ml_list_params)\n authorize! :create, @ml_list\n\n respond_to do |format|\n if @ml_list.save\n format.html { redirect_to @ml_list, notice: 'List was successfully created.' }\n format.json { render :show, status: :created, location: @ml_list }\n else\n\n format.html { render :new }\n format.json { render json: @ml_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def lists\n result1 = call(\"Lists\", \"get_list_collection\")\n result2 = call(\"SiteData\", \"get_list_collection\")\n result2_by_id = {}\n result2.xpath(\"//sp:_sList\", NS).each do |element|\n data = {}\n element.children.each do |ch|\n data[ch.name] = ch.inner_text\n end\n result2_by_id[data[\"InternalName\"]] = data\n end\n result1.xpath(\"//sp:List\", NS).select { |list| list[\"Title\"] != \"User Information List\" }.map do |list|\n List.new(self, list[\"ID\"].to_s, list[\"Title\"].to_s, clean_attributes(list.attributes), result2_by_id[list[\"ID\"].to_s])\n end\n end", "def list\n call! :list\n end", "def list\n @list ||= PublicSuffix::List::parse(File.new(list_path, \"r:utf-8\"))\n end", "def index\n @list_items = ListItem.all\n end", "def index\n @list_items = ListItem.all\n end", "def set_list\n @list = current_user.lists.find(params[:id])\n end", "def list(name, type = :string)\n class_name = marshal_class_name(name, type)\n \n fields << {:name => name.to_s, :type => :list}\n class_eval \"def #{name}; @#{name} ||= ListProxy.new(self.store, field_key('#{name}'), Marshal::#{class_name}); end\"\n eval_writer(name)\n end", "def set_list\n @list = Blog::List.find(params[:id])\n end", "def show\n @list = List.find(params[:id])\n end", "def show\n @list = List.find(params[:id])\n end", "def get_list\n \t@items\n end", "def list_items\n @list_items ||= children(tag_name: 'li')\n end", "def list_items\n @list_items ||= children(tag_name: 'li')\n end", "def list\n raise NotImplementedError\n end", "def index\n @lists = List.all\n end", "def index\n @lists = List.all\n end", "def index\n @lists = List.all\n end", "def index\n @lists = List.all\n end", "def create\n\t\t@list = List.new(params[:list])\n\n\t\trespond_to do |format|\n\t\t\tif @list.save\n\t\t\t\t\tformat.html\t{ redirect_to(@list, :notice => 'List was successfully created.') }\n\t\t\t\t\tformat.xml\t{ render :xml => @list, :status => :created, :location => @list }\n\t\t\t\t@perm = Permission.new(\n\t\t\t\t\t:add => true,\n\t\t\t\t\t:edit => true,\n\t\t\t\t\t:own => true,\n\t\t\t\t\t:del => true,\n\t\t\t\t\t:user_id => session[:user_id],\n\t\t\t\t\t:list_id => @list.id)\n\t\t\t\[email protected]\n\t\t\telse\n\t\t\t\tformat.html\t{ render :action => \"new\" }\n\t\t\t\tformat.xml\t{ render :xml => @list.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def initialize(list)\n @list = list\n end", "def _list\n if @_structure_changed \n @list = nil\n @_structure_changed = false\n end\n unless @list\n $log.debug \" XXX recreating _list\"\n convert_to_list @treemodel\n #$log.debug \" XXXX list: #{@list.size} : #{@list} \"\n $log.debug \" XXXX list: #{@list.size} \"\n end\n return @list\n end", "def list_entry\n cursor(pos_list_entry).name(\"list\") do |c|\n Innodb::List.get_node(c)\n end\n end", "def new\n\t\t@list = current_user.lists.find params[:list_id]\n\t\t@item = @list.items.build\n\tend", "def set_list_item\n @list_item = ListItem.find(params[:id])\n end", "def lists\n response = get 'lists'\n response.map{|item| Hashie::Mash.new(item)}\n end", "def list(name, type = :string)\n class_name = marshal_class_name(name, type)\n\n fields << {:name => name.to_s, :type => :list}\n class_eval \"def #{name}; @#{name} ||= ListProxy.new(self.redis, field_key('#{name}'), Marshal::#{class_name}); end\"\n eval_writer(name)\n end", "def set_list\n @list = current_user.lists.find(params[:list_id])\n end", "def set_list\n @list = current_user.lists.find(params[:list_id])\n end" ]
[ "0.77844584", "0.7516809", "0.7247719", "0.710566", "0.6937961", "0.6919102", "0.6906006", "0.6654938", "0.66280895", "0.6599661", "0.65787715", "0.65721375", "0.65721375", "0.65430504", "0.65415287", "0.65198594", "0.6518074", "0.65118045", "0.6510626", "0.64977205", "0.6415923", "0.63862664", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6361324", "0.6316161", "0.63006383", "0.62853163", "0.62853163", "0.62853163", "0.62061465", "0.618447", "0.61795735", "0.61795735", "0.61795735", "0.61795735", "0.6170033", "0.61684656", "0.616724", "0.615877", "0.61540604", "0.61494803", "0.614178", "0.61351806", "0.6127218", "0.61205083", "0.6080719", "0.6054725", "0.6040033", "0.6012584", "0.5987541", "0.5986976", "0.59855396", "0.5976775", "0.5975466", "0.59733075", "0.5965947", "0.5965947", "0.5956795", "0.5949068", "0.59401554", "0.59145206", "0.59145206", "0.59077525", "0.5891105", "0.5891001", "0.5880956", "0.58716995", "0.58716995", "0.58716995", "0.58716995", "0.58708674", "0.5851873", "0.58451074", "0.58333737", "0.58227086", "0.5815535", "0.5811012", "0.58099365", "0.58047086", "0.58047086" ]
0.7316944
2
Answer headers values which should be stripped from outgoing email.
def strip_headers %w(return-receipt-to domainkey-signature dkim-signature) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scrub_headers(headers)\n headers.select {|h| UserMailer.legal_headers.include? h}\n end", "def headers\n @headers ||= begin\n @mail.header.fields.inject({}) do |memo, field|\n name = field.name.downcase.to_s\n next memo if self.class.skipped_headers.include?(name)\n\n header = unquoted_header(name)\n memo.update(name => self.class.unescape(header))\n end\n end\n end", "def headers\n @headers.reject {|k, v| k == :body }.map do |k, v|\n translate_header_name(k) + ': ' + v + \"\\n\"\n end.join\n end", "def headers\n msg['headers']||{}\n end", "def normalized_headers\n\t\theaders = self.headers.dup\n\n\t\theaders[:date] ||= Time.now.httpdate\n\n\t\tif self.bodiless? && !self.extended_reply?\n\t\t\theaders.delete( :content_length )\n\t\t\theaders.delete( :content_type )\n\t\telse\n\t\t\theaders[:content_length] ||= self.get_content_length\n\t\t\theaders[:content_type] ||= DEFAULT_CONTENT_TYPE.dup\n\t\tend\n\n\t\treturn headers\n\tend", "def expected_headers_unmet\n unmet = []\n expected = test_case.expected_headers\n expected.each_pair do |k,v|\n got = response.headers[k]\n unmet << \"[headers] #{v} expected for #{k}, got #{got}\" unless (got == v)\n end\n unmet.empty? ? nil : unmet.join(\"\\n\")\n end", "def headerlist; return ['X-ZohoMail']; end", "def unquoted_header(key)\n if header = @mail[key]\n value = header.respond_to?(:map) ?\n header.map { |h| h.value }.join(\"\\n\") :\n header.value\n Mail::Encodings.value_decode(value)\n else\n ''\n end\n end", "def headers\n @headers ||= begin\n mail = Mail.new(self.raw_headers)\n mail.header.fields.each_with_object({}) do |field, hash|\n hash[field.name.downcase] ||= []\n hash[field.name.downcase] << field.decoded\n end\n end\n end", "def populate_headers\n\t\t\t# construct a From value\n\t\t\t# should this kind of thing only be done when headers don't exist already? maybe not. if its\n\t\t\t# sent, then modified and saved, the headers could be wrong?\n\t\t\t# hmmm. i just had an example where a mail is sent, from an internal user, but it has transport\n\t\t\t# headers, i think because one recipient was external. the only place the senders email address\n\t\t\t# exists is in the transport headers. so its maybe not good to overwrite from.\n\t\t\t# recipients however usually have smtp address available.\n\t\t\t# maybe we'll do it for all addresses that are smtp? (is that equivalent to \n\t\t\t# sender_email_address !~ /^\\//\n\t\t\tname, email = props.sender_name, props.sender_email_address\n\t\t\tif props.sender_addrtype == 'SMTP'\n\t\t\t\theaders['From'] = if name and email and name != email\n\t\t\t\t\t[%{\"#{name}\" <#{email}>}]\n\t\t\t\telse\n\t\t\t\t\t[email || name]\n\t\t\t\tend\n\t\t\telsif !headers.has_key?('From')\n\t\t\t\t# some messages were never sent, so that sender stuff isn't filled out. need to find another\n\t\t\t\t# way to get something\n\t\t\t\t# what about marking whether we thing the email was sent or not? or draft?\n\t\t\t\t# for partition into an eventual Inbox, Sent, Draft mbox set?\n\t\t\t\t# i've now seen cases where this stuff is missing, but exists in transport message headers,\n\t\t\t\t# so maybe i should inhibit this in that case.\n\t\t\t\tif email\n\t\t\t\t\t# disabling this warning for now\n\t\t\t\t\t#Log.warn \"* no smtp sender email address available (only X.400). creating fake one\"\n\t\t\t\t\t# this is crap. though i've specially picked the logic so that it generates the correct\n\t\t\t\t\t# email addresses in my case (for my organisation).\n\t\t\t\t\t# this user stuff will give valid email i think, based on alias.\n\t\t\t\t\tuser = name ? name.sub(/(.*), (.*)/, \"\\\\2.\\\\1\") : email[/\\w+$/].downcase\n\t\t\t\t\tdomain = (email[%r{^/O=([^/]+)}i, 1].downcase + '.com' rescue email)\n\t\t\t\t\theaders['From'] = [name ? %{\"#{name}\" <#{user}@#{domain}>} : \"<#{user}@#{domain}>\" ]\n\t\t\t\telsif name\n\t\t\t\t\t# we only have a name? thats screwed up.\n\t\t\t\t\t# disabling this warning for now\n\t\t\t\t\t#Log.warn \"* no smtp sender email address available (only name). creating fake one\"\n\t\t\t\t\theaders['From'] = [%{\"#{name}\"}]\n\t\t\t\telse\n\t\t\t\t\t# disabling this warning for now\n\t\t\t\t\t#Log.warn \"* no sender email address available at all. FIXME\"\n\t\t\t\tend\n\t\t\t# else we leave the transport message header version\n\t\t\tend\n\n\t\t\t# for all of this stuff, i'm assigning in utf8 strings.\n\t\t\t# thats ok i suppose, maybe i can say its the job of the mime class to handle that.\n\t\t\t# but a lot of the headers are overloaded in different ways. plain string, many strings\n\t\t\t# other stuff. what happens to a person who has a \" in their name etc etc. encoded words\n\t\t\t# i suppose. but that then happens before assignment. and can't be automatically undone\n\t\t\t# until the header is decomposed into recipients.\n\t\t\trecips_by_type = recipients.group_by { |r| r.type }\n\t\t\t# i want to the the types in a specific order.\n\t\t\t[:to, :cc, :bcc].each do |type|\n\t\t\t\t# for maximal (probably pointless) fidelity, we try to sort recipients by the\n\t\t\t\t# numerical part of the ole name\n\t\t\t\trecips = recips_by_type[type] || []\n\t\t\t\trecips = (recips.sort_by { |r| r.obj.name[/\\d{8}$/].hex } rescue recips)\n\t\t\t\t# switched to using , for separation, not ;. see issue #4\n\t\t\t\t# recips.empty? is strange. i wouldn't have thought it possible, but it was right?\n\t\t\t\theaders[type.to_s.sub(/^(.)/) { $1.upcase }] = [recips.join(', ')] unless recips.empty?\n\t\t\tend\n\t\t\theaders['Subject'] = [props.subject] if props.subject\n\n\t\t\t# fill in a date value. by default, we won't mess with existing value hear\n\t\t\tif !headers.has_key?('Date')\n\t\t\t\t# we want to get a received date, as i understand it.\n\t\t\t\t# use this preference order, or pull the most recent?\n\t\t\t\tkeys = %w[message_delivery_time client_submit_time last_modification_time creation_time]\n\t\t\t\ttime = keys.each { |key| break time if time = props.send(key) }\n\t\t\t\ttime = nil unless Date === time\n\n\t\t\t\t# now convert and store\n\t\t\t\t# this is a little funky. not sure about time zone stuff either?\n\t\t\t\t# actually seems ok. maybe its always UTC and interpreted anyway. or can be timezoneless.\n\t\t\t\t# i have no timezone info anyway.\n\t\t\t\t# in gmail, i see stuff like 15 Jan 2007 00:48:19 -0000, and it displays as 11:48.\n\t\t\t\t# can also add .localtime here if desired. but that feels wrong.\n\t\t\t\theaders['Date'] = [Time.iso8601(time.to_s).rfc2822] if time\n\t\t\tend\n\n\t\t\t# some very simplistic mapping between internet message headers and the\n\t\t\t# mapi properties\n\t\t\t# any of these could be causing duplicates due to case issues. the hack in #to_mime\n\t\t\t# just stops re-duplication at that point. need to move some smarts into the mime\n\t\t\t# code to handle it.\n\t\t\tmapi_header_map = [\n\t\t\t\t[:internet_message_id, 'Message-ID'],\n\t\t\t\t[:in_reply_to_id, 'In-Reply-To'],\n\t\t\t\t# don't set these values if they're equal to the defaults anyway\n\t\t\t\t[:importance, 'Importance', proc { |val| val.to_s == '1' ? nil : val }],\n\t\t\t\t[:priority, 'Priority', proc { |val| val.to_s == '1' ? nil : val }],\n\t\t\t\t[:sensitivity, 'Sensitivity', proc { |val| val.to_s == '0' ? nil : val }],\n\t\t\t\t# yeah?\n\t\t\t\t[:conversation_topic, 'Thread-Topic'],\n\t\t\t\t# not sure of the distinction here\n\t\t\t\t# :originator_delivery_report_requested ??\n\t\t\t\t[:read_receipt_requested, 'Disposition-Notification-To', proc { |val| from }]\n\t\t\t]\n\t\t\tmapi_header_map.each do |mapi, mime, *f|\n\t\t\t\tnext unless q = val = props.send(mapi) or headers.has_key?(mime)\n\t\t\t\tnext if f[0] and !(val = f[0].call(val))\n\t\t\t\theaders[mime] = [val.to_s]\n\t\t\tend\n\t\tend", "def headers\n {\n :subject => \"Message from WebsiteOne\",\n :to => \"[email protected]\",\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def headers\n {\n :subject => \"Nouvelle alerte acheteur\",\n :to => \"[email protected]\",\n :from => \"[email protected]\"\n }\n end", "def headers\n {\n :subject => %(<#{subject}>),\n\t\t\t:to => %(#{to}),\n :from => \"[email protected]\"\n }\n end", "def headers\n {\n :subject => \"IRL Checklist\",\n :to => \"[email protected]; [email protected]; [email protected]; [email protected]; [email protected]\",\n :from => \"IRL Checklist <[email protected]>\"\n }\n end", "def headers\n {\n :subject => \"Обратная связь Bender\",\n \"X-Priority\" => \"1 (Highest)\",\n \"X-MSMail-Priority\" => \"High\",\n :to => \"[email protected]\",\n :from => \"[email protected]\",\n :from_to => %(\"#{name}\" <#{email}>)\n }\n end", "def headers; return {}; end", "def headers; return {}; end", "def headers\r\n {\r\n :subject => \"izmedi.ru - письмо с сайта\",\r\n :to => \"[email protected]\",\r\n :from => %(\"Измеди.ру\" <@[email protected]>)\r\n }\r\n end", "def headers\n {\n :subject => \"#{subject}\",\n :to => \"#{to_user}\",\n :from => \"#{from_user}\",\n :bcc => \"#{bcc_list}\",\n :body => \"#{message}\"\n }\n end", "def unprefixed_headers\n {\"Content-Type\" => @request.content_type,\n \"Content-Length\" => @request.content_length}.compact\n end", "def remove_delayed_message_header(headers)\n headers.reject { |k| k == \"x-delay\" }\n end", "def headers\n {\n :subject => \"#{subject}\",\n :to => \"[email protected]\",\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def unquoted_address_header(key)\n if header = @mail[key]\n emails = if header.respond_to?(:value)\n [header.value]\n else\n header.map { |h| h.value }\n end\n address_list_for(emails)\n else\n []\n end\n end", "def headers\n begin\n JSON(data['message_headers'])\n rescue => e\n return []\n end\n end", "def normalize_headers(headers)\n result = headers.inject({}) do |h, (k, v)|\n # value is in raw form as array of sequential header values\n h[normalize_header_key(k)] = v\n h\n end\n\n # eliminate headers that interfere with playback or don't make sense to\n # record.\n %w(\n connection status host user_agent content_encoding\n ).each { |key| result.delete(key) }\n\n # always obfuscate cookie headers as they won't be needed for playback and\n # would be non-trivial to configure for each service.\n %w(cookie set_cookie).each do |k|\n if cookies = result[k]\n if cookies.is_a?(::String)\n cookies = cookies.split(';').map { |c| c.strip }\n end\n result[k] = cookies.map do |cookie|\n if offset = cookie.index('=')\n cookie_name = cookie[0..(offset-1)]\n \"#{cookie_name}=#{HIDDEN_CREDENTIAL_VALUE}\"\n else\n cookie\n end\n end\n end\n end\n result\n end", "def clear_headers\n self.headers.delete_if { |k,v| true }\n \"headers cleared\"\n end", "def delete_empty_headers(res)\n res[1].delete_if{|_, v| v.is_a?(String) && v.empty?}\n res\n end", "def raw_headers; end", "def headers\n {\n subject: \"[#{Setting.site_name}] Neue Quelle eingesendet\",\n to: Setting.email,\n reply_to: email,\n from: Setting.get('from'),\n }\n end", "def normalize_rack_response_headers(headers)\n result = headers.inject({}) do |h, (k, v)|\n h[k.to_s.gsub('_', '-').downcase] = v.join(\"\\n\")\n h\n end\n\n # a proxy server must always instruct the client close the connection by\n # specification because a live socket cannot be proxied from client to\n # the real server. this also works around a lame warning in ruby 1.9.3\n # webbrick code (fixed in 2.1.0+) saying:\n # Could not determine content-length of response body.\n # Set content-length of the response or set Response#chunked = true\n # in the case of 204 empty response, which is incorrect.\n result['connection'] = 'close'\n result\n end", "def headers\n {\n :subject => \"<#{subject}>\",\n :to => \"[email protected]\",\n :from => \"CatchAll\",\n :reply_to => \"#{reply}\"\n }\n end", "def stringify_headers(headers); end", "def uncached_headers(id_set)\n log \"Fetching headers for #{id_set.size} messages\"\n results = reconnect_if_necessary do\n @imap.fetch(id_set, [\"FLAGS\", \"ENVELOPE\", \"RFC822.SIZE\", \"UID\"])\n end\n results.reverse.map do |x|\n envelope = x.attr[\"ENVELOPE\"]\n message_id = envelope.message_id\n subject = Mail::Encodings.unquote_and_convert_to((envelope.subject || ''), 'UTF-8')\n recipients = ((envelope.to || []) + (envelope.cc || [])).map {|a| extract_address(a)}.join(', ')\n sender = extract_address envelope.from.first\n uid = x.attr[\"UID\"]\n params = {\n subject: (subject || ''),\n flags: x.attr['FLAGS'].join(','),\n date: Time.parse(envelope.date).localtime.to_s,\n size: x.attr['RFC822.SIZE'],\n sender: sender,\n recipients: recipients\n }\n end\n end", "def uncached_headers(id_set)\n log \"Fetching headers for #{ id_set.size } messages\"\n results = reconnect_if_necessary do\n @imap.fetch(id_set, [\"FLAGS\", \"ENVELOPE\", \"RFC822.SIZE\", \"UID\"])\n end\n results.reverse.map do |x|\n envelope = x.attr[\"ENVELOPE\"]\n message_id = envelope.message_id\n subject = Mail::Encodings.unquote_and_convert_to((envelope.subject || ''), 'UTF-8')\n recipients = ((envelope.to || []) + (envelope.cc || [])).map {|a| extract_address(a)}.join(', ')\n sender = extract_address envelope.from.first\n uid = x.attr[\"UID\"]\n params = {\n subject: (subject || ''),\n flags: x.attr['FLAGS'].join(','),\n date: Time.parse(envelope.date).localtime.to_s,\n size: x.attr['RFC822.SIZE'],\n sender: sender,\n recipients: recipients\n }\n end\n end", "def headers\n {\n :subject => \"Quote Request\",\n :to => \"[email protected]\",\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def headers\n {\n :subject => 'Contact from completed from marincricketclub.com',\n :to => '[email protected], [email protected], [email protected]',\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def headers\n @headers ||= message.header_fields\n end", "def headers\n {\n :subject => \"Prise de contact - Chavanne & Witt\",\n :to => \"[email protected], [email protected], [email protected], [email protected], [email protected]\",\n :from => %(\"#{nom}\" <#{email}>)\n }\n end", "def unwrap_headers(headers, env)\n\t\t\t\theaders.each do |key, value|\n\t\t\t\t\thttp_key = \"HTTP_#{key.upcase.tr('-', '_')}\"\n\t\t\t\t\t\n\t\t\t\t\tif current_value = env[http_key]\n\t\t\t\t\t\tenv[http_key] = \"#{current_value}\\n#{value}\"\n\t\t\t\t\telse\n\t\t\t\t\t\tenv[http_key] = value\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def remove_fws headers_with_fws\n\t\theaders = Array.new\n\t\theaders_with_fws.each_line do |line|\n\t\t\tnext if line =~ /^\\s+$/ # If line is empty\n\t\t\tnext if line =~ /^((?!:)[\\s\\S])*$/ && headers.size == 0 # If they're trying to pull a fast one\n\t\t\tline =~ /^\\s/ ? headers[-1] += line.strip : headers << line.strip\n\t\tend\n\t\theaders\n\tend", "def headers\r\n # NB: return value is supposed to be an array of strings\r\n @headers || []\r\n end", "def unify_headers(headers)\n lines = []\n headers.each_pair do |k, v|\n lines << v.map { |val| \"#{k}: #{val}\" }\n end\n\n logger.debug \"Unified headers #{lines.inspect}\" if logger_debug?\n lines.flatten.sort\n end", "def headers\n {\n :subject => \"澄清:對於#{candidate_name}的#{record_type}\",\n # :to => \"[email protected]\",\n :to => Setting.email.clarify,\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def normalize_headers(headers)\n return {} unless headers\n\n headers = Hash[\n headers.map { |k, v| [k.gsub(HEADER_HTTP_PREFIX, '').capitalize, v] }\n ] # remove 'HTTP_' prefix in keys\n headers.delete_if { |_k, v| v.blank? } # remove pairs with empty values\n headers.keep_if { |k, _v| OCCI_KEYS.include?(k) } # drop non-OCCI pairs\n\n logger.debug \"Normalized headers #{headers.inspect}\" if logger_debug?\n headers\n end", "def sanitize_header(header, value)\n value\n end", "def headers\n {\n :subject => \"Contact ULAP Research\",\n :to => \"[email protected]\",\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def headers\n {\n :subject => \"Business Plan Summary\",\n :to => \"[email protected]\",\n :from => %(\"#{pname}\" <#{pemail}>)\n }\n end", "def headers\n {\n subject: I18n.t('contact.subject'),\n to: info_email,\n from: \"Deskspotting <#{info_email}>\"\n }\n end", "def parse_headers(raw_headers)\n headers = {}\n raw_headers.each do |h|\n if h =~ /^# *([a-zA-Z_]+) *:(.*)/\n h_key = $1.downcase.intern\n h_value = $2.split(\",\").collect { |v| v.strip }\n if h_value.length > 0 # ignore empty headers\n headers[h_key] = h_value.length > 1 ? h_value : h_value[0]\n end\n end\n end\n \n return headers\n end", "def seperate_headers()\n\t\[email protected](\"\\n\\n\")[0].split(\"\\n\", 2)[1]\n\tend", "def headers\r\n {\r\n :subject => \"JP Health Insurance Contact Form\",\r\n :to => [\"[email protected]\", \"[email protected]\", \"[email protected]\"],\r\n :from => %(\"#{name}\" <#{email}>)\r\n }\r\n end", "def processed_headers; end", "def headers\n {\n :subject => %(#{subject}),\n :to => Contact.first.email,\n :body => %(#{message}),\n :from => %(\"#{email}\")\n }\n end", "def catch_pm_headers(headers)\n return {} unless Array === headers\n caught = {}\n headers.each do |h|\n case h[:name]\n when 'X-Spam-Status'\n caught[:spam_status] = h[:value].downcase.start_with?('yes')\n when 'X-Spam-Score'\n caught[:spam_score] = h[:value].to_f\n when 'Received-SPF'\n caught[:received_spf_status] = (h[:value].split)[0].downcase\n end\n end\n return caught\n end", "def headers\n {\n :subject => %(#{subject}),\n :to => %(\"#{cattery_name}\" <#{cattery_email}>),\n :from => %(\"Cat Linker\" <[email protected]>),\n :reply_to => %(\"#{email_to_name(email)}\" <#{email}>)\n }\n end", "def remove_fws headers_with_fws\n headers = Array.new\n headers_with_fws.each_line do |line|\n next if line =~ /^\\s+$/ # If line is empty\n next if line =~ /^((?!:)[\\s\\S])*$/ && headers.size == 0 # If they're trying to pull a fast one\n line =~ /^\\s/ ? headers[-1] += line.strip : headers << line.strip\n end\n headers\n end", "def internet_message_headers\n return @internet_message_headers\n end", "def headers\n {\n :subject => Contact.first.response_subject,\n :to => %(\"#{email}\"),\n :from => Contact.first.name,\n :body => Contact.first.response_message.html_safe,\n content_type: \"text/html\"\n }\n end", "def parse_headers\n headers = {}\n @request.lines[1..-1].each do |line|\n # puts line.inspect\n # puts line.split.inspect\n return headers if line == \"\\r\\n\" # Because HTTP header's last line will be /r/n we return bc we're done\n header, value = line.split\n header = normalize(header)\n headers[header] = value\n end\n \n return headers\n end", "def parse_headers raw_headers\n\t\theaders = Hash.new\n\n\t\t# Store values as hash, but don't include duplicate values\n\t\tremove_fws(raw_headers).map do |line|\n\t\t\tkey, value = line.split(\": \", 2)\n\t\t\theaders[key] ||= []\n\t\t\theaders[key] << value unless headers[key].include? value\n\t\tend\n\n\t\t# Pop value from array if there's only one value\n\t\theaders.each{ |key, value| headers[key] = value.pop if value.length == 1 }\n\tend", "def headers\n {\n :subject => \"Contact from website\",\n :to => Site.current.preferred_contact_email,\n :from => %(\"#{lastname}\" <#{email}>)\n }\n end", "def headers\n {\n :subject => \"Contact from website\",\n :to => Site.current.preferred_contact_email,\n :from => %(\"#{lastname}\" <#{email}>)\n }\n end", "def clear_headers\n headers.clear # Yes, this returns an empty hash not nil\n end", "def canonicalized_headers\n x_amz = headers.select{|name, value| name.to_s =~ /^x-amz-/i }\n x_amz = x_amz.collect{|name, value| [name.downcase, value] }\n x_amz = x_amz.sort_by{|name, value| name }\n x_amz = x_amz.collect{|name, value| \"#{name}:#{value}\" }.join(\"\\n\")\n x_amz == '' ? nil : x_amz\n end", "def headers\n {\n subject: \"RSVP Form\",\n to: \"Cecilia Rinaldi <[email protected]>, André Thiollier <[email protected]>, Belén Cesa Martínez <[email protected]>, Laura Castro <[email protected]>\",\n bcc: \"Juan Pablo Rinaldi <[email protected]>\",\n from: \"André and Ceci <[email protected]>\"\n }\n end", "def headers\n {\n :subject => \"Contacto Eurotaller\",\n :to => \"[email protected]\",\n :from => %(\"#{nombre}\" <#{correo}>)\n }\n end", "def lkey_strip(hdrs)\n hdrs.split(\": \")[0].downcase.gsub(\"-\", \"\").to_s.strip\n end", "def proper_headers(arr)\n\t\tarr.first.map! {|i| i.split(/(?=[A-Z])/).join(' ')}\n\tend", "def headers\n @headers ||= self.class.beautify_headers(@net_http_res.to_hash)\n end", "def sanitize_header_field(value)\n value.to_s\n .gsub(\"\\r\\n\", \"\\n\")\n .gsub(HEADER_FIELD_SANITIZER_PATTERN, HEADER_FIELD_SANITIZER_MAPPING)\n end", "def headers\n {\n :subject => \"You have a new client interested in training!\",\n :to => \"[email protected]\",\n :from => %(\"#{name}\" <#{email}>)\n }\n end", "def headers\n\n {\n :subject => \"POF Details \",\n :from => %(\"#{username}\"),\n :to => '[email protected]',\n :bcc => \"[email protected]\"\n\n }\nend", "def get_headers_\n hin = ATS::Headers_in.new\n hin.all.reduce({}) do |memo, pair| \n memo[pair.first.downcase] = pair[1]; memo\n end\n end", "def headers\n {\n subject: 'PIO Network - Message sent via contact form',\n to: '[email protected]',\n from: %(\"#{name}\" <#{email}>)\n }\n end", "def headers\n {\n :subject => \"New Enquiry\",\n :to => \"[email protected]\",\n :from => %(\"#{title} #{first_name} #{last_name}\")\n }\n end", "def extract_headers_from(raw_headers)\n raw_headers.\n to_h.\n keep_if { |header, _value| pagination_headers.include?(header) }.\n transform_keys(&:to_sym).\n transform_values(&:to_i)\n end", "def headers\n {}\n end", "def headers\n {}\n end", "def headers\n {}\n end", "def headers(headers); end", "def headers\n @headers.to_a\n end", "def headers\n @headers.to_a\n end", "def headers\n @headers ||={}\n end", "def postmark_headers\n array = []\n header_fields.each do |field|\n key = field.name.downcase\n # @see https://github.com/wildbit/postmark-gem/blob/master/lib/postmark/message_extensions/mail.rb#L74\n # @see https://github.com/wildbit/postmark-gem/pull/36#issuecomment-22298955\n unless %w(from to cc bcc reply-to subject tag content-type date).include?(key) || (Array === field.value && field.value.size > 1)\n array << {'Name' => field.name, 'Value' => field.value}\n end\n end\n array\n end", "def join_headers; end", "def headerlist; return ['X-MXL-NoteHash', 'X-MXL-Hash', 'X-MX-Bounce']; end", "def get_normalised_headers(headers = nil)\n normalised_keys = {}\n if !headers.nil?\n if headers.kind_of?Hash\n headers.each do |key,value|\n normalised_key = key.to_s.downcase.gsub('_','-').sub(/http-/,'')\n normalised_keys[normalised_key] = value\n end\n elsif headers.kind_of?String\n normalised_keys = {'user-agent' => headers}\n end\n elsif [email protected]?\n @headers.each do |key,value|\n normalised_key = key.to_s.downcase.gsub('_','-').sub(/http-/,'')\n normalised_keys[normalised_key] = value\n end\n end\n return normalised_keys\n end", "def get_headers\n @headers = headers\n @headers\n end", "def headers\n {\n :subject => \"Inscripción de músico - #{musician_name}\",\n :to => \"[email protected]\",\n :from => %(\"#{musician_name}\" <#{musician_email}>)\n }\n end", "def headers\n # units and source have to go last, so if we push in a new header, these go\n # at end\n @headers+['units','source']\n end", "def prepare_custom_headers(header)\n header.end_with?(\"__c\") ? header.slice(0..-4).downcase : header.downcase\n end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end" ]
[ "0.74925417", "0.69806767", "0.6820429", "0.6765788", "0.6558968", "0.6534521", "0.6496803", "0.64682406", "0.6442433", "0.6368016", "0.6357242", "0.6352929", "0.63377213", "0.62453717", "0.6227568", "0.61822546", "0.61822546", "0.61698854", "0.61617815", "0.61376923", "0.61245584", "0.6122627", "0.60939217", "0.60892564", "0.6067121", "0.6055181", "0.6043103", "0.604289", "0.60326415", "0.6029083", "0.60175073", "0.6016421", "0.6010372", "0.6004998", "0.60025144", "0.60003567", "0.5994646", "0.59890604", "0.5985708", "0.5984687", "0.5973094", "0.59681785", "0.5963305", "0.5962042", "0.59558684", "0.5954923", "0.59461546", "0.594056", "0.5934396", "0.5930417", "0.5925181", "0.59207463", "0.58909374", "0.58822477", "0.5839586", "0.5831335", "0.58297825", "0.5828783", "0.58230484", "0.5807152", "0.580237", "0.580237", "0.57977283", "0.5797518", "0.5796792", "0.5793311", "0.5789446", "0.5779343", "0.57763195", "0.57660633", "0.5761614", "0.5759016", "0.57567704", "0.5753591", "0.5748103", "0.5731671", "0.57102126", "0.57102126", "0.57102126", "0.5696279", "0.5693721", "0.5693721", "0.56764245", "0.5668032", "0.5664822", "0.56592476", "0.564896", "0.564161", "0.56382763", "0.56371737", "0.5628032", "0.56073517", "0.56073517", "0.56073517", "0.56073517", "0.56073517", "0.56073517", "0.56073517", "0.56073517", "0.56073517" ]
0.7680087
0
Finalize the instance variables based on the fetched items
def finalize(fetched) fetched == 0 && @page > 1 and raise(OverflowError.new(self), "page #{@page} got no items") @pages = @last = (fetched > @items ? @page + 1 : @page) # set the @pages and @last @items = fetched if fetched < @items && fetched > 0 # adjust items for last non-empty page @from = fetched == 0 ? 0 : @offset+1 - @outset # page begins from item @to = fetched == 0 ? 0 : @offset + @items - @outset # page ends to item @prev = (@page-1 unless @page == 1) # nil if no prev page @next = @page == @last ? (1 if @vars[:cycle]) : @page+1 # nil if no next page, 1 if :cycle self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finalize\n @list.each do |bp|\n bp.related_bp.each { |bp| bp.remove! }\n bp.remove!\n end\n clear\n end", "def finalize\n @entities.clear\n end", "def finalize!\n @_values.freeze\n end", "def initialize()\n @items = nil\n end", "def initialize()\n\t\t@items = nil\n\t\t@copies = nil\n end", "def initialize_items\n find_printed_items\n find_slug_items\n find_categories\n end", "def finalize!\n @finalized = true\n self\n end", "def finalized; end", "def finalize\n @name = Config.get_if_unset(@name, '')\n @description = Config.get_if_unset(@description, '')\n\n self\n end", "def finalise\n end", "def reload_items\n @item_data = nil\n end", "def finalize\n end", "def finalize\n end", "def finalize\n end", "def finalize\n end", "def finalize\n end", "def finalize\n end", "def finalize\n end", "def cleanup\n super\n end", "def initialize\n @items = Hash.new\n @item_id_count = 0\n end", "def finalize!\n @users = nil if @users == UNSET_VALUE\n end", "def finalize!\n super\n keys.each { |key| set(key, resolve_value(key)) }\n end", "def cleanup\n super\n end", "def finalize\n end", "def finalize\n\n end", "def clean_post_fetch\n @base = nil\n end", "def finalize\n nil\n end", "def initialize()\n\t begin\n\t @items = Item.find_with_conditions(nil)\n\t\trescue Exception => e\n\t\t model_exception(e)\n\t\tend\n\t\t@copies = nil\n end", "def finalize \n \tself[:unit_price] = self.product.sale_price\n \tself[:total] = self.quantity * self[:unit_price]\n end", "def finalize\n yield [key, @count]\n end", "def finalize_response(resp)\n resp.tap do |r|\n r.response[:limit] = r.response.items.size - 1\n r.response[:moreItems] = false\n end\n end", "def finalize\n @request_count = @orm_module::Request.count\n ActiveRecord::Base.remove_connection\n end", "def finalize\n destroy_previous\n promote_cached\n @previous = nil\n end", "def cleanup\r\n end", "def items\n if @items.nil?\n raise NoData.new(\"No data has been retrieved yet.\", self)\n else\n @items.collect do |hsh|\n item = self.class.item_class.new\n item.store_result(:attrs => hsh)\n item\n end\n end\n end", "def finalize_operations\n\tend", "def cleanup\n end", "def cleanup\n end", "def finalize_associations\n allow_lazy_load_for_static_cache_associations\n super\n end", "def cleanup; end", "def cleanup; end", "def cleanup; end", "def cleanup; end", "def finalize!; end", "def finalize()\n if @ready_to_go\n return\n end\n if @needs_help\n add_help \n end\n @attributes.sort!\n dups = []\n previous = nil\n @attributes.each do |an_attr|\n if an_attr == previous\n dups.push(an_attr)\n else\n previous = an_attr\n end\n end\n if dups.length > 0\n raise \"Duplicate attribute names, #{dups}, for command line options.\"\n end\n @positionals.push(@parms_list.length)\n @attributes.freeze\n @defaults.freeze\n @parms_list.freeze\n @parms_hash.freeze\n @positionals.freeze\n @ready_to_go = true\n end", "def read\n super\n\n self.fetch\n\n self.items\n end", "def initialize_owned_items\n if self.owned_ingredients.length == 0\n Ingredient.all.each do |ingredient|\n self.owned_ingredients.create(ingredient_id: ingredient.id, giveable_count: 0, received_count: 0)\n end\n CookieRecipe.all.each do |cookie|\n self.owned_cookies.create(cookie_recipe_id: cookie.id, giveable_count: 0, received_count: 0)\n end\n end\n end", "def cleanup!\n # This method may be left unimplemented if that is applicable\n end", "def cleanup\n cleanup_nonces\n cleanup_associations\n end", "def finalize\n self[:unit_price] = unit_price\n self[:total_price] = quantity * self[:unit_price]\n\n end", "def finish()\n #This is a stub, used for indexing\n end", "def finalize_associations!(relations:)\n super do\n associations.map do |definition|\n Memory::Associations.const_get(definition.type).new(definition, relations)\n end\n end\n end", "def finalize\n self[:unit_price] = unit_price\n self[:total_price] = quantity * self[:unit_price]\n end", "def finalize\n self[:unit_price] = unit_price\n self[:total_price] = quantity * self[:unit_price]\n end", "def finalize_associations\n @association_reflections.each_value(&:finalize)\n end", "def __finalize__\n\t\t@__hash__.each { |k,v|\n\t\t\t@__hash__[k] = v.call if v.respond_to?(:call)\n\t\t}\n\tend", "def finalize\n return unless cache = self[:cache]\n\n finalize_settings.each do |meth, key|\n next if has_key?(key)\n\n send(meth)\n self[key] = cache.delete(key) if cache.has_key?(key)\n end\n\n nil\n end", "def fetch\n data = WebApi.json! \"IEconItems_#{app_id}\", 'GetSchema', 1, language: language\n\n @attributes = {}\n data[:attributes].each do |attribute|\n @attributes[attribute[:defindex]] = attribute\n @attributes[attribute[:name]] = attribute\n end\n\n @effects = {}\n data[:attribute_controlled_attached_particles].each do |effect|\n @effects[effect[:id]] = effect[:name]\n end\n\n @items = {}\n @item_names = {}\n data[:items].each do |item|\n @items[item[:defindex]] = item\n @item_names[item[:name]] = item[:defindex]\n end\n\n @item_levels = {}\n data[:item_levels].each do |item_level_type|\n @item_levels[item_level_type[:name]] = {}\n item_level_type[:levels].each do |level|\n @item_levels[item_level_type[:name]][level[:level]] = level[:name]\n end\n end if data.key? :item_levels\n\n @item_sets = {}\n data[:item_sets].each do |item_set|\n @item_sets[item_set[:item_set]] = item_set\n end\n\n @origins = []\n data[:originNames].each do |origin|\n @origins[origin[:origin]] = origin[:name]\n end\n\n @qualities = []\n data[:qualities].keys.each_with_index do |key, index|\n @qualities[index] = data[:qualityNames][key] || key.to_s.capitalize\n end\n end", "def finalize_all\n for id, assocs in @dependency\n\tfor dependant, method, *opt in assocs\n\t dependant.send(method, id, *opt)\n\tend\n\tassocs.clear\n end\n end", "def dispose()\n self.entries.each do |entry|\n entry.instance_variable_set(\"@root_node\", nil)\n entry.instance_variable_set(\"@feed\", nil)\n entry.instance_variable_set(\"@parent_feed\", nil)\n entry.dispose if entry.respond_to?(:dispose)\n end\n self.entries = []\n \n @cache_object = nil\n @http_headers = nil\n @xml_document = nil\n @feed_data = nil\n @feed_data_type = nil\n @root_node = nil\n @channel_node = nil\n @href = nil\n @id = nil\n @title = nil\n @subtitle = nil\n @link = nil\n @last_retrieved = nil\n @time_to_live = nil\n @entries = nil\n @live = false\n @encoding = nil\n @options = nil\n\n GC.start()\n self\n end", "def prepareForReuse; end", "def initialize\n @items_list = []\n end", "def allocateFinalize()\n @corpList.each{|corp|\n corp.allocator.allocateFinalize() ;\n @allocatedList.concat(corp.allocator.allocatedList) ;\n @cancelledList.concat(corp.allocator.cancelledList) ;\n }\n super() ;\n end", "def finalize\n Pez.destroy_all\n Comida.destroy_all\n Tiburon.destroy_all\n end", "def after_fetch response, page\n super response, page\n update_counts(response) if (response && response.items)\n # p [response.items.map{|item| item['id']}.max, response.items.map{|item| item['id']}.min, prev_max, sess_span, response.parsed_contents.slice('max_id','next_page')]\n # p response.items.map{|item| (\"%6.2f\" % [Time.now - Time.parse(item['created_at'])])}\n end", "def clear\n @fetch = nil\n reset_query\n self\n end", "def items\n @items ||= items_from_response\n end", "def clean_up!\n puts Item.where(thread_id: self.uid).count\n Item.where(thread_id: self.uid).destroy_all\n @forum_items = []\n self.items = []\n self.items_md5 = nil\n save\n end", "def finalize\n if self.attributes.has_key? \"uuid\"\n set_uuid\n end\n end", "def cleanup\n Feed.processing.update_all(processing: false)\n FeedItem.processing.update_all(processing: false)\n end", "def items\n load\n @data\n end", "def after_initialize\n @parts_counted = false \n end", "def after_initialize\n @loaded = Set.new\n end", "def cleanup\n keys = redis.keys(raw_data_key('*')) + redis.keys(data_key('*'))\n multi do\n keys.each{|key| redis.del(key)}\n end\n super\n end", "def fetch_objects(lookup = :parallel)\n items = valid_parse_objects\n lookup == :parallel ? items.threaded_each(2, &:fetch) : items.each(&:fetch)\n #self.replace items\n self\n end", "def load_data\n # @categories = Category.find(:all)\n # @infoitems = Expert.find(:all)\n end", "def after_initialize\n @associations = {}\n @definitions = initial_definitions\n @scopes = [@definitions]\n @in_sclass = false\n @value_stack = NestedStack.new\n @variable_stack = NestedStack.new\n @ignored_nodes = []\n @visibility = :public\n\n reset_method_type\n end", "def finalize\n lifecycle.container.each do |key, item|\n container.register(key, item) unless container.registered?(key)\n end\n self\n end", "def finalize\n yield [key, size]\n end", "def initvars\n @provider_instances = []\n @needs_flush = false\n @failed = false\n end", "def fully_fetched\n true\n end", "def initialize\n @collection={}\n end", "def initialize\n @items = []\n end", "def cleanup\n end", "def cleanup\n end", "def cleanup\n end", "def cleanup\n end", "def fetch\n super\n if [:followers, :followings, :repos].any? {|assoc| self.send(assoc).empty?}\n api_obj.fetch(:followers, :followings, :repos)\n @followers = @followings = @projects = nil\n end\n self\n end", "def initialize\r\n self.items = []\r\n end", "def reload(*_)\n super.tap do\n @cart_items = nil\n @incomplete_order = nil\n end\n end", "def clear\n if loaded?\n orphan_resources(self)\n end\n super\n end", "def initialize\n @items = []\n end", "def finalize()\n # below function is not yet fully functional\n unlock_all_instances()\n end", "def reset\n @items = Hash.new\n @item_id_count = 0\n end", "def initialize(data) #data.length on data array is 20, for the keyword \"banana\"...i just chose [0] from the data array ...should it be an each loop here instead? Is that what they meant by the 20 favorite? :/\n @item_id = data.id\n @name = data.name #this is weird...do a raise and look at it\n @type = data.type\n @image_url = #there are multiple url's in the image hash\n if data.type == \"track\" && data.album.images.present?\n data.album.images[0][\"url\"]\n else\n #PLACEHOLDER_IMG_URL\n @url = data.external_urls.values[0]\n end\n @uri = data.uri\n\n end", "def fetch_metadata\n self.title ||= biblio_commons.title\n self.thumbnail ||= RemoteImage.new(:url => biblio_commons.thumbnail_url)\n self.format ||= biblio_commons.format\n end", "def cleanup!; end", "def cleanup!; end", "def items(); @items || CrateAPI::Items.new(); end", "def finalize\n self[:unit_cost] = unit_cost\n self[:total_cost] = count * self[:unit_cost]\n end" ]
[ "0.62318605", "0.6145475", "0.611263", "0.605794", "0.6038065", "0.59955746", "0.59418404", "0.59045935", "0.5856873", "0.5852319", "0.58349836", "0.58221203", "0.58221203", "0.58221203", "0.58221203", "0.58221203", "0.58221203", "0.58221203", "0.58192694", "0.57981336", "0.5791529", "0.57724684", "0.57564986", "0.5747719", "0.5734678", "0.5713377", "0.5702444", "0.5690498", "0.5687789", "0.5686257", "0.56756717", "0.5644962", "0.5628023", "0.5599854", "0.5575772", "0.5566268", "0.5558036", "0.5558036", "0.551278", "0.5509696", "0.5509696", "0.5509696", "0.5509696", "0.5503024", "0.5498814", "0.5491483", "0.5483537", "0.5483164", "0.5474668", "0.5464901", "0.546096", "0.5460727", "0.54456306", "0.54456306", "0.5443582", "0.543209", "0.5429847", "0.5411945", "0.53985137", "0.536706", "0.5335504", "0.5322058", "0.5304137", "0.5300484", "0.52948177", "0.5292244", "0.5289444", "0.5288361", "0.52734923", "0.5261141", "0.5258958", "0.5256628", "0.52531075", "0.52477574", "0.5242456", "0.5240361", "0.52333724", "0.52333647", "0.5230319", "0.5205413", "0.5202705", "0.5202083", "0.51941234", "0.5193068", "0.5193068", "0.5193068", "0.5193068", "0.5192773", "0.5187039", "0.5184396", "0.5181317", "0.5180276", "0.5177548", "0.5168911", "0.5159178", "0.5150664", "0.5146743", "0.5146743", "0.5142722", "0.5134209" ]
0.61566955
1